Skip to content

Commit 5a24237

Browse files
committed
add comments
1 parent f93b5cd commit 5a24237

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/types.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,18 @@ function get_extent(face::FTFont, char::Char)
196196
end
197197

198198
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+
=#
199207
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
202211
return FontExtent(face.glyph.metrics, Float32(face.units_per_EM))
203212
end
204213

0 commit comments

Comments
 (0)