1
- check_error (err, error_msg) = err == 0 || error (error_msg * " with error: $( err) " )
1
+ check_error (err, error_msg) = err == 0 || error (" $ error_msg with error: $err " )
2
2
3
3
const FREE_FONT_LIBRARY = FT_Library[C_NULL ]
4
4
5
5
function ft_init ()
6
- FREE_FONT_LIBRARY[1 ] != C_NULL && error (" Freetype already initalized. init() called two times?" )
7
- err = FT_Init_FreeType (FREE_FONT_LIBRARY)
8
- return err == 0
6
+ if FREE_FONT_LIBRARY[1 ] != C_NULL
7
+ error (" Freetype already initalized. init() called two times?" )
8
+ end
9
+ return FT_Init_FreeType (FREE_FONT_LIBRARY) == 0
9
10
end
10
11
11
12
function ft_done ()
12
- FREE_FONT_LIBRARY[1 ] == C_NULL && error (" Library == CNULL. FreeTypeAbstraction.done() called before init(), or done called two times?" )
13
+ if FREE_FONT_LIBRARY[1 ] == C_NULL
14
+ error (" Library == CNULL. FreeTypeAbstraction.done() called before init(), or done called two times?" )
15
+ end
13
16
err = FT_Done_FreeType (FREE_FONT_LIBRARY[1 ])
14
17
FREE_FONT_LIBRARY[1 ] = C_NULL
15
18
return err == 0
@@ -114,7 +117,9 @@ function safe_free(face)
114
117
end
115
118
end
116
119
117
- boundingbox (extent:: FontExtent{T} ) where T = Rect2 (bearing (extent), Vec2 {T} (extent. scale))
120
+ function boundingbox (extent:: FontExtent{T} ) where T
121
+ return Rect2 (bearing (extent), Vec2 {T} (extent. scale))
122
+ end
118
123
119
124
mutable struct FTFont
120
125
ft_ptr:: FreeType.FT_Face
@@ -136,7 +141,9 @@ FTFont(path::String) = FTFont(newface(path))
136
141
# C interop
137
142
Base. cconvert (:: Type{FreeType.FT_Face} , font:: FTFont ) = font
138
143
139
- Base. unsafe_convert (:: Type{FreeType.FT_Face} , font:: FTFont ) = getfield (font, :ft_ptr )
144
+ function Base. unsafe_convert (:: Type{FreeType.FT_Face} , font:: FTFont )
145
+ return getfield (font, :ft_ptr )
146
+ end
140
147
141
148
Base. propertynames (font:: FTFont ) = fieldnames (FreeType. FT_FaceRec)
142
149
0 commit comments