|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0006320||Spring engine||General||public||2019-10-11 19:23||2019-10-15 22:13|
|Status||resolved||Resolution||no change required|
|Product Version||104.0 +git|
|Target Version||Fixed in Version||104.0 +git|
|Summary||0006320: Font drawing on develop|
|Description||I'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 Reproduce||local 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)
local px, py, sx, sy, cs = 500, 500, 800, 800, 8
local tcol = WhiteStr
font:Print(tcol.."leftleft", px, py, 50, "or")
|Tags||No tags attached.|
|Checked infolog.txt for Errors||Yes|
1) update to 1965-g4c26c8e
2) px and py should not be given in pixels but in relative coords [0,1]
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.
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).
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.
>>>> 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?
|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|