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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
//! The encodings.

use crate::compact1::{GlyphID, StringID};

/// An encoding.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Encoding {
    Standard,
    Expert,
}

impl Encoding {
    /// Return the string identifier of a glyph.
    #[inline]
    pub fn get(&self, gid: GlyphID) -> Option<StringID> {
        match *self {
            Encoding::Standard => get_standard(gid),
            Encoding::Expert => get_expert(gid),
        }
    }
}

macro_rules! get(
    ($one:ident { $($gid:pat => $sid:expr => $name:expr,)+ }) => (
        Some(match $one {
            $($gid => $sid,)+
            _ => return None,
        })
    );
);

fn get_standard(gid: GlyphID) -> Option<StringID> {
    get!(gid {
        0 => 0 => ".notdef",
        1 => 0 => ".notdef",
        2 => 0 => ".notdef",
        3 => 0 => ".notdef",
        4 => 0 => ".notdef",
        5 => 0 => ".notdef",
        6 => 0 => ".notdef",
        7 => 0 => ".notdef",
        8 => 0 => ".notdef",
        9 => 0 => ".notdef",
        10 => 0 => ".notdef",
        11 => 0 => ".notdef",
        12 => 0 => ".notdef",
        13 => 0 => ".notdef",
        14 => 0 => ".notdef",
        15 => 0 => ".notdef",
        16 => 0 => ".notdef",
        17 => 0 => ".notdef",
        18 => 0 => ".notdef",
        19 => 0 => ".notdef",
        20 => 0 => ".notdef",
        21 => 0 => ".notdef",
        22 => 0 => ".notdef",
        23 => 0 => ".notdef",
        24 => 0 => ".notdef",
        25 => 0 => ".notdef",
        26 => 0 => ".notdef",
        27 => 0 => ".notdef",
        28 => 0 => ".notdef",
        29 => 0 => ".notdef",
        30 => 0 => ".notdef",
        31 => 0 => ".notdef",
        32 => 1 => "space",
        33 => 2 => "exclam",
        34 => 3 => "quotedbl",
        35 => 4 => "numbersign",
        36 => 5 => "dollar",
        37 => 6 => "percent",
        38 => 7 => "ampersand",
        39 => 8 => "quoteright",
        40 => 9 => "parenleft",
        41 => 10 => "parenright",
        42 => 11 => "asterisk",
        43 => 12 => "plus",
        44 => 13 => "comma",
        45 => 14 => "hyphen",
        46 => 15 => "period",
        47 => 16 => "slash",
        48 => 17 => "zero",
        49 => 18 => "one",
        50 => 19 => "two",
        51 => 20 => "three",
        52 => 21 => "four",
        53 => 22 => "five",
        54 => 23 => "six",
        55 => 24 => "seven",
        56 => 25 => "eight",
        57 => 26 => "nine",
        58 => 27 => "colon",
        59 => 28 => "semicolon",
        60 => 29 => "less",
        61 => 30 => "equal",
        62 => 31 => "greater",
        63 => 32 => "question",
        64 => 33 => "at",
        65 => 34 => "A",
        66 => 35 => "B",
        67 => 36 => "C",
        68 => 37 => "D",
        69 => 38 => "E",
        70 => 39 => "F",
        71 => 40 => "G",
        72 => 41 => "H",
        73 => 42 => "I",
        74 => 43 => "J",
        75 => 44 => "K",
        76 => 45 => "L",
        77 => 46 => "M",
        78 => 47 => "N",
        79 => 48 => "O",
        80 => 49 => "P",
        81 => 50 => "Q",
        82 => 51 => "R",
        83 => 52 => "S",
        84 => 53 => "T",
        85 => 54 => "U",
        86 => 55 => "V",
        87 => 56 => "W",
        88 => 57 => "X",
        89 => 58 => "Y",
        90 => 59 => "Z",
        91 => 60 => "bracketleft",
        92 => 61 => "backslash",
        93 => 62 => "bracketright",
        94 => 63 => "asciicircum",
        95 => 64 => "underscore",
        96 => 65 => "quoteleft",
        97 => 66 => "a",
        98 => 67 => "b",
        99 => 68 => "c",
        100 => 69 => "d",
        101 => 70 => "e",
        102 => 71 => "f",
        103 => 72 => "g",
        104 => 73 => "h",
        105 => 74 => "i",
        106 => 75 => "j",
        107 => 76 => "k",
        108 => 77 => "l",
        109 => 78 => "m",
        110 => 79 => "n",
        111 => 80 => "o",
        112 => 81 => "p",
        113 => 82 => "q",
        114 => 83 => "r",
        115 => 84 => "s",
        116 => 85 => "t",
        117 => 86 => "u",
        118 => 87 => "v",
        119 => 88 => "w",
        120 => 89 => "x",
        121 => 90 => "y",
        122 => 91 => "z",
        123 => 92 => "braceleft",
        124 => 93 => "bar",
        125 => 94 => "braceright",
        126 => 95 => "asciitilde",
        127 => 0 => ".notdef",
        128 => 0 => ".notdef",
        129 => 0 => ".notdef",
        130 => 0 => ".notdef",
        131 => 0 => ".notdef",
        132 => 0 => ".notdef",
        133 => 0 => ".notdef",
        134 => 0 => ".notdef",
        135 => 0 => ".notdef",
        136 => 0 => ".notdef",
        137 => 0 => ".notdef",
        138 => 0 => ".notdef",
        139 => 0 => ".notdef",
        140 => 0 => ".notdef",
        141 => 0 => ".notdef",
        142 => 0 => ".notdef",
        143 => 0 => ".notdef",
        144 => 0 => ".notdef",
        145 => 0 => ".notdef",
        146 => 0 => ".notdef",
        147 => 0 => ".notdef",
        148 => 0 => ".notdef",
        149 => 0 => ".notdef",
        150 => 0 => ".notdef",
        151 => 0 => ".notdef",
        152 => 0 => ".notdef",
        153 => 0 => ".notdef",
        154 => 0 => ".notdef",
        155 => 0 => ".notdef",
        156 => 0 => ".notdef",
        157 => 0 => ".notdef",
        158 => 0 => ".notdef",
        159 => 0 => ".notdef",
        160 => 0 => ".notdef",
        161 => 96 => "exclamdown",
        162 => 97 => "cent",
        163 => 98 => "sterling",
        164 => 99 => "fraction",
        165 => 100 => "yen",
        166 => 101 => "florin",
        167 => 102 => "section",
        168 => 103 => "currency",
        169 => 104 => "quotesingle",
        170 => 105 => "quotedblleft",
        171 => 106 => "guillemotleft",
        172 => 107 => "guilsinglleft",
        173 => 108 => "guilsinglright",
        174 => 109 => "fi",
        175 => 110 => "fl",
        176 => 0 => ".notdef",
        177 => 111 => "endash",
        178 => 112 => "dagger",
        179 => 113 => "daggerdbl",
        180 => 114 => "periodcentered",
        181 => 0 => ".notdef",
        182 => 115 => "paragraph",
        183 => 116 => "bullet",
        184 => 117 => "quotesinglbase",
        185 => 118 => "quotedblbase",
        186 => 119 => "quotedblright",
        187 => 120 => "guillemotright",
        188 => 121 => "ellipsis",
        189 => 122 => "perthousand",
        190 => 0 => ".notdef",
        191 => 123 => "questiondown",
        192 => 0 => ".notdef",
        193 => 124 => "grave",
        194 => 125 => "acute",
        195 => 126 => "circumflex",
        196 => 127 => "tilde",
        197 => 128 => "macron",
        198 => 129 => "breve",
        199 => 130 => "dotaccent",
        200 => 131 => "dieresis",
        201 => 0 => ".notdef",
        202 => 132 => "ring",
        203 => 133 => "cedilla",
        204 => 0 => ".notdef",
        205 => 134 => "hungarumlaut",
        206 => 135 => "ogonek",
        207 => 136 => "caron",
        208 => 137 => "emdash",
        209 => 0 => ".notdef",
        210 => 0 => ".notdef",
        211 => 0 => ".notdef",
        212 => 0 => ".notdef",
        213 => 0 => ".notdef",
        214 => 0 => ".notdef",
        215 => 0 => ".notdef",
        216 => 0 => ".notdef",
        217 => 0 => ".notdef",
        218 => 0 => ".notdef",
        219 => 0 => ".notdef",
        220 => 0 => ".notdef",
        221 => 0 => ".notdef",
        222 => 0 => ".notdef",
        223 => 0 => ".notdef",
        224 => 0 => ".notdef",
        225 => 138 => "AE",
        226 => 0 => ".notdef",
        227 => 139 => "ordfeminine",
        228 => 0 => ".notdef",
        229 => 0 => ".notdef",
        230 => 0 => ".notdef",
        231 => 0 => ".notdef",
        232 => 140 => "Lslash",
        233 => 141 => "Oslash",
        234 => 142 => "OE",
        235 => 143 => "ordmasculine",
        236 => 0 => ".notdef",
        237 => 0 => ".notdef",
        238 => 0 => ".notdef",
        239 => 0 => ".notdef",
        240 => 0 => ".notdef",
        241 => 144 => "ae",
        242 => 0 => ".notdef",
        243 => 0 => ".notdef",
        244 => 0 => ".notdef",
        245 => 145 => "dotlessi",
        246 => 0 => ".notdef",
        247 => 0 => ".notdef",
        248 => 146 => "lslash",
        249 => 147 => "oslash",
        250 => 148 => "oe",
        251 => 149 => "germandbls",
        252 => 0 => ".notdef",
        253 => 0 => ".notdef",
        254 => 0 => ".notdef",
        255 => 0 => ".notdef",
    })
}

fn get_expert(gid: GlyphID) -> Option<StringID> {
    get!(gid {
        0 => 0 => ".notdef",
        1 => 0 => ".notdef",
        2 => 0 => ".notdef",
        3 => 0 => ".notdef",
        4 => 0 => ".notdef",
        5 => 0 => ".notdef",
        6 => 0 => ".notdef",
        7 => 0 => ".notdef",
        8 => 0 => ".notdef",
        9 => 0 => ".notdef",
        10 => 0 => ".notdef",
        11 => 0 => ".notdef",
        12 => 0 => ".notdef",
        13 => 0 => ".notdef",
        14 => 0 => ".notdef",
        15 => 0 => ".notdef",
        16 => 0 => ".notdef",
        17 => 0 => ".notdef",
        18 => 0 => ".notdef",
        19 => 0 => ".notdef",
        20 => 0 => ".notdef",
        21 => 0 => ".notdef",
        22 => 0 => ".notdef",
        23 => 0 => ".notdef",
        24 => 0 => ".notdef",
        25 => 0 => ".notdef",
        26 => 0 => ".notdef",
        27 => 0 => ".notdef",
        28 => 0 => ".notdef",
        29 => 0 => ".notdef",
        30 => 0 => ".notdef",
        31 => 0 => ".notdef",
        32 => 1 => "space",
        33 => 229 => "exclamsmall",
        34 => 230 => "Hungarumlautsmall",
        35 => 0 => ".notdef",
        36 => 231 => "dollaroldstyle",
        37 => 232 => "dollarsuperior",
        38 => 233 => "ampersandsmall",
        39 => 234 => "Acutesmall",
        40 => 235 => "parenleftsuperior",
        41 => 236 => "parenrightsuperior",
        42 => 237 => "twodotenleader",
        43 => 238 => "onedotenleader",
        44 => 13 => "comma",
        45 => 14 => "hyphen",
        46 => 15 => "period",
        47 => 99 => "fraction",
        48 => 239 => "zerooldstyle",
        49 => 240 => "oneoldstyle",
        50 => 241 => "twooldstyle",
        51 => 242 => "threeoldstyle",
        52 => 243 => "fouroldstyle",
        53 => 244 => "fiveoldstyle",
        54 => 245 => "sixoldstyle",
        55 => 246 => "sevenoldstyle",
        56 => 247 => "eightoldstyle",
        57 => 248 => "nineoldstyle",
        58 => 27 => "colon",
        59 => 28 => "semicolon",
        60 => 249 => "commasuperior",
        61 => 250 => "threequartersemdash",
        62 => 251 => "periodsuperior",
        63 => 252 => "questionsmall",
        64 => 0 => ".notdef",
        65 => 253 => "asuperior",
        66 => 254 => "bsuperior",
        67 => 255 => "centsuperior",
        68 => 256 => "dsuperior",
        69 => 257 => "esuperior",
        70 => 0 => ".notdef",
        71 => 0 => ".notdef",
        72 => 0 => ".notdef",
        73 => 258 => "isuperior",
        74 => 0 => ".notdef",
        75 => 0 => ".notdef",
        76 => 259 => "lsuperior",
        77 => 260 => "msuperior",
        78 => 261 => "nsuperior",
        79 => 262 => "osuperior",
        80 => 0 => ".notdef",
        81 => 0 => ".notdef",
        82 => 263 => "rsuperior",
        83 => 264 => "ssuperior",
        84 => 265 => "tsuperior",
        85 => 0 => ".notdef",
        86 => 266 => "ff",
        87 => 109 => "fi",
        88 => 110 => "fl",
        89 => 267 => "ffi",
        90 => 268 => "ffl",
        91 => 269 => "parenleftinferior",
        92 => 0 => ".notdef",
        93 => 270 => "parenrightinferior",
        94 => 271 => "Circumflexsmall",
        95 => 272 => "hyphensuperior",
        96 => 273 => "Gravesmall",
        97 => 274 => "Asmall",
        98 => 275 => "Bsmall",
        99 => 276 => "Csmall",
        100 => 277 => "Dsmall",
        101 => 278 => "Esmall",
        102 => 279 => "Fsmall",
        103 => 280 => "Gsmall",
        104 => 281 => "Hsmall",
        105 => 282 => "Ismall",
        106 => 283 => "Jsmall",
        107 => 284 => "Ksmall",
        108 => 285 => "Lsmall",
        109 => 286 => "Msmall",
        110 => 287 => "Nsmall",
        111 => 288 => "Osmall",
        112 => 289 => "Psmall",
        113 => 290 => "Qsmall",
        114 => 291 => "Rsmall",
        115 => 292 => "Ssmall",
        116 => 293 => "Tsmall",
        117 => 294 => "Usmall",
        118 => 295 => "Vsmall",
        119 => 296 => "Wsmall",
        120 => 297 => "Xsmall",
        121 => 298 => "Ysmall",
        122 => 299 => "Zsmall",
        123 => 300 => "colonmonetary",
        124 => 301 => "onefitted",
        125 => 302 => "rupiah",
        126 => 303 => "Tildesmall",
        127 => 0 => ".notdef",
        128 => 0 => ".notdef",
        129 => 0 => ".notdef",
        130 => 0 => ".notdef",
        131 => 0 => ".notdef",
        132 => 0 => ".notdef",
        133 => 0 => ".notdef",
        134 => 0 => ".notdef",
        135 => 0 => ".notdef",
        136 => 0 => ".notdef",
        137 => 0 => ".notdef",
        138 => 0 => ".notdef",
        139 => 0 => ".notdef",
        140 => 0 => ".notdef",
        141 => 0 => ".notdef",
        142 => 0 => ".notdef",
        143 => 0 => ".notdef",
        144 => 0 => ".notdef",
        145 => 0 => ".notdef",
        146 => 0 => ".notdef",
        147 => 0 => ".notdef",
        148 => 0 => ".notdef",
        149 => 0 => ".notdef",
        150 => 0 => ".notdef",
        151 => 0 => ".notdef",
        152 => 0 => ".notdef",
        153 => 0 => ".notdef",
        154 => 0 => ".notdef",
        155 => 0 => ".notdef",
        156 => 0 => ".notdef",
        157 => 0 => ".notdef",
        158 => 0 => ".notdef",
        159 => 0 => ".notdef",
        160 => 0 => ".notdef",
        161 => 304 => "exclamdownsmall",
        162 => 305 => "centoldstyle",
        163 => 306 => "Lslashsmall",
        164 => 0 => ".notdef",
        165 => 0 => ".notdef",
        166 => 307 => "Scaronsmall",
        167 => 308 => "Zcaronsmall",
        168 => 309 => "Dieresissmall",
        169 => 310 => "Brevesmall",
        170 => 311 => "Caronsmall",
        171 => 0 => ".notdef",
        172 => 312 => "Dotaccentsmall",
        173 => 0 => ".notdef",
        174 => 0 => ".notdef",
        175 => 313 => "Macronsmall",
        176 => 0 => ".notdef",
        177 => 0 => ".notdef",
        178 => 314 => "figuredash",
        179 => 315 => "hypheninferior",
        180 => 0 => ".notdef",
        181 => 0 => ".notdef",
        182 => 316 => "Ogoneksmall",
        183 => 317 => "Ringsmall",
        184 => 318 => "Cedillasmall",
        185 => 0 => ".notdef",
        186 => 0 => ".notdef",
        187 => 0 => ".notdef",
        188 => 158 => "onequarter",
        189 => 155 => "onehalf",
        190 => 163 => "threequarters",
        191 => 319 => "questiondownsmall",
        192 => 320 => "oneeighth",
        193 => 321 => "threeeighths",
        194 => 322 => "fiveeighths",
        195 => 323 => "seveneighths",
        196 => 324 => "onethird",
        197 => 325 => "twothirds",
        198 => 0 => ".notdef",
        199 => 0 => ".notdef",
        200 => 326 => "zerosuperior",
        201 => 150 => "onesuperior",
        202 => 164 => "twosuperior",
        203 => 169 => "threesuperior",
        204 => 327 => "foursuperior",
        205 => 328 => "fivesuperior",
        206 => 329 => "sixsuperior",
        207 => 330 => "sevensuperior",
        208 => 331 => "eightsuperior",
        209 => 332 => "ninesuperior",
        210 => 333 => "zeroinferior",
        211 => 334 => "oneinferior",
        212 => 335 => "twoinferior",
        213 => 336 => "threeinferior",
        214 => 337 => "fourinferior",
        215 => 338 => "fiveinferior",
        216 => 339 => "sixinferior",
        217 => 340 => "seveninferior",
        218 => 341 => "eightinferior",
        219 => 342 => "nineinferior",
        220 => 343 => "centinferior",
        221 => 344 => "dollarinferior",
        222 => 345 => "periodinferior",
        223 => 346 => "commainferior",
        224 => 347 => "Agravesmall",
        225 => 348 => "Aacutesmall",
        226 => 349 => "Acircumflexsmall",
        227 => 350 => "Atildesmall",
        228 => 351 => "Adieresissmall",
        229 => 352 => "Aringsmall",
        230 => 353 => "AEsmall",
        231 => 354 => "Ccedillasmall",
        232 => 355 => "Egravesmall",
        233 => 356 => "Eacutesmall",
        234 => 357 => "Ecircumflexsmall",
        235 => 358 => "Edieresissmall",
        236 => 359 => "Igravesmall",
        237 => 360 => "Iacutesmall",
        238 => 361 => "Icircumflexsmall",
        239 => 362 => "Idieresissmall",
        240 => 363 => "Ethsmall",
        241 => 364 => "Ntildesmall",
        242 => 365 => "Ogravesmall",
        243 => 366 => "Oacutesmall",
        244 => 367 => "Ocircumflexsmall",
        245 => 368 => "Otildesmall",
        246 => 369 => "Odieresissmall",
        247 => 370 => "OEsmall",
        248 => 371 => "Oslashsmall",
        249 => 372 => "Ugravesmall",
        250 => 373 => "Uacutesmall",
        251 => 374 => "Ucircumflexsmall",
        252 => 375 => "Udieresissmall",
        253 => 376 => "Yacutesmall",
        254 => 377 => "Thornsmall",
        255 => 378 => "Ydieresissmall",
    })
}