@@ -31,73 +31,81 @@ struct FontExtent{T}
31
31
scale:: Vec{2, T}
32
32
end
33
33
34
- @inline hadvance (ext:: FontExtent ) = ext. advance[1 ]
35
- @inline vadvance (ext:: FontExtent ) = ext. advance[2 ]
36
- @inline inkwidth (ext:: FontExtent ) = ext. scale[1 ]
37
- @inline inkheight (ext:: FontExtent ) = ext. scale[2 ]
38
- @inline hbearing_ori_to_left (ext:: FontExtent ) = ext. horizontal_bearing[1 ]
39
- @inline hbearing_ori_to_top (ext:: FontExtent ) = ext. horizontal_bearing[2 ]
40
- @inline leftinkbound (ext:: FontExtent ) = hbearing_ori_to_left (ext)
41
- @inline rightinkbound (ext:: FontExtent ) = leftinkbound (ext) + inkwidth (ext)
42
- @inline bottominkbound (ext:: FontExtent ) = hbearing_ori_to_top (ext) - inkheight (ext)
43
- @inline topinkbound (ext:: FontExtent ) = hbearing_ori_to_top (ext)
34
+ hadvance (ext:: FontExtent ) = ext. advance[1 ]
35
+ vadvance (ext:: FontExtent ) = ext. advance[2 ]
36
+ inkwidth (ext:: FontExtent ) = ext. scale[1 ]
37
+ inkheight (ext:: FontExtent ) = ext. scale[2 ]
38
+ hbearing_ori_to_left (ext:: FontExtent ) = ext. horizontal_bearing[1 ]
39
+ hbearing_ori_to_top (ext:: FontExtent ) = ext. horizontal_bearing[2 ]
40
+ leftinkbound (ext:: FontExtent ) = hbearing_ori_to_left (ext)
41
+ rightinkbound (ext:: FontExtent ) = leftinkbound (ext) + inkwidth (ext)
42
+ bottominkbound (ext:: FontExtent ) = hbearing_ori_to_top (ext) - inkheight (ext)
43
+ topinkbound (ext:: FontExtent ) = hbearing_ori_to_top (ext)
44
44
45
45
BroadcastStyle (:: Type{<: FontExtent} ) = Style {FontExtent} ()
46
46
BroadcastStyle (:: Style{FontExtent} , x) = Style {FontExtent} ()
47
47
BroadcastStyle (x, :: Style{FontExtent} ) = Style {FontExtent} ()
48
48
49
- broadcasted (op:: Function , f:: FontExtent , scaling:: StaticVector ) =
50
- FontExtent (
49
+ function broadcasted (op:: Function , f:: FontExtent , scaling:: StaticVector )
50
+ return FontExtent (
51
51
op .(f. vertical_bearing, scaling[1 ]),
52
52
op .(f. horizontal_bearing, scaling[2 ]),
53
53
op .(f. advance, scaling),
54
54
op .(f. scale, scaling),
55
55
)
56
+ end
56
57
57
- broadcasted (op:: Function , f:: FontExtent ) =
58
- FontExtent (
58
+ function broadcasted (op:: Function , f:: FontExtent )
59
+ return FontExtent (
59
60
op .(f. vertical_bearing),
60
61
op .(f. horizontal_bearing),
61
62
op .(f. advance),
62
63
op .(f. scale),
63
64
)
65
+ end
64
66
65
- broadcasted (op:: Function , :: Type{T} , f:: FontExtent ) where T =
66
- FontExtent (
67
+ function broadcasted (op:: Function , :: Type{T} , f:: FontExtent ) where T
68
+ return FontExtent (
67
69
map (x-> op (T, x), f. vertical_bearing),
68
70
map (x-> op (T, x), f. horizontal_bearing),
69
71
map (x-> op (T, x), f. advance),
70
72
map (x-> op (T, x), f. scale),
71
73
)
74
+ end
72
75
73
- FontExtent (fontmetric:: FreeType.FT_Glyph_Metrics , scale:: T = 64.0 ) where T <: AbstractFloat =
74
- FontExtent (
76
+ function FontExtent (fontmetric:: FreeType.FT_Glyph_Metrics , scale:: T = 64.0 ) where T <: AbstractFloat
77
+ return FontExtent (
75
78
Vec {2, T} (fontmetric. vertBearingX, fontmetric. vertBearingY) ./ scale,
76
79
Vec {2, T} (fontmetric. horiBearingX, fontmetric. horiBearingY) ./ scale,
77
80
Vec {2, T} (fontmetric. horiAdvance, fontmetric. vertAdvance) ./ scale,
78
81
Vec {2, T} (fontmetric. width, fontmetric. height) ./ scale
79
82
)
83
+ end
80
84
81
- == (x:: FontExtent , y:: FontExtent ) = (
82
- x. vertical_bearing == y. vertical_bearing &&
83
- x. horizontal_bearing == y. horizontal_bearing &&
84
- x. advance == y. advance &&
85
- x. scale == y. scale
86
- )
85
+ function == (x:: FontExtent , y:: FontExtent )
86
+ return (
87
+ x. vertical_bearing == y. vertical_bearing &&
88
+ x. horizontal_bearing == y. horizontal_bearing &&
89
+ x. advance == y. advance &&
90
+ x. scale == y. scale
91
+ )
92
+ end
87
93
88
- FontExtent (fontmetric:: FreeType.FT_Glyph_Metrics , scale:: Integer ) =
89
- FontExtent (
94
+ function FontExtent (fontmetric:: FreeType.FT_Glyph_Metrics , scale:: Integer )
95
+ return FontExtent (
90
96
div .(Vec {2, Int} (fontmetric. vertBearingX, fontmetric. vertBearingY), scale),
91
97
div .(Vec {2, Int} (fontmetric. horiBearingX, fontmetric. horiBearingY), scale),
92
98
div .(Vec {2, Int} (fontmetric. horiAdvance, fontmetric. vertAdvance), scale),
93
99
div .(Vec {2, Int} (fontmetric. width, fontmetric. height), scale)
94
100
)
101
+ end
95
102
96
- bearing (extent:: FontExtent{T} ) where T =
97
- Vec2 {T} (
103
+ function bearing (extent:: FontExtent{T} ) where T
104
+ return Vec2 {T} (
98
105
+ extent. horizontal_bearing[1 ],
99
106
- extent. horizontal_bearing[2 ],
100
107
)
108
+ end
101
109
102
110
function safe_free (face)
103
111
ptr = getfield (face, :ft_ptr )
@@ -143,8 +151,9 @@ function Base.getproperty(font::FTFont, fieldname::Symbol)
143
151
end
144
152
end
145
153
146
- Base. show (io:: IO , font:: FTFont ) =
154
+ function Base. show (io:: IO , font:: FTFont )
147
155
print (io, " FTFont (family = $(font. family_name) , style = $(font. style_name) )" )
156
+ end
148
157
149
158
# Allow broadcasting over fonts
150
159
Base. Broadcast. broadcastable (ft:: FTFont ) = Ref (ft)
0 commit comments