[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Math differences between FT_Set_Transform and FT_Glyph_Transform
From: |
Derek Nylen |
Subject: |
Math differences between FT_Set_Transform and FT_Glyph_Transform |
Date: |
Fri, 19 Jun 2020 20:51:55 -0700 |
I've been integrating FreeType for text rendering in a game engine and have
everything I need working, but I recently ran into an oddity. When switching
from using FT_Set_Transform before loading a glyph to FT_Glyph_Transform on the
copy of the glyph I render with, I noticed that the glyph advances were
slightly different between the two transform functions, even though both use
FT_Vector_Transform.
What seems to be going on is that when the advance is transformed in
FT_Set_Transform, FT_MulFix is multiplying a 26.6 fixed-point value (the face
advance vector) by a 16.16 value (the matrix), whereas FT_Glyph_Transform is
multiplying two 16.16 values (the glyph advance is 16.16). The side-effect is
that when FT_MulFix adds 1/2 to round the intermediate value, the math is
different depending on the fixed-point precision of that intermediate value.
The difference is minor (and not visible from what I can tell), but I'm seeing
a couple off-by-one errors when calculating control boxes after transforming
with FT_Glyph_Transform.
I’m not really sure this is something that should be fixed, and I have a simple
workaround by converting the glyph advance to 26.6 before transforming, then
back to 16.16 afterwards. It's definitely odd that you can get different values
for the advance depending on when the transform is applied, though.
I don't really have a question beyond: is my understanding of what's going on
correct?
— Derek
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Math differences between FT_Set_Transform and FT_Glyph_Transform,
Derek Nylen <=