@@ -178,12 +178,14 @@ fn render_glyph_run(glyph_run: &GlyphRun<'_, ()>, path_builder: &mut PathBuilder
178178fn layout_text ( str : & str , font_data : Option < Blob < u8 > > , typesetting : TypesettingConfig ) -> Option < Layout < ( ) > > {
179179 FONT_CONTEXT . with_borrow_mut ( |mut font_cx| {
180180 LAYOUT_CONTEXT . with_borrow_mut ( |layout_cx| {
181- let font_family = font_data. and_then ( |font_data| {
182- font_cx
183- . collection
184- . register_fonts ( font_data, None )
185- . first ( )
186- . and_then ( |( family_id, _) | font_cx. collection . family_name ( * family_id) . map ( String :: from) )
181+ let ( font_family, font_info) = font_data. and_then ( |font_data| {
182+ let families = font_cx. collection . register_fonts ( font_data, None ) ;
183+
184+ families. first ( ) . and_then ( |( family_id, fonts_info) | {
185+ fonts_info
186+ . first ( )
187+ . and_then ( |font_info| font_cx. collection . family_name ( * family_id) . map ( |f| ( f. to_string ( ) , font_info. clone ( ) ) ) )
188+ } )
187189 } ) ?;
188190
189191 const DISPLAY_SCALE : f32 = 1. ;
@@ -192,6 +194,9 @@ fn layout_text(str: &str, font_data: Option<Blob<u8>>, typesetting: TypesettingC
192194 builder. push_default ( StyleProperty :: FontSize ( typesetting. font_size as f32 ) ) ;
193195 builder. push_default ( StyleProperty :: LetterSpacing ( typesetting. character_spacing as f32 ) ) ;
194196 builder. push_default ( StyleProperty :: FontStack ( parley:: FontStack :: Single ( parley:: FontFamily :: Named ( std:: borrow:: Cow :: Owned ( font_family) ) ) ) ) ;
197+ builder. push_default ( StyleProperty :: FontWeight ( font_info. weight ( ) ) ) ;
198+ builder. push_default ( StyleProperty :: FontStyle ( font_info. style ( ) ) ) ;
199+ builder. push_default ( StyleProperty :: FontWidth ( font_info. width ( ) ) ) ;
195200 builder. push_default ( LineHeight :: FontSizeRelative ( typesetting. line_height_ratio as f32 ) ) ;
196201
197202 let mut layout: Layout < ( ) > = builder. build ( str) ;
0 commit comments