11use std:: collections:: BTreeMap ;
22
33use super :: grammar:: {
4- CMapFormat0 , CMapFormat4 , CMapSubtable , ComponentGlyph , ComponentGlyphArgument ,
4+ CMapFormat0 , CMapFormat4 , CMapFormat6 , CMapSubtable , ComponentGlyph , ComponentGlyphArgument ,
55 ComponentGlyphFlag , ComponentGlyphTransformation , F2Dot14 , FWord , Fixed , FontDirectory , Glyph ,
66 GlyphDescription , GlyphTable , HHeaTable , HMtxTable , HeadTable , LongDateTime ,
77 LongHorizontalMetric , MaxPTable , OffsetSubTable , ScalarType , SimpleGlyphFlag , TableRecord ,
@@ -306,6 +306,7 @@ impl<'a> TrueTypeFontParser<'a> {
306306 let subtable = match format {
307307 0 => CMapSubtable :: Zero ( self . parse_cmap_subtable_format_0 ( ) ?) ,
308308 4 => CMapSubtable :: Four ( self . parse_cmap_subtable_format_4 ( ) ?) ,
309+ 6 => CMapSubtable :: Six ( self . parse_cmap_subtable_format_6 ( ) ?) ,
309310 _ => todo ! ( ) ,
310311 } ;
311312
@@ -326,8 +327,8 @@ impl<'a> TrueTypeFontParser<'a> {
326327
327328 length
328329 }
329- 4 => self . read_u16 ( ) ? as usize ,
330- 2 | 6 | 8 | 10 | 12 | 13 | 14 => todo ! ( ) ,
330+ 4 | 6 => self . read_u16 ( ) ? as usize ,
331+ 2 | 8 | 10 | 12 | 13 | 14 => todo ! ( ) ,
331332 foreign => bail ! ( "Unexpected cmap format: {}." , foreign) ,
332333 } ;
333334
@@ -383,6 +384,19 @@ impl<'a> TrueTypeFontParser<'a> {
383384 } )
384385 }
385386
387+ fn parse_cmap_subtable_format_6 ( & mut self ) -> Result < CMapFormat6 > {
388+ let language = self . read_u16 ( ) ?;
389+ let first_code = self . read_u16 ( ) ?;
390+ let entry_count = self . read_u16 ( ) ?;
391+ let glyph_index_array = self . read_list ( entry_count as usize , Self :: read_u16) ?;
392+
393+ Ok ( CMapFormat6 {
394+ language,
395+ first_code,
396+ glyph_index_array,
397+ } )
398+ }
399+
386400 fn parse_glyph_table ( & mut self , num_glyphs : u16 ) -> Result < GlyphTable > {
387401 let mut glyphs = Vec :: with_capacity ( num_glyphs as usize ) ;
388402
0 commit comments