@@ -278,7 +278,7 @@ pub mod oft_metrics {
278278 enum MaxpMetrics {
279279 Postscript { version : u32 } , // version 0.5
280280 // STUB - enrich with any further details we care about presenting
281- Version1 { version : u32 } , // version 1.0
281+ Version1 { version : u32 } , // version 1.0
282282 UnknownVersion { version : u32 } , // anything else
283283 }
284284
@@ -379,11 +379,14 @@ pub mod oft_metrics {
379379
380380 impl std:: fmt:: Display for BoundingBox {
381381 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
382- write ! ( f, "[({}, {}) <-> ({}, {})]" , self . x_min, self . y_min, self . x_max, self . y_max)
382+ write ! (
383+ f,
384+ "[({}, {}) <-> ({}, {})]" ,
385+ self . x_min, self . y_min, self . x_max, self . y_max
386+ )
383387 }
384388 }
385389
386-
387390 type LocaMetrics = ( ) ;
388391
389392 #[ derive( Clone , Debug ) ]
@@ -494,12 +497,15 @@ pub mod oft_metrics {
494497 match & maxp. data {
495498 opentype_maxp_table_data:: MaxpPostScript => MaxpMetrics :: Postscript { version } ,
496499 opentype_maxp_table_data:: MaxpV1 ( _table) => MaxpMetrics :: Version1 { version } ,
497- opentype_maxp_table_data:: MaxpUnknown ( _) => MaxpMetrics :: UnknownVersion { version } ,
500+ opentype_maxp_table_data:: MaxpUnknown ( _) => {
501+ MaxpMetrics :: UnknownVersion { version }
502+ }
498503 }
499504 } ;
500505 let hmtx = {
501506 let hmtx = & dir. table_links . hmtx ;
502- let mut accum = Vec :: with_capacity ( hmtx. h_metrics . len ( ) + hmtx. left_side_bearings . len ( ) ) ;
507+ let mut accum =
508+ Vec :: with_capacity ( hmtx. h_metrics . len ( ) + hmtx. left_side_bearings . len ( ) ) ;
503509 for hmet in hmtx. h_metrics . iter ( ) {
504510 accum. push ( UnifiedHmtxMetric {
505511 advance_width : Some ( hmet. advance_width ) ,
@@ -523,7 +529,10 @@ pub mod oft_metrics {
523529 Some ( link) => Some ( String :: from_utf8_lossy ( & link) . into_owned ( ) ) ,
524530 None => None ,
525531 } ;
526- tmp. push ( NameRecord { name_id : record. name_id , buf } ) ;
532+ tmp. push ( NameRecord {
533+ name_id : record. name_id ,
534+ buf,
535+ } ) ;
527536 }
528537 tmp
529538 } ;
@@ -542,7 +551,10 @@ pub mod oft_metrics {
542551 Some ( tmp)
543552 }
544553 opentype_name_table_data:: NameVersionUnknown ( ver) => {
545- return Err ( Box :: new ( UnknownValueError { what : format ! ( "name table version" ) , bad_value : * ver } ) )
554+ return Err ( Box :: new ( UnknownValueError {
555+ what : format ! ( "name table version" ) ,
556+ bad_value : * ver,
557+ } ) )
546558 }
547559 }
548560 } ;
@@ -575,20 +587,31 @@ pub mod oft_metrics {
575587 }
576588 } ;
577589 let optional = {
578- let cvt = dir. table_links . cvt . as_ref ( ) . map ( |cvt| RawArrayMetrics ( cvt. len ( ) ) ) ;
579- let fpgm = dir. table_links . fpgm . as_ref ( ) . map ( |fpgm| RawArrayMetrics ( fpgm. len ( ) ) ) ;
590+ let cvt = dir
591+ . table_links
592+ . cvt
593+ . as_ref ( )
594+ . map ( |cvt| RawArrayMetrics ( cvt. len ( ) ) ) ;
595+ let fpgm = dir
596+ . table_links
597+ . fpgm
598+ . as_ref ( )
599+ . map ( |fpgm| RawArrayMetrics ( fpgm. len ( ) ) ) ;
580600 let loca = dir. table_links . loca . as_ref ( ) . map ( |_| ( ) ) ;
581601 let glyf = dir. table_links . glyf . as_ref ( ) . map ( |glyf| {
582602 let num_glyphs = glyf. len ( ) ;
583- let glyphs = glyf. iter ( ) . map ( |g| {
584- match g {
603+ let glyphs = glyf
604+ . iter ( )
605+ . map ( |g| match g {
585606 opentype_glyf_table:: EmptyGlyph => GlyphMetric :: Empty ,
586607 opentype_glyf_table:: Glyph ( gl) => match & gl. description {
587608 GlyphDescription :: HeaderOnly => GlyphMetric :: Empty ,
588609 GlyphDescription :: Simple ( simple) => {
589610 GlyphMetric :: Simple ( SimpleGlyphMetric {
590611 contours : gl. number_of_contours as usize ,
591- coordinates : * simple. end_points_of_contour . last ( ) . unwrap ( ) as usize + 1 ,
612+ coordinates : * simple. end_points_of_contour . last ( ) . unwrap ( )
613+ as usize
614+ + 1 ,
592615 instructions : simple. instruction_length as usize ,
593616 bounding_box : bounding_box ( gl) ,
594617 } )
@@ -600,9 +623,9 @@ pub mod oft_metrics {
600623 bounding_box : bounding_box ( gl) ,
601624 } )
602625 }
603- }
604- }
605- } ) . collect ( ) ;
626+ } ,
627+ } )
628+ . collect ( ) ;
606629 GlyfMetrics { num_glyphs, glyphs }
607630 } ) ;
608631 OptionalTableMetrics {
@@ -632,7 +655,11 @@ pub mod oft_metrics {
632655 pub fn show_opentype_stats ( metrics : & OpentypeMetrics ) {
633656 match metrics {
634657 OpentypeMetrics :: MultiFont ( multi) => {
635- println ! ( "TTC: version {} ({} fonts)" , format_version_major_minor( multi. version. 0 , multi. version. 1 ) , multi. num_fonts) ;
658+ println ! (
659+ "TTC: version {} ({} fonts)" ,
660+ format_version_major_minor( multi. version. 0 , multi. version. 1 ) ,
661+ multi. num_fonts
662+ ) ;
636663 for ( i, o_font) in multi. font_metrics . iter ( ) . enumerate ( ) {
637664 match o_font. as_ref ( ) {
638665 Some ( font) => {
@@ -675,8 +702,6 @@ pub mod oft_metrics {
675702 show_magic ( font. sfnt_version ) ;
676703 show_required_metrics ( & font. required ) ;
677704 show_optional_metrics ( & font. optional ) ;
678-
679-
680705 }
681706
682707 fn show_required_metrics ( required : & RequiredTableMetrics ) {
@@ -700,7 +725,7 @@ pub mod oft_metrics {
700725 fn show_cvt_metrics ( cvt : & Option < CvtMetrics > ) {
701726 match cvt {
702727 Some ( RawArrayMetrics ( count) ) => println ! ( "cvt: FWORD[{count}]" ) ,
703- None => ( )
728+ None => ( ) ,
704729 }
705730 }
706731
@@ -816,35 +841,50 @@ pub mod oft_metrics {
816841 }
817842
818843 fn show_htmx_metrics ( hmtx : & HmtxMetrics ) {
819- let show_unified = |ix : usize , hmet : & UnifiedHmtxMetric | {
820- match & hmet. advance_width {
821- Some ( width) => println ! ( "Glyph ID [{ix}]: advanceWidth={width}, lsb={}" , hmet. left_side_bearing) ,
822- None => println ! ( "Glyph ID [{ix}]: lsb={}" , hmet. left_side_bearing) ,
823- }
844+ let show_unified = |ix : usize , hmet : & UnifiedHmtxMetric | match & hmet. advance_width {
845+ Some ( width) => println ! (
846+ "Glyph ID [{ix}]: advanceWidth={width}, lsb={}" ,
847+ hmet. left_side_bearing
848+ ) ,
849+ None => println ! ( "Glyph ID [{ix}]: lsb={}" , hmet. left_side_bearing) ,
824850 } ;
825851
826- show_items_elided (
827- & hmtx. 0 ,
828- show_unified,
829- 8 ,
830- |start, stop| format ! ( "skipping hmetrics {start}..{stop}" ) ,
831- ) ;
852+ show_items_elided ( & hmtx. 0 , show_unified, 8 , |start, stop| {
853+ format ! ( "skipping hmetrics {start}..{stop}" )
854+ } ) ;
832855 }
833856
834857 fn show_maxp_metrics ( maxp : & MaxpMetrics ) {
835858 match maxp {
836- MaxpMetrics :: Postscript { version } => println ! ( "maxp: version {} (PostScript)" , format_version16dot16( * version) ) ,
837- MaxpMetrics :: UnknownVersion { version} => println ! ( "maxp: version {} (not recognized)" , format_version16dot16( * version) ) ,
859+ MaxpMetrics :: Postscript { version } => println ! (
860+ "maxp: version {} (PostScript)" ,
861+ format_version16dot16( * version)
862+ ) ,
863+ MaxpMetrics :: UnknownVersion { version } => println ! (
864+ "maxp: version {} (not recognized)" ,
865+ format_version16dot16( * version)
866+ ) ,
838867 // STUB - currently limited by definition of Version1 variant, but the information available in the type may be enriched later
839- MaxpMetrics :: Version1 { version } => println ! ( "maxp: version {} (contents omitted)" , format_version16dot16( * version) ) ,
868+ MaxpMetrics :: Version1 { version } => println ! (
869+ "maxp: version {} (contents omitted)" ,
870+ format_version16dot16( * version)
871+ ) ,
840872 }
841873 }
842874
843875 fn show_name_metrics ( name : & NameMetrics ) {
844876 // STUB - add more details if appropriate
845877 match & name. lang_tag_records {
846- Some ( records) => println ! ( "name: version {}, {} name_records, {} language tag records" , name. version, name. name_count, records. len( ) ) ,
847- None => println ! ( "name: version {}, {} name_records" , name. version, name. name_count) ,
878+ Some ( records) => println ! (
879+ "name: version {}, {} name_records, {} language tag records" ,
880+ name. version,
881+ name. name_count,
882+ records. len( )
883+ ) ,
884+ None => println ! (
885+ "name: version {}, {} name_records" ,
886+ name. version, name. name_count
887+ ) ,
848888 }
849889 }
850890
@@ -858,17 +898,19 @@ pub mod oft_metrics {
858898 println ! ( "post: version {}" , format_version16dot16( post. version) ) ;
859899 }
860900
861-
862901 // NOTE - scaffolding to mark the values we currently parse into u16 but which are logically i16, to flag changes to the gencode API as they crop up
863902 const fn as_s16 ( v : u16 ) -> i16 {
864903 v as i16
865904 }
866905
867906 fn show_glyf_metrics ( glyf : & Option < GlyfMetrics > ) {
868907 if let Some ( glyf) = glyf. as_ref ( ) {
869- show_items_elided ( glyf. glyphs . as_slice ( ) , show_glyph_metric, 8 , |start, stop| {
870- format ! ( "skipping glyphs {start}..{stop}" )
871- } )
908+ show_items_elided (
909+ glyf. glyphs . as_slice ( ) ,
910+ show_glyph_metric,
911+ 8 ,
912+ |start, stop| format ! ( "skipping glyphs {start}..{stop}" ) ,
913+ )
872914 } else {
873915 println ! ( "glyf: <not present>" )
874916 }
@@ -879,18 +921,15 @@ pub mod oft_metrics {
879921 match glyf {
880922 GlyphMetric :: Empty => println ! ( "<empty>" ) ,
881923 GlyphMetric :: Simple ( simple) => {
882- println ! ( "Simple Glyph [{} contours, {} coordinates, {} instructions, xy: {}]" ,
883- simple. contours,
884- simple. coordinates,
885- simple. instructions,
886- simple. bounding_box
924+ println ! (
925+ "Simple Glyph [{} contours, {} coordinates, {} instructions, xy: {}]" ,
926+ simple. contours, simple. coordinates, simple. instructions, simple. bounding_box
887927 ) ;
888928 }
889929 GlyphMetric :: Composite ( composite) => {
890- println ! ( "Composite Glyph [{} components, {} instructions, xy: {}]" ,
891- composite. components,
892- composite. instructions,
893- composite. bounding_box,
930+ println ! (
931+ "Composite Glyph [{} components, {} instructions, xy: {}]" ,
932+ composite. components, composite. instructions, composite. bounding_box,
894933 ) ;
895934 }
896935 }
0 commit comments