Closed TJYSunset closed 4 months ago
Can you point out the specific division that you think is incorrect? I believe it is done to convert FreeType's fixed point number format (integer whose most significant 26 bits are the whole part and least significant 6 bits are the fractional part) to floating point.
I believe it's in ftPoint2()
, which is called by all the FT_Outline_Decompose
callback functions.
According to FreeType docs, FT_Pos
(used in FT_Vector
) can either be 26.6 pixels or 1:1 font units, which seems to actually be font units in this case.
I tested rendering Fira Sans Bold's capital M with
msdfgen msdf -font .\FiraSans-Bold.otf "'M'" -scale 64 -size 1000 1000 -pxrange 4 -testrender test.png 1000 1000
And the output test render is exactly 720px wide, matching FontForge's telling me this glyph is 720 font units wide.
test.png:
FontForge:
Alright, in that case, I guess it is wrong.
Fixed in bc9f02e156115860e28094565c57d383ab03b761, hopefully with full backwards compatibility.
Use:
-noemnormalize
/ FONT_SCALING_NONE
to switch to the correct native font coordinates,-emnormalize
/ FONT_SCALING_EM_NORMALIZED
to switch to coordinates normalized to 1 em, or-legacyfontscaling
/ FONT_SCALING_LEGACY
to keep old behavior and make sure it will not change.If you do not specify any of the above, you will get a warning in the console version, but for now, the old behavior will be kept.
Sorry if this have already been mentioned before.
I'm no expert in typography, but if I'm not mistaken -
FT_Load_Glyph
set theFT_LOAD_NO_SCALE
flag, so its return value is expressed in the exact font units, not 26.6 fractional pixels;FT_FaceRec.units_per_em
;To be clear, I don't think this behavior needs "fixing" (changing the behavior will only break existing code). It just needs clear documentation in the README.