11use super :: buffer:: GlyphPropsFlags ;
22use super :: ot_layout:: TableIndex ;
3- use super :: { common:: TagExt , set_digest :: hb_set_digest_t } ;
3+ use super :: { common:: TagExt } ;
44use crate :: hb:: hb_tag_t;
55use crate :: hb:: ot_layout_gsubgpos:: MappingCache ;
66use crate :: hb:: tables:: TableOffsets ;
@@ -16,8 +16,9 @@ use read_fonts::{
1616 varc:: { Condition , CoverageTable } ,
1717 variations:: { DeltaSetIndex , ItemVariationStore } ,
1818 } ,
19- types:: { BigEndian , F2Dot14 , GlyphId , Offset32 } ,
20- FontData , FontRef , ReadError , ResolveOffset , TableProvider ,
19+ types:: { F2Dot14 , GlyphId } ,
20+ collections:: int_set:: U32Set ,
21+ FontRef , ReadError , TableProvider ,
2122} ;
2223
2324pub mod contextual;
@@ -29,7 +30,7 @@ pub struct OtCache {
2930 pub gsub : LookupCache ,
3031 pub gpos : LookupCache ,
3132 pub gdef_glyph_props_cache : MappingCache ,
32- pub gdef_mark_set_digests : Vec < hb_set_digest_t > ,
33+ pub gdef_mark_sets : Vec < U32Set > ,
3334}
3435
3536impl OtCache {
@@ -50,12 +51,29 @@ impl OtCache {
5051 cache
5152 } )
5253 . unwrap_or_default ( ) ;
53- let mut gdef_mark_set_digests = Vec :: new ( ) ;
54+ let mut gdef_mark_sets = Vec :: new ( ) ;
5455 if let Ok ( gdef) = font. gdef ( ) {
5556 if let Some ( Ok ( mark_sets) ) = gdef. mark_glyph_sets_def ( ) {
56- gdef_mark_set_digests . extend ( mark_sets. coverages ( ) . iter ( ) . map ( |set| {
57+ gdef_mark_sets . extend ( mark_sets. coverages ( ) . iter ( ) . map ( |set| {
5758 set. ok ( )
58- . map ( |coverage| hb_set_digest_t:: from_coverage ( & coverage) )
59+ . map ( |coverage| {
60+ let mut set = U32Set :: empty ( ) ;
61+
62+ // TODO Move somewhere in Coverage.
63+ match coverage {
64+ CoverageTable :: Format1 ( table) => {
65+ for glyph in table. glyph_array ( ) {
66+ set. insert ( glyph. get ( ) . into ( ) ) ;
67+ }
68+ }
69+ CoverageTable :: Format2 ( table) => {
70+ for range in table. range_records ( ) {
71+ set. insert_range ( range. start_glyph_id ( ) . into ( ) ..=range. end_glyph_id ( ) . into ( ) ) ;
72+ }
73+ }
74+ }
75+ set
76+ } )
5977 . unwrap_or_default ( )
6078 } ) ) ;
6179 }
@@ -64,7 +82,7 @@ impl OtCache {
6482 gsub,
6583 gpos,
6684 gdef_glyph_props_cache : MappingCache :: new ( ) ,
67- gdef_mark_set_digests ,
85+ gdef_mark_sets ,
6886 }
6987 }
7088}
@@ -106,25 +124,17 @@ pub struct GdefTable<'a> {
106124 table : Option < Gdef < ' a > > ,
107125 classes : Option < ClassDef < ' a > > ,
108126 mark_classes : Option < ClassDef < ' a > > ,
109- mark_sets : Option < ( FontData < ' a > , & ' a [ BigEndian < Offset32 > ] ) > ,
110127}
111128
112129impl < ' a > GdefTable < ' a > {
113130 fn new ( font : & FontRef < ' a > , table_offsets : & TableOffsets ) -> Self {
114131 if let Some ( gdef) = table_offsets. gdef . resolve_table :: < Gdef > ( font) {
115132 let classes = gdef. glyph_class_def ( ) . transpose ( ) . ok ( ) . flatten ( ) ;
116133 let mark_classes = gdef. mark_attach_class_def ( ) . transpose ( ) . ok ( ) . flatten ( ) ;
117- let mark_sets = gdef
118- . mark_glyph_sets_def ( )
119- . transpose ( )
120- . ok ( )
121- . flatten ( )
122- . map ( |sets| ( sets. offset_data ( ) , sets. coverage_offsets ( ) ) ) ;
123134 Self {
124135 table : Some ( gdef) ,
125136 classes,
126137 mark_classes,
127- mark_sets,
128138 }
129139 } else {
130140 Self :: default ( )
@@ -138,7 +148,7 @@ pub struct OtTables<'a> {
138148 pub gpos : Option < GposTable < ' a > > ,
139149 pub gdef : GdefTable < ' a > ,
140150 pub gdef_glyph_props_cache : & ' a MappingCache ,
141- pub gdef_mark_set_digests : & ' a [ hb_set_digest_t ] ,
151+ pub gdef_mark_sets : & ' a [ U32Set ] ,
142152 pub coords : & ' a [ F2Dot14 ] ,
143153 pub var_store : Option < ItemVariationStore < ' a > > ,
144154 pub value_context : ValueContext < ' a > ,
@@ -187,7 +197,7 @@ impl<'a> OtTables<'a> {
187197 gpos,
188198 gdef,
189199 gdef_glyph_props_cache : & cache. gdef_glyph_props_cache ,
190- gdef_mark_set_digests : & cache. gdef_mark_set_digests ,
200+ gdef_mark_sets : & cache. gdef_mark_sets ,
191201 var_store,
192202 coords,
193203 value_context,
@@ -235,20 +245,10 @@ impl<'a> OtTables<'a> {
235245 }
236246
237247 pub fn is_mark_glyph ( & self , glyph_id : u32 , set_index : u16 ) -> bool {
238- if self
239- . gdef_mark_set_digests
248+ self
249+ . gdef_mark_sets
240250 . get ( set_index as usize )
241- . is_some_and ( |digest| digest. may_have_glyph ( glyph_id. into ( ) ) )
242- {
243- self . gdef
244- . mark_sets
245- . as_ref ( )
246- . and_then ( |( data, offsets) | Some ( ( data, offsets. get ( set_index as usize ) ?. get ( ) ) ) )
247- . and_then ( |( data, offset) | offset. resolve :: < CoverageTable > ( * data) . ok ( ) )
248- . is_some_and ( |coverage| coverage. get ( glyph_id) . is_some ( ) )
249- } else {
250- false
251- }
251+ . is_some_and ( |set| set. contains ( glyph_id. into ( ) ) )
252252 }
253253
254254 pub fn table_data_and_lookups (
0 commit comments