1pub struct FontFile {
2 file_type: FontFileType,
3 bytes: Vec<u8>,
4 table_records: Vec<TableRecord>
5}
6
7impl FontFile {
8 pub(super) fn new(file_type: FontFileType, bytes: Vec<u8>, table_records: Vec<TableRecord>) -> Self {
9 Self {
10 file_type,
11 bytes,
12 table_records
13 }
14 }
15
16 pub fn file_type(&self) -> FontFileType {
17 self.file_type
18 }
19
20 pub fn bytes(&self) -> &[u8] {
21 &self.bytes
22 }
23
24 pub fn table_records(&self) -> &[TableRecord] {
25 &self.table_records
26 }
27}
28
29#[derive(Clone, Copy)]
30pub enum FontFileType {
31 TrueType,
32 OpenType
33}
34
35#[derive(Clone, Copy)]
36pub struct TableRecord {
37 tag: [u8; 4],
38 checksum: u32,
39 offset: u32,
40 length: u32
41}
42
43impl TableRecord {
44 pub(super) fn new(tag: [u8; 4], checksum: u32, offset: u32, length: u32) -> Self {
45 Self { tag, checksum, offset, length }
46 }
47
48 pub fn tag(&self) -> [u8; 4] {
49 self.tag
50 }
51
52 pub fn checksum(&self) -> u32 {
53 self.checksum
54 }
55
56 pub fn offset(&self) -> u32 {
57 self.offset
58 }
59
60 pub fn length(&self) -> u32 {
61 self.length
62 }
63}
64
65pub struct HeadTable {
66 units_per_em: u16,
67 created: i64,
68 modified: i64,
69 x_min: i16,
70 y_min: i16,
71 x_max: i16,
72 y_max: i16,
73 mac_style: u16,
74 lowest_rec_ppem: u16,
75 font_direction_hint: i16,
76 index_to_loc_format: i16
77}
78
79impl HeadTable {
80 pub(super) fn new(
81 units_per_em: u16,
82 created: i64,
83 modified: i64,
84 x_min: i16,
85 y_min: i16,
86 x_max: i16,
87 y_max: i16,
88 mac_style: u16,
89 lowest_rec_ppem: u16,
90 font_direction_hint: i16,
91 index_to_loc_format: i16
92 ) -> Self {
93 Self {
94 units_per_em,
95 created,
96 modified,
97 x_min,
98 y_min,
99 x_max,
100 y_max,
101 mac_style,
102 lowest_rec_ppem,
103 font_direction_hint,
104 index_to_loc_format
105 }
106 }
107
108 pub fn units_per_em(&self) -> u16 {
109 self.units_per_em
110 }
111
112 pub fn created(&self) -> i64 {
113 self.created
114 }
115
116 pub fn modified(&self) -> i64 {
117 self.modified
118 }
119
120 pub fn x_min(&self) -> i16 {
121 self.x_min
122 }
123
124 pub fn y_min(&self) -> i16 {
125 self.y_min
126 }
127
128 pub fn x_max(&self) -> i16 {
129 self.x_max
130 }
131
132 pub fn y_max(&self) -> i16 {
133 self.y_max
134 }
135
136 pub fn mac_style(&self) -> u16 {
137 self.mac_style
138 }
139
140 pub fn lowest_rec_ppem(&self) -> u16 {
141 self.lowest_rec_ppem
142 }
143
144 pub fn font_direction_hint(&self) -> i16 {
145 self.font_direction_hint
146 }
147
148 pub fn index_to_loc_format(&self) -> i16 {
149 self.index_to_loc_format
150 }
151}
152
153pub struct MaxpTable {
154 version: u32,
155 num_glyphs: u16,
156 max_points: Option<u16>,
157 max_contours: Option<u16>,
158 max_composite_points: Option<u16>,
159 max_composite_contours: Option<u16>,
160 max_zones: Option<u16>,
161 max_twilight_points: Option<u16>,
162 max_storage: Option<u16>,
163 max_function_defs: Option<u16>,
164 max_instruction_defs: Option<u16>,
165 max_stack_elements: Option<u16>,
166 max_size_of_instructions: Option<u16>,
167 max_components_elements: Option<u16>,
168 max_component_depth: Option<u16>
169}
170
171impl MaxpTable {
172 pub(super) fn new(
173 version: u32,
174 num_glyphs: u16,
175 max_points: Option<u16>,
176 max_contours: Option<u16>,
177 max_composite_points: Option<u16>,
178 max_composite_contours: Option<u16>,
179 max_zones: Option<u16>,
180 max_twilight_points: Option<u16>,
181 max_storage: Option<u16>,
182 max_function_defs: Option<u16>,
183 max_instruction_defs: Option<u16>,
184 max_stack_elements: Option<u16>,
185 max_size_of_instructions: Option<u16>,
186 max_components_elements: Option<u16>,
187 max_component_depth: Option<u16>
188 ) -> Self {
189 Self {
190 version,
191 num_glyphs,
192 max_points,
193 max_contours,
194 max_composite_points,
195 max_composite_contours,
196 max_zones,
197 max_twilight_points,
198 max_storage,
199 max_function_defs,
200 max_instruction_defs,
201 max_stack_elements,
202 max_size_of_instructions,
203 max_components_elements,
204 max_component_depth
205 }
206 }
207
208 pub fn version(&self) -> u32 {
209 self.version
210 }
211
212 pub fn num_glyphs(&self) -> u16 {
213 self.num_glyphs
214 }
215
216 pub fn max_points(&self) -> Option<u16> {
217 self.max_points
218 }
219
220 pub fn max_contours(&self) -> Option<u16> {
221 self.max_contours
222 }
223
224 pub fn max_composite_points(&self) -> Option<u16> {
225 self.max_composite_points
226 }
227
228 pub fn max_composite_contours(&self) -> Option<u16> {
229 self.max_composite_contours
230 }
231
232 pub fn max_zones(&self) -> Option<u16> {
233 self.max_zones
234 }
235
236 pub fn max_twilight_points(&self) -> Option<u16> {
237 self.max_twilight_points
238 }
239
240 pub fn max_storage(&self) -> Option<u16> {
241 self.max_storage
242 }
243
244 pub fn max_function_defs(&self) -> Option<u16> {
245 self.max_function_defs
246 }
247
248 pub fn max_instruction_defs(&self) -> Option<u16> {
249 self.max_instruction_defs
250 }
251
252 pub fn max_stack_elements(&self) -> Option<u16> {
253 self.max_stack_elements
254 }
255
256 pub fn max_size_of_instructions(&self) -> Option<u16> {
257 self.max_size_of_instructions
258 }
259
260 pub fn max_component_elements(&self) -> Option<u16> {
261 self.max_components_elements
262 }
263
264 pub fn max_component_depth(&self) -> Option<u16> {
265 self.max_component_depth
266 }
267}
268
269pub struct CmapTable {
270 version: u16,
271 num_tables: u16,
272 encoding_records: Vec<EncodingRecord>,
273 subtables: Vec<CmapSubtable>
274}
275
276impl CmapTable {
277 pub(super) fn new(
278 version: u16,
279 num_tables: u16,
280 encoding_records: Vec<EncodingRecord>,
281 subtables: Vec<CmapSubtable>
282 ) -> Self {
283 Self {
284 version,
285 num_tables,
286 encoding_records,
287 subtables
288 }
289 }
290
291 pub fn version(&self) -> u16 {
292 self.version
293 }
294
295 pub fn num_tables(&self) -> u16 {
296 self.num_tables
297 }
298
299 pub fn encoding_records(&self) -> &[EncodingRecord] {
300 &self.encoding_records
301 }
302
303 pub fn subtables(&self) -> &[CmapSubtable] {
304 &self.subtables
305 }
306}
307
308pub struct EncodingRecord {
309 platform_id: u16,
310 encoding_id: u16,
311 offset: u32
312}
313
314impl EncodingRecord {
315 pub(super) fn new(
316 platform_id: u16,
317 encoding_id: u16,
318 offset: u32
319 ) -> Self {
320 Self {
321 platform_id,
322 encoding_id,
323 offset
324 }
325 }
326
327 pub fn platform_id(&self) -> u16 {
328 self.platform_id
329 }
330
331 pub fn encoding_id(&self) -> u16 {
332 self.encoding_id
333 }
334
335 pub fn offset(&self) -> u32 {
336 self.offset
337 }
338}
339
340#[derive(Clone, PartialEq, Eq)]
341pub enum CmapSubtable {
342 Format0 {
343 length: u16,
344 language: u16,
345 glyph_id_array: [u8; 256]
346 },
347 Format2 {
348 length: u16,
349 language: u16,
350 sub_header_keys: [u16; 256],
351 sub_headers: Vec<SubHeader>,
352 glyph_id_array: Vec<u16>
353 },
354 Format4 {
355 length: u16,
356 language: u16,
357 seg_count_x2: u16,
358 search_range: u16,
359 entry_selector: u16,
360 range_shift: u16,
361 end_code: Vec<u16>,
362 _reserved_pad: u16,
363 start_code: Vec<u16>,
364 id_delta: Vec<i16>,
365 id_range_offset: Vec<u16>,
366 glyph_id_array: Vec<u16>
367 },
368 Format6 {
369 length: u16,
370 language: u16,
371 first_code: u16,
372 entry_count: u16,
373 glyph_id_array: Vec<u16>
374 },
375 Format12 {
376 _reserved: u16,
377 length: u32,
378 language: u32,
379 num_groups: u32,
380 groups: Vec<Group>
381 },
382 Format13 {
383 _reserved: u16,
384 length: u32,
385 language: u32,
386 num_groups: u32,
387 groups: Vec<Group>
388 },
389 Format14 {
390 length: u32,
391 num_var_selector_records: u32,
392 var_selector: Vec<VariationSelectorRecord>
393 }
394}
395
396#[derive(Clone, Copy, PartialEq, Eq)]
397pub struct SubHeader {
398 first_code: u16,
399 entry_count: u16,
400 id_delta: i16,
401 id_range_offset: u16
402}
403
404impl SubHeader {
405 pub(super) fn new(
406 first_code: u16,
407 entry_count: u16,
408 id_delta: i16,
409 id_range_offset: u16
410 ) -> Self {
411 Self {
412 first_code,
413 entry_count,
414 id_delta,
415 id_range_offset
416 }
417 }
418
419 pub fn first_code(&self) -> u16 {
420 self.first_code
421 }
422
423 pub fn entry_count(&self) -> u16 {
424 self.entry_count
425 }
426
427 pub fn id_delta(&self) -> i16 {
428 self.id_delta
429 }
430
431 pub fn id_range_offset(&self) -> u16 {
432 self.id_range_offset
433 }
434}
435
436#[derive(Clone, Copy, PartialEq, Eq)]
437pub struct Group {
438 start_char_code: u32,
439 end_char_code: u32,
440 start_glyph_id: u32
441}
442
443impl Group {
444 pub(super) fn new(
445 start_char_code: u32,
446 end_char_code: u32,
447 start_glyph_id: u32
448 ) -> Self {
449 Self {
450 start_char_code,
451 end_char_code,
452 start_glyph_id
453 }
454 }
455
456 pub fn start_char_code(&self) -> u32 {
457 self.start_char_code
458 }
459
460 pub fn end_char_code(&self) -> u32 {
461 self.end_char_code
462 }
463
464 pub fn start_glyph_id(&self) -> u32 {
465 self.start_glyph_id
466 }
467}
468
469#[derive(Clone, Copy, PartialEq, Eq)]
470pub struct VariationSelectorRecord {
471 var_selector: [u8; 3],
472 default_uvs_offset: u32,
473 non_default_uvs_offset: u32
474}
475
476impl VariationSelectorRecord {
477 pub(super) fn new(
478 var_selector: [u8; 3],
479 default_uvs_offset: u32,
480 non_default_uvs_offset: u32
481 ) -> Self {
482 Self {
483 var_selector,
484 default_uvs_offset,
485 non_default_uvs_offset
486 }
487 }
488
489 pub fn var_selector(&self) -> [u8; 3] {
490 self.var_selector
491 }
492
493 pub fn default_uvs_offset(&self) -> u32 {
494 self.default_uvs_offset
495 }
496
497 pub fn non_default_uvs_offset(&self) -> u32 {
498 self.non_default_uvs_offset
499 }
500}
501
502#[derive(Clone)]
503pub enum Glyph {
504 Simple {
505 header: GlyphHeader,
506 end_pts_of_contours: Vec<u16>,
507 instruction_length: u16,
508 instructions: Vec<u8>,
509 flags: Vec<u8>,
510 x_coordinates: Vec<i16>,
511 y_coordinates: Vec<i16>
512 },
513 Composite {
514 header: GlyphHeader,
515 components: Vec<Component>,
516 instruction_length: Option<u16>,
517 instructions: Option<Vec<u8>>
518 }
519}
520
521#[derive(Clone, Copy, Default)]
522pub struct GlyphHeader {
523 number_of_contours: i16,
524 x_min: i16,
525 y_min: i16,
526 x_max: i16,
527 y_max: i16
528}
529
530impl GlyphHeader {
531 pub(crate) fn new(
532 number_of_contours: i16,
533 x_min: i16,
534 y_min: i16,
535 x_max: i16,
536 y_max: i16
537 ) -> Self {
538 Self {
539 number_of_contours,
540 x_min,
541 y_min,
542 x_max,
543 y_max
544 }
545 }
546
547 pub fn number_of_contours(&self) -> i16 {
548 self.number_of_contours
549 }
550
551 pub fn x_min(&self) -> i16 {
552 self.x_min
553 }
554
555 pub fn y_min(&self) -> i16 {
556 self.y_min
557 }
558
559 pub fn x_max(&self) -> i16 {
560 self.x_max
561 }
562
563 pub fn y_max(&self) -> i16 {
564 self.y_max
565 }
566}
567
568#[derive(Clone, Copy)]
569pub struct Component {
570 flags: u16,
571 glyph_index: u16,
572 argument_1: i16,
573 argument_2: i16,
574 transformation: [i16; 4]
575}
576
577impl Component {
578 pub(super) fn new(
579 flags: u16,
580 glyph_index: u16,
581 argument_1: i16,
582 argument_2: i16,
583 transformation: [i16; 4]
584 ) -> Self {
585 Self {
586 flags,
587 glyph_index,
588 argument_1,
589 argument_2,
590 transformation
591 }
592 }
593
594 pub fn flags(&self) -> u16 {
595 self.flags
596 }
597
598 pub fn glyph_index(&self) -> u16 {
599 self.glyph_index
600 }
601
602 pub fn argument_1(&self) -> i16 {
603 self.argument_1
604 }
605
606 pub fn argument_2(&self) -> i16 {
607 self.argument_2
608 }
609
610 pub fn transformation(&self) -> [i16; 4] {
611 self.transformation
612 }
613}
614
615pub struct HheaTable {
616 version: u32,
617 ascender: i16,
618 descender: i16,
619 line_gap: i16,
620 advance_width_max: u16,
621 min_left_side_bearing: i16,
622 min_right_side_bearing: i16,
623 x_max_extent: i16,
624 caret_slope_rise: i16,
625 caret_slope_run: i16,
626 caret_offset: i16,
627 _reserved1: i16,
628 _reserved2: i16,
629 _reserved3: i16,
630 _reserved4: i16,
631 metric_data_format: i16,
632 number_of_h_metrics: u16
633}
634
635impl HheaTable {
636 pub(super) fn new(
637 version: u32,
638 ascender: i16,
639 descender: i16,
640 line_gap: i16,
641 advance_width_max: u16,
642 min_left_side_bearing: i16,
643 min_right_side_bearing: i16,
644 x_max_extent: i16,
645 caret_slope_rise: i16,
646 caret_slope_run: i16,
647 caret_offset: i16,
648 _reserved1: i16,
649 _reserved2: i16,
650 _reserved3: i16,
651 _reserved4: i16,
652 metric_data_format: i16,
653 number_of_h_metrics: u16
654 ) -> Self {
655 Self {
656 version,
657 ascender,
658 descender,
659 line_gap,
660 advance_width_max,
661 min_left_side_bearing,
662 min_right_side_bearing,
663 x_max_extent,
664 caret_slope_rise,
665 caret_slope_run,
666 caret_offset,
667 _reserved1,
668 _reserved2,
669 _reserved3,
670 _reserved4,
671 metric_data_format,
672 number_of_h_metrics
673 }
674 }
675
676 pub fn version(&self) -> u32 {
677 self.version
678 }
679
680 pub fn ascender(&self) -> i16 {
681 self.ascender
682 }
683
684 pub fn descender(&self) -> i16 {
685 self.descender
686 }
687
688 pub fn line_gap(&self) -> i16 {
689 self.line_gap
690 }
691
692 pub fn advance_width_max(&self) -> u16 {
693 self.advance_width_max
694 }
695
696 pub fn min_left_side_bearing(&self) -> i16 {
697 self.min_left_side_bearing
698 }
699
700 pub fn min_right_side_bearing(&self) -> i16 {
701 self.min_right_side_bearing
702 }
703
704 pub fn x_max_extent(&self) -> i16 {
705 self.x_max_extent
706 }
707
708 pub fn caret_slope_rise(&self) -> i16 {
709 self.caret_slope_rise
710 }
711
712 pub fn caret_slope_run(&self) -> i16 {
713 self.caret_slope_run
714 }
715
716 pub fn caret_offset(&self) -> i16 {
717 self.caret_offset
718 }
719
720 pub fn metric_data_format(&self) -> i16 {
721 self.metric_data_format
722 }
723
724 pub fn number_of_h_metrics(&self) -> u16 {
725 self.number_of_h_metrics
726 }
727}
728
729pub struct HmtxTable {
730 entries: Vec<HmtxEntry>,
731 shared_advance_width: u16
732}
733
734impl HmtxTable {
735 pub(super) fn new(
736 entries: Vec<HmtxEntry>,
737 shared_advance_width: u16
738 ) -> Self {
739 Self {
740 entries,
741 shared_advance_width
742 }
743 }
744
745 pub fn entries(&self) -> &[HmtxEntry] {
746 &self.entries
747 }
748
749 pub fn shared_advance_width(&self) -> u16 {
750 self.shared_advance_width
751 }
752}
753
754pub enum HmtxEntry {
755 FullMetric {
756 advance_width: u16,
757 lsb: i16
758 },
759 LeftoverBearing(i16)
760}
761
762pub struct NameTable {
763 version: u16,
764 count: u16,
765 storage_offset: u16,
766 records: Vec<NameRecord>,
767 lang_tag_count: Option<u16>,
768 lang_tag_records: Option<Vec<LangTagRecord>>
769}
770
771impl NameTable {
772 pub(super) fn new(
773 version: u16,
774 count: u16,
775 storage_offset: u16,
776 records: Vec<NameRecord>,
777 lang_tag_count: Option<u16>,
778 lang_tag_records: Option<Vec<LangTagRecord>>
779 ) -> Self {
780 Self {
781 version,
782 count,
783 storage_offset,
784 records,
785 lang_tag_count,
786 lang_tag_records
787 }
788 }
789
790 pub fn version(&self) -> u16 {
791 self.version
792 }
793
794 pub fn count(&self) -> u16 {
795 self.count
796 }
797
798 pub fn storage_offset(&self) -> u16 {
799 self.storage_offset
800 }
801
802 pub fn records(&self) -> &[NameRecord] {
803 &self.records
804 }
805
806 pub fn lang_tag_count(&self) -> Option<u16> {
807 self.lang_tag_count
808 }
809
810 pub fn lang_tag_records(&self) -> Option<&[LangTagRecord]> {
811 self.lang_tag_records.as_deref()
812 }
813}
814
815pub struct NameRecord {
816 platform_id: u16,
817 encoding_id: u16,
818 language_id: u16,
819 name_id: u16,
820 length: u16,
821 string_offset: u16,
822 string: String
823}
824
825impl NameRecord {
826 pub(super) fn new(
827 platform_id: u16,
828 encoding_id: u16,
829 language_id: u16,
830 name_id: u16,
831 length: u16,
832 string_offset: u16,
833 string: String
834 ) -> Self {
835 Self {
836 platform_id,
837 encoding_id,
838 language_id,
839 name_id,
840 length,
841 string_offset,
842 string
843 }
844 }
845
846 pub fn platform_id(&self) -> u16 {
847 self.platform_id
848 }
849
850 pub fn encoding_id(&self) -> u16 {
851 self.encoding_id
852 }
853
854 pub fn language_id(&self) -> u16 {
855 self.language_id
856 }
857
858 pub fn name_id(&self) -> u16 {
859 self.name_id
860 }
861
862 pub fn length(&self) -> u16 {
863 self.length
864 }
865
866 pub fn string_offset(&self) -> u16 {
867 self.string_offset
868 }
869
870 pub fn string(&self) -> &str {
871 &self.string
872 }
873}
874
875pub struct LangTagRecord {
876 length: u16,
877 lang_tag_offset: u16,
878 string: String
879}
880
881impl LangTagRecord {
882 pub(super) fn new(
883 length: u16,
884 lang_tag_offset: u16,
885 string: String
886 ) -> Self {
887 Self {
888 length,
889 lang_tag_offset,
890 string
891 }
892 }
893
894 pub fn length(&self) -> u16 {
895 self.length
896 }
897
898 pub fn lang_tag_offset(&self) -> u16 {
899 self.lang_tag_offset
900 }
901
902 pub fn string(&self) -> &str {
903 &self.string
904 }
905}
906
907pub struct OS2Table {
908 version: u16,
909 x_avg_char_width: i16,
910 us_weight_class: u16,
911 us_width_class: u16,
912 fs_type: u16,
913 y_subscript_x_size: i16,
914 y_subscript_y_size: i16,
915 y_subscript_x_offset: i16,
916 y_subscript_y_offset: i16,
917 y_superscript_x_size: i16,
918 y_superscript_y_size: i16,
919 y_superscript_x_offset: i16,
920 y_superscript_y_offset: i16,
921 y_strikeout_size: i16,
922 y_strikeout_position: i16,
923 s_family_class: i16,
924 panose: [u8; 10],
925 ul_unicode_range_1: u32,
926 ul_unicode_range_2: u32,
927 ul_unicode_range_3: u32,
928 ul_unicode_range_4: u32,
929 ach_vend_id: [u8; 4],
930 fs_selection: u16,
931 us_first_char_index: u16,
932 us_last_char_index: u16,
933 s_typo_ascender: i16,
934 s_typo_descender: i16,
935 s_typo_line_gap: i16,
936 us_win_ascent: u16,
937 us_win_descent: u16,
938 ul_code_page_range_1: Option<u32>,
940 ul_code_page_range_2: Option<u32>,
941 sx_height: Option<i16>,
943 s_cap_height: Option<i16>,
944 us_default_char: Option<u16>,
945 us_break_char: Option<u16>,
946 us_max_context: Option<u16>,
947 us_lower_optical_point_size: Option<u16>,
949 us_upper_optical_point_size: Option<u16>
950}
951
952impl OS2Table {
953 pub(super) fn new(
954 version: u16,
955 x_avg_char_width: i16,
956 us_weight_class: u16,
957 us_width_class: u16,
958 fs_type: u16,
959 y_subscript_x_size: i16,
960 y_subscript_y_size: i16,
961 y_subscript_x_offset: i16,
962 y_subscript_y_offset: i16,
963 y_superscript_x_size: i16,
964 y_superscript_y_size: i16,
965 y_superscript_x_offset: i16,
966 y_superscript_y_offset: i16,
967 y_strikeout_size: i16,
968 y_strikeout_position: i16,
969 s_family_class: i16,
970 panose: [u8; 10],
971 ul_unicode_range_1: u32,
972 ul_unicode_range_2: u32,
973 ul_unicode_range_3: u32,
974 ul_unicode_range_4: u32,
975 ach_vend_id: [u8; 4],
976 fs_selection: u16,
977 us_first_char_index: u16,
978 us_last_char_index: u16,
979 s_typo_ascender: i16,
980 s_typo_descender: i16,
981 s_typo_line_gap: i16,
982 us_win_ascent: u16,
983 us_win_descent: u16,
984 ul_code_page_range_1: Option<u32>,
985 ul_code_page_range_2: Option<u32>,
986 sx_height: Option<i16>,
987 s_cap_height: Option<i16>,
988 us_default_char: Option<u16>,
989 us_break_char: Option<u16>,
990 us_max_context: Option<u16>,
991 us_lower_optical_point_size: Option<u16>,
992 us_upper_optical_point_size: Option<u16>
993 ) -> Self {
994 Self {
995 version,
996 x_avg_char_width,
997 us_weight_class,
998 us_width_class,
999 fs_type,
1000 y_subscript_x_size,
1001 y_subscript_y_size,
1002 y_subscript_x_offset,
1003 y_subscript_y_offset,
1004 y_superscript_x_size,
1005 y_superscript_y_size,
1006 y_superscript_x_offset,
1007 y_superscript_y_offset,
1008 y_strikeout_size,
1009 y_strikeout_position,
1010 s_family_class,
1011 panose,
1012 ul_unicode_range_1,
1013 ul_unicode_range_2,
1014 ul_unicode_range_3,
1015 ul_unicode_range_4,
1016 ach_vend_id,
1017 fs_selection,
1018 us_first_char_index,
1019 us_last_char_index,
1020 s_typo_ascender,
1021 s_typo_descender,
1022 s_typo_line_gap,
1023 us_win_ascent,
1024 us_win_descent,
1025 ul_code_page_range_1,
1026 ul_code_page_range_2,
1027 sx_height,
1028 s_cap_height,
1029 us_default_char,
1030 us_break_char,
1031 us_max_context,
1032 us_lower_optical_point_size,
1033 us_upper_optical_point_size
1034 }
1035 }
1036
1037 pub fn version(&self) -> u16 {
1038 self.version
1039 }
1040
1041 pub fn x_avg_char_width(&self) -> i16 {
1042 self.x_avg_char_width
1043 }
1044
1045 pub fn us_weight_class(&self) -> u16 {
1046 self.us_weight_class
1047 }
1048
1049 pub fn us_width_class(&self) -> u16 {
1050 self.us_width_class
1051 }
1052
1053 pub fn fs_type(&self) -> u16 {
1054 self.fs_type
1055 }
1056
1057 pub fn y_subscript_x_size(&self) -> i16 {
1058 self.y_subscript_x_size
1059 }
1060
1061 pub fn y_subscript_y_size(&self) -> i16 {
1062 self.y_subscript_y_size
1063 }
1064
1065 pub fn y_subscript_x_offset(&self) -> i16 {
1066 self.y_subscript_x_offset
1067 }
1068
1069 pub fn y_subscript_y_offset(&self) -> i16 {
1070 self.y_subscript_y_offset
1071 }
1072
1073 pub fn y_superscript_x_size(&self) -> i16 {
1074 self.y_superscript_x_size
1075 }
1076
1077 pub fn y_superscript_y_size(&self) -> i16 {
1078 self.y_superscript_y_size
1079 }
1080
1081 pub fn y_superscript_x_offset(&self) -> i16 {
1082 self.y_superscript_x_offset
1083 }
1084
1085 pub fn y_superscript_y_offset(&self) -> i16 {
1086 self.y_superscript_y_offset
1087 }
1088
1089 pub fn y_strikeout_size(&self) -> i16 {
1090 self.y_strikeout_size
1091 }
1092
1093 pub fn y_strikeout_position(&self) -> i16 {
1094 self.y_strikeout_position
1095 }
1096
1097 pub fn s_family_class(&self) -> i16 {
1098 self.s_family_class
1099 }
1100
1101 pub fn panose(&self) -> [u8; 10] {
1102 self.panose
1103 }
1104
1105 pub fn ul_unicode_range_1(&self) -> u32 {
1106 self.ul_unicode_range_1
1107 }
1108
1109 pub fn ul_unicode_range_2(&self) -> u32 {
1110 self.ul_unicode_range_2
1111 }
1112
1113 pub fn ul_unicode_range_3(&self) -> u32 {
1114 self.ul_unicode_range_3
1115 }
1116
1117 pub fn ul_unicode_range_4(&self) -> u32 {
1118 self.ul_unicode_range_4
1119 }
1120
1121 pub fn ach_vend_id(&self) -> [u8; 4] {
1122 self.ach_vend_id
1123 }
1124
1125 pub fn fs_selection(&self) -> u16 {
1126 self.fs_selection
1127 }
1128
1129 pub fn us_first_char_index(&self) -> u16 {
1130 self.us_first_char_index
1131 }
1132
1133 pub fn us_last_char_index(&self) -> u16 {
1134 self.us_last_char_index
1135 }
1136
1137 pub fn s_typo_ascender(&self) -> i16 {
1138 self.s_typo_ascender
1139 }
1140
1141 pub fn s_typo_descender(&self) -> i16 {
1142 self.s_typo_descender
1143 }
1144
1145 pub fn s_typo_line_gap(&self) -> i16 {
1146 self.s_typo_line_gap
1147 }
1148
1149 pub fn us_win_ascent(&self) -> u16 {
1150 self.us_win_ascent
1151 }
1152
1153 pub fn us_win_descent(&self) -> u16 {
1154 self.us_win_descent
1155 }
1156
1157 pub fn ul_code_page_range_1(&self) -> Option<u32> {
1158 self.ul_code_page_range_1
1159 }
1160
1161 pub fn ul_code_page_range_2(&self) -> Option<u32> {
1162 self.ul_code_page_range_2
1163 }
1164
1165 pub fn sx_height(&self) -> Option<i16> {
1166 self.sx_height
1167 }
1168
1169 pub fn s_cap_height(&self) -> Option<i16> {
1170 self.s_cap_height
1171 }
1172
1173 pub fn us_default_char(&self) -> Option<u16> {
1174 self.us_default_char
1175 }
1176
1177 pub fn us_break_char(&self) -> Option<u16> {
1178 self.us_break_char
1179 }
1180
1181 pub fn us_max_context(&self) -> Option<u16> {
1182 self.us_max_context
1183 }
1184
1185 pub fn us_lower_optical_point_size(&self) -> Option<u16> {
1186 self.us_lower_optical_point_size
1187 }
1188
1189 pub fn us_upper_optical_point_size(&self) -> Option<u16> {
1190 self.us_upper_optical_point_size
1191 }
1192}
1193
1194pub struct PostTable {
1195 version: u32,
1196 italic_angle: i32,
1197 underline_position: i16,
1198 underline_thickness: i16,
1199 is_fixed_pitch: u32,
1200 min_mem_type_42: u32,
1201 max_mem_type_42: u32,
1202 min_mem_type_1: u32,
1203 max_mem_type_1: u32,
1204 num_glyphs: Option<u16>,
1205 glyph_name_index: Option<Vec<u16>>,
1206 names: Option<Vec<String>>
1207}
1208
1209impl PostTable {
1210 pub(super) fn new(
1211 version: u32,
1212 italic_angle: i32,
1213 underline_position: i16,
1214 underline_thickness: i16,
1215 is_fixed_pitch: u32,
1216 min_mem_type_42: u32,
1217 max_mem_type_42: u32,
1218 min_mem_type_1: u32,
1219 max_mem_type_1: u32,
1220 num_glyphs: Option<u16>,
1221 glyph_name_index: Option<Vec<u16>>,
1222 names: Option<Vec<String>>
1223 ) -> Self {
1224 Self {
1225 version,
1226 italic_angle,
1227 underline_position,
1228 underline_thickness,
1229 is_fixed_pitch,
1230 min_mem_type_42,
1231 max_mem_type_42,
1232 min_mem_type_1,
1233 max_mem_type_1,
1234 num_glyphs,
1235 glyph_name_index,
1236 names
1237 }
1238 }
1239
1240 pub fn version(&self) -> u32 {
1241 self.version
1242 }
1243
1244 pub fn italic_angle(&self) -> i32 {
1245 self.italic_angle
1246 }
1247
1248 pub fn underline_position(&self) -> i16 {
1249 self.underline_position
1250 }
1251
1252 pub fn underline_thickness(&self) -> i16 {
1253 self.underline_thickness
1254 }
1255
1256 pub fn is_fixed_pitch(&self) -> u32 {
1257 self.is_fixed_pitch
1258 }
1259
1260 pub fn min_mem_type_42(&self) -> u32 {
1261 self.min_mem_type_42
1262 }
1263
1264 pub fn max_mem_type_42(&self) -> u32 {
1265 self.max_mem_type_42
1266 }
1267
1268 pub fn min_mem_type_1(&self) -> u32 {
1269 self.min_mem_type_1
1270 }
1271
1272 pub fn max_mem_type_1(&self) -> u32 {
1273 self.max_mem_type_1
1274 }
1275
1276 pub fn num_glyphs(&self) -> Option<u16> {
1277 self.num_glyphs
1278 }
1279
1280 pub fn glyph_name_index(&self) -> Option<&[u16]> {
1281 self.glyph_name_index.as_deref()
1282 }
1283
1284 pub fn names(&self) -> Option<&[String]> {
1285 self.names.as_deref()
1286 }
1287}
1288
1289pub struct VheaTable {
1290 version: u32,
1291 vert_typo_ascender: i16,
1292 vert_typo_descender: i16,
1293 vert_typo_line_gap: i16,
1294 advance_height_max: u16,
1295 min_top_side_bearing: i16,
1296 min_bottom_side_bearing: i16,
1297 y_max_extent: i16,
1298 caret_slope_rise: i16,
1299 caret_slope_run: i16,
1300 caret_offset: i16,
1301 _reserved1: i16,
1302 _reserved2: i16,
1303 _reserved3: i16,
1304 _reserved4: i16,
1305 metric_data_format: i16,
1306 num_of_long_ver_metrics: u16
1307}
1308
1309impl VheaTable {
1310 pub(super) fn new(
1311 version: u32,
1312 vert_typo_ascender: i16,
1313 vert_typo_descender: i16,
1314 vert_typo_line_gap: i16,
1315 advance_height_max: u16,
1316 min_top_side_bearing: i16,
1317 min_bottom_side_bearing: i16,
1318 y_max_extent: i16,
1319 caret_slope_rise: i16,
1320 caret_slope_run: i16,
1321 caret_offset: i16,
1322 _reserved1: i16,
1323 _reserved2: i16,
1324 _reserved3: i16,
1325 _reserved4: i16,
1326 metric_data_format: i16,
1327 num_of_long_ver_metrics: u16
1328 ) -> Self {
1329 Self {
1330 version,
1331 vert_typo_ascender,
1332 vert_typo_descender,
1333 vert_typo_line_gap,
1334 advance_height_max,
1335 min_top_side_bearing,
1336 min_bottom_side_bearing,
1337 y_max_extent,
1338 caret_slope_rise,
1339 caret_slope_run,
1340 caret_offset,
1341 _reserved1,
1342 _reserved2,
1343 _reserved3,
1344 _reserved4,
1345 metric_data_format,
1346 num_of_long_ver_metrics
1347 }
1348 }
1349
1350 pub fn version(&self) -> u32 {
1351 self.version
1352 }
1353
1354 pub fn vert_typo_ascender(&self) -> i16 {
1355 self.vert_typo_ascender
1356 }
1357
1358 pub fn vert_typo_descender(&self) -> i16 {
1359 self.vert_typo_descender
1360 }
1361
1362 pub fn vert_typo_line_gap(&self) -> i16 {
1363 self.vert_typo_line_gap
1364 }
1365
1366 pub fn advance_height_max(&self) -> u16 {
1367 self.advance_height_max
1368 }
1369
1370 pub fn min_top_side_bearing(&self) -> i16 {
1371 self.min_top_side_bearing
1372 }
1373
1374 pub fn min_bottom_side_bearing(&self) -> i16 {
1375 self.min_bottom_side_bearing
1376 }
1377
1378 pub fn y_max_extent(&self) -> i16 {
1379 self.y_max_extent
1380 }
1381
1382 pub fn caret_slope_rise(&self) -> i16 {
1383 self.caret_slope_rise
1384 }
1385
1386 pub fn caret_slope_run(&self) -> i16 {
1387 self.caret_slope_run
1388 }
1389
1390 pub fn caret_offset(&self) -> i16 {
1391 self.caret_offset
1392 }
1393
1394 pub fn metric_data_format(&self) -> i16 {
1395 self.metric_data_format
1396 }
1397
1398 pub fn num_of_long_ver_metrics(&self) -> u16 {
1399 self.num_of_long_ver_metrics
1400 }
1401}
1402
1403pub struct VmtxTable {
1404 entries: Vec<VmtxEntry>,
1405 shared_advance_height: u16
1406}
1407
1408impl VmtxTable {
1409 pub(super) fn new(
1410 entries: Vec<VmtxEntry>,
1411 shared_advance_height: u16
1412 ) -> Self {
1413 Self {
1414 entries,
1415 shared_advance_height
1416 }
1417 }
1418
1419 pub fn entries(&self) -> &[VmtxEntry] {
1420 &self.entries
1421 }
1422
1423 pub fn shared_advance_height(&self) -> u16 {
1424 self.shared_advance_height
1425 }
1426}
1427
1428pub enum VmtxEntry {
1429 FullMetric {
1430 advance_height: u16,
1431 tsb: i16
1432 },
1433 LeftoverBearing(i16)
1434}
1435
1436pub enum KernTable {
1437 Windows {
1438 version: u16,
1439 n_tables: u16,
1440 subtables: Vec<WindowsSubtable>,
1441 },
1442 Mac {
1443 version: u32,
1444 n_tables: u32,
1445 subtables: Vec<MacSubtable>,
1446 }
1447}
1448
1449pub struct WindowsSubtable {
1450 version: u16,
1451 length: u16,
1452 coverage: u16,
1453 subtable: KernSubtable
1454}
1455
1456impl WindowsSubtable {
1457 pub(super) fn new(
1458 version: u16,
1459 length: u16,
1460 coverage: u16,
1461 subtable: KernSubtable
1462 ) -> Self {
1463 Self {
1464 version,
1465 length,
1466 coverage,
1467 subtable
1468 }
1469 }
1470
1471 pub fn version(&self) -> u16 {
1472 self.version
1473 }
1474
1475 pub fn length(&self) -> u16 {
1476 self.length
1477 }
1478
1479 pub fn coverage(&self) -> u16 {
1480 self.coverage
1481 }
1482
1483 pub fn subtable(&self) -> &KernSubtable {
1484 &self.subtable
1485 }
1486}
1487
1488pub struct MacSubtable {
1489 length: u32,
1490 coverage: u16,
1491 tuple_index: u16,
1492 subtable: KernSubtable
1493}
1494
1495impl MacSubtable {
1496 pub(super) fn new(
1497 length: u32,
1498 coverage: u16,
1499 tuple_index: u16,
1500 subtable: KernSubtable
1501 ) -> Self {
1502 Self {
1503 length,
1504 coverage,
1505 tuple_index,
1506 subtable
1507 }
1508 }
1509
1510 pub fn length(&self) -> u32 {
1511 self.length
1512 }
1513
1514 pub fn coverage(&self) -> u16 {
1515 self.coverage
1516 }
1517
1518 pub fn tuple_index(&self) -> u16 {
1519 self.tuple_index
1520 }
1521
1522 pub fn subtable(&self) -> &KernSubtable {
1523 &self.subtable
1524 }
1525}
1526
1527pub enum KernSubtable {
1528 Format0 {
1529 n_pairs: u16,
1530 search_range: u16,
1531 entry_selector: u16,
1532 range_shift: u16,
1533 pairs: Vec<KernPair>
1534 },
1535 Format2 {
1536 row_width: u16,
1537 left_offset: u16,
1538 right_offset: u16,
1539 array_offset: u16,
1540 left_class_table: KernClassTable,
1541 right_class_table: KernClassTable,
1542 kerning_array: Vec<i16>
1543 }
1544}
1545
1546pub struct KernPair {
1547 left: u16,
1548 right: u16,
1549 value: i16
1550}
1551
1552impl KernPair {
1553 pub(super) fn new(
1554 left: u16,
1555 right: u16,
1556 value: i16
1557 ) -> Self {
1558 Self {
1559 left,
1560 right,
1561 value
1562 }
1563 }
1564
1565 pub fn left(&self) -> u16 {
1566 self.left
1567 }
1568
1569 pub fn right(&self) -> u16 {
1570 self.right
1571 }
1572
1573 pub fn value(&self) -> i16 {
1574 self.value
1575 }
1576}
1577
1578pub enum KernClassTable {
1579 Format1 {
1580 start_glyph: u16,
1581 glyph_count: u16,
1582 class_ids: Vec<u16>
1583 },
1584 Format2 {
1585 range_count: u16,
1586 ranges: Vec<Range>
1587 }
1588}
1589
1590pub struct Range {
1591 start_glyph: u16,
1592 end_glyph: u16,
1593 class: u16
1594}
1595
1596impl Range {
1597 pub(super) fn new(
1598 start_glyph: u16,
1599 end_glyph: u16,
1600 class: u16
1601 ) -> Self {
1602 Self {
1603 start_glyph,
1604 end_glyph,
1605 class
1606 }
1607 }
1608
1609 pub fn start_glyph(&self) -> u16 {
1610 self.start_glyph
1611 }
1612
1613 pub fn end_glyph(&self) -> u16 {
1614 self.end_glyph
1615 }
1616
1617 pub fn class(&self) -> u16 {
1618 self.class
1619 }
1620}
1621
1622pub struct GaspTable {
1623 version: u16,
1624 num_ranges: u16,
1625 range_records: Vec<GaspRangeRecord>
1626}
1627
1628impl GaspTable {
1629 pub(super) fn new(
1630 version: u16,
1631 num_ranges: u16,
1632 range_records: Vec<GaspRangeRecord>
1633 ) -> Self {
1634 Self {
1635 version,
1636 num_ranges,
1637 range_records
1638 }
1639 }
1640
1641 pub fn version(&self) -> u16 {
1642 self.version
1643 }
1644
1645 pub fn num_ranges(&self) -> u16 {
1646 self.num_ranges
1647 }
1648
1649 pub fn range_records(&self) -> &[GaspRangeRecord] {
1650 &self.range_records
1651 }
1652}
1653
1654pub struct GaspRangeRecord {
1655 range_max_ppem: u16,
1656 range_gasp_behavior: u16
1657}
1658
1659impl GaspRangeRecord {
1660 pub(super) fn new(
1661 range_max_ppem: u16,
1662 range_gasp_behavior: u16
1663 ) -> Self {
1664 Self {
1665 range_max_ppem,
1666 range_gasp_behavior
1667 }
1668 }
1669
1670 pub fn range_max_ppem(&self) -> u16 {
1671 self.range_max_ppem
1672 }
1673
1674 pub fn range_gasp_behavior(&self) -> u16 {
1675 self.range_gasp_behavior
1676 }
1677}
1678
1679pub struct GposTable<GposSubtable> {
1680 header: TableHeader,
1681 script_list: ScriptList,
1682 feature_list: FeatureList,
1683 lookup_list: LookupList<GposSubtable>,
1684 feature_variations: Option<FeatureVariations>
1685}
1686
1687impl GposTable<GposSubtable> {
1688 pub(super) fn new(
1689 header: TableHeader,
1690 script_list: ScriptList,
1691 feature_list: FeatureList,
1692 lookup_list: LookupList<GposSubtable>,
1693 feature_variations: Option<FeatureVariations>
1694 ) -> Self {
1695 Self {
1696 header,
1697 script_list,
1698 feature_list,
1699 lookup_list,
1700 feature_variations
1701 }
1702 }
1703
1704 pub fn header(&self) -> TableHeader {
1705 self.header
1706 }
1707
1708 pub fn script_list(&self) -> &ScriptList {
1709 &self.script_list
1710 }
1711
1712 pub fn feature_list(&self) -> &FeatureList {
1713 &self.feature_list
1714 }
1715
1716 pub fn lookup_list(&self) -> &LookupList<GposSubtable> {
1717 &self.lookup_list
1718 }
1719
1720 pub fn feature_variations(&self) -> Option<&FeatureVariations> {
1721 self.feature_variations.as_ref()
1722 }
1723}
1724
1725pub struct GsubTable<GsubSubtable> {
1726 header: TableHeader,
1727 script_list: ScriptList,
1728 feature_list: FeatureList,
1729 lookup_list: LookupList<GsubSubtable>,
1730 feature_variations: Option<FeatureVariations>
1731}
1732
1733impl GsubTable<GsubSubtable> {
1734 pub fn new(
1735 header: TableHeader,
1736 script_list: ScriptList,
1737 feature_list: FeatureList,
1738 lookup_list: LookupList<GsubSubtable>,
1739 feature_variations: Option<FeatureVariations>
1740 ) -> Self {
1741 Self {
1742 header,
1743 script_list,
1744 feature_list,
1745 lookup_list,
1746 feature_variations
1747 }
1748 }
1749
1750 pub fn header(&self) -> &TableHeader {
1751 &self.header
1752 }
1753
1754 pub fn script_list(&self) -> &ScriptList {
1755 &self.script_list
1756 }
1757
1758 pub fn feature_list(&self) -> &FeatureList {
1759 &self.feature_list
1760 }
1761
1762 pub fn lookup_list(&self) -> &LookupList<GsubSubtable> {
1763 &self.lookup_list
1764 }
1765
1766 pub fn feature_variations(&self) -> Option<&FeatureVariations> {
1767 self.feature_variations.as_ref()
1768 }
1769}
1770
1771#[derive(Clone, Copy)]
1772pub struct TableHeader {
1773 major_version: u16,
1774 minor_version: u16,
1775 script_list_offset: u16,
1776 feature_list_offset: u16,
1777 lookup_list_offset: u16,
1778 feature_variations_offset: Option<u32>
1779}
1780
1781impl TableHeader {
1782 pub fn new(
1783 major_version: u16,
1784 minor_version: u16,
1785 script_list_offset: u16,
1786 feature_list_offset: u16,
1787 lookup_list_offset: u16,
1788 feature_variations_offset: Option<u32>
1789 ) -> Self {
1790 TableHeader {
1791 major_version,
1792 minor_version,
1793 script_list_offset,
1794 feature_list_offset,
1795 lookup_list_offset,
1796 feature_variations_offset,
1797 }
1798 }
1799
1800 pub fn major_version(&self) -> u16 {
1801 self.major_version
1802 }
1803
1804 pub fn minor_version(&self) -> u16 {
1805 self.minor_version
1806 }
1807
1808 pub fn script_list_offset(&self) -> u16 {
1809 self.script_list_offset
1810 }
1811
1812 pub fn feature_list_offset(&self) -> u16 {
1813 self.feature_list_offset
1814 }
1815
1816 pub fn lookup_list_offset(&self) -> u16 {
1817 self.lookup_list_offset
1818 }
1819
1820 pub fn feature_variations_offset(&self) -> Option<u32> {
1821 self.feature_variations_offset
1822 }
1823}
1824
1825pub struct ScriptList {
1826 script_count: u16,
1827 script_records: Vec<ScriptRecord>,
1828 scripts: Vec<Script>
1829}
1830
1831impl ScriptList {
1832 pub fn new(
1833 script_count: u16,
1834 script_records: Vec<ScriptRecord>,
1835 scripts: Vec<Script>
1836 ) -> Self {
1837 Self {
1838 script_count,
1839 script_records,
1840 scripts,
1841 }
1842 }
1843
1844 pub fn script_count(&self) -> u16 {
1845 self.script_count
1846 }
1847
1848 pub fn script_records(&self) -> &[ScriptRecord] {
1849 &self.script_records
1850 }
1851
1852 pub fn scripts(&self) -> &[Script] {
1853 &self.scripts
1854 }
1855}
1856
1857pub struct ScriptRecord {
1858 script_tag: [u8; 4],
1859 script_offset: u16
1860}
1861
1862impl ScriptRecord {
1863 pub fn new(
1864 script_tag: [u8; 4],
1865 script_offset: u16
1866 ) -> Self {
1867 Self {
1868 script_tag,
1869 script_offset,
1870 }
1871 }
1872
1873 pub fn script_tag(&self) -> [u8; 4] {
1874 self.script_tag
1875 }
1876
1877 pub fn script_offset(&self) -> u16 {
1878 self.script_offset
1879 }
1880}
1881
1882pub struct Script {
1883 default_lang_sys_offset: Option<u16>,
1884 default_lang_sys: Option<LangSys>,
1885 lang_sys_count: u16,
1886 lang_sys_records: Vec<LangSysRecord>,
1887 lang_syses: Vec<LangSys>
1888}
1889
1890impl Script {
1891 pub fn new(
1892 default_lang_sys_offset: Option<u16>,
1893 default_lang_sys: Option<LangSys>,
1894 lang_sys_count: u16,
1895 lang_sys_records: Vec<LangSysRecord>,
1896 lang_syses: Vec<LangSys>
1897 ) -> Self {
1898 Self {
1899 default_lang_sys_offset,
1900 default_lang_sys,
1901 lang_sys_count,
1902 lang_sys_records,
1903 lang_syses,
1904 }
1905 }
1906
1907 pub fn default_lang_sys_offset(&self) -> Option<u16> {
1908 self.default_lang_sys_offset
1909 }
1910
1911 pub fn default_lang_sys(&self) -> Option<&LangSys> {
1912 self.default_lang_sys.as_ref()
1913 }
1914
1915 pub fn lang_sys_count(&self) -> u16 {
1916 self.lang_sys_count
1917 }
1918
1919 pub fn lang_sys_records(&self) -> &[LangSysRecord] {
1920 &self.lang_sys_records
1921 }
1922
1923 pub fn lang_syses(&self) -> &[LangSys] {
1924 &self.lang_syses
1925 }
1926}
1927
1928pub struct LangSysRecord {
1929 lang_sys_tag: [u8; 4],
1930 lang_sys_offset: u16,
1931}
1932
1933impl LangSysRecord {
1934 pub fn new(
1935 lang_sys_tag: [u8; 4],
1936 lang_sys_offset: u16
1937 ) -> Self {
1938 Self {
1939 lang_sys_tag,
1940 lang_sys_offset,
1941 }
1942 }
1943
1944 pub fn lang_sys_tag(&self) -> [u8; 4] {
1945 self.lang_sys_tag
1946 }
1947
1948 pub fn lang_sys_offset(&self) -> u16 {
1949 self.lang_sys_offset
1950 }
1951}
1952
1953pub struct LangSys {
1954 _lookup_order_offset: u16,
1955 required_feature_index: u16,
1956 feature_index_count: u16,
1957 feature_indices: Vec<u16>
1958}
1959
1960impl LangSys {
1961 pub fn new(
1962 _lookup_order_offset: u16,
1963 required_feature_index: u16,
1964 feature_index_count: u16,
1965 feature_indices: Vec<u16>
1966 ) -> Self {
1967 Self {
1968 _lookup_order_offset,
1969 required_feature_index,
1970 feature_index_count,
1971 feature_indices,
1972 }
1973 }
1974
1975 pub fn required_feature_index(&self) -> u16 {
1976 self.required_feature_index
1977 }
1978
1979 pub fn feature_index_count(&self) -> u16 {
1980 self.feature_index_count
1981 }
1982
1983 pub fn feature_indices(&self) -> &[u16] {
1984 &self.feature_indices
1985 }
1986}
1987
1988#[derive(Clone)]
1989pub struct FeatureList {
1990 feature_count: u16,
1991 feature_records: Vec<FeatureRecord>,
1992 features: Vec<Feature>
1993}
1994
1995impl FeatureList {
1996 pub fn new(
1997 feature_count: u16,
1998 feature_records: Vec<FeatureRecord>,
1999 features: Vec<Feature>
2000 ) -> Self {
2001 Self {
2002 feature_count,
2003 feature_records,
2004 features,
2005 }
2006 }
2007
2008 pub fn feature_count(&self) -> u16 {
2009 self.feature_count
2010 }
2011
2012 pub fn feature_records(&self) -> &[FeatureRecord] {
2013 &self.feature_records
2014 }
2015
2016 pub fn features(&self) -> &[Feature] {
2017 &self.features
2018 }
2019}
2020
2021#[derive(Clone)]
2022pub struct FeatureRecord {
2023 feature_tag: [u8; 4],
2024 feature_offset: u16
2025}
2026
2027impl FeatureRecord {
2028 pub fn new(
2029 feature_tag: [u8; 4],
2030 feature_offset: u16
2031 ) -> Self {
2032 Self {
2033 feature_tag,
2034 feature_offset,
2035 }
2036 }
2037
2038 pub fn feature_tag(&self) -> [u8; 4] {
2039 self.feature_tag
2040 }
2041
2042 pub fn feature_offset(&self) -> u16 {
2043 self.feature_offset
2044 }
2045}
2046
2047#[derive(Clone)]
2048pub struct Feature {
2049 feature_params_offset: Option<u16>,
2050 feature_params: Option<FeatureParams>,
2051 lookup_index_count: u16,
2052 lookup_list_indices: Vec<u16>
2053}
2054
2055impl Feature {
2056 pub fn new(
2057 feature_params_offset: Option<u16>,
2058 feature_params: Option<FeatureParams>,
2059 lookup_index_count: u16,
2060 lookup_list_indices: Vec<u16>
2061 ) -> Self {
2062 Self {
2063 feature_params_offset,
2064 feature_params,
2065 lookup_index_count,
2066 lookup_list_indices,
2067 }
2068 }
2069
2070 pub fn feature_params_offset(&self) -> Option<u16> {
2071 self.feature_params_offset
2072 }
2073
2074 pub fn feature_params(&self) -> Option<FeatureParams> {
2075 self.feature_params
2076 }
2077
2078 pub fn lookup_index_count(&self) -> u16 {
2079 self.lookup_index_count
2080 }
2081
2082 pub fn lookup_list_indices(&self) -> &[u16] {
2083 &self.lookup_list_indices
2084 }
2085}
2086
2087#[derive(Clone, Copy)]
2088pub enum FeatureParams {
2089 Size {
2090 design_size: u16,
2091 subfamily_id: u16,
2092 subfamily_name_id: u16,
2093 range_start: u16,
2094 range_end: u16
2095 },
2096 StylisticSet {
2097 version: u16,
2098 ui_name_id: u16
2099 },
2100 CharacterVariant {
2101 format: u16,
2102 feat_ui_label_name_id: u16,
2103 feat_tooltip_text_name_id: u16,
2104 sample_text_name_id: u16,
2105 num_named_parameters: u16,
2106 first_param_ui_label_name_id: u16,
2107 char_count: u16,
2108 character: [u8; 3]
2109 }
2110}
2111
2112pub struct LookupList<T> {
2113 lookup_count: u16,
2114 lookup_offsets: Vec<u16>,
2115 lookups: Vec<Lookup<T>>
2116}
2117
2118impl<T> LookupList<T> {
2119 pub fn new(
2120 lookup_count: u16,
2121 lookup_offsets: Vec<u16>,
2122 lookups: Vec<Lookup<T>>
2123 ) -> Self {
2124 Self {
2125 lookup_count,
2126 lookup_offsets,
2127 lookups,
2128 }
2129 }
2130
2131 pub fn lookup_count(&self) -> u16 {
2132 self.lookup_count
2133 }
2134
2135 pub fn lookup_offsets(&self) -> &[u16] {
2136 &self.lookup_offsets
2137 }
2138
2139 pub fn lookups(&self) -> &[Lookup<T>] {
2140 &self.lookups
2141 }
2142}
2143
2144pub struct Lookup<T> {
2145 lookup_type: u16,
2146 lookup_flag: u16,
2147 subtable_count: u16,
2148 subtable_offsets: Vec<u16>,
2149 subtables: Vec<T>,
2150 mark_filtering_set: Option<u16>
2151}
2152
2153impl<T> Lookup<T> {
2154 pub fn new(
2155 lookup_type: u16,
2156 lookup_flag: u16,
2157 subtable_count: u16,
2158 subtable_offsets: Vec<u16>,
2159 subtables: Vec<T>,
2160 mark_filtering_set: Option<u16>
2161 ) -> Self {
2162 Self {
2163 lookup_type,
2164 lookup_flag,
2165 subtable_count,
2166 subtable_offsets,
2167 subtables,
2168 mark_filtering_set
2169 }
2170 }
2171
2172 pub fn lookup_type(&self) -> u16 {
2173 self.lookup_type
2174 }
2175
2176 pub fn lookup_flag(&self) -> u16 {
2177 self.lookup_flag
2178 }
2179
2180 pub fn subtable_count(&self) -> u16 {
2181 self.subtable_count
2182 }
2183
2184 pub fn subtable_offsets(&self) -> &[u16] {
2185 &self.subtable_offsets
2186 }
2187
2188 pub fn subtables(&self) -> &[T] {
2189 &self.subtables
2190 }
2191
2192 pub fn mark_filtering_set(&self) -> Option<u16> {
2193 self.mark_filtering_set
2194 }
2195}
2196
2197pub struct FeatureVariations {
2198 major_version: u16,
2199 minor_version: u16,
2200 feature_variation_record_count: u32,
2201 feature_variation_records: Vec<FeatureVariationRecord>
2202}
2203
2204impl FeatureVariations {
2205 pub fn new(
2206 major_version: u16,
2207 minor_version: u16,
2208 feature_variation_record_count: u32,
2209 feature_variation_records: Vec<FeatureVariationRecord>
2210 ) -> Self {
2211 Self {
2212 major_version,
2213 minor_version,
2214 feature_variation_record_count,
2215 feature_variation_records
2216 }
2217 }
2218
2219 pub fn major_version(&self) -> u16 {
2220 self.major_version
2221 }
2222
2223 pub fn minor_version(&self) -> u16 {
2224 self.minor_version
2225 }
2226
2227 pub fn feature_variation_record_count(&self) -> u32 {
2228 self.feature_variation_record_count
2229 }
2230
2231 pub fn feature_variation_records(&self) -> &[FeatureVariationRecord] {
2232 &self.feature_variation_records
2233 }
2234}
2235
2236pub struct FeatureVariationRecord {
2237 condition_set_offset: u32,
2238 condition_set: ConditionSet,
2239 feature_table_substitution_offset: u32,
2240 feature_table_substitution: FeatureTableSubstitution
2241}
2242
2243impl FeatureVariationRecord {
2244 pub(super) fn new(
2245 condition_set_offset: u32,
2246 condition_set: ConditionSet,
2247 feature_table_substitution_offset: u32,
2248 feature_table_substitution: FeatureTableSubstitution
2249 ) -> Self {
2250 Self {
2251 condition_set_offset,
2252 condition_set,
2253 feature_table_substitution_offset,
2254 feature_table_substitution
2255 }
2256 }
2257
2258 pub fn condition_set_offset(&self) -> u32 {
2259 self.condition_set_offset
2260 }
2261
2262 pub fn condition_set(&self) -> &ConditionSet {
2263 &self.condition_set
2264 }
2265
2266 pub fn feature_table_substitution_offset(&self) -> u32 {
2267 self.feature_table_substitution_offset
2268 }
2269
2270 pub fn feature_table_substitution(&self) -> &FeatureTableSubstitution {
2271 &self.feature_table_substitution
2272 }
2273}
2274
2275pub struct ConditionSet {
2276 condition_count: u16,
2277 condition_offsets: Vec<u32>,
2278 conditions: Vec<Condition>
2279}
2280
2281impl ConditionSet {
2282 pub(super) fn new(
2283 condition_count: u16,
2284 condition_offsets: Vec<u32>,
2285 conditions: Vec<Condition>
2286 ) -> Self {
2287 Self {
2288 condition_count,
2289 condition_offsets,
2290 conditions
2291 }
2292 }
2293
2294 pub fn condition_count(&self) -> u16 {
2295 self.condition_count
2296 }
2297
2298 pub fn condition_offsets(&self) -> &[u32] {
2299 &self.condition_offsets
2300 }
2301
2302 pub fn conditions(&self) -> &[Condition] {
2303 &self.conditions
2304 }
2305}
2306
2307pub enum Condition {
2308 Format1 {
2309 axis_index: u16,
2310 filter_range_min_value: i16,
2311 filter_range_max_value: i16
2312 }
2313}
2314
2315pub struct FeatureTableSubstitution {
2316 major_version: u16,
2317 minor_version: u16,
2318 substitution_count: u16,
2319 substitution_records: Vec<FeatureTableSubstitutionRecord>
2320}
2321
2322impl FeatureTableSubstitution {
2323 pub(super) fn new(
2324 major_version: u16,
2325 minor_version: u16,
2326 substitution_count: u16,
2327 substitution_records: Vec<FeatureTableSubstitutionRecord>
2328 ) -> Self {
2329 Self {
2330 major_version,
2331 minor_version,
2332 substitution_count,
2333 substitution_records
2334 }
2335 }
2336
2337 pub fn major_version(&self) -> u16 {
2338 self.major_version
2339 }
2340
2341 pub fn minor_version(&self) -> u16 {
2342 self.minor_version
2343 }
2344
2345 pub fn substitution_count(&self) -> u16 {
2346 self.substitution_count
2347 }
2348
2349 pub fn substitution_records(&self) -> &[FeatureTableSubstitutionRecord] {
2350 &self.substitution_records
2351 }
2352}
2353
2354pub struct FeatureTableSubstitutionRecord {
2355 feature_index: u16,
2356 alternate_feature_table_offset: u32,
2357 alternate_feature_table: Feature
2358}
2359
2360impl FeatureTableSubstitutionRecord {
2361 pub(super) fn new(
2362 feature_index: u16,
2363 alternate_feature_table_offset: u32,
2364 alternate_feature_table: Feature
2365 ) -> Self {
2366 Self {
2367 feature_index,
2368 alternate_feature_table_offset,
2369 alternate_feature_table
2370 }
2371 }
2372
2373 pub fn feature_index(&self) -> u16 {
2374 self.feature_index
2375 }
2376
2377 pub fn alternate_feature_table_offset(&self) -> u32 {
2378 self.alternate_feature_table_offset
2379 }
2380
2381 pub fn alternate_feature_table(&self) -> &Feature {
2382 &self.alternate_feature_table
2383 }
2384}
2385
2386pub enum Coverage {
2387 Format1 {
2388 glyph_count: u16,
2389 glyph_array: Vec<u16>
2390 },
2391 Format2 {
2392 range_count: u16,
2393 range_records: Vec<CoverageRangeRecord>
2394 }
2395}
2396
2397pub struct CoverageRangeRecord {
2398 start_glyph_id: u16,
2399 end_glyph_id: u16,
2400 start_coverage_index: u16
2401}
2402
2403impl CoverageRangeRecord {
2404 pub(super) fn new(
2405 start_glyph_id: u16,
2406 end_glyph_id: u16,
2407 start_coverage_index: u16
2408 ) -> Self {
2409 Self {
2410 start_glyph_id,
2411 end_glyph_id,
2412 start_coverage_index
2413 }
2414 }
2415
2416 pub fn start_glyph_id(&self) -> u16 {
2417 self.start_glyph_id
2418 }
2419
2420 pub fn end_glyph_id(&self) -> u16 {
2421 self.end_glyph_id
2422 }
2423
2424 pub fn start_coverage_index(&self) -> u16 {
2425 self.start_coverage_index
2426 }
2427}
2428
2429pub enum ClassDef {
2430 Format1 {
2431 start_glyph_id: u16,
2432 glyph_count: u16,
2433 class_value_array: Vec<u16>
2434 },
2435 Format2 {
2436 class_range_count: u16,
2437 class_range_records: Vec<ClassRangeRecord>
2438 }
2439}
2440
2441pub struct ClassRangeRecord {
2442 start_glyph_id: u16,
2443 end_glyph_id: u16,
2444 class: u16
2445}
2446
2447impl ClassRangeRecord {
2448 pub(super) fn new(
2449 start_glyph_id: u16,
2450 end_glyph_id: u16,
2451 class: u16
2452 ) -> Self {
2453 Self {
2454 start_glyph_id,
2455 end_glyph_id,
2456 class
2457 }
2458 }
2459
2460 pub fn start_glyph_id(&self) -> u16 {
2461 self.start_glyph_id
2462 }
2463
2464 pub fn end_glyph_id(&self) -> u16 {
2465 self.end_glyph_id
2466 }
2467
2468 pub fn class(&self) -> u16 {
2469 self.class
2470 }
2471}
2472
2473pub enum DeviceOrVariationIndex {
2474 Device(Device),
2475 VariationIndex(VariationIndex)
2476}
2477
2478pub struct Device {
2479 start_size: u16,
2480 end_size: u16,
2481 delta_format: u16,
2482 delta_values: Vec<u16>
2483}
2484
2485impl Device {
2486 pub(super) fn new(
2487 start_size: u16,
2488 end_size: u16,
2489 delta_format: u16,
2490 delta_values: Vec<u16>
2491 ) -> Self {
2492 Self {
2493 start_size,
2494 end_size,
2495 delta_format,
2496 delta_values
2497 }
2498 }
2499
2500 pub fn start_size(&self) -> u16 {
2501 self.start_size
2502 }
2503
2504 pub fn end_size(&self) -> u16 {
2505 self.end_size
2506 }
2507
2508 pub fn delta_format(&self) -> u16 {
2509 self.delta_format
2510 }
2511
2512 pub fn delta_values(&self) -> &[u16] {
2513 &self.delta_values
2514 }
2515}
2516
2517pub struct VariationIndex {
2518 delta_set_outer_index: u16,
2519 delta_set_inner_index: u16,
2520 delta_format: u16
2521}
2522
2523impl VariationIndex {
2524 pub(super) fn new(
2525 delta_set_outer_index: u16,
2526 delta_set_inner_index: u16,
2527 delta_format: u16
2528 ) -> Self {
2529 Self {
2530 delta_set_outer_index,
2531 delta_set_inner_index,
2532 delta_format
2533 }
2534 }
2535
2536 pub fn delta_set_outer_index(&self) -> u16 {
2537 self.delta_set_outer_index
2538 }
2539
2540 pub fn delta_set_inner_index(&self) -> u16 {
2541 self.delta_set_inner_index
2542 }
2543
2544 pub fn delta_format(&self) -> u16 {
2545 self.delta_format
2546 }
2547}
2548
2549pub struct ValueRecord {
2550 x_placement: Option<i16>,
2551 y_placement: Option<i16>,
2552 x_advance: Option<i16>,
2553 y_advance: Option<i16>,
2554 x_pla_device_offset: Option<u16>,
2555 x_pla_device: Option<DeviceOrVariationIndex>,
2556 y_pla_device_offset: Option<u16>,
2557 y_pla_device: Option<DeviceOrVariationIndex>,
2558 x_adv_device_offset: Option<u16>,
2559 x_adv_device: Option<DeviceOrVariationIndex>,
2560 y_adv_device_offset: Option<u16>,
2561 y_adv_device: Option<DeviceOrVariationIndex>
2562}
2563
2564impl ValueRecord {
2565 pub(super) fn new(
2566 x_placement: Option<i16>,
2567 y_placement: Option<i16>,
2568 x_advance: Option<i16>,
2569 y_advance: Option<i16>,
2570 x_pla_device_offset: Option<u16>,
2571 x_pla_device: Option<DeviceOrVariationIndex>,
2572 y_pla_device_offset: Option<u16>,
2573 y_pla_device: Option<DeviceOrVariationIndex>,
2574 x_adv_device_offset: Option<u16>,
2575 x_adv_device: Option<DeviceOrVariationIndex>,
2576 y_adv_device_offset: Option<u16>,
2577 y_adv_device: Option<DeviceOrVariationIndex>
2578 ) -> Self {
2579 Self {
2580 x_placement,
2581 y_placement,
2582 x_advance,
2583 y_advance,
2584 x_pla_device_offset,
2585 x_pla_device,
2586 y_pla_device_offset,
2587 y_pla_device,
2588 x_adv_device_offset,
2589 x_adv_device,
2590 y_adv_device_offset,
2591 y_adv_device
2592 }
2593 }
2594
2595 pub fn x_placement(&self) -> Option<i16> {
2596 self.x_placement
2597 }
2598
2599 pub fn y_placement(&self) -> Option<i16> {
2600 self.y_placement
2601 }
2602
2603 pub fn x_advance(&self) -> Option<i16> {
2604 self.x_advance
2605 }
2606
2607 pub fn y_advance(&self) -> Option<i16> {
2608 self.y_advance
2609 }
2610
2611 pub fn x_pla_device_offset(&self) -> Option<u16> {
2612 self.x_pla_device_offset
2613 }
2614
2615 pub fn x_pla_device(&self) -> Option<&DeviceOrVariationIndex> {
2616 self.x_pla_device.as_ref()
2617 }
2618
2619 pub fn y_pla_device_offset(&self) -> Option<u16> {
2620 self.y_pla_device_offset
2621 }
2622
2623 pub fn y_pla_device(&self) -> Option<&DeviceOrVariationIndex> {
2624 self.y_pla_device.as_ref()
2625 }
2626
2627 pub fn x_adv_device_offset(&self) -> Option<u16> {
2628 self.x_adv_device_offset
2629 }
2630
2631 pub fn x_adv_device(&self) -> Option<&DeviceOrVariationIndex> {
2632 self.x_adv_device.as_ref()
2633 }
2634
2635 pub fn y_adv_device_offset(&self) -> Option<u16> {
2636 self.y_adv_device_offset
2637 }
2638
2639 pub fn y_adv_device(&self) -> Option<&DeviceOrVariationIndex> {
2640 self.y_adv_device.as_ref()
2641 }
2642}
2643
2644pub enum Anchor {
2645 Format1 {
2646 x_coordinate: i16,
2647 y_coordinate: i16
2648 },
2649 Format2 {
2650 x_coordinate: i16,
2651 y_coordinate: i16,
2652 anchor_point: u16
2653 },
2654 Format3 {
2655 x_coordinate: i16,
2656 y_coordinate: i16,
2657 x_device_offset: u16,
2658 x_device: DeviceOrVariationIndex,
2659 y_device_offset: u16,
2660 y_device: DeviceOrVariationIndex
2661 }
2662}
2663
2664pub struct MarkArray {
2665 mark_count: u16,
2666 mark_records: Vec<MarkRecord>
2667}
2668
2669impl MarkArray {
2670 pub(super) fn new(
2671 mark_count: u16,
2672 mark_records: Vec<MarkRecord>
2673 ) -> Self {
2674 Self {
2675 mark_count,
2676 mark_records
2677 }
2678 }
2679
2680 pub fn mark_count(&self) -> u16 {
2681 self.mark_count
2682 }
2683
2684 pub fn mark_records(&self) -> &[MarkRecord] {
2685 &self.mark_records
2686 }
2687}
2688
2689pub struct MarkRecord {
2690 mark_class: u16,
2691 mark_anchor_offset: u16,
2692 mark_anchor: Anchor
2693}
2694
2695impl MarkRecord {
2696 pub(super) fn new(
2697 mark_class: u16,
2698 mark_anchor_offset: u16,
2699 mark_anchor: Anchor
2700 ) -> Self {
2701 Self {
2702 mark_class,
2703 mark_anchor_offset,
2704 mark_anchor
2705 }
2706 }
2707
2708 pub fn mark_class(&self) -> u16 {
2709 self.mark_class
2710 }
2711
2712 pub fn mark_anchor_offset(&self) -> u16 {
2713 self.mark_anchor_offset
2714 }
2715
2716 pub fn mark_anchor(&self) -> &Anchor {
2717 &self.mark_anchor
2718 }
2719}
2720
2721pub enum GposSubtable {
2722 Type1(GposType1Format),
2723 Type2(GposType2Format),
2724 Type3(GposType3Format),
2725 Type4(GposType4Format),
2726 Type5(GposType5Format),
2727 Type6(GposType6Format),
2728 Type7(GposType7Format),
2729 Type8(GposType8Format),
2730 Type9(GposType9Format)
2731}
2732
2733pub enum GposType1Format {
2734 Format1 {
2735 coverage_offset: u16,
2736 coverage: Coverage,
2737 value_format: u16,
2738 value_record: ValueRecord
2739 },
2740 Format2 {
2741 coverage_offset: u16,
2742 coverage: Coverage,
2743 value_format: u16,
2744 value_count: u16,
2745 value_records: Vec<ValueRecord>
2746 }
2747}
2748
2749pub enum GposType2Format {
2750 Format1 {
2751 coverage_offset: u16,
2752 coverage: Coverage,
2753 value_format1: u16,
2754 value_format2: u16,
2755 pair_set_count: u16,
2756 pair_set_offsets: Vec<u16>,
2757 pair_sets: Vec<PairSet>
2758 },
2759 Format2 {
2760 coverage_offset: u16,
2761 coverage: Coverage,
2762 value_format1: u16,
2763 value_format2: u16,
2764 class_def1_offset: u16,
2765 class_def1: ClassDef,
2766 class_def2_offset: u16,
2767 class_def2: ClassDef,
2768 class1_count: u16,
2769 class2_count: u16,
2770 class1_records: Vec<Class1Record>
2771 }
2772}
2773
2774pub struct PairSet {
2775 pair_value_count: u16,
2776 pair_value_records: Vec<PairValueRecord>
2777}
2778
2779impl PairSet {
2780 pub(super) fn new(
2781 pair_value_count: u16,
2782 pair_value_records: Vec<PairValueRecord>
2783 ) -> Self {
2784 Self {
2785 pair_value_count,
2786 pair_value_records
2787 }
2788 }
2789
2790 pub fn pair_value_count(&self) -> u16 {
2791 self.pair_value_count
2792 }
2793
2794 pub fn pair_value_records(&self) -> &[PairValueRecord] {
2795 &self.pair_value_records
2796 }
2797}
2798
2799pub struct PairValueRecord {
2800 second_glyph: u16,
2801 value_record1: ValueRecord,
2802 value_record2: ValueRecord
2803}
2804
2805impl PairValueRecord {
2806 pub(super) fn new(
2807 second_glyph: u16,
2808 value_record1: ValueRecord,
2809 value_record2: ValueRecord
2810 ) -> Self {
2811 Self {
2812 second_glyph,
2813 value_record1,
2814 value_record2
2815 }
2816 }
2817
2818 pub fn second_glyph(&self) -> u16 {
2819 self.second_glyph
2820 }
2821
2822 pub fn value_record1(&self) -> &ValueRecord {
2823 &self.value_record1
2824 }
2825
2826 pub fn value_record2(&self) -> &ValueRecord {
2827 &self.value_record2
2828 }
2829}
2830
2831pub struct Class1Record {
2832 class2_records: Vec<Class2Record>
2833}
2834
2835impl Class1Record {
2836 pub(super) fn new(
2837 class2_records: Vec<Class2Record>
2838 ) -> Self {
2839 Self {
2840 class2_records
2841 }
2842 }
2843
2844 pub fn class2_records(&self) -> &[Class2Record] {
2845 &self.class2_records
2846 }
2847}
2848
2849pub struct Class2Record {
2850 value_record1: ValueRecord,
2851 value_record2: ValueRecord
2852}
2853
2854impl Class2Record {
2855 pub(super) fn new(
2856 value_record1: ValueRecord,
2857 value_record2: ValueRecord
2858 ) -> Self {
2859 Self {
2860 value_record1,
2861 value_record2
2862 }
2863 }
2864
2865 pub fn value_record1(&self) -> &ValueRecord {
2866 &self.value_record1
2867 }
2868
2869 pub fn value_record2(&self) -> &ValueRecord {
2870 &self.value_record2
2871 }
2872}
2873
2874pub enum GposType3Format {
2875 Format1 {
2876 coverage_offset: u16,
2877 coverage: Coverage,
2878 entry_exit_count: u16,
2879 entry_exit_records: Vec<EntryExitRecord>
2880 }
2881}
2882
2883pub struct EntryExitRecord {
2884 entry_anchor_offset: Option<u16>,
2885 entry_anchor: Option<Anchor>,
2886 exit_anchor_offset: Option<u16>,
2887 exit_anchor: Option<Anchor>
2888}
2889
2890impl EntryExitRecord {
2891 pub(super) fn new(
2892 entry_anchor_offset: Option<u16>,
2893 entry_anchor: Option<Anchor>,
2894 exit_anchor_offset: Option<u16>,
2895 exit_anchor: Option<Anchor>
2896 ) -> Self {
2897 Self {
2898 entry_anchor_offset,
2899 entry_anchor,
2900 exit_anchor_offset,
2901 exit_anchor
2902 }
2903 }
2904
2905 pub fn entry_anchor_offset(&self) -> Option<u16> {
2906 self.entry_anchor_offset
2907 }
2908
2909 pub fn entry_anchor(&self) -> Option<&Anchor> {
2910 self.entry_anchor.as_ref()
2911 }
2912
2913 pub fn exit_anchor_offset(&self) -> Option<u16> {
2914 self.exit_anchor_offset
2915 }
2916
2917 pub fn exit_anchor(&self) -> Option<&Anchor> {
2918 self.exit_anchor.as_ref()
2919 }
2920}
2921
2922pub enum GposType4Format {
2923 Format1 {
2924 mark_coverage_offset: u16,
2925 mark_coverage: Coverage,
2926 base_coverage_offset: u16,
2927 base_coverage: Coverage,
2928 mark_class_count: u16,
2929 mark_array_offset: u16,
2930 mark_array: MarkArray,
2931 base_array_offset: u16,
2932 base_array: BaseArray
2933 }
2934}
2935
2936pub struct BaseArray {
2937 base_count: u16,
2938 base_records: Vec<BaseRecord>
2939}
2940
2941impl BaseArray {
2942 pub(super) fn new(
2943 base_count: u16,
2944 base_records: Vec<BaseRecord>
2945 ) -> Self {
2946 Self {
2947 base_count,
2948 base_records
2949 }
2950 }
2951
2952 pub fn base_count(&self) -> u16 {
2953 self.base_count
2954 }
2955
2956 pub fn base_records(&self) -> &[BaseRecord] {
2957 &self.base_records
2958 }
2959}
2960
2961pub struct BaseRecord {
2962 base_anchor_offsets: Vec<u16>,
2963 base_anchors: Vec<Anchor>
2964}
2965
2966impl BaseRecord {
2967 pub(super) fn new(
2968 base_anchor_offsets: Vec<u16>,
2969 base_anchors: Vec<Anchor>
2970 ) -> Self {
2971 Self {
2972 base_anchor_offsets,
2973 base_anchors
2974 }
2975 }
2976
2977 pub fn base_anchor_offsets(&self) -> &[u16] {
2978 &self.base_anchor_offsets
2979 }
2980
2981 pub fn base_anchors(&self) -> &[Anchor] {
2982 &self.base_anchors
2983 }
2984}
2985
2986pub enum GposType5Format {
2987 Format1 {
2988 mark_coverage_offset: u16,
2989 mark_coverage: Coverage,
2990 ligature_coverage_offset: u16,
2991 ligature_coverage: Coverage,
2992 mark_class_count: u16,
2993 mark_array_offset: u16,
2994 mark_array: MarkArray,
2995 ligature_array_offset: u16,
2996 ligature_array: LigatureArray
2997 }
2998}
2999
3000pub struct LigatureArray {
3001 ligature_count: u16,
3002 ligature_attach_offsets: Vec<u16>,
3003 ligature_attaches: Vec<LigatureAttach>
3004}
3005
3006impl LigatureArray {
3007 pub(super) fn new(
3008 ligature_count: u16,
3009 ligature_attach_offsets: Vec<u16>,
3010 ligature_attaches: Vec<LigatureAttach>
3011 ) -> Self {
3012 Self {
3013 ligature_count,
3014 ligature_attach_offsets,
3015 ligature_attaches
3016 }
3017 }
3018
3019 pub fn ligature_count(&self) -> u16 {
3020 self.ligature_count
3021 }
3022
3023 pub fn ligature_attach_offsets(&self) -> &[u16] {
3024 &self.ligature_attach_offsets
3025 }
3026
3027 pub fn ligature_attaches(&self) -> &[LigatureAttach] {
3028 &self.ligature_attaches
3029 }
3030}
3031
3032pub struct LigatureAttach {
3033 component_count: u16,
3034 component_records: Vec<ComponentRecord>
3035}
3036
3037impl LigatureAttach {
3038 pub(super) fn new(
3039 component_count: u16,
3040 component_records: Vec<ComponentRecord>
3041 ) -> Self {
3042 Self {
3043 component_count,
3044 component_records
3045 }
3046 }
3047
3048 pub fn component_count(&self) -> u16 {
3049 self.component_count
3050 }
3051
3052 pub fn component_records(&self) -> &[ComponentRecord] {
3053 &self.component_records
3054 }
3055}
3056
3057pub struct ComponentRecord {
3058 ligature_anchor_offsets: Vec<u16>,
3059 ligature_anchors: Vec<Anchor>
3060}
3061
3062impl ComponentRecord {
3063 pub(super) fn new(
3064 ligature_anchor_offsets: Vec<u16>,
3065 ligature_anchors: Vec<Anchor>
3066 ) -> Self {
3067 Self {
3068 ligature_anchor_offsets,
3069 ligature_anchors
3070 }
3071 }
3072
3073 pub fn ligature_anchor_offsets(&self) -> &[u16] {
3074 &self.ligature_anchor_offsets
3075 }
3076
3077 pub fn ligature_anchors(&self) -> &[Anchor] {
3078 &self.ligature_anchors
3079 }
3080}
3081
3082pub enum GposType6Format {
3083 Format1 {
3084 mark1_coverage_offset: u16,
3085 mark1_coverage: Coverage,
3086 mark2_coverage_offset: u16,
3087 mark2_coverage: Coverage,
3088 mark_class_count: u16,
3089 mark1_array_offset: u16,
3090 mark1_array: MarkArray,
3091 mark2_array_offset: u16,
3092 mark2_array: Mark2Array
3093 }
3094}
3095
3096pub struct Mark2Array {
3097 mark2_count: u16,
3098 mark2_records: Vec<Mark2Record>
3099}
3100
3101impl Mark2Array {
3102 pub(super) fn new(
3103 mark2_count: u16,
3104 mark2_records: Vec<Mark2Record>
3105 ) -> Self {
3106 Self {
3107 mark2_count,
3108 mark2_records
3109 }
3110 }
3111
3112 pub fn mark2_count(&self) -> u16 {
3113 self.mark2_count
3114 }
3115
3116 pub fn mark2_records(&self) -> &[Mark2Record] {
3117 &self.mark2_records
3118 }
3119}
3120
3121pub struct Mark2Record {
3122 mark2_anchor_offsets: Vec<u16>,
3123 mark2_anchors: Vec<Anchor>
3124}
3125
3126impl Mark2Record {
3127 pub(super) fn new(
3128 mark2_anchor_offsets: Vec<u16>,
3129 mark2_anchors: Vec<Anchor>
3130 ) -> Self {
3131 Self {
3132 mark2_anchor_offsets,
3133 mark2_anchors
3134 }
3135 }
3136
3137 pub fn mark2_anchor_offsets(&self) -> &[u16] {
3138 &self.mark2_anchor_offsets
3139 }
3140
3141 pub fn mark2_anchors(&self) -> &[Anchor] {
3142 &self.mark2_anchors
3143 }
3144}
3145
3146pub enum GposType7Format {
3147 Format1 {
3148 coverage_offset: u16,
3149 coverage: Coverage,
3150 sub_rule_set_count: u16,
3151 sub_rule_set_offsets: Vec<u16>,
3152 sub_rule_sets: Vec<GposSubRuleSet>
3153 },
3154 Format2 {
3155 coverage_offset: u16,
3156 coverage: Coverage,
3157 class_def_offset: u16,
3158 class_def: ClassDef,
3159 sub_class_set_count: u16,
3160 sub_class_set_offsets: Vec<u16>,
3161 sub_class_sets: Vec<GposSubClassSet>
3162 },
3163 Format3 {
3164 glyph_count: u16,
3165 sub_count: u16,
3166 coverage_offsets: Vec<u16>,
3167 coverages: Vec<Coverage>,
3168 pos_lookup_records: Vec<PosLookupRecord>
3169 }
3170}
3171
3172pub struct GposSubRuleSet {
3173 sub_rule_count: u16,
3174 sub_rule_offsets: Vec<u16>,
3175 sub_rules: Vec<GposSubRule>
3176}
3177
3178impl GposSubRuleSet {
3179 pub(super) fn new(
3180 sub_rule_count: u16,
3181 sub_rule_offsets: Vec<u16>,
3182 sub_rules: Vec<GposSubRule>
3183 ) -> Self {
3184 Self {
3185 sub_rule_count,
3186 sub_rule_offsets,
3187 sub_rules
3188 }
3189 }
3190
3191 pub fn sub_rule_count(&self) -> u16 {
3192 self.sub_rule_count
3193 }
3194
3195 pub fn sub_rule_offsets(&self) -> &[u16] {
3196 &self.sub_rule_offsets
3197 }
3198
3199 pub fn sub_rules(&self) -> &[GposSubRule] {
3200 &self.sub_rules
3201 }
3202}
3203
3204pub struct GposSubRule {
3205 glyph_count: u16,
3206 sub_count: u16,
3207 input_glyph_ids: Vec<u16>,
3208 pos_lookup_records: Vec<PosLookupRecord>
3209}
3210
3211impl GposSubRule {
3212 pub(super) fn new(
3213 glyph_count: u16,
3214 sub_count: u16,
3215 input_glyph_ids: Vec<u16>,
3216 pos_lookup_records: Vec<PosLookupRecord>
3217 ) -> Self {
3218 Self {
3219 glyph_count,
3220 sub_count,
3221 input_glyph_ids,
3222 pos_lookup_records
3223 }
3224 }
3225
3226 pub fn glyph_count(&self) -> u16 {
3227 self.glyph_count
3228 }
3229
3230 pub fn sub_count(&self) -> u16 {
3231 self.sub_count
3232 }
3233
3234 pub fn input_glyph_ids(&self) -> &[u16] {
3235 &self.input_glyph_ids
3236 }
3237
3238 pub fn pos_lookup_records(&self) -> &[PosLookupRecord] {
3239 &self.pos_lookup_records
3240 }
3241}
3242
3243pub struct PosLookupRecord {
3244 glyph_sequence_index: u16,
3245 lookup_list_index: u16
3246}
3247
3248impl PosLookupRecord {
3249 pub(super) fn new(
3250 glyph_sequence_index: u16,
3251 lookup_list_index: u16
3252 ) -> Self {
3253 Self {
3254 glyph_sequence_index,
3255 lookup_list_index
3256 }
3257 }
3258
3259 pub fn glyph_sequence_index(&self) -> u16 {
3260 self.glyph_sequence_index
3261 }
3262
3263 pub fn lookup_list_index(&self) -> u16 {
3264 self.lookup_list_index
3265 }
3266}
3267
3268pub struct GposSubClassSet {
3269 sub_class_rule_count: u16,
3270 sub_class_rule_offsets: Vec<u16>,
3271 sub_class_rules: Vec<GposSubClassRule>
3272}
3273
3274impl GposSubClassSet {
3275 pub(super) fn new(
3276 sub_class_rule_count: u16,
3277 sub_class_rule_offsets: Vec<u16>,
3278 sub_class_rules: Vec<GposSubClassRule>
3279 ) -> Self {
3280 Self {
3281 sub_class_rule_count,
3282 sub_class_rule_offsets,
3283 sub_class_rules
3284 }
3285 }
3286
3287 pub fn sub_class_rule_count(&self) -> u16 {
3288 self.sub_class_rule_count
3289 }
3290
3291 pub fn sub_class_rule_offsets(&self) -> &[u16] {
3292 &self.sub_class_rule_offsets
3293 }
3294
3295 pub fn sub_class_rules(&self) -> &[GposSubClassRule] {
3296 &self.sub_class_rules
3297 }
3298}
3299
3300pub struct GposSubClassRule {
3301 glyph_count: u16,
3302 sub_count: u16,
3303 class_ids: Vec<u16>,
3304 pos_lookup_records: Vec<PosLookupRecord>
3305}
3306
3307impl GposSubClassRule {
3308 pub(super) fn new(
3309 glyph_count: u16,
3310 sub_count: u16,
3311 class_ids: Vec<u16>,
3312 pos_lookup_records: Vec<PosLookupRecord>
3313 ) -> Self {
3314 Self {
3315 glyph_count,
3316 sub_count,
3317 class_ids,
3318 pos_lookup_records
3319 }
3320 }
3321
3322 pub fn glyph_count(&self) -> u16 {
3323 self.glyph_count
3324 }
3325
3326 pub fn sub_count(&self) -> u16 {
3327 self.sub_count
3328 }
3329
3330 pub fn class_ids(&self) -> &[u16] {
3331 &self.class_ids
3332 }
3333
3334 pub fn pos_lookup_records(&self) -> &[PosLookupRecord] {
3335 &self.pos_lookup_records
3336 }
3337}
3338
3339pub enum GposType8Format {
3340 Format1 {
3341 coverage_offset: u16,
3342 coverage: Coverage,
3343 chain_sub_rule_set_count: u16,
3344 chain_sub_rule_set_offsets: Vec<u16>,
3345 chain_sub_rule_sets: Vec<GposChainSubRuleSet>
3346 },
3347 Format2 {
3348 coverage_offset: u16,
3349 coverage: Coverage,
3350 backtrack_class_def_offset: u16,
3351 backtrack_class_def: ClassDef,
3352 input_class_def_offset: u16,
3353 input_class_def: ClassDef,
3354 lookahead_class_def_offset: u16,
3355 lookahead_class_def: ClassDef,
3356 chain_sub_class_set_count: u16,
3357 chain_sub_class_set_offsets: Vec<u16>,
3358 chain_sub_class_sets: Vec<GposChainSubClassSet>
3359 },
3360 Format3 {
3361 backtrack_glyph_count: u16,
3362 backtrack_coverage_offsets: Vec<u16>,
3363 backtrack_coverages: Vec<Coverage>,
3364 input_glyph_count: u16,
3365 input_coverage_offsets: Vec<u16>,
3366 input_coverages: Vec<Coverage>,
3367 lookahead_glyph_count: u16,
3368 lookahead_coverage_offsets: Vec<u16>,
3369 lookahead_coverages: Vec<Coverage>,
3370 sub_count: u16,
3371 pos_lookup_records: Vec<PosLookupRecord>
3372 }
3373}
3374
3375pub struct GposChainSubRuleSet {
3376 chain_sub_rule_count: u16,
3377 chain_sub_rule_offsets: Vec<u16>,
3378 chain_sub_rules: Vec<GposChainSubRule>
3379}
3380
3381impl GposChainSubRuleSet {
3382 pub(super) fn new(
3383 chain_sub_rule_count: u16,
3384 chain_sub_rule_offsets: Vec<u16>,
3385 chain_sub_rules: Vec<GposChainSubRule>
3386 ) -> Self {
3387 Self {
3388 chain_sub_rule_count,
3389 chain_sub_rule_offsets,
3390 chain_sub_rules
3391 }
3392 }
3393
3394 pub fn chain_sub_rule_count(&self) -> u16 {
3395 self.chain_sub_rule_count
3396 }
3397
3398 pub fn chain_sub_rule_offsets(&self) -> &[u16] {
3399 &self.chain_sub_rule_offsets
3400 }
3401
3402 pub fn chain_sub_rules(&self) -> &[GposChainSubRule] {
3403 &self.chain_sub_rules
3404 }
3405}
3406
3407pub struct GposChainSubRule {
3408 backtrack_glyph_count: u16,
3409 backtrack_glyph_ids: Vec<u16>,
3410 input_glyph_count: u16,
3411 input_glyph_ids: Vec<u16>,
3412 lookahead_glyph_count: u16,
3413 lookahead_glyph_ids: Vec<u16>,
3414 sub_count: u16,
3415 pos_lookup_records: Vec<PosLookupRecord>
3416}
3417
3418impl GposChainSubRule {
3419 pub(super) fn new(
3420 backtrack_glyph_count: u16,
3421 backtrack_glyph_ids: Vec<u16>,
3422 input_glyph_count: u16,
3423 input_glyph_ids: Vec<u16>,
3424 lookahead_glyph_count: u16,
3425 lookahead_glyph_ids: Vec<u16>,
3426 sub_count: u16,
3427 pos_lookup_records: Vec<PosLookupRecord>
3428 ) -> Self {
3429 Self {
3430 backtrack_glyph_count,
3431 backtrack_glyph_ids,
3432 input_glyph_count,
3433 input_glyph_ids,
3434 lookahead_glyph_count,
3435 lookahead_glyph_ids,
3436 sub_count,
3437 pos_lookup_records
3438 }
3439 }
3440
3441 pub fn backtrack_glyph_count(&self) -> u16 {
3442 self.backtrack_glyph_count
3443 }
3444
3445 pub fn backtrack_glyph_ids(&self) -> &[u16] {
3446 &self.backtrack_glyph_ids
3447 }
3448
3449 pub fn input_glyph_count(&self) -> u16 {
3450 self.input_glyph_count
3451 }
3452
3453 pub fn input_glyph_ids(&self) -> &[u16] {
3454 &self.input_glyph_ids
3455 }
3456
3457 pub fn lookahead_glyph_count(&self) -> u16 {
3458 self.lookahead_glyph_count
3459 }
3460
3461 pub fn lookahead_glyph_ids(&self) -> &[u16] {
3462 &self.lookahead_glyph_ids
3463 }
3464
3465 pub fn sub_count(&self) -> u16 {
3466 self.sub_count
3467 }
3468
3469 pub fn pos_lookup_records(&self) -> &[PosLookupRecord] {
3470 &self.pos_lookup_records
3471 }
3472}
3473
3474pub struct GposChainSubClassSet {
3475 chain_sub_class_rule_count: u16,
3476 chain_sub_class_rule_offsets: Vec<u16>,
3477 chain_sub_class_rules: Vec<GposChainSubClassRule>
3478}
3479
3480impl GposChainSubClassSet {
3481 pub(super) fn new(
3482 chain_sub_class_rule_count: u16,
3483 chain_sub_class_rule_offsets: Vec<u16>,
3484 chain_sub_class_rules: Vec<GposChainSubClassRule>
3485 ) -> Self {
3486 Self {
3487 chain_sub_class_rule_count,
3488 chain_sub_class_rule_offsets,
3489 chain_sub_class_rules
3490 }
3491 }
3492
3493 pub fn chain_sub_class_rule_count(&self) -> u16 {
3494 self.chain_sub_class_rule_count
3495 }
3496
3497 pub fn chain_sub_class_rule_offsets(&self) -> &[u16] {
3498 &self.chain_sub_class_rule_offsets
3499 }
3500
3501 pub fn chain_sub_class_rules(&self) -> &[GposChainSubClassRule] {
3502 &self.chain_sub_class_rules
3503 }
3504}
3505
3506pub struct GposChainSubClassRule {
3507 backtrack_glyph_count: u16,
3508 backtrack_class_ids: Vec<u16>,
3509 input_glyph_count: u16,
3510 input_class_ids: Vec<u16>,
3511 lookahead_glyph_count: u16,
3512 lookahead_class_ids: Vec<u16>,
3513 sub_count: u16,
3514 pos_lookup_records: Vec<PosLookupRecord>
3515}
3516
3517impl GposChainSubClassRule {
3518 pub(super) fn new(
3519 backtrack_glyph_count: u16,
3520 backtrack_class_ids: Vec<u16>,
3521 input_glyph_count: u16,
3522 input_class_ids: Vec<u16>,
3523 lookahead_glyph_count: u16,
3524 lookahead_class_ids: Vec<u16>,
3525 sub_count: u16,
3526 pos_lookup_records: Vec<PosLookupRecord>
3527 ) -> Self {
3528 Self {
3529 backtrack_glyph_count,
3530 backtrack_class_ids,
3531 input_glyph_count,
3532 input_class_ids,
3533 lookahead_glyph_count,
3534 lookahead_class_ids,
3535 sub_count,
3536 pos_lookup_records
3537 }
3538 }
3539
3540 pub fn backtrack_glyph_count(&self) -> u16 {
3541 self.backtrack_glyph_count
3542 }
3543
3544 pub fn backtrack_class_ids(&self) -> &[u16] {
3545 &self.backtrack_class_ids
3546 }
3547
3548 pub fn input_glyph_count(&self) -> u16 {
3549 self.input_glyph_count
3550 }
3551
3552 pub fn input_class_ids(&self) -> &[u16] {
3553 &self.input_class_ids
3554 }
3555
3556 pub fn lookahead_glyph_count(&self) -> u16 {
3557 self.lookahead_glyph_count
3558 }
3559
3560 pub fn lookahead_class_ids(&self) -> &[u16] {
3561 &self.lookahead_class_ids
3562 }
3563
3564 pub fn sub_count(&self) -> u16 {
3565 self.sub_count
3566 }
3567
3568 pub fn pos_lookup_records(&self) -> &[PosLookupRecord] {
3569 &self.pos_lookup_records
3570 }
3571}
3572
3573pub enum GposType9Format {
3574 Format1 {
3575 extension_lookup_type: u16,
3576 extension_offset: u32,
3577 extension: Box<GposSubtable>
3578 }
3579}
3580
3581pub enum GsubSubtable {
3582 Type1(GsubType1Format),
3583 Type2(GsubType2Format),
3584 Type3(GsubType3Format),
3585 Type4(GsubType4Format),
3586 Type5(GsubType5Format),
3587 Type6(GsubType6Format),
3588 Type7(GsubType7Format),
3589 Type8(GsubType8Format)
3590}
3591
3592pub enum GsubType1Format {
3593 Format1 {
3594 coverage_offset: u16,
3595 coverage: Coverage,
3596 delta_glyph_id: i16
3597 },
3598 Format2 {
3599 coverage_offset: u16,
3600 coverage: Coverage,
3601 glyph_count: u16,
3602 substitute_glyph_ids: Vec<u16>
3603 }
3604}
3605
3606pub enum GsubType2Format {
3607 Format1 {
3608 coverage_offset: u16,
3609 coverage: Coverage,
3610 sequence_count: u16,
3611 sequence_offsets: Vec<u16>,
3612 sequences: Vec<Sequence>
3613 }
3614}
3615
3616pub struct Sequence {
3617 glyph_count: u16,
3618 substitute_glyph_ids: Vec<u16>
3619}
3620
3621impl Sequence {
3622 pub(super) fn new(
3623 glyph_count: u16,
3624 substitute_glyph_ids: Vec<u16>
3625 ) -> Self {
3626 Self {
3627 glyph_count,
3628 substitute_glyph_ids
3629 }
3630 }
3631
3632 pub fn glyph_count(&self) -> u16 {
3633 self.glyph_count
3634 }
3635
3636 pub fn substitute_glyph_ids(&self) -> &[u16] {
3637 &self.substitute_glyph_ids
3638 }
3639}
3640
3641pub enum GsubType3Format {
3642 Format1 {
3643 coverage_offset: u16,
3644 coverage: Coverage,
3645 alternate_set_count: u16,
3646 alternate_set_offsets: Vec<u16>,
3647 alternate_sets: Vec<AlternateSet>
3648 }
3649}
3650
3651pub struct AlternateSet {
3652 glyph_count: u16,
3653 alternate_glyph_ids: Vec<u16>
3654}
3655
3656impl AlternateSet {
3657 pub(super) fn new(
3658 glyph_count: u16,
3659 alternate_glyph_ids: Vec<u16>
3660 ) -> Self {
3661 Self {
3662 glyph_count,
3663 alternate_glyph_ids
3664 }
3665 }
3666
3667 pub fn glyph_count(&self) -> u16 {
3668 self.glyph_count
3669 }
3670
3671 pub fn alternate_glyph_ids(&self) -> &[u16] {
3672 &self.alternate_glyph_ids
3673 }
3674}
3675
3676pub enum GsubType4Format {
3677 Format1 {
3678 coverage_offset: u16,
3679 coverage: Coverage,
3680 ligature_set_count: u16,
3681 ligature_set_offsets: Vec<u16>,
3682 ligature_sets: Vec<LigatureSet>
3683 }
3684}
3685
3686pub struct LigatureSet {
3687 ligature_count: u16,
3688 ligature_offsets: Vec<u16>,
3689 ligatures: Vec<Ligature>
3690}
3691
3692impl LigatureSet {
3693 pub(super) fn new(
3694 ligature_count: u16,
3695 ligature_offsets: Vec<u16>,
3696 ligatures: Vec<Ligature>
3697 ) -> Self {
3698 Self {
3699 ligature_count,
3700 ligature_offsets,
3701 ligatures
3702 }
3703 }
3704
3705 pub fn ligature_count(&self) -> u16 {
3706 self.ligature_count
3707 }
3708
3709 pub fn ligature_offsets(&self) -> &[u16] {
3710 &self.ligature_offsets
3711 }
3712
3713 pub fn ligatures(&self) -> &[Ligature] {
3714 &self.ligatures
3715 }
3716}
3717
3718pub struct Ligature {
3719 ligature_glyph: u16,
3720 component_count: u16,
3721 component_glyph_ids: Vec<u16>
3722}
3723
3724impl Ligature {
3725 pub(super) fn new(
3726 ligature_glyph: u16,
3727 component_count: u16,
3728 component_glyph_ids: Vec<u16>
3729 ) -> Self {
3730 Self {
3731 ligature_glyph,
3732 component_count,
3733 component_glyph_ids
3734 }
3735 }
3736
3737 pub fn ligature_glyph(&self) -> u16 {
3738 self.ligature_glyph
3739 }
3740
3741 pub fn component_count(&self) -> u16 {
3742 self.component_count
3743 }
3744
3745 pub fn component_glyph_ids(&self) -> &[u16] {
3746 &self.component_glyph_ids
3747 }
3748}
3749
3750pub enum GsubType5Format {
3751 Format1 {
3752 coverage_offset: u16,
3753 coverage: Coverage,
3754 sub_rule_set_count: u16,
3755 sub_rule_set_offsets: Vec<u16>,
3756 sub_rule_sets: Vec<GsubSubRuleSet>
3757 },
3758 Format2 {
3759 coverage_offset: u16,
3760 coverage: Coverage,
3761 class_def_offset: u16,
3762 class_def: ClassDef,
3763 sub_class_set_count: u16,
3764 sub_class_set_offsets: Vec<u16>,
3765 sub_class_sets: Vec<GsubSubClassSet>
3766 },
3767 Format3 {
3768 glyph_count: u16,
3769 sub_count: u16,
3770 coverage_offsets: Vec<u16>,
3771 coverages: Vec<Coverage>,
3772 subst_lookup_records: Vec<SubstLookupRecord>
3773 }
3774}
3775
3776pub struct GsubSubRuleSet {
3777 sub_rule_count: u16,
3778 sub_rule_offsets: Vec<u16>,
3779 sub_rules: Vec<GsubSubRule>
3780}
3781
3782impl GsubSubRuleSet {
3783 pub(super) fn new(
3784 sub_rule_count: u16,
3785 sub_rule_offsets: Vec<u16>,
3786 sub_rules: Vec<GsubSubRule>
3787 ) -> Self {
3788 Self {
3789 sub_rule_count,
3790 sub_rule_offsets,
3791 sub_rules
3792 }
3793 }
3794
3795 pub fn sub_rule_count(&self) -> u16 {
3796 self.sub_rule_count
3797 }
3798
3799 pub fn sub_rule_offsets(&self) -> &[u16] {
3800 &self.sub_rule_offsets
3801 }
3802
3803 pub fn sub_rules(&self) -> &[GsubSubRule] {
3804 &self.sub_rules
3805 }
3806}
3807
3808pub struct GsubSubRule {
3809 glyph_count: u16,
3810 sub_count: u16,
3811 input_glyph_ids: Vec<u16>,
3812 subst_lookup_records: Vec<SubstLookupRecord>
3813}
3814
3815impl GsubSubRule {
3816 pub(super) fn new(
3817 glyph_count: u16,
3818 sub_count: u16,
3819 input_glyph_ids: Vec<u16>,
3820 subst_lookup_records: Vec<SubstLookupRecord>
3821 ) -> Self {
3822 Self {
3823 glyph_count,
3824 sub_count,
3825 input_glyph_ids,
3826 subst_lookup_records
3827 }
3828 }
3829
3830 pub fn glyph_count(&self) -> u16 {
3831 self.glyph_count
3832 }
3833
3834 pub fn sub_count(&self) -> u16 {
3835 self.sub_count
3836 }
3837
3838 pub fn input_glyph_ids(&self) -> &[u16] {
3839 &self.input_glyph_ids
3840 }
3841
3842 pub fn subst_lookup_records(&self) -> &[SubstLookupRecord] {
3843 &self.subst_lookup_records
3844 }
3845}
3846
3847pub struct SubstLookupRecord {
3848 glyph_sequence_index: u16,
3849 lookup_list_index: u16
3850}
3851
3852impl SubstLookupRecord {
3853 pub(super) fn new(
3854 glyph_sequence_index: u16,
3855 lookup_list_index: u16
3856 ) -> Self {
3857 Self {
3858 glyph_sequence_index,
3859 lookup_list_index
3860 }
3861 }
3862
3863 pub fn glyph_sequence_index(&self) -> u16 {
3864 self.glyph_sequence_index
3865 }
3866
3867 pub fn lookup_list_index(&self) -> u16 {
3868 self.lookup_list_index
3869 }
3870}
3871
3872pub struct GsubSubClassSet {
3873 sub_class_rule_count: u16,
3874 sub_class_rule_offsets: Vec<u16>,
3875 sub_class_rules: Vec<GsubSubClassRule>
3876}
3877
3878impl GsubSubClassSet {
3879 pub(super) fn new(
3880 sub_class_rule_count: u16,
3881 sub_class_rule_offsets: Vec<u16>,
3882 sub_class_rules: Vec<GsubSubClassRule>
3883 ) -> Self {
3884 Self {
3885 sub_class_rule_count,
3886 sub_class_rule_offsets,
3887 sub_class_rules
3888 }
3889 }
3890
3891 pub fn sub_class_rule_count(&self) -> u16 {
3892 self.sub_class_rule_count
3893 }
3894
3895 pub fn sub_class_rule_offsets(&self) -> &[u16] {
3896 &self.sub_class_rule_offsets
3897 }
3898
3899 pub fn sub_class_rules(&self) -> &[GsubSubClassRule] {
3900 &self.sub_class_rules
3901 }
3902}
3903
3904pub struct GsubSubClassRule {
3905 glyph_count: u16,
3906 sub_count: u16,
3907 class_ids: Vec<u16>,
3908 subst_lookup_records: Vec<SubstLookupRecord>
3909}
3910
3911impl GsubSubClassRule {
3912 pub(super) fn new(
3913 glyph_count: u16,
3914 sub_count: u16,
3915 class_ids: Vec<u16>,
3916 subst_lookup_records: Vec<SubstLookupRecord>
3917 ) -> Self {
3918 Self {
3919 glyph_count,
3920 sub_count,
3921 class_ids,
3922 subst_lookup_records
3923 }
3924 }
3925
3926 pub fn glyph_count(&self) -> u16 {
3927 self.glyph_count
3928 }
3929
3930 pub fn sub_count(&self) -> u16 {
3931 self.sub_count
3932 }
3933
3934 pub fn class_ids(&self) -> &[u16] {
3935 &self.class_ids
3936 }
3937
3938 pub fn subst_lookup_records(&self) -> &[SubstLookupRecord] {
3939 &self.subst_lookup_records
3940 }
3941}
3942
3943pub enum GsubType6Format {
3944 Format1 {
3945 coverage_offset: u16,
3946 coverage: Coverage,
3947 chain_sub_rule_set_count: u16,
3948 chain_sub_rule_set_offsets: Vec<u16>,
3949 chain_sub_rule_sets: Vec<GsubChainSubRuleSet>
3950 },
3951 Format2 {
3952 coverage_offset: u16,
3953 coverage: Coverage,
3954 backtrack_class_def_offset: u16,
3955 backtrack_class_def: ClassDef,
3956 input_class_def_offset: u16,
3957 input_class_def: ClassDef,
3958 lookahead_class_def_offset: u16,
3959 lookahead_class_def: ClassDef,
3960 chain_sub_class_set_count: u16,
3961 chain_sub_class_set_offsets: Vec<u16>,
3962 chain_sub_class_sets: Vec<GsubChainSubClassSet>
3963 },
3964 Format3 {
3965 backtrack_glyph_count: u16,
3966 backtrack_coverage_offsets: Vec<u16>,
3967 backtrack_coverages: Vec<Coverage>,
3968 input_glyph_count: u16,
3969 input_coverage_offsets: Vec<u16>,
3970 input_coverages: Vec<Coverage>,
3971 lookahead_glyph_count: u16,
3972 lookahead_coverage_offsets: Vec<u16>,
3973 lookahead_coverages: Vec<Coverage>,
3974 sub_count: u16,
3975 subst_lookup_records: Vec<SubstLookupRecord>
3976 }
3977}
3978
3979pub struct GsubChainSubRuleSet {
3980 chain_sub_rule_count: u16,
3981 chain_sub_rule_offsets: Vec<u16>,
3982 chain_sub_rules: Vec<GsubChainSubRule>
3983}
3984
3985impl GsubChainSubRuleSet {
3986 pub(super) fn new(
3987 chain_sub_rule_count: u16,
3988 chain_sub_rule_offsets: Vec<u16>,
3989 chain_sub_rules: Vec<GsubChainSubRule>
3990 ) -> Self {
3991 Self {
3992 chain_sub_rule_count,
3993 chain_sub_rule_offsets,
3994 chain_sub_rules
3995 }
3996 }
3997
3998 pub fn chain_sub_rule_count(&self) -> u16 {
3999 self.chain_sub_rule_count
4000 }
4001
4002 pub fn chain_sub_rule_offsets(&self) -> &[u16] {
4003 &self.chain_sub_rule_offsets
4004 }
4005
4006 pub fn chain_sub_rules(&self) -> &[GsubChainSubRule] {
4007 &self.chain_sub_rules
4008 }
4009}
4010
4011pub struct GsubChainSubRule {
4012 backtrack_glyph_count: u16,
4013 backtrack_glyph_ids: Vec<u16>,
4014 input_glyph_count: u16,
4015 input_glyph_ids: Vec<u16>,
4016 lookahead_glyph_count: u16,
4017 lookahead_glyph_ids: Vec<u16>,
4018 sub_count: u16,
4019 subst_lookup_records: Vec<SubstLookupRecord>
4020}
4021
4022impl GsubChainSubRule {
4023 pub(super) fn new(
4024 backtrack_glyph_count: u16,
4025 backtrack_glyph_ids: Vec<u16>,
4026 input_glyph_count: u16,
4027 input_glyph_ids: Vec<u16>,
4028 lookahead_glyph_count: u16,
4029 lookahead_glyph_ids: Vec<u16>,
4030 sub_count: u16,
4031 subst_lookup_records: Vec<SubstLookupRecord>
4032 ) -> Self {
4033 Self {
4034 backtrack_glyph_count,
4035 backtrack_glyph_ids,
4036 input_glyph_count,
4037 input_glyph_ids,
4038 lookahead_glyph_count,
4039 lookahead_glyph_ids,
4040 sub_count,
4041 subst_lookup_records
4042 }
4043 }
4044
4045 pub fn backtrack_glyph_count(&self) -> u16 {
4046 self.backtrack_glyph_count
4047 }
4048
4049 pub fn backtrack_glyph_ids(&self) -> &[u16] {
4050 &self.backtrack_glyph_ids
4051 }
4052
4053 pub fn input_glyph_count(&self) -> u16 {
4054 self.input_glyph_count
4055 }
4056
4057 pub fn input_glyph_ids(&self) -> &[u16] {
4058 &self.input_glyph_ids
4059 }
4060
4061 pub fn lookahead_glyph_count(&self) -> u16 {
4062 self.lookahead_glyph_count
4063 }
4064
4065 pub fn lookahead_glyph_ids(&self) -> &[u16] {
4066 &self.lookahead_glyph_ids
4067 }
4068
4069 pub fn sub_count(&self) -> u16 {
4070 self.sub_count
4071 }
4072
4073 pub fn subst_lookup_records(&self) -> &[SubstLookupRecord] {
4074 &self.subst_lookup_records
4075 }
4076}
4077
4078pub struct GsubChainSubClassSet {
4079 chain_sub_class_rule_count: u16,
4080 chain_sub_class_rule_offsets: Vec<u16>,
4081 chain_sub_class_rules: Vec<GsubChainSubClassRule>
4082}
4083
4084impl GsubChainSubClassSet {
4085 pub(super) fn new(
4086 chain_sub_class_rule_count: u16,
4087 chain_sub_class_rule_offsets: Vec<u16>,
4088 chain_sub_class_rules: Vec<GsubChainSubClassRule>
4089 ) -> Self {
4090 Self {
4091 chain_sub_class_rule_count,
4092 chain_sub_class_rule_offsets,
4093 chain_sub_class_rules
4094 }
4095 }
4096
4097 pub fn chain_sub_class_rule_count(&self) -> u16 {
4098 self.chain_sub_class_rule_count
4099 }
4100
4101 pub fn chain_sub_class_rule_offsets(&self) -> &[u16] {
4102 &self.chain_sub_class_rule_offsets
4103 }
4104
4105 pub fn chain_sub_class_rules(&self) -> &[GsubChainSubClassRule] {
4106 &self.chain_sub_class_rules
4107 }
4108}
4109
4110pub struct GsubChainSubClassRule {
4111 backtrack_glyph_count: u16,
4112 backtrack_class_ids: Vec<u16>,
4113 input_glyph_count: u16,
4114 input_class_ids: Vec<u16>,
4115 lookahead_glyph_count: u16,
4116 lookahead_class_ids: Vec<u16>,
4117 sub_count: u16,
4118 subst_lookup_records: Vec<SubstLookupRecord>
4119}
4120
4121impl GsubChainSubClassRule {
4122 pub(super) fn new(
4123 backtrack_glyph_count: u16,
4124 backtrack_class_ids: Vec<u16>,
4125 input_glyph_count: u16,
4126 input_class_ids: Vec<u16>,
4127 lookahead_glyph_count: u16,
4128 lookahead_class_ids: Vec<u16>,
4129 sub_count: u16,
4130 subst_lookup_records: Vec<SubstLookupRecord>
4131 ) -> Self {
4132 Self {
4133 backtrack_glyph_count,
4134 backtrack_class_ids,
4135 input_glyph_count,
4136 input_class_ids,
4137 lookahead_glyph_count,
4138 lookahead_class_ids,
4139 sub_count,
4140 subst_lookup_records
4141 }
4142 }
4143
4144 pub fn backtrack_glyph_count(&self) -> u16 {
4145 self.backtrack_glyph_count
4146 }
4147
4148 pub fn backtrack_class_ids(&self) -> &[u16] {
4149 &self.backtrack_class_ids
4150 }
4151
4152 pub fn input_glyph_count(&self) -> u16 {
4153 self.input_glyph_count
4154 }
4155
4156 pub fn input_class_ids(&self) -> &[u16] {
4157 &self.input_class_ids
4158 }
4159
4160 pub fn lookahead_glyph_count(&self) -> u16 {
4161 self.lookahead_glyph_count
4162 }
4163
4164 pub fn lookahead_class_ids(&self) -> &[u16] {
4165 &self.lookahead_class_ids
4166 }
4167
4168 pub fn sub_count(&self) -> u16 {
4169 self.sub_count
4170 }
4171
4172 pub fn subst_lookup_records(&self) -> &[SubstLookupRecord] {
4173 &self.subst_lookup_records
4174 }
4175}
4176
4177pub enum GsubType7Format {
4178 Format1 {
4179 extension_lookup_type: u16,
4180 extension_offset: u32,
4181 extension: Box<GsubSubtable>
4182 }
4183}
4184
4185pub enum GsubType8Format {
4186 Format1 {
4187 coverage_offset: u16,
4188 coverage: Coverage,
4189 backtrack_glyph_count: u16,
4190 backtrack_coverage_offsets: Vec<u16>,
4191 backtrack_coverages: Vec<Coverage>,
4192 lookahead_glyph_count: u16,
4193 lookahead_coverage_offsets: Vec<u16>,
4194 lookahead_coverages: Vec<Coverage>,
4195 glyph_count: u16,
4196 substitute_glyph_ids: Vec<u16>
4197 }
4198}