@@ -4,13 +4,11 @@ use core_maths::CoreFloat;
4
4
5
5
use crate :: hb:: paint_extents:: hb_paint_extents_context_t;
6
6
use ttf_parser:: gdef:: GlyphClass ;
7
- use ttf_parser:: opentype_layout:: LayoutTable ;
8
7
use ttf_parser:: { GlyphId , RgbaColor } ;
9
8
10
9
use super :: buffer:: GlyphPropsFlags ;
11
10
use super :: fonta;
12
11
use super :: ot_layout:: TableIndex ;
13
- use super :: ot_layout_common:: { PositioningTable , SubstitutionTable } ;
14
12
use crate :: Variation ;
15
13
16
14
/// A font face handle.
@@ -21,22 +19,6 @@ pub struct hb_font_t<'a> {
21
19
pub ( crate ) units_per_em : u16 ,
22
20
pixels_per_em : Option < ( u16 , u16 ) > ,
23
21
pub ( crate ) points_per_em : Option < f32 > ,
24
- pub ( crate ) gsub : Option < SubstitutionTable < ' a > > ,
25
- pub ( crate ) gpos : Option < PositioningTable < ' a > > ,
26
- }
27
-
28
- impl < ' a > AsRef < ttf_parser:: Face < ' a > > for hb_font_t < ' a > {
29
- #[ inline]
30
- fn as_ref ( & self ) -> & ttf_parser:: Face < ' a > {
31
- & self . ttfp_face
32
- }
33
- }
34
-
35
- impl < ' a > AsMut < ttf_parser:: Face < ' a > > for hb_font_t < ' a > {
36
- #[ inline]
37
- fn as_mut ( & mut self ) -> & mut ttf_parser:: Face < ' a > {
38
- & mut self . ttfp_face
39
- }
40
22
}
41
23
42
24
impl < ' a > core:: ops:: Deref for hb_font_t < ' a > {
@@ -48,13 +30,6 @@ impl<'a> core::ops::Deref for hb_font_t<'a> {
48
30
}
49
31
}
50
32
51
- impl < ' a > core:: ops:: DerefMut for hb_font_t < ' a > {
52
- #[ inline]
53
- fn deref_mut ( & mut self ) -> & mut Self :: Target {
54
- & mut self . ttfp_face
55
- }
56
- }
57
-
58
33
impl < ' a > hb_font_t < ' a > {
59
34
/// Creates a new `Face` from data.
60
35
///
@@ -67,28 +42,10 @@ impl<'a> hb_font_t<'a> {
67
42
units_per_em : face. units_per_em ( ) ,
68
43
pixels_per_em : None ,
69
44
points_per_em : None ,
70
- gsub : face. tables ( ) . gsub . map ( SubstitutionTable :: new) ,
71
- gpos : face. tables ( ) . gpos . map ( PositioningTable :: new) ,
72
45
ttfp_face : face,
73
46
} )
74
47
}
75
48
76
- /// Creates a new [`Face`] from [`ttf_parser::Face`].
77
- ///
78
- /// Data will be referenced, not owned.
79
- pub fn from_face ( face : ttf_parser:: Face < ' a > ) -> Self {
80
- let font = fonta:: Font :: new ( face. raw_face ( ) . data , 0 ) . unwrap ( ) ;
81
- hb_font_t {
82
- font,
83
- units_per_em : face. units_per_em ( ) ,
84
- pixels_per_em : None ,
85
- points_per_em : None ,
86
- gsub : face. tables ( ) . gsub . map ( SubstitutionTable :: new) ,
87
- gpos : face. tables ( ) . gpos . map ( PositioningTable :: new) ,
88
- ttfp_face : face,
89
- }
90
- }
91
-
92
49
// TODO: remove
93
50
/// Returns face’s units per EM.
94
51
#[ inline]
@@ -124,7 +81,7 @@ impl<'a> hb_font_t<'a> {
124
81
/// Sets font variations.
125
82
pub fn set_variations ( & mut self , variations : & [ Variation ] ) {
126
83
for variation in variations {
127
- self . set_variation ( variation. tag , variation. value ) ;
84
+ self . ttfp_face . set_variation ( variation. tag , variation. value ) ;
128
85
}
129
86
self . font . set_coords ( self . ttfp_face . variation_coordinates ( ) ) ;
130
87
}
@@ -338,17 +295,24 @@ impl<'a> hb_font_t<'a> {
338
295
}
339
296
}
340
297
341
- pub ( crate ) fn layout_table ( & self , table_index : TableIndex ) -> Option < & LayoutTable < ' a > > {
298
+ pub ( crate ) fn layout_table (
299
+ & self ,
300
+ table_index : TableIndex ,
301
+ ) -> Option < fonta:: ot:: LayoutTable < ' a > > {
342
302
match table_index {
343
- TableIndex :: GSUB => self . gsub . as_ref ( ) . map ( |table| & table. inner ) ,
344
- TableIndex :: GPOS => self . gpos . as_ref ( ) . map ( |table| & table. inner ) ,
303
+ TableIndex :: GSUB => Some ( fonta:: ot:: LayoutTable :: Gsub (
304
+ self . font . ot . gsub . as_ref ( ) ?. table . clone ( ) ,
305
+ ) ) ,
306
+ TableIndex :: GPOS => Some ( fonta:: ot:: LayoutTable :: Gpos (
307
+ self . font . ot . gpos . as_ref ( ) ?. table . clone ( ) ,
308
+ ) ) ,
345
309
}
346
310
}
347
311
348
312
pub ( crate ) fn layout_tables (
349
313
& self ,
350
- ) -> impl Iterator < Item = ( TableIndex , & LayoutTable < ' a > ) > + ' _ {
351
- TableIndex :: iter ( ) . filter_map ( move |idx| self . layout_table ( idx) . map ( |table| ( idx , table ) ) )
314
+ ) -> impl Iterator < Item = ( TableIndex , fonta :: ot :: LayoutTable < ' a > ) > + ' _ {
315
+ TableIndex :: iter ( ) . filter_map ( move |idx| Some ( ( idx , self . layout_table ( idx) ? ) ) )
352
316
}
353
317
}
354
318
0 commit comments