@@ -146,21 +146,26 @@ impl YamlFrameReader {
146
146
panic ! ( "text item had neither text nor glyphs!" ) ;
147
147
}
148
148
149
- let glyphs = if item[ "text" ] . is_badvalue ( ) {
149
+ let ( glyphs, rect ) = if item[ "text" ] . is_badvalue ( ) {
150
150
// if glyphs are specified, then the glyph positions can have the
151
151
// origin baked in.
152
152
let origin = item[ "origin" ] . as_point ( ) . unwrap_or ( Point2D :: new ( 0.0 , 0.0 ) ) ;
153
153
let glyph_indices = item[ "glyphs" ] . as_vec_u32 ( ) . unwrap ( ) ;
154
154
let glyph_offsets = item[ "offsets" ] . as_vec_f32 ( ) . unwrap ( ) ;
155
155
assert ! ( glyph_offsets. len( ) == glyph_indices. len( ) * 2 ) ;
156
156
157
- glyph_indices. iter ( ) . enumerate ( ) . map ( |k| {
157
+ let glyphs = glyph_indices. iter ( ) . enumerate ( ) . map ( |k| {
158
158
GlyphInstance {
159
159
index : * k. 1 ,
160
160
x : origin. x + glyph_offsets[ k. 0 * 2 ] ,
161
161
y : origin. y + glyph_offsets[ k. 0 * 2 +1 ] ,
162
162
}
163
- } ) . collect ( )
163
+ } ) . collect ( ) ;
164
+ // TODO(gw): We could optionally use the WR API to query glyph dimensions
165
+ // here and calculate the bounding region here if we want to.
166
+ let rect = item[ "bounds" ] . as_rect ( )
167
+ . expect ( "Text items with glyphs require bounds [for now]" ) ;
168
+ ( glyphs, rect)
164
169
} else {
165
170
if native_key. is_none ( ) {
166
171
panic ! ( "Can't layout simple ascii text with raw font [for now]" ) ;
@@ -174,15 +179,15 @@ impl YamlFrameReader {
174
179
175
180
let mut x = origin. x ;
176
181
let y = origin. y ;
177
- glyph_indices. iter ( ) . zip ( glyph_advances) . map ( |arg| {
182
+ let glyphs = glyph_indices. iter ( ) . zip ( glyph_advances) . map ( |arg| {
178
183
let gi = GlyphInstance { index : * arg. 0 as u32 , x : x, y : y } ;
179
184
x = x + arg. 1 ;
180
185
gi
181
- } ) . collect ( )
186
+ } ) . collect ( ) ;
187
+ let rect = Rect :: new ( Point2D :: new ( 0.0 , 0.0 ) , wrench. window_size_f32 ( ) ) ;
188
+ ( glyphs, rect)
182
189
} ;
183
190
184
- let rect = Rect :: new ( Point2D :: new ( 0.0 , 0.0 ) , wrench. window_size_f32 ( ) ) ;
185
-
186
191
let ( builder, aux_builder) = self . both_builders ( ) ;
187
192
let clip = item[ "clip" ] . as_clip_region ( aux_builder) . unwrap_or ( * clip_region) ;
188
193
// FIXME this is the full bounds of the glyphs; we should calculate this more accurately
0 commit comments