Skip to content

Commit 5bf8cfe

Browse files
committed
Revert "face.glyph should be used as a pointer instead of a value"
This reverts commit d9bd35c.
1 parent d9bd35c commit 5bf8cfe

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/rendering.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ end
77
function renderface(face::FTFont, c::Char, pixelsize::Integer)
88
set_pixelsize(face, pixelsize)
99
loadchar(face, c)
10-
glyph = unsafe_load(face.glyph)
10+
glyph = face.glyph
1111
@assert glyph.format == FreeType.FT_GLYPH_FORMAT_BITMAP
1212
return glyphbitmap(glyph.bitmap), FontExtent(glyph.metrics)
1313
end

src/types.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ function Base.getproperty(font::FTFont, fieldname::Symbol)
156156
if field isa Ptr{FT_String}
157157
field == C_NULL && return ""
158158
return unsafe_string(field)
159+
# Some fields segfault with unsafe_load...Lets find out which another day :D
160+
elseif field isa Ptr{FreeType.LibFreeType.FT_GlyphSlotRec}
161+
return unsafe_load(field)
159162
else
160163
return field
161164
end
@@ -205,7 +208,7 @@ function internal_get_extent(face::FTFont, char::Char)
205208
check_error(err, "Could not load char to get extent.")
206209
# This gives us the font metrics in normalized units (0, 1), with negative
207210
# numbers interpreted as an offset
208-
return FontExtent(unsafe_load(face.glyph).metrics, Float32(face.units_per_EM))
211+
return FontExtent(face.glyph.metrics, Float32(face.units_per_EM))
209212
end
210213

211214
descender(font) = font.descender / font.units_per_EM

0 commit comments

Comments
 (0)