You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been trying to figure out why my Arabic rendering is wrong, and it turns out that the y_offset of a glyph needs to be subtracted from its y coordinate, as opposed to x_offset which always needs to be added. This fixes my code, but turns out cosmic-text does it exactly like this internally too. This is very confusing, seemingly not documented and possibly a bug (that cancels itself out internally):
libm::truncf((self.y - y_offset)* scale + offset.1),// Hinting in Y axis
One way I could explain this to myself is that the fonts use a coordinate system where Y Up points in the opposite direction. If this however is the case, then y_advance is not properly subtracted throughout the codebase, such as here:
I'm guessing it's indeed a difference in Y Up (fonts) and Y Down (images). I'm fairly convinced a purely vertical font / script, where y_advance would be non-zero, would probably be messed up, cause there's no reason to believe that y_advance would use a different coordinate system than y_offset when they are emitted from the underlying rustybuzz right next to each other. But then again, a vertical font is probably broken in many other ways in terms of text layout anyway.
I've been trying to figure out why my Arabic rendering is wrong, and it turns out that the
y_offset
of a glyph needs to be subtracted from itsy
coordinate, as opposed tox_offset
which always needs to be added. This fixes my code, but turns outcosmic-text
does it exactly like this internally too. This is very confusing, seemingly not documented and possibly a bug (that cancels itself out internally):cosmic-text/src/layout.rs
Lines 77 to 78 in 6aadfad
One way I could explain this to myself is that the fonts use a coordinate system where Y Up points in the opposite direction. If this however is the case, then
y_advance
is not properly subtracted throughout the codebase, such as here:cosmic-text/src/shape.rs
Line 1279 in 6aadfad
and here:
cosmic-text/src/shape.rs
Line 526 in 6aadfad
The text was updated successfully, but these errors were encountered: