/src/fontations/write-fonts/src/tables/gsub.rs
Line | Count | Source |
1 | | //! the [GSUB] table |
2 | | //! |
3 | | //! [GSUB]: https://docs.microsoft.com/en-us/typography/opentype/spec/gsub |
4 | | |
5 | | include!("../../generated/generated_gsub.rs"); |
6 | | |
7 | | use super::layout::{ |
8 | | ChainedSequenceContext, CoverageTable, FeatureList, FeatureVariations, Lookup, LookupList, |
9 | | LookupSubtable, LookupType, ScriptList, SequenceContext, |
10 | | }; |
11 | | |
12 | | pub mod builders; |
13 | | #[cfg(test)] |
14 | | mod spec_tests; |
15 | | |
16 | | /// A GSUB lookup list table. |
17 | | pub type SubstitutionLookupList = LookupList<SubstitutionLookup>; |
18 | | |
19 | | super::layout::table_newtype!( |
20 | | SubstitutionSequenceContext, |
21 | | SequenceContext, |
22 | | read_fonts::tables::layout::SequenceContext<'a> |
23 | | ); |
24 | | |
25 | | super::layout::table_newtype!( |
26 | | SubstitutionChainContext, |
27 | | ChainedSequenceContext, |
28 | | read_fonts::tables::layout::ChainedSequenceContext<'a> |
29 | | ); |
30 | | |
31 | | impl Gsub { |
32 | 0 | fn compute_version(&self) -> MajorMinor { |
33 | 0 | if self.feature_variations.is_none() { |
34 | 0 | MajorMinor::VERSION_1_0 |
35 | | } else { |
36 | 0 | MajorMinor::VERSION_1_1 |
37 | | } |
38 | 0 | } |
39 | | } |
40 | | |
41 | | super::layout::lookup_type!(gsub, SingleSubst, 1); |
42 | | super::layout::lookup_type!(gsub, MultipleSubstFormat1, 2); |
43 | | super::layout::lookup_type!(gsub, AlternateSubstFormat1, 3); |
44 | | super::layout::lookup_type!(gsub, LigatureSubstFormat1, 4); |
45 | | super::layout::lookup_type!(gsub, SubstitutionSequenceContext, 5); |
46 | | super::layout::lookup_type!(gsub, SubstitutionChainContext, 6); |
47 | | super::layout::lookup_type!(gsub, ExtensionSubtable, 7); |
48 | | super::layout::lookup_type!(gsub, ReverseChainSingleSubstFormat1, 8); |
49 | | |
50 | | impl<T: LookupSubtable + FontWrite> FontWrite for ExtensionSubstFormat1<T> { |
51 | 0 | fn write_into(&self, writer: &mut TableWriter) { |
52 | 0 | 1u16.write_into(writer); |
53 | 0 | T::TYPE.write_into(writer); |
54 | 0 | self.extension.write_into(writer); |
55 | 0 | } Unexecuted instantiation: <write_fonts::tables::gsub::ExtensionSubstFormat1<write_fonts::tables::gsub::SingleSubst> as write_fonts::write::FontWrite>::write_into Unexecuted instantiation: <write_fonts::tables::gsub::ExtensionSubstFormat1<write_fonts::tables::gsub::LigatureSubstFormat1> as write_fonts::write::FontWrite>::write_into Unexecuted instantiation: <write_fonts::tables::gsub::ExtensionSubstFormat1<write_fonts::tables::gsub::MultipleSubstFormat1> as write_fonts::write::FontWrite>::write_into Unexecuted instantiation: <write_fonts::tables::gsub::ExtensionSubstFormat1<write_fonts::tables::gsub::AlternateSubstFormat1> as write_fonts::write::FontWrite>::write_into Unexecuted instantiation: <write_fonts::tables::gsub::ExtensionSubstFormat1<write_fonts::tables::gsub::SubstitutionChainContext> as write_fonts::write::FontWrite>::write_into Unexecuted instantiation: <write_fonts::tables::gsub::ExtensionSubstFormat1<write_fonts::tables::gsub::SubstitutionSequenceContext> as write_fonts::write::FontWrite>::write_into Unexecuted instantiation: <write_fonts::tables::gsub::ExtensionSubstFormat1<write_fonts::tables::gsub::ReverseChainSingleSubstFormat1> as write_fonts::write::FontWrite>::write_into |
56 | | } |
57 | | |
58 | | // these can't have auto impls because the traits don't support generics |
59 | | impl<'a> FontRead<'a> for SubstitutionLookup { |
60 | 0 | fn read(data: FontData<'a>) -> Result<Self, ReadError> { |
61 | 0 | read_fonts::tables::gsub::SubstitutionLookup::read(data).map(|x| x.to_owned_table()) |
62 | 0 | } |
63 | | } |
64 | | |
65 | | impl<'a> FontRead<'a> for SubstitutionLookupList { |
66 | 0 | fn read(data: FontData<'a>) -> Result<Self, ReadError> { |
67 | 0 | read_fonts::tables::gsub::SubstitutionLookupList::read(data).map(|x| x.to_owned_table()) |
68 | 0 | } |
69 | | } |