Skip to main content

stet_fonts/
encoding.rs

1// stet - A PostScript Interpreter
2// Copyright (c) 2026 Scott Bowman
3// SPDX-License-Identifier: Apache-2.0 OR MIT
4
5//! PostScript standard encoding tables.
6//!
7//! Provides `STANDARD_ENCODING` and `ISO_LATIN1_ENCODING` as static arrays
8//! mapping byte values (0–255) to glyph name strings.
9
10/// PostScript StandardEncoding: maps byte values 0–255 to glyph names.
11/// Empty string means `.notdef` (no glyph assigned to that code point).
12pub static STANDARD_ENCODING: [&str; 256] = [
13    // 0x00–0x0F
14    ".notdef",
15    ".notdef",
16    ".notdef",
17    ".notdef",
18    ".notdef",
19    ".notdef",
20    ".notdef",
21    ".notdef",
22    ".notdef",
23    ".notdef",
24    ".notdef",
25    ".notdef",
26    ".notdef",
27    ".notdef",
28    ".notdef",
29    ".notdef",
30    // 0x10–0x1F
31    ".notdef",
32    ".notdef",
33    ".notdef",
34    ".notdef",
35    ".notdef",
36    ".notdef",
37    ".notdef",
38    ".notdef",
39    ".notdef",
40    ".notdef",
41    ".notdef",
42    ".notdef",
43    ".notdef",
44    ".notdef",
45    ".notdef",
46    ".notdef",
47    // 0x20–0x2F
48    "space",
49    "exclam",
50    "quotedbl",
51    "numbersign",
52    "dollar",
53    "percent",
54    "ampersand",
55    "quoteright",
56    "parenleft",
57    "parenright",
58    "asterisk",
59    "plus",
60    "comma",
61    "hyphen",
62    "period",
63    "slash",
64    // 0x30–0x3F
65    "zero",
66    "one",
67    "two",
68    "three",
69    "four",
70    "five",
71    "six",
72    "seven",
73    "eight",
74    "nine",
75    "colon",
76    "semicolon",
77    "less",
78    "equal",
79    "greater",
80    "question",
81    // 0x40–0x4F
82    "at",
83    "A",
84    "B",
85    "C",
86    "D",
87    "E",
88    "F",
89    "G",
90    "H",
91    "I",
92    "J",
93    "K",
94    "L",
95    "M",
96    "N",
97    "O",
98    // 0x50–0x5F
99    "P",
100    "Q",
101    "R",
102    "S",
103    "T",
104    "U",
105    "V",
106    "W",
107    "X",
108    "Y",
109    "Z",
110    "bracketleft",
111    "backslash",
112    "bracketright",
113    "asciicircum",
114    "underscore",
115    // 0x60–0x6F
116    "quoteleft",
117    "a",
118    "b",
119    "c",
120    "d",
121    "e",
122    "f",
123    "g",
124    "h",
125    "i",
126    "j",
127    "k",
128    "l",
129    "m",
130    "n",
131    "o",
132    // 0x70–0x7F
133    "p",
134    "q",
135    "r",
136    "s",
137    "t",
138    "u",
139    "v",
140    "w",
141    "x",
142    "y",
143    "z",
144    "braceleft",
145    "bar",
146    "braceright",
147    "asciitilde",
148    ".notdef",
149    // 0x80–0x8F
150    ".notdef",
151    ".notdef",
152    ".notdef",
153    ".notdef",
154    ".notdef",
155    ".notdef",
156    ".notdef",
157    ".notdef",
158    ".notdef",
159    ".notdef",
160    ".notdef",
161    ".notdef",
162    ".notdef",
163    ".notdef",
164    ".notdef",
165    ".notdef",
166    // 0x90–0x9F
167    ".notdef",
168    ".notdef",
169    ".notdef",
170    ".notdef",
171    ".notdef",
172    ".notdef",
173    ".notdef",
174    ".notdef",
175    ".notdef",
176    ".notdef",
177    ".notdef",
178    ".notdef",
179    ".notdef",
180    ".notdef",
181    ".notdef",
182    ".notdef",
183    // 0xA0–0xAF
184    ".notdef",
185    "exclamdown",
186    "cent",
187    "sterling",
188    "fraction",
189    "yen",
190    "florin",
191    "section",
192    "currency",
193    "quotesingle",
194    "quotedblleft",
195    "guillemotleft",
196    "guilsinglleft",
197    "guilsinglright",
198    "fi",
199    "fl",
200    // 0xB0–0xBF
201    ".notdef",
202    "endash",
203    "dagger",
204    "daggerdbl",
205    "periodcentered",
206    ".notdef",
207    "paragraph",
208    "bullet",
209    "quotesinglbase",
210    "quotedblbase",
211    "quotedblright",
212    "guillemotright",
213    "ellipsis",
214    "perthousand",
215    ".notdef",
216    "questiondown",
217    // 0xC0–0xCF
218    ".notdef",
219    "grave",
220    "acute",
221    "circumflex",
222    "tilde",
223    "macron",
224    "breve",
225    "dotaccent",
226    "dieresis",
227    ".notdef",
228    "ring",
229    "cedilla",
230    ".notdef",
231    "hungarumlaut",
232    "ogonek",
233    "caron",
234    // 0xD0–0xDF
235    "emdash",
236    ".notdef",
237    ".notdef",
238    ".notdef",
239    ".notdef",
240    ".notdef",
241    ".notdef",
242    ".notdef",
243    ".notdef",
244    ".notdef",
245    ".notdef",
246    ".notdef",
247    ".notdef",
248    ".notdef",
249    ".notdef",
250    ".notdef",
251    // 0xE0–0xEF
252    ".notdef",
253    "AE",
254    ".notdef",
255    "ordfeminine",
256    ".notdef",
257    ".notdef",
258    ".notdef",
259    ".notdef",
260    "Lslash",
261    "Oslash",
262    "OE",
263    "ordmasculine",
264    ".notdef",
265    ".notdef",
266    ".notdef",
267    ".notdef",
268    // 0xF0–0xFF
269    ".notdef",
270    "ae",
271    ".notdef",
272    ".notdef",
273    ".notdef",
274    "dotlessi",
275    ".notdef",
276    ".notdef",
277    "lslash",
278    "oslash",
279    "oe",
280    "germandbls",
281    ".notdef",
282    ".notdef",
283    ".notdef",
284    ".notdef",
285];
286
287/// ISOLatin1Encoding: maps byte values 0–255 to glyph names.
288pub static ISO_LATIN1_ENCODING: [&str; 256] = [
289    // 0x00–0x0F
290    ".notdef",
291    ".notdef",
292    ".notdef",
293    ".notdef",
294    ".notdef",
295    ".notdef",
296    ".notdef",
297    ".notdef",
298    ".notdef",
299    ".notdef",
300    ".notdef",
301    ".notdef",
302    ".notdef",
303    ".notdef",
304    ".notdef",
305    ".notdef",
306    // 0x10–0x1F
307    ".notdef",
308    ".notdef",
309    ".notdef",
310    ".notdef",
311    ".notdef",
312    ".notdef",
313    ".notdef",
314    ".notdef",
315    ".notdef",
316    ".notdef",
317    ".notdef",
318    ".notdef",
319    ".notdef",
320    ".notdef",
321    ".notdef",
322    ".notdef",
323    // 0x20–0x2F
324    "space",
325    "exclam",
326    "quotedbl",
327    "numbersign",
328    "dollar",
329    "percent",
330    "ampersand",
331    "quotesingle",
332    "parenleft",
333    "parenright",
334    "asterisk",
335    "plus",
336    "comma",
337    "hyphen",
338    "period",
339    "slash",
340    // 0x30–0x3F
341    "zero",
342    "one",
343    "two",
344    "three",
345    "four",
346    "five",
347    "six",
348    "seven",
349    "eight",
350    "nine",
351    "colon",
352    "semicolon",
353    "less",
354    "equal",
355    "greater",
356    "question",
357    // 0x40–0x4F
358    "at",
359    "A",
360    "B",
361    "C",
362    "D",
363    "E",
364    "F",
365    "G",
366    "H",
367    "I",
368    "J",
369    "K",
370    "L",
371    "M",
372    "N",
373    "O",
374    // 0x50–0x5F
375    "P",
376    "Q",
377    "R",
378    "S",
379    "T",
380    "U",
381    "V",
382    "W",
383    "X",
384    "Y",
385    "Z",
386    "bracketleft",
387    "backslash",
388    "bracketright",
389    "asciicircum",
390    "underscore",
391    // 0x60–0x6F
392    "grave",
393    "a",
394    "b",
395    "c",
396    "d",
397    "e",
398    "f",
399    "g",
400    "h",
401    "i",
402    "j",
403    "k",
404    "l",
405    "m",
406    "n",
407    "o",
408    // 0x70–0x7F
409    "p",
410    "q",
411    "r",
412    "s",
413    "t",
414    "u",
415    "v",
416    "w",
417    "x",
418    "y",
419    "z",
420    "braceleft",
421    "bar",
422    "braceright",
423    "asciitilde",
424    ".notdef",
425    // 0x80–0x8F
426    ".notdef",
427    ".notdef",
428    ".notdef",
429    ".notdef",
430    ".notdef",
431    ".notdef",
432    ".notdef",
433    ".notdef",
434    ".notdef",
435    ".notdef",
436    ".notdef",
437    ".notdef",
438    ".notdef",
439    ".notdef",
440    ".notdef",
441    ".notdef",
442    // 0x90–0x9F
443    "dotlessi",
444    "grave",
445    "acute",
446    "circumflex",
447    "tilde",
448    "macron",
449    "breve",
450    "dotaccent",
451    "dieresis",
452    ".notdef",
453    "ring",
454    "cedilla",
455    ".notdef",
456    "hungarumlaut",
457    "ogonek",
458    "caron",
459    // 0xA0–0xAF
460    "space",
461    "exclamdown",
462    "cent",
463    "sterling",
464    "currency",
465    "yen",
466    "brokenbar",
467    "section",
468    "dieresis",
469    "copyright",
470    "ordfeminine",
471    "guillemotleft",
472    "logicalnot",
473    "hyphen",
474    "registered",
475    "macron",
476    // 0xB0–0xBF
477    "degree",
478    "plusminus",
479    "twosuperior",
480    "threesuperior",
481    "acute",
482    "mu",
483    "paragraph",
484    "periodcentered",
485    "cedilla",
486    "onesuperior",
487    "ordmasculine",
488    "guillemotright",
489    "onequarter",
490    "onehalf",
491    "threequarters",
492    "questiondown",
493    // 0xC0–0xCF
494    "Agrave",
495    "Aacute",
496    "Acircumflex",
497    "Atilde",
498    "Adieresis",
499    "Aring",
500    "AE",
501    "Ccedilla",
502    "Egrave",
503    "Eacute",
504    "Ecircumflex",
505    "Edieresis",
506    "Igrave",
507    "Iacute",
508    "Icircumflex",
509    "Idieresis",
510    // 0xD0–0xDF
511    "Eth",
512    "Ntilde",
513    "Ograve",
514    "Oacute",
515    "Ocircumflex",
516    "Otilde",
517    "Odieresis",
518    "multiply",
519    "Oslash",
520    "Ugrave",
521    "Uacute",
522    "Ucircumflex",
523    "Udieresis",
524    "Yacute",
525    "Thorn",
526    "germandbls",
527    // 0xE0–0xEF
528    "agrave",
529    "aacute",
530    "acircumflex",
531    "atilde",
532    "adieresis",
533    "aring",
534    "ae",
535    "ccedilla",
536    "egrave",
537    "eacute",
538    "ecircumflex",
539    "edieresis",
540    "igrave",
541    "iacute",
542    "icircumflex",
543    "idieresis",
544    // 0xF0–0xFF
545    "eth",
546    "ntilde",
547    "ograve",
548    "oacute",
549    "ocircumflex",
550    "otilde",
551    "odieresis",
552    "divide",
553    "oslash",
554    "ugrave",
555    "uacute",
556    "ucircumflex",
557    "udieresis",
558    "yacute",
559    "thorn",
560    "ydieresis",
561];
562
563/// WinAnsiEncoding: maps byte values 0–255 to glyph names.
564/// PDF Reference §D.1 — Windows code page 1252 mapping.
565pub static WINANSI_ENCODING: [&str; 256] = [
566    // 0x00–0x0F
567    ".notdef",
568    ".notdef",
569    ".notdef",
570    ".notdef",
571    ".notdef",
572    ".notdef",
573    ".notdef",
574    ".notdef",
575    ".notdef",
576    ".notdef",
577    ".notdef",
578    ".notdef",
579    ".notdef",
580    ".notdef",
581    ".notdef",
582    ".notdef",
583    // 0x10–0x1F
584    ".notdef",
585    ".notdef",
586    ".notdef",
587    ".notdef",
588    ".notdef",
589    ".notdef",
590    ".notdef",
591    ".notdef",
592    ".notdef",
593    ".notdef",
594    ".notdef",
595    ".notdef",
596    ".notdef",
597    ".notdef",
598    ".notdef",
599    ".notdef",
600    // 0x20–0x2F
601    "space",
602    "exclam",
603    "quotedbl",
604    "numbersign",
605    "dollar",
606    "percent",
607    "ampersand",
608    "quotesingle",
609    "parenleft",
610    "parenright",
611    "asterisk",
612    "plus",
613    "comma",
614    "hyphen",
615    "period",
616    "slash",
617    // 0x30–0x3F
618    "zero",
619    "one",
620    "two",
621    "three",
622    "four",
623    "five",
624    "six",
625    "seven",
626    "eight",
627    "nine",
628    "colon",
629    "semicolon",
630    "less",
631    "equal",
632    "greater",
633    "question",
634    // 0x40–0x4F
635    "at",
636    "A",
637    "B",
638    "C",
639    "D",
640    "E",
641    "F",
642    "G",
643    "H",
644    "I",
645    "J",
646    "K",
647    "L",
648    "M",
649    "N",
650    "O",
651    // 0x50–0x5F
652    "P",
653    "Q",
654    "R",
655    "S",
656    "T",
657    "U",
658    "V",
659    "W",
660    "X",
661    "Y",
662    "Z",
663    "bracketleft",
664    "backslash",
665    "bracketright",
666    "asciicircum",
667    "underscore",
668    // 0x60–0x6F
669    "grave",
670    "a",
671    "b",
672    "c",
673    "d",
674    "e",
675    "f",
676    "g",
677    "h",
678    "i",
679    "j",
680    "k",
681    "l",
682    "m",
683    "n",
684    "o",
685    // 0x70–0x7F
686    "p",
687    "q",
688    "r",
689    "s",
690    "t",
691    "u",
692    "v",
693    "w",
694    "x",
695    "y",
696    "z",
697    "braceleft",
698    "bar",
699    "braceright",
700    "asciitilde",
701    ".notdef",
702    // 0x80–0x8F
703    "Euro",
704    ".notdef",
705    "quotesinglbase",
706    "florin",
707    "quotedblbase",
708    "ellipsis",
709    "dagger",
710    "daggerdbl",
711    "circumflex",
712    "perthousand",
713    "Scaron",
714    "guilsinglleft",
715    "OE",
716    ".notdef",
717    "Zcaron",
718    ".notdef",
719    // 0x90–0x9F
720    ".notdef",
721    "quoteleft",
722    "quoteright",
723    "quotedblleft",
724    "quotedblright",
725    "bullet",
726    "endash",
727    "emdash",
728    "tilde",
729    "trademark",
730    "scaron",
731    "guilsinglright",
732    "oe",
733    ".notdef",
734    "zcaron",
735    "Ydieresis",
736    // 0xA0–0xAF
737    "space",
738    "exclamdown",
739    "cent",
740    "sterling",
741    "currency",
742    "yen",
743    "brokenbar",
744    "section",
745    "dieresis",
746    "copyright",
747    "ordfeminine",
748    "guillemotleft",
749    "logicalnot",
750    "hyphen",
751    "registered",
752    "macron",
753    // 0xB0–0xBF
754    "degree",
755    "plusminus",
756    "twosuperior",
757    "threesuperior",
758    "acute",
759    "mu",
760    "paragraph",
761    "periodcentered",
762    "cedilla",
763    "onesuperior",
764    "ordmasculine",
765    "guillemotright",
766    "onequarter",
767    "onehalf",
768    "threequarters",
769    "questiondown",
770    // 0xC0–0xCF
771    "Agrave",
772    "Aacute",
773    "Acircumflex",
774    "Atilde",
775    "Adieresis",
776    "Aring",
777    "AE",
778    "Ccedilla",
779    "Egrave",
780    "Eacute",
781    "Ecircumflex",
782    "Edieresis",
783    "Igrave",
784    "Iacute",
785    "Icircumflex",
786    "Idieresis",
787    // 0xD0–0xDF
788    "Eth",
789    "Ntilde",
790    "Ograve",
791    "Oacute",
792    "Ocircumflex",
793    "Otilde",
794    "Odieresis",
795    "multiply",
796    "Oslash",
797    "Ugrave",
798    "Uacute",
799    "Ucircumflex",
800    "Udieresis",
801    "Yacute",
802    "Thorn",
803    "germandbls",
804    // 0xE0–0xEF
805    "agrave",
806    "aacute",
807    "acircumflex",
808    "atilde",
809    "adieresis",
810    "aring",
811    "ae",
812    "ccedilla",
813    "egrave",
814    "eacute",
815    "ecircumflex",
816    "edieresis",
817    "igrave",
818    "iacute",
819    "icircumflex",
820    "idieresis",
821    // 0xF0–0xFF
822    "eth",
823    "ntilde",
824    "ograve",
825    "oacute",
826    "ocircumflex",
827    "otilde",
828    "odieresis",
829    "divide",
830    "oslash",
831    "ugrave",
832    "uacute",
833    "ucircumflex",
834    "udieresis",
835    "yacute",
836    "thorn",
837    "ydieresis",
838];
839
840/// MacRomanEncoding: maps byte values 0–255 to glyph names.
841/// PDF Reference §D.1 — Mac OS standard Roman character set.
842pub static MACROMAN_ENCODING: [&str; 256] = [
843    // 0x00–0x0F
844    ".notdef",
845    ".notdef",
846    ".notdef",
847    ".notdef",
848    ".notdef",
849    ".notdef",
850    ".notdef",
851    ".notdef",
852    ".notdef",
853    ".notdef",
854    ".notdef",
855    ".notdef",
856    ".notdef",
857    ".notdef",
858    ".notdef",
859    ".notdef",
860    // 0x10–0x1F
861    ".notdef",
862    ".notdef",
863    ".notdef",
864    ".notdef",
865    ".notdef",
866    ".notdef",
867    ".notdef",
868    ".notdef",
869    ".notdef",
870    ".notdef",
871    ".notdef",
872    ".notdef",
873    ".notdef",
874    ".notdef",
875    ".notdef",
876    ".notdef",
877    // 0x20–0x2F
878    "space",
879    "exclam",
880    "quotedbl",
881    "numbersign",
882    "dollar",
883    "percent",
884    "ampersand",
885    "quotesingle",
886    "parenleft",
887    "parenright",
888    "asterisk",
889    "plus",
890    "comma",
891    "hyphen",
892    "period",
893    "slash",
894    // 0x30–0x3F
895    "zero",
896    "one",
897    "two",
898    "three",
899    "four",
900    "five",
901    "six",
902    "seven",
903    "eight",
904    "nine",
905    "colon",
906    "semicolon",
907    "less",
908    "equal",
909    "greater",
910    "question",
911    // 0x40–0x4F
912    "at",
913    "A",
914    "B",
915    "C",
916    "D",
917    "E",
918    "F",
919    "G",
920    "H",
921    "I",
922    "J",
923    "K",
924    "L",
925    "M",
926    "N",
927    "O",
928    // 0x50–0x5F
929    "P",
930    "Q",
931    "R",
932    "S",
933    "T",
934    "U",
935    "V",
936    "W",
937    "X",
938    "Y",
939    "Z",
940    "bracketleft",
941    "backslash",
942    "bracketright",
943    "asciicircum",
944    "underscore",
945    // 0x60–0x6F
946    "grave",
947    "a",
948    "b",
949    "c",
950    "d",
951    "e",
952    "f",
953    "g",
954    "h",
955    "i",
956    "j",
957    "k",
958    "l",
959    "m",
960    "n",
961    "o",
962    // 0x70–0x7F
963    "p",
964    "q",
965    "r",
966    "s",
967    "t",
968    "u",
969    "v",
970    "w",
971    "x",
972    "y",
973    "z",
974    "braceleft",
975    "bar",
976    "braceright",
977    "asciitilde",
978    ".notdef",
979    // 0x80–0x8F
980    "Adieresis",
981    "Aring",
982    "Ccedilla",
983    "Eacute",
984    "Ntilde",
985    "Odieresis",
986    "Udieresis",
987    "aacute",
988    "agrave",
989    "acircumflex",
990    "adieresis",
991    "atilde",
992    "aring",
993    "ccedilla",
994    "eacute",
995    "egrave",
996    // 0x90–0x9F
997    "ecircumflex",
998    "edieresis",
999    "iacute",
1000    "igrave",
1001    "icircumflex",
1002    "idieresis",
1003    "ntilde",
1004    "oacute",
1005    "ograve",
1006    "ocircumflex",
1007    "odieresis",
1008    "otilde",
1009    "uacute",
1010    "ugrave",
1011    "ucircumflex",
1012    "udieresis",
1013    // 0xA0–0xAF
1014    "dagger",
1015    "degree",
1016    "cent",
1017    "sterling",
1018    "section",
1019    "bullet",
1020    "paragraph",
1021    "germandbls",
1022    "registered",
1023    "copyright",
1024    "trademark",
1025    "acute",
1026    "dieresis",
1027    "notequal",
1028    "AE",
1029    "Oslash",
1030    // 0xB0–0xBF
1031    "infinity",
1032    "plusminus",
1033    "lessequal",
1034    "greaterequal",
1035    "yen",
1036    "mu",
1037    "partialdiff",
1038    "summation",
1039    "product",
1040    "pi",
1041    "integral",
1042    "ordfeminine",
1043    "ordmasculine",
1044    "Omega",
1045    "ae",
1046    "oslash",
1047    // 0xC0–0xCF
1048    "questiondown",
1049    "exclamdown",
1050    "logicalnot",
1051    "radical",
1052    "florin",
1053    "approxequal",
1054    "Delta",
1055    "guillemotleft",
1056    "guillemotright",
1057    "ellipsis",
1058    "space",
1059    "Agrave",
1060    "Atilde",
1061    "Otilde",
1062    "OE",
1063    "oe",
1064    // 0xD0–0xDF
1065    "endash",
1066    "emdash",
1067    "quotedblleft",
1068    "quotedblright",
1069    "quoteleft",
1070    "quoteright",
1071    "divide",
1072    "lozenge",
1073    "ydieresis",
1074    "Ydieresis",
1075    "fraction",
1076    "currency",
1077    "guilsinglleft",
1078    "guilsinglright",
1079    "fi",
1080    "fl",
1081    // 0xE0–0xEF
1082    "daggerdbl",
1083    "periodcentered",
1084    "quotesinglbase",
1085    "quotedblbase",
1086    "perthousand",
1087    "Acircumflex",
1088    "Ecircumflex",
1089    "Aacute",
1090    "Edieresis",
1091    "Egrave",
1092    "Iacute",
1093    "Icircumflex",
1094    "Idieresis",
1095    "Igrave",
1096    "Oacute",
1097    "Ocircumflex",
1098    // 0xF0–0xFF
1099    "apple",
1100    "Ograve",
1101    "Uacute",
1102    "Ucircumflex",
1103    "Ugrave",
1104    "dotlessi",
1105    "circumflex",
1106    "tilde",
1107    "macron",
1108    "breve",
1109    "dotaccent",
1110    "ring",
1111    "cedilla",
1112    "hungarumlaut",
1113    "ogonek",
1114    "caron",
1115];
1116
1117/// ZapfDingbats built-in encoding (from the URW D050000L font).
1118/// Used as the base encoding for symbolic ZapfDingbats fonts when no /BaseEncoding is specified.
1119/// Symbol font encoding (maps character codes to Greek/mathematical symbol glyph names).
1120pub static SYMBOL_ENCODING: [&str; 256] = [
1121    // 0x00-0x1F: .notdef
1122    ".notdef",
1123    ".notdef",
1124    ".notdef",
1125    ".notdef",
1126    ".notdef",
1127    ".notdef",
1128    ".notdef",
1129    ".notdef",
1130    ".notdef",
1131    ".notdef",
1132    ".notdef",
1133    ".notdef",
1134    ".notdef",
1135    ".notdef",
1136    ".notdef",
1137    ".notdef",
1138    ".notdef",
1139    ".notdef",
1140    ".notdef",
1141    ".notdef",
1142    ".notdef",
1143    ".notdef",
1144    ".notdef",
1145    ".notdef",
1146    ".notdef",
1147    ".notdef",
1148    ".notdef",
1149    ".notdef",
1150    ".notdef",
1151    ".notdef",
1152    ".notdef",
1153    ".notdef",
1154    // 0x20-0x3F
1155    "space",
1156    "exclam",
1157    "universal",
1158    "numbersign",
1159    "existential",
1160    "percent",
1161    "ampersand",
1162    "suchthat",
1163    "parenleft",
1164    "parenright",
1165    "asteriskmath",
1166    "plus",
1167    "comma",
1168    "minus",
1169    "period",
1170    "slash",
1171    "zero",
1172    "one",
1173    "two",
1174    "three",
1175    "four",
1176    "five",
1177    "six",
1178    "seven",
1179    "eight",
1180    "nine",
1181    "colon",
1182    "semicolon",
1183    "less",
1184    "equal",
1185    "greater",
1186    "question",
1187    // 0x40-0x5F
1188    "congruent",
1189    "Alpha",
1190    "Beta",
1191    "Chi",
1192    "Delta",
1193    "Epsilon",
1194    "Phi",
1195    "Gamma",
1196    "Eta",
1197    "Iota",
1198    "theta1",
1199    "Kappa",
1200    "Lambda",
1201    "Mu",
1202    "Nu",
1203    "Omicron",
1204    "Pi",
1205    "Theta",
1206    "Rho",
1207    "Sigma",
1208    "Tau",
1209    "Upsilon",
1210    "sigma1",
1211    "Omega",
1212    "Xi",
1213    "Psi",
1214    "Zeta",
1215    "bracketleft",
1216    "therefore",
1217    "bracketright",
1218    "perpendicular",
1219    "underscore",
1220    // 0x60-0x7F
1221    "radicalex",
1222    "alpha",
1223    "beta",
1224    "chi",
1225    "delta",
1226    "epsilon",
1227    "phi",
1228    "gamma",
1229    "eta",
1230    "iota",
1231    "phi1",
1232    "kappa",
1233    "lambda",
1234    "mu",
1235    "nu",
1236    "omicron",
1237    "pi",
1238    "theta",
1239    "rho",
1240    "sigma",
1241    "tau",
1242    "upsilon",
1243    "omega1",
1244    "omega",
1245    "xi",
1246    "psi",
1247    "zeta",
1248    "braceleft",
1249    "bar",
1250    "braceright",
1251    "similar",
1252    ".notdef",
1253    // 0x80-0x9F: .notdef
1254    ".notdef",
1255    ".notdef",
1256    ".notdef",
1257    ".notdef",
1258    ".notdef",
1259    ".notdef",
1260    ".notdef",
1261    ".notdef",
1262    ".notdef",
1263    ".notdef",
1264    ".notdef",
1265    ".notdef",
1266    ".notdef",
1267    ".notdef",
1268    ".notdef",
1269    ".notdef",
1270    ".notdef",
1271    ".notdef",
1272    ".notdef",
1273    ".notdef",
1274    ".notdef",
1275    ".notdef",
1276    ".notdef",
1277    ".notdef",
1278    ".notdef",
1279    ".notdef",
1280    ".notdef",
1281    ".notdef",
1282    ".notdef",
1283    ".notdef",
1284    ".notdef",
1285    ".notdef",
1286    // 0xA0-0xBF
1287    "Euro",
1288    "Upsilon1",
1289    "minute",
1290    "lessequal",
1291    "fraction",
1292    "infinity",
1293    "florin",
1294    "club",
1295    "diamond",
1296    "heart",
1297    "spade",
1298    "arrowboth",
1299    "arrowleft",
1300    "arrowup",
1301    "arrowright",
1302    "arrowdown",
1303    "degree",
1304    "plusminus",
1305    "second",
1306    "greaterequal",
1307    "multiply",
1308    "proportional",
1309    "partialdiff",
1310    "bullet",
1311    "divide",
1312    "notequal",
1313    "equivalence",
1314    "approxequal",
1315    "ellipsis",
1316    "arrowvertex",
1317    "arrowhorizex",
1318    "carriagereturn",
1319    // 0xC0-0xDF
1320    "aleph",
1321    "Ifraktur",
1322    "Rfraktur",
1323    "weierstrass",
1324    "circlemultiply",
1325    "circleplus",
1326    "emptyset",
1327    "intersection",
1328    "union",
1329    "propersuperset",
1330    "reflexsuperset",
1331    "notsubset",
1332    "propersubset",
1333    "reflexsubset",
1334    "element",
1335    "notelement",
1336    "angle",
1337    "gradient",
1338    "registerserif",
1339    "copyrightserif",
1340    "trademarkserif",
1341    "product",
1342    "radical",
1343    "dotmath",
1344    "logicalnot",
1345    "logicaland",
1346    "logicalor",
1347    "arrowdblboth",
1348    "arrowdblleft",
1349    "arrowdblup",
1350    "arrowdblright",
1351    "arrowdbldown",
1352    // 0xE0-0xFF
1353    "lozenge",
1354    "angleleft",
1355    "registersans",
1356    "copyrightsans",
1357    "trademarksans",
1358    "summation",
1359    "parenlefttp",
1360    "parenleftex",
1361    "parenleftbt",
1362    "bracketlefttp",
1363    "bracketleftex",
1364    "bracketleftbt",
1365    "bracelefttp",
1366    "braceleftmid",
1367    "braceleftbt",
1368    "braceex",
1369    ".notdef",
1370    "angleright",
1371    "integral",
1372    "integraltp",
1373    "integralex",
1374    "integralbt",
1375    "parenrighttp",
1376    "parenrightex",
1377    "parenrightbt",
1378    "bracketrighttp",
1379    "bracketrightex",
1380    "bracketrightbt",
1381    "bracerighttp",
1382    "bracerightmid",
1383    "bracerightbt",
1384    ".notdef",
1385];
1386
1387pub static ZAPFDINGBATS_ENCODING: [&str; 256] = [
1388    ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
1389    ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
1390    ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
1391    ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
1392    "space", "a1", "a2", "a202", "a3", "a4", "a5", "a119", "a118", "a117", "a11", "a12", "a13",
1393    "a14", "a15", "a16", "a105", "a17", "a18", "a19", "a20", "a21", "a22", "a23", "a24", "a25",
1394    "a26", "a27", "a28", "a6", "a7", "a8", "a9", "a10", "a29", "a30", "a31", "a32", "a33", "a34",
1395    "a35", "a36", "a37", "a38", "a39", "a40", "a41", "a42", "a43", "a44", "a45", "a46", "a47",
1396    "a48", "a49", "a50", "a51", "a52", "a53", "a54", "a55", "a56", "a57", "a58", "a59", "a60",
1397    "a61", "a62", "a63", "a64", "a65", "a66", "a67", "a68", "a69", "a70", "a71", "a72", "a73",
1398    "a74", "a203", "a75", "a204", "a76", "a77", "a78", "a79", "a81", "a82", "a83", "a84", "a97",
1399    "a98", "a99", "a100", ".notdef", "a89", "a90", "a93", "a94", "a91", "a92", "a205", "a85",
1400    "a206", "a86", "a87", "a88", "a95", "a96", ".notdef", ".notdef", ".notdef", ".notdef",
1401    ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
1402    ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", "a101", "a102",
1403    "a103", "a104", "a106", "a107", "a108", "a112", "a111", "a110", "a109", "a120", "a121", "a122",
1404    "a123", "a124", "a125", "a126", "a127", "a128", "a129", "a130", "a131", "a132", "a133", "a134",
1405    "a135", "a136", "a137", "a138", "a139", "a140", "a141", "a142", "a143", "a144", "a145", "a146",
1406    "a147", "a148", "a149", "a150", "a151", "a152", "a153", "a154", "a155", "a156", "a157", "a158",
1407    "a159", "a160", "a161", "a163", "a164", "a196", "a165", "a192", "a166", "a167", "a168", "a169",
1408    "a170", "a171", "a172", "a173", "a162", "a174", "a175", "a176", "a177", "a178", "a179", "a193",
1409    "a180", "a199", "a181", "a200", "a182", ".notdef", "a201", "a183", "a184", "a197", "a185",
1410    "a194", "a198", "a186", "a195", "a187", "a188", "a189", "a190", "a191", ".notdef",
1411];
1412
1413/// Look up a glyph name by StandardEncoding code point.
1414/// Returns `None` for `.notdef` entries.
1415pub fn standard_encoding_name(code: u8) -> Option<&'static str> {
1416    let name = STANDARD_ENCODING[code as usize];
1417    if name == ".notdef" { None } else { Some(name) }
1418}
1419
1420#[cfg(test)]
1421mod tests {
1422    use super::*;
1423
1424    #[test]
1425    fn test_standard_encoding_ascii_letters() {
1426        assert_eq!(STANDARD_ENCODING[0x41], "A");
1427        assert_eq!(STANDARD_ENCODING[0x5A], "Z");
1428        assert_eq!(STANDARD_ENCODING[0x61], "a");
1429        assert_eq!(STANDARD_ENCODING[0x7A], "z");
1430    }
1431
1432    #[test]
1433    fn test_standard_encoding_space() {
1434        assert_eq!(STANDARD_ENCODING[0x20], "space");
1435    }
1436
1437    #[test]
1438    fn test_standard_encoding_notdef() {
1439        assert_eq!(STANDARD_ENCODING[0x00], ".notdef");
1440        assert_eq!(STANDARD_ENCODING[0x7F], ".notdef");
1441        assert!(standard_encoding_name(0).is_none());
1442    }
1443
1444    #[test]
1445    fn test_standard_encoding_helper() {
1446        assert_eq!(standard_encoding_name(0x41), Some("A"));
1447        assert_eq!(standard_encoding_name(0x20), Some("space"));
1448        assert_eq!(standard_encoding_name(0x00), None);
1449    }
1450
1451    #[test]
1452    fn test_iso_latin1_encoding_ascii() {
1453        assert_eq!(ISO_LATIN1_ENCODING[0x41], "A");
1454        assert_eq!(ISO_LATIN1_ENCODING[0x61], "a");
1455        assert_eq!(ISO_LATIN1_ENCODING[0x20], "space");
1456    }
1457
1458    #[test]
1459    fn test_iso_latin1_encoding_accented() {
1460        assert_eq!(ISO_LATIN1_ENCODING[0xC0], "Agrave");
1461        assert_eq!(ISO_LATIN1_ENCODING[0xE9], "eacute");
1462        assert_eq!(ISO_LATIN1_ENCODING[0xFF], "ydieresis");
1463    }
1464}