View Issue Details

IDProjectCategoryView StatusLast Update
0006320Spring engineGeneralpublic2019-10-15 22:13
Reporterlhog Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Product Version104.0 +git 
Fixed in Version104.0 +git 
Summary0006320: Font drawing on develop
DescriptionI'm trying to put some text on the screen on develop, but the text doesn't appear in the expected place.

As far as I was able to understand from the engine code, the font handlers load default shader and should set right matrices for the shader. Still I got nothing.
Steps To Reproducelocal fontfile = LUAUI_DIRNAME .. "fonts/" .. Spring.GetConfigString("bar_font", "Poppins-Regular.otf")
local vsx,vsy = Spring.GetViewGeometry()
local fontfileScale = (0.5 + (vsx*vsy / 5700000))
local fontfileSize = 25
local fontfileOutlineSize = 6
local fontfileOutlineStrength = 1.4
local font = gl.LoadFont(fontfile, fontfileSize*fontfileScale, fontfileOutlineSize*fontfileScale, fontfileOutlineStrength)


function widget:DrawScreen()
    local px, py, sx, sy, cs = 500, 500, 800, 800, 8
    local tcol = WhiteStr
    
    font:Begin()
        font:Print(tcol.."leftleft", px, py, 50, "or")
    font:End()
end
TagsNo tags attached.
Checked infolog.txt for ErrorsYes

Activities

Kloot

2019-10-11 22:18

developer   ~0020175

1) update to 1965-g4c26c8e
2) px and py should not be given in pixels but in relative coords [0,1]

lhog

2019-10-12 00:25

reporter   ~0020177

Although the recent has made text to appear on the screen, it always appear in the left bottom part of the screen if px and py are within [0,1] range. If I go slightly over 1 or below 0 text just disappears, no actual movement of text is present.

Also aren't normalized coords supposed to only be relevant with FONT_NORM option (which is not even exposed to Lua)

font:Print(tcol.."leftleft", px, py, 0.05, "ocvB")

P.S. I'm doing wrapper, so for me normalized or screen coordinates are just a small annoyance, but overall gamedevs will prefer to define their elements in pixels, as it's consistent with the rest of the emulated GL1.x functions.

lhog

2019-10-12 00:59

reporter   ~0020178

BTW, if called in DrawWorld

font:Print() draws the text the same way as in DrawScreen* i.e. in screen space, rather than in the world space. If [0,1] coords in DrawScreen() are just small annoyance, then same [0,1] coords in DrawWorld() are totally user unfriendly (if it's not a bug).

Kloot

2019-10-12 01:33

developer   ~0020179

FONT_NORM normalizes the text *size*, not the coors. You indeed can't pass it to font:Print but that is easily fixed.

"it always appear in the left bottom part of the screen if px and py are within [0,1] range" sounds like a wrong projection matrix, the default should always be equal to glOrtho(0, 1, 0, 1, -1, 1) with rescaled z if clipctrl is enabled.

It seems LuaFonts is also missing WorldPrint, will be added later.

lhog

2019-10-12 22:00

reporter   ~0020181

>>>> the default should always be equal to glOrtho(0, 1, 0, 1, -1, 1)

Am I supposed to construct Orthographic projection myself or did you mean it was an engine bug you were going to fix?

Issue History

Date Modified Username Field Change
2019-10-11 19:23 lhog New Issue
2019-10-11 22:18 Kloot Note Added: 0020175
2019-10-12 00:25 lhog Note Added: 0020177
2019-10-12 00:59 lhog Note Added: 0020178
2019-10-12 01:33 Kloot Note Added: 0020179
2019-10-12 22:00 lhog Note Added: 0020181
2019-10-15 22:13 Kloot Status new => resolved
2019-10-15 22:13 Kloot Resolution open => no change required
2019-10-15 22:13 Kloot Fixed in Version => 104.0 +git