@@ -91,33 +91,39 @@ pub enum Images {
91
91
Svg ( tables:: Svg ) ,
92
92
}
93
93
94
- rental ! {
95
- mod tables {
96
- use super :: * ;
97
-
98
- #[ rental]
99
- pub struct CBLC {
100
- data: Box <[ u8 ] >,
101
- table: CBLCTable <' data>
102
- }
94
+ mod tables {
95
+ use ouroboros:: self_referencing;
96
+ use super :: * ;
97
+ #[ self_referencing( pub_extras) ]
98
+ pub struct CBLC {
99
+ data : Box < [ u8 ] > ,
100
+ #[ borrows( data) ]
101
+ #[ not_covariant]
102
+ pub ( crate ) table : CBLCTable < ' this > ,
103
+ }
103
104
104
- #[ rental( covariant) ]
105
- pub struct CBDT {
106
- data: Box <[ u8 ] >,
107
- table: CBDTTable <' data>
108
- }
105
+ #[ self_referencing( pub_extras) ]
106
+ pub struct CBDT {
107
+ data : Box < [ u8 ] > ,
108
+ #[ borrows( data) ]
109
+ #[ covariant]
110
+ pub ( crate ) table : CBDTTable < ' this > ,
111
+ }
109
112
110
- #[ rental]
111
- pub struct Sbix {
112
- data: Box <[ u8 ] >,
113
- table: SbixTable <' data>
114
- }
113
+ #[ self_referencing( pub_extras) ]
114
+ pub struct Sbix {
115
+ data : Box < [ u8 ] > ,
116
+ #[ borrows( data) ]
117
+ #[ not_covariant]
118
+ pub ( crate ) table : SbixTable < ' this > ,
119
+ }
115
120
116
- #[ rental]
117
- pub struct Svg {
118
- data: Box <[ u8 ] >,
119
- table: SvgTable <' data>
120
- }
121
+ #[ self_referencing( pub_extras) ]
122
+ pub struct Svg {
123
+ data : Box < [ u8 ] > ,
124
+ #[ borrows( data) ]
125
+ #[ not_covariant]
126
+ pub ( crate ) table : SvgTable < ' this > ,
121
127
}
122
128
}
123
129
@@ -529,15 +535,15 @@ impl<T: FontTableProvider> Font<T> {
529
535
None => return Ok ( None ) ,
530
536
} ;
531
537
match embedded_bitmaps. as_ref ( ) {
532
- Images :: Embedded { cblc, cbdt } => cblc. rent ( |cblc : & CBLCTable < ' _ > | {
538
+ Images :: Embedded { cblc, cbdt } => cblc. with_table ( |cblc : & CBLCTable < ' _ > | {
533
539
let target_ppem = if target_ppem > u16:: from ( std:: u8:: MAX ) {
534
540
std:: u8:: MAX
535
541
} else {
536
542
target_ppem as u8
537
543
} ;
538
544
let bitmap = match cblc. find_strike ( glyph_index, target_ppem, max_bit_depth) {
539
545
Some ( matching_strike) => {
540
- let cbdt = cbdt. suffix ( ) ;
546
+ let cbdt = cbdt. borrow_table ( ) ;
541
547
cbdt:: lookup ( glyph_index, & matching_strike, cbdt) ?. map ( |bitmap| {
542
548
BitmapGlyph :: try_from ( ( & matching_strike. bitmap_size . inner , bitmap) )
543
549
} )
@@ -565,7 +571,7 @@ impl<T: FontTableProvider> Font<T> {
565
571
target_ppem : u16 ,
566
572
max_bit_depth : BitDepth ,
567
573
) -> Result < Option < BitmapGlyph > , ParseError > {
568
- sbix. rent ( |sbix_table : & SbixTable < ' _ > | {
574
+ sbix. with_table ( |sbix_table : & SbixTable < ' _ > | {
569
575
match sbix_table. find_strike ( glyph_index, target_ppem, max_bit_depth) {
570
576
Some ( strike) => {
571
577
match strike. read_glyph ( glyph_index) ? {
@@ -604,7 +610,7 @@ impl<T: FontTableProvider> Font<T> {
604
610
svg : & tables:: Svg ,
605
611
glyph_index : u16 ,
606
612
) -> Result < Option < BitmapGlyph > , ParseError > {
607
- svg. rent (
613
+ svg. with_table (
608
614
|svg_table : & SvgTable < ' _ > | match svg_table. lookup_glyph ( glyph_index) ? {
609
615
Some ( svg_record) => BitmapGlyph :: try_from ( & svg_record) . map ( Some ) ,
610
616
None => Ok ( None ) ,
@@ -813,10 +819,10 @@ fn load_cblc_cbdt(
813
819
let cblc_data = read_and_box_table ( provider, tag:: CBLC ) ?;
814
820
let cbdt_data = read_and_box_table ( provider, tag:: CBDT ) ?;
815
821
816
- let cblc = tables:: CBLC :: try_new_or_drop ( cblc_data, |data| {
822
+ let cblc = tables:: CBLC :: try_new ( cblc_data, |data| {
817
823
ReadScope :: new ( data) . read :: < CBLCTable < ' _ > > ( )
818
824
} ) ?;
819
- let cbdt = tables:: CBDT :: try_new_or_drop ( cbdt_data, |data| {
825
+ let cbdt = tables:: CBDT :: try_new ( cbdt_data, |data| {
820
826
ReadScope :: new ( data) . read :: < CBDTTable < ' _ > > ( )
821
827
} ) ?;
822
828
@@ -828,14 +834,14 @@ fn load_sbix(
828
834
num_glyphs : usize ,
829
835
) -> Result < tables:: Sbix , ParseError > {
830
836
let sbix_data = read_and_box_table ( provider, tag:: SBIX ) ?;
831
- tables:: Sbix :: try_new_or_drop ( sbix_data, |data| {
837
+ tables:: Sbix :: try_new ( sbix_data, |data| {
832
838
ReadScope :: new ( data) . read_dep :: < SbixTable < ' _ > > ( num_glyphs)
833
839
} )
834
840
}
835
841
836
842
fn load_svg ( provider : & impl FontTableProvider ) -> Result < tables:: Svg , ParseError > {
837
843
let svg_data = read_and_box_table ( provider, tag:: SVG ) ?;
838
- tables:: Svg :: try_new_or_drop ( svg_data, |data| ReadScope :: new ( data) . read :: < SvgTable < ' _ > > ( ) )
844
+ tables:: Svg :: try_new ( svg_data, |data| ReadScope :: new ( data) . read :: < SvgTable < ' _ > > ( ) )
839
845
}
840
846
841
847
fn charmap_info ( cmap_buf : & [ u8 ] ) -> Result < Option < ( Encoding , u32 ) > , ParseError > {
0 commit comments