/
ot_gsub_src.go
115 lines (90 loc) · 4.6 KB
/
ot_gsub_src.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package tables
type SingleSubs struct {
Data SingleSubstData
}
type SingleSubstData interface {
isSingleSubstData()
Cov() Coverage
}
func (SingleSubstData1) isSingleSubstData() {}
func (SingleSubstData2) isSingleSubstData() {}
type SingleSubstData1 struct {
format uint16 `unionTag:"1"`
Coverage Coverage `offsetSize:"Offset16"` // Offset to Coverage table, from beginning of substitution subtable
DeltaGlyphID int16 // Add to original glyph ID to get substitute glyph ID
}
type SingleSubstData2 struct {
format uint16 `unionTag:"2"`
Coverage Coverage `offsetSize:"Offset16"` // Offset to Coverage table, from beginning of substitution subtable
SubstituteGlyphIDs []GlyphID `arrayCount:"FirstUint16"` //[glyphCount] Array of substitute glyph IDs — ordered by Coverage index
}
type MultipleSubs struct {
substFormat uint16 // Format identifier: format = 1
Coverage Coverage `offsetSize:"Offset16"` // Offset to Coverage table, from beginning of substitution subtable
Sequences []Sequence `arrayCount:"FirstUint16" offsetsArray:"Offset16"`
//[sequenceCount] Array of offsets to Sequence tables. Offsets are from beginning of substitution subtable, ordered by Coverage index
}
type Sequence struct {
SubstituteGlyphIDs []GlyphID `arrayCount:"FirstUint16"` // [glyphCount] String of glyph IDs to substitute
}
type AlternateSubs struct {
substFormat uint16 // Format identifier: format = 1
Coverage Coverage `offsetSize:"Offset16"` // Offset to Coverage table, from beginning of substitution subtable
AlternateSets []AlternateSet `arrayCount:"FirstUint16" offsetsArray:"Offset16"`
}
type AlternateSet struct {
AlternateGlyphIDs []GlyphID `arrayCount:"FirstUint16"` // Array of alternate glyph IDs, in arbitrary order
}
type LigatureSubs struct {
substFormat uint16 // Format identifier: format = 1
Coverage Coverage `offsetSize:"Offset16"` // Offset to Coverage table, from beginning of substitution subtable
LigatureSets []LigatureSet `arrayCount:"FirstUint16" offsetsArray:"Offset16"` //[ligatureSetCount] Array of offsets to LigatureSet tables. Offsets are from beginning of substitution subtable, ordered by Coverage index
}
// All ligatures beginning with the same glyph
type LigatureSet struct {
Ligatures []Ligature `arrayCount:"FirstUint16" offsetsArray:"Offset16"` // [LigatureCount] Array of offsets to Ligature tables. Offsets are from beginning of LigatureSet table, ordered by preference.
}
// Glyph components for one ligature
type Ligature struct {
LigatureGlyph GlyphID // glyph ID of ligature to substitute
componentCount uint16 // Number of components in the ligature
ComponentGlyphIDs []GlyphID `arrayCount:"ComputedField-componentCount-1"` // [componentCount - 1] Array of component glyph IDs — start with the second component, ordered in writing direction
}
type ContextualSubs struct {
Data ContextualSubsITF
}
type ContextualSubsITF interface {
isContextualSubsITF()
Cov() Coverage
}
type (
ContextualSubs1 SequenceContextFormat1
ContextualSubs2 SequenceContextFormat2
ContextualSubs3 SequenceContextFormat3
)
func (ContextualSubs1) isContextualSubsITF() {}
func (ContextualSubs2) isContextualSubsITF() {}
func (ContextualSubs3) isContextualSubsITF() {}
type ChainedContextualSubs struct {
Data ChainedContextualSubsITF
}
type ChainedContextualSubsITF interface {
isChainedContextualSubsITF()
Cov() Coverage
}
type (
ChainedContextualSubs1 ChainedSequenceContextFormat1
ChainedContextualSubs2 ChainedSequenceContextFormat2
ChainedContextualSubs3 ChainedSequenceContextFormat3
)
func (ChainedContextualSubs1) isChainedContextualSubsITF() {}
func (ChainedContextualSubs2) isChainedContextualSubsITF() {}
func (ChainedContextualSubs3) isChainedContextualSubsITF() {}
type ExtensionSubs Extension
type ReverseChainSingleSubs struct {
substFormat uint16 // Format identifier: format = 1
coverage Coverage `offsetSize:"Offset16"` // Offset to Coverage table, from beginning of substitution subtable.
BacktrackCoverages []Coverage `arrayCount:"FirstUint16" offsetsArray:"Offset16"` //[backtrackGlyphCount] Array of offsets to coverage tables in backtrack sequence, in glyph sequence order.
LookaheadCoverages []Coverage `arrayCount:"FirstUint16" offsetsArray:"Offset16"` //[lookaheadGlyphCount] Array of offsets to coverage tables in lookahead sequence, in glyph sequence order.
SubstituteGlyphIDs []GlyphID `arrayCount:"FirstUint16"` //[glyphCount] Array of substitute glyph IDs — ordered by Coverage index.
}