-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
source.opentype.js
302 lines (300 loc) · 14.2 KB
/
source.opentype.js
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/Alhadis/language-fontforge>
// and licensed `isc`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.fea'],
names: ['opentype-feature-file', 'afdko'],
patterns: [{include: '#main'}],
repository: {
blocks: {
patterns: [
{
begin:
'(?<=^|[\\s{}])(feature)\\s+(\\w+)(?:\\s+(useExtension))?\\s*({)',
beginCaptures: {
1: {name: 'storage.type.var.feature.opentype'},
2: {name: 'entity.name.feature.opentype'},
3: {name: 'keyword.operator.opentype'},
4: {name: 'punctuation.section.bracket.curly.begin.opentype'}
},
end: '(})\\s*(\\2)\\s*(?=[#;]|$)',
endCaptures: {
1: {name: 'punctuation.section.bracket.curly.end.opentype'},
2: {name: 'entity.name.feature.opentype'}
},
name: 'meta.feature.opentype',
patterns: [
{
match: '(?<=^|[\\s{};])sizemenuname(?=[\\s#;]|$)',
name: 'keyword.operator.opentype'
},
{include: '#main'}
]
},
{
begin:
'(?<=^|[\\s{}])(lookup)\\s+((?![\\d.])[A-Za-z0-9._]+)(?:\\s+(useExtension))?\\s*({)',
beginCaptures: {
1: {name: 'storage.type.var.lookup.opentype'},
2: {name: 'entity.name.lookup.opentype'},
3: {name: 'keyword.operator.opentype'},
4: {name: 'punctuation.section.bracket.curly.begin.opentype'}
},
end: '(})\\s*(\\2)\\s*(?=[#;]|$)',
endCaptures: {
1: {name: 'punctuation.section.bracket.curly.end.opentype'},
2: {name: 'entity.name.lookup.opentype'}
},
name: 'meta.lookup.opentype',
patterns: [{include: '#main'}]
},
{
begin: '(?<=^|[\\s{};])(table)\\s+([\\w/]+)\\s*({)',
beginCaptures: {
1: {name: 'storage.type.var.table.opentype'},
2: {name: 'entity.name.table.opentype'},
3: {name: 'punctuation.section.bracket.curly.begin.opentype'}
},
end: '(})\\s*(\\2)\\s*(?=[#;]|$)',
endCaptures: {
1: {name: 'punctuation.section.bracket.curly.end.opentype'},
2: {name: 'entity.name.table.opentype'}
},
name: 'meta.table.opentype',
patterns: [
{
match:
'(?x) (?<=^|[\\s{};])\n(GlyphClassDef|Attach|LigatureCaretBy(?:Dev|Index|Pos)|MarkAttachClass\n|(?:Horiz|Vert)Axis\\.(?:BaseTagList|BaseScriptList|MinMax)|FontRevision\n|CaretOffset|Ascender|Descender|LineGap|Panose|TypoAscender|TypoDescender\n|TypoLineGap|winAscent|winDescent|UnicodeRange|CodePageRange|XHeight|CapHeight\n|Vendor|VertTypoAscender|VertTypoDescender|VertTypoLineGap|VertOriginY|VertAdvanceY)\n(?=[\\s#;]|$)',
name: 'keyword.operator.table-field.opentype'
},
{include: '#main'}
]
},
{
begin: '(?<=^|[\\s{};])(anonymous|anon)\\s+([\\w.]+)\\s*({)',
beginCaptures: {
1: {name: 'storage.type.var.opentype'},
2: {name: 'entity.name.anon-tag.opentype'},
3: {name: 'punctuation.section.bracket.curly.begin.opentype'}
},
contentName: 'string.unquoted.heredoc.opentype',
end: '(})\\s*(\\2)\\s*(;)',
endCaptures: {
1: {name: 'punctuation.section.bracket.curly.end.opentype'},
2: {name: 'entity.name.anon-tag.opentype'},
3: {name: 'punctuation.terminator.statement.opentype'}
}
},
{
begin: '(?<=^|[\\s{}])(cvParameters)\\s*({)',
beginCaptures: {
1: {name: 'storage.type.var.opentype'},
2: {name: 'punctuation.section.bracket.curly.begin.opentype'}
},
end: '(})',
endCaptures: {
1: {name: 'punctuation.section.bracket.curly.end.opentype'}
},
name: 'meta.cv-params.opentype',
patterns: [
{
begin:
'(?<=^|[\\s{}])(FeatUILabelNameID|FeatUITooltipTextNameID|SampleTextNameID|ParamUILabelNameID)\\s*({)',
beginCaptures: {
1: {name: 'keyword.operator.parameter.opentype'},
2: {name: 'punctuation.section.bracket.curly.begin.opentype'}
},
end: '(})',
endCaptures: {
1: {name: 'punctuation.section.bracket.curly.end.opentype'}
},
name: 'meta.cv-param.$1.opentype',
patterns: [{include: '#main'}]
},
{
match: '(?<=\\s|^)Character(?=\\s|$|#)',
name: 'keyword.operator.parameter.opentype'
},
{include: '#main'}
]
},
{
begin: '(?<=^|[\\s{}])(featureNames)\\s*({)',
beginCaptures: {
1: {name: 'storage.type.var.opentype'},
2: {name: 'punctuation.section.bracket.curly.begin.opentype'}
},
end: '(})',
endCaptures: {
1: {name: 'punctuation.section.bracket.curly.end.opentype'}
},
name: 'meta.$1.opentype',
patterns: [{include: '#main'}]
}
]
},
comments: {
begin: '#',
beginCaptures: {0: {name: 'punctuation.definition.comment.opentype'}},
end: '$',
name: 'comment.line.number-sign.opentype'
},
identifier: {
captures: {
1: {name: 'punctuation.definition.backslash.opentype'},
2: {name: 'punctuation.definition.glyph-class.opentype'}
},
match: '(\\\\)?(@)?(?![\\d.])[A-Za-z0-9._]+',
name: 'variable.parameter.opentype'
},
inclusion: {
begin: '\\(',
beginCaptures: {
0: {name: 'punctuation.section.bracket.round.begin.opentype'}
},
contentName: 'string.other.filename.opentype',
end: '\\)',
endCaptures: {
0: {name: 'punctuation.section.bracket.round.end.opentype'}
},
patterns: [{include: '#strings'}]
},
keywords: {
patterns: [
{
match: '(?<=^|[\\s{};])(excludeDFLT|includeDFLT)(?=$|[\\s{}#;])',
name: 'invalid.deprecated.keyword.opentype'
},
{
match: '(?<=^|[\\s{};])NULL(?=[\\s{}#;]|$)',
name: 'constant.language.null.opentype'
},
{
match: '(?<=^|[\\s{};])name(?=[\\s{}#;]|$)',
name: 'storage.type.var.name.opentype'
},
{
match: '(?<![\\w.])\\.notdef(?![\\w.])',
name: 'support.constant.language.opentype'
},
{
match: '(?<=^|[\\s{};])ignore(?=$|[\\s{}\\#;])',
name: 'storage.modifier.ignore.opentype'
},
{
match:
'(?x) (?<=^|[\\s{};])\n(anchor|anchorDef|by|contour|cursive|device|enumerate|enum|exclude_dflt|feature|from\n|IgnoreBaseGlyphs|IgnoreLigatures|IgnoreMarks|MarkAttachmentType|UseMarkFilteringSet\n|include|include_dflt|language|languagesystem|lookupflag|mark|markClass|nameid|parameters\n|position|pos|required|RightToLeft|reversesub|rsub|script|substitute|sub|subtable|table\n|useExtension|valueRecordDef|FSType|WeightClass|WidthClass)\n(?=$|[\\s{}\\#(;])',
name: 'keyword.operator.opentype'
}
]
},
main: {
patterns: [
{include: '#comments'},
{include: '#target'},
{include: '#blocks'},
{include: '#keywords'},
{include: '#tags'},
{include: '#inclusion'},
{include: '#strings'},
{include: '#number'},
{include: '#punctuation'},
{include: '#identifier'}
]
},
number: {
patterns: [
{
match: '(?<!\\w)[-+]?0x[A-Fa-f0-9]+',
name: 'constant.numeric.integer.hex.opentype'
},
{match: '(?<!\\w)[-+]?\\d+', name: 'constant.numeric.integer.opentype'}
]
},
punctuation: {
patterns: [
{match: '=', name: 'keyword.operator.assignment.opentype'},
{match: ';', name: 'punctuation.terminator.statement.opentype'},
{match: ',', name: 'punctuation.separator.list.comma.opentype'},
{match: '-', name: 'punctuation.separator.range.dash.opentype'},
{match: "'", name: 'punctuation.definition.context-mark.opentype'},
{match: '{', name: 'punctuation.section.bracket.curly.begin.opentype'},
{match: '}', name: 'punctuation.section.bracket.curly.end.opentype'},
{match: '<', name: 'punctuation.section.bracket.angle.begin.opentype'},
{match: '>', name: 'punctuation.section.bracket.angle.end.opentype'},
{
match: '\\[',
name: 'punctuation.section.bracket.square.begin.opentype'
},
{match: '\\]', name: 'punctuation.section.bracket.square.end.opentype'},
{
match: '\\(',
name: 'punctuation.section.bracket.round.begin.opentype'
},
{match: '\\)', name: 'punctuation.section.bracket.round.end.opentype'}
]
},
strings: {
patterns: [
{
begin: '"',
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.opentype'}
},
end: '"',
endCaptures: {
0: {name: 'punctuation.definition.string.end.opentype'}
},
name: 'string.quoted.double.opentype',
patterns: [
{
match: '\\\\[A-Fa-f0-9]{1,4}',
name: 'constant.character.escape.codepoint.opentype'
}
]
}
]
},
tags: {
patterns: [
{
match:
'(?x) (?<=^|[\\s{};])\n(aalt|abvf|abvm|abvs|afrc|akhn|blwf|blwm|blws|calt|case|ccmp|cfar|cjct|clig|cpct|cpsp\n|cswh|curs|cv[0-9]{2}|c2pc|c2sc|dist|dlig|dnom|dtls|expt|falt|fin2|fin3|fina|flac|frac\n|fwid|half|haln|halt|hist|hkna|hlig|hngl|hojo|hwid|init|isol|ital|jalt|jp78|jp83|jp90\n|jp04|kern|lfbd|liga|ljmo|lnum|locl|ltra|ltrm|mark|med2|medi|mgrk|mkmk|mset|nalt|nlck\n|nukt|numr|onum|opbd|ordn|ornm|palt|pcap|pkna|pnum|pref|pres|pstf|psts|pwid|qwid|rand\n|rclt|rkrf|rlig|rphf|rtbd|rtla|rtlm|ruby|rvrn|salt|sinf|size|smcp|smpl|ss[0-9]{2}|ssty\n|stch|subs|sups|swsh|titl|tjmo|tnam|tnum|trad|twid|unic|valt|vatu|vert|vhal|vjmo|vkna\n|vkrn|vpal|vrt2|vrtr|zero)\n(?=[\\s#;]|$)',
name: 'support.constant.language.tag.feature.opentype'
},
{
match:
'(?x) (?<=^|[\\s{};])\n(arab|armn|avst|bali|bamu|batk|beng|bng2|bopo|brah|brai|bugi|buhd|byzm|cans|cari|cakm\n|cham|cher|hani|copt|cprt|cyrl|DFLT|dsrt|deva|dev2|egyp|ethi|geor|glag|goth|grek|gujr\n|gjr2|guru|gur2|hang|jamo|hano|hebr|kana|armi|phli|prti|java|kthi|knda|knd2|kana|kali\n|khar|khmr|lao|latn|lepc|limb|linb|lisu|lyci|lydi|mlym|mlm2|mand|math|mtei|merc|mero\n|plrd|mong|musc|mymr|mym2|talu|nko|ogam|olck|ital|xpeo|sarb|orkh|orya|ory2|osma|phag\n|phnx|rjng|runr|samr|saur|shrd|shaw|sinh|sora|xsux|sund|sylo|syrc|tglg|tagb|tale|lana\n|tavt|takr|taml|tml2|telu|tel2|thaa|thai|tibt|tfng|ugar|vai|yi)\n(?=[\\s#;]|$)',
name: 'support.constant.language.tag.script.opentype'
},
{
match:
'(?x) (?<=^|[\\s{};])\n(ARA|APPH|ANG|AMH|ALT|ALS|AKA|AIO|AGW|AFR|AFK|ADY|ACR|ACH|ABK|ABA|BGQ|BGC|BEN|BEM|BEL\n|BDY|BCR|BCH|BBR|BBC|BAU|BAR|BAN|BAL|BAG|BAD0|BAD|AZE|AZB|AYM|AWA|AVR|ATH|AST|ASM|ARK\n|ARI|ARG|CHE|CEB|CBK|CAT|CAK|BUG|BTS|BTI|BSH|BRX|BRM|BRI|BRH|BRE|BPY|BOS|BML|BMB|BLT\n|BLN|BLK|BLI|BKF|BJJ|BIS|BIL|BIK|BHO|BHI|BGR|DEU|DCR|DAX|DAR|DAN|CUK|CTG|CSY|CSL|CSB\n|CRT|CRR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opentype'
}
]
},
target: {
captures: {
1: {name: 'punctuation.definition.backslash.opentype'},
2: {name: 'punctuation.definition.context-mark.opentype'},
3: {name: 'punctuation.definition.glyph-class.opentype'}
},
match: "(\\\\)?(@)?(?![\\d.])[A-Za-z0-9._]+(')",
name: 'entity.name.subject.opentype'
}
},
scopeName: 'source.opentype'
}
export default grammar