File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -196,9 +196,18 @@ function get_extent(face::FTFont, char::Char)
196
196
end
197
197
198
198
function internal_get_extent (face:: FTFont , char:: Char )
199
+ #=
200
+ Load chars without scaling. This leaves all glyph metrics that can be
201
+ retrieved in font units, which can be normalized by dividing with the
202
+ font's units_per_EM. This is more robust than relying on extents
203
+ that are only valid with a specific pixelsize, because a font's
204
+ pixelsize can be silently changed by third parties, such as Cairo.
205
+ If that happens, all glyph metrics are incorrect. We avoid this by using the normalized space.
206
+ =#
199
207
err = FT_Load_Char (face, char, FT_LOAD_NO_SCALE)
200
- check_error (err, " Could not load char to get extend." )
201
- # This gives us the font metrics in normalized units (-1, 1)
208
+ check_error (err, " Could not load char to get extent." )
209
+ # This gives us the font metrics in normalized units (0, 1), with negative
210
+ # numbers interpreted as an offset
202
211
return FontExtent (face. glyph. metrics, Float32 (face. units_per_EM))
203
212
end
204
213
You can’t perform that action at this time.
0 commit comments