1// Copyright 2016 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "core/fpdfapi/font/cpdf_fontencoding.h"
8
9#include <utility>
10
11#include "core/fpdfapi/parser/cpdf_array.h"
12#include "core/fpdfapi/parser/cpdf_dictionary.h"
13#include "core/fpdfapi/parser/cpdf_name.h"
14#include "core/fpdfapi/parser/cpdf_number.h"
15#include "core/fpdfapi/parser/fpdf_parser_decode.h"
16#include "core/fxge/fx_freetype.h"
17
18namespace {
19
20const uint16_t MSSymbolEncoding[256] = {
21    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
22    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
23    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
24    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 32,     33,     8704,   35,
25    8707,   37,     38,     8715,   40,     41,     8727,   43,     44,
26    8722,   46,     47,     48,     49,     50,     51,     52,     53,
27    54,     55,     56,     57,     58,     59,     60,     61,     62,
28    63,     8773,   913,    914,    935,    916,    917,    934,    915,
29    919,    921,    977,    922,    923,    924,    925,    927,    928,
30    920,    929,    931,    932,    933,    962,    937,    926,    936,
31    918,    91,     8756,   93,     8869,   95,     8254,   945,    946,
32    967,    948,    949,    966,    947,    951,    953,    981,    954,
33    955,    956,    957,    959,    960,    952,    961,    963,    964,
34    965,    982,    969,    958,    968,    950,    123,    124,    125,
35    8764,   0,      0,      0,      0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
36    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
37    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
38    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 978,
39    8242,   8804,   8725,   8734,   402,    9827,   9830,   9828,   9824,
40    8596,   8592,   8593,   8594,   8595,   176,    177,    8243,   8805,
41    215,    8733,   8706,   8729,   247,    8800,   8801,   8776,   8943,
42    0,      0,      8629,   0,      8465,   8476,   8472,   8855,   8853,
43    8709,   8745,   8746,   8835,   8839,   8836,   8834,   8838,   8712,
44    8713,   8736,   8711,   174,    169,    8482,   8719,   8730,   8901,
45    172,    8743,   8744,   8660,   8656,   8657,   8658,   8659,   9674,
46    9001,   0,      0,      0,      8721,   0,      0,      0,      0,
47    0,      0,      0,      0,      0,      0,      0x0000, 9002,   8747,
48    8992,   0,      8993,   0,      0,      0,      0,      0,      0,
49    0x0000, 0x0000, 0x0000, 0x0000};
50
51const uint16_t StandardEncoding[256] = {
52    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
53    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
54    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
55    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0021, 0x0022, 0x0023,
56    0x0024, 0x0025, 0x0026, 0x2019, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c,
57    0x002d, 0x002e, 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035,
58    0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e,
59    0x003f, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
60    0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, 0x0050,
61    0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059,
62    0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f, 0x2018, 0x0061, 0x0062,
63    0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b,
64    0x006c, 0x006d, 0x006e, 0x006f, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074,
65    0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d,
66    0x007e, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
67    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
68    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
69    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00a1,
70    0x00a2, 0x00a3, 0x2044, 0x00a5, 0x0192, 0x00a7, 0x00a4, 0x0027, 0x201c,
71    0x00ab, 0x2039, 0x203a, 0xfb01, 0xfb02, 0x0000, 0x2013, 0x2020, 0x2021,
72    0x00b7, 0x0000, 0x00b6, 0x2022, 0x201a, 0x201e, 0x201d, 0x00bb, 0x2026,
73    0x2030, 0x0000, 0x00bf, 0x0000, 0x0060, 0x00b4, 0x02c6, 0x02dc, 0x00af,
74    0x02d8, 0x02d9, 0x00a8, 0x0000, 0x02da, 0x00b8, 0x0000, 0x02dd, 0x02db,
75    0x02c7, 0x2014, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
76    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
77    0x00c6, 0x0000, 0x00aa, 0x0000, 0x0000, 0x0000, 0x0000, 0x0141, 0x00d8,
78    0x0152, 0x00ba, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00e6, 0x0000,
79    0x0000, 0x0000, 0x0131, 0x0000, 0x0000, 0x0142, 0x00f8, 0x0153, 0x00df,
80    0x0000, 0x0000, 0x0000, 0x0000};
81
82const uint16_t MacRomanEncoding[256] = {
83    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
84    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
85    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
86    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0021, 0x0022, 0x0023,
87    0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c,
88    0x002d, 0x002e, 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035,
89    0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e,
90    0x003f, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
91    0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, 0x0050,
92    0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059,
93    0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f, 0x0060, 0x0061, 0x0062,
94    0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b,
95    0x006c, 0x006d, 0x006e, 0x006f, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074,
96    0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d,
97    0x007e, 0x0000, 0x00c4, 0x00c5, 0x00c7, 0x00c9, 0x00d1, 0x00d6, 0x00dc,
98    0x00e1, 0x00e0, 0x00e2, 0x00e4, 0x00e3, 0x00e5, 0x00e7, 0x00e9, 0x00e8,
99    0x00ea, 0x00eb, 0x00ed, 0x00ec, 0x00ee, 0x00ef, 0x00f1, 0x00f3, 0x00f2,
100    0x00f4, 0x00f6, 0x00f5, 0x00fa, 0x00f9, 0x00fb, 0x00fc, 0x2020, 0x00b0,
101    0x00a2, 0x00a3, 0x00a7, 0x2022, 0x00b6, 0x00df, 0x00ae, 0x00a9, 0x2122,
102    0x00b4, 0x00a8, 0x0000, 0x00c6, 0x00d8, 0x0000, 0x00b1, 0x0000, 0x0000,
103    0x00a5, 0x00b5, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00aa, 0x00ba,
104    0x0000, 0x00e6, 0x00f8, 0x00bf, 0x00a3, 0x00ac, 0x0000, 0x0192, 0x0000,
105    0x0000, 0x00ab, 0x00bb, 0x2026, 0x0020, 0x00c0, 0x00c3, 0x00d5, 0x0152,
106    0x0153, 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0x00f7, 0x0000,
107    0x00ff, 0x0178, 0x2044, 0x00a4, 0x2039, 0x203a, 0xfb01, 0xfb02, 0x2021,
108    0x00b7, 0x201a, 0x201e, 0x2030, 0x00c2, 0x00ca, 0x00c1, 0x00cb, 0x00c8,
109    0x00cd, 0x00ce, 0x00cf, 0x00cc, 0x00d3, 0x00d4, 0x0000, 0x00d2, 0x00da,
110    0x00db, 0x00d9, 0x0131, 0x02c6, 0x02dc, 0x00af, 0x02d8, 0x02d9, 0x02da,
111    0x00b8, 0x02dd, 0x02db, 0x02c7};
112
113const uint16_t AdobeWinAnsiEncoding[256] = {
114    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
115    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
116    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
117    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0021, 0x0022, 0x0023,
118    0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c,
119    0x002d, 0x002e, 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035,
120    0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e,
121    0x003f, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
122    0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, 0x0050,
123    0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059,
124    0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f, 0x0060, 0x0061, 0x0062,
125    0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b,
126    0x006c, 0x006d, 0x006e, 0x006f, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074,
127    0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d,
128    0x007e, 0x2022, 0x20ac, 0x2022, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020,
129    0x2021, 0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x2022, 0x017d, 0x2022,
130    0x2022, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x02dc,
131    0x2122, 0x0161, 0x203a, 0x0153, 0x2022, 0x017e, 0x0178, 0x0020, 0x00a1,
132    0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x00aa,
133    0x00ab, 0x00ac, 0x002d, 0x00ae, 0x00af, 0x00b0, 0x00b1, 0x00b2, 0x00b3,
134    0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc,
135    0x00bd, 0x00be, 0x00bf, 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5,
136    0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce,
137    0x00cf, 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
138    0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df, 0x00e0,
139    0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9,
140    0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, 0x00f0, 0x00f1, 0x00f2,
141    0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb,
142    0x00fc, 0x00fd, 0x00fe, 0x00ff};
143
144const uint16_t MacExpertEncoding[256] = {
145    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
146    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
147    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
148    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0xf721, 0xf6f8, 0xf7a2,
149    0xf724, 0xf6e4, 0xf726, 0xf7b4, 0x207d, 0x207e, 0x2025, 0x2024, 0x002c,
150    0x002d, 0x002e, 0x2044, 0xf730, 0xf731, 0xf732, 0xf733, 0xf734, 0xf735,
151    0xf736, 0xf737, 0xf738, 0xf739, 0x003a, 0x003b, 0x0000, 0xf6de, 0x0000,
152    0xf73f, 0x0000, 0x0000, 0x0000, 0x0000, 0xf7f0, 0x0000, 0x0000, 0x00bc,
153    0x00bd, 0x00be, 0x215b, 0x215c, 0x215d, 0x215e, 0x2153, 0x2154, 0x0000,
154    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfb00, 0xfb01, 0xfb02, 0xfb03,
155    0xfb04, 0x208d, 0x0000, 0x208e, 0xf6f6, 0xf6e5, 0xf760, 0xf761, 0xf762,
156    0xf763, 0xf764, 0xf765, 0xf766, 0xf767, 0xf768, 0xf769, 0xf76a, 0xf76b,
157    0xf76c, 0xf76d, 0xf76e, 0xf76f, 0xf770, 0xf771, 0xf772, 0xf773, 0xf774,
158    0xf775, 0xf776, 0xf777, 0xf778, 0xf779, 0xf77a, 0x20a1, 0xf6dc, 0xf6dd,
159    0xf6fe, 0x0000, 0x0000, 0xf6e9, 0xf6e0, 0x0000, 0x0000, 0x0000, 0x0000,
160    0xf7e1, 0xf7e0, 0xf7e2, 0xf7e4, 0xf7e3, 0xf7e5, 0xf7e7, 0xf7e9, 0xf7e8,
161    0xf7ea, 0xf7eb, 0xf7ed, 0xf7ec, 0xf7ee, 0xf7ef, 0xf7f1, 0xf7f3, 0xf7f2,
162    0xf7f4, 0xf7f6, 0xf7f5, 0xf7fa, 0xf7f9, 0xf7fb, 0xf7fc, 0x0000, 0x2078,
163    0x2084, 0x2083, 0x2086, 0x2088, 0x2087, 0xf6fd, 0x0000, 0xf6df, 0x2082,
164    0x0000, 0xf7a8, 0x0000, 0xf6f5, 0xf6fd, 0x2085, 0x0000, 0xf6e1, 0xf6e7,
165    0xf7fd, 0x0000, 0xf6e3, 0x0000, 0x0000, 0xf7fe, 0x0000, 0x2089, 0x2080,
166    0xf6ff, 0xf7e6, 0xf7f8, 0xf7bf, 0x2081, 0xf6e9, 0x0000, 0x0000, 0x0000,
167    0x0000, 0x0000, 0x0000, 0xf7b8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
168    0xf6fa, 0x2012, 0xf6e6, 0x0000, 0x0000, 0x0000, 0x0000, 0xf7a1, 0x0000,
169    0xf7ff, 0x0000, 0x00b9, 0x00b2, 0x00b3, 0x2074, 0x2075, 0x2076, 0x2077,
170    0x2079, 0x2070, 0x0000, 0xf6ec, 0xf6f1, 0x0000, 0x0000, 0x0000, 0xf6ed,
171    0xf6f2, 0xf6eb, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xf6ee, 0xf6fb,
172    0xf6f4, 0xf7af, 0xf6ea, 0x207f, 0xf6ef, 0xf6e2, 0xf6e8, 0xf6f7, 0xf6fc,
173    0x0000, 0x0000, 0x0000, 0x0000};
174
175const uint16_t AdobeSymbolEncoding[256] = {
176    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
177    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
178    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
179    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0021, 0x2200, 0x0023,
180    0x2203, 0x0025, 0x0026, 0x220B, 0x0028, 0x0029, 0x2217, 0x002B, 0x002C,
181    0x2212, 0x002E, 0x002F, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035,
182    0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E,
183    0x003F, 0x2245, 0x0391, 0x0392, 0x03A7, 0x0394, 0x0395, 0x03A6, 0x0393,
184    0x0397, 0x0399, 0x03D1, 0x039A, 0x039B, 0x039C, 0x039D, 0x039F, 0x03A0,
185    0x0398, 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03C2, 0x03A9, 0x039E, 0x03A8,
186    0x0396, 0x005B, 0x2234, 0x005D, 0x22A5, 0x005F, 0xF8E5, 0x03B1, 0x03B2,
187    0x03C7, 0x03B4, 0x03B5, 0x03C6, 0x03B3, 0x03B7, 0x03B9, 0x03D5, 0x03BA,
188    0x03BB, 0x03BC, 0x03BD, 0x03BF, 0x03C0, 0x03B8, 0x03C1, 0x03C3, 0x03C4,
189    0x03C5, 0x03D6, 0x03C9, 0x03BE, 0x03C8, 0x03B6, 0x007B, 0x007C, 0x007D,
190    0x223C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
191    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
192    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
193    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x20AC, 0x03D2,
194    0x2032, 0x2264, 0x2044, 0x221E, 0x0192, 0x2663, 0x2666, 0x2665, 0x2660,
195    0x2194, 0x2190, 0x2191, 0x2192, 0x2193, 0x00B0, 0x00B1, 0x2033, 0x2265,
196    0x00D7, 0x221D, 0x2202, 0x2022, 0x00F7, 0x2260, 0x2261, 0x2248, 0x2026,
197    0xF8E6, 0xF8E7, 0x21B5, 0x2135, 0x2111, 0x211C, 0x2118, 0x2297, 0x2295,
198    0x2205, 0x2229, 0x222A, 0x2283, 0x2287, 0x2284, 0x2282, 0x2286, 0x2208,
199    0x2209, 0x2220, 0x2207, 0xF6DA, 0xF6D9, 0xF6DB, 0x220F, 0x221A, 0x22C5,
200    0x00AC, 0x2227, 0x2228, 0x21D4, 0x21D0, 0x21D1, 0x21D2, 0x21D3, 0x25CA,
201    0x2329, 0xF8E8, 0xF8E9, 0xF8EA, 0x2211, 0xF8EB, 0xF8EC, 0xF8ED, 0xF8EE,
202    0xF8EF, 0xF8F0, 0xF8F1, 0xF8F2, 0xF8F3, 0xF8F4, 0x0000, 0x232A, 0x222B,
203    0x2320, 0xF8F5, 0x2321, 0xF8F6, 0xF8F7, 0xF8F8, 0xF8F9, 0xF8FA, 0xF8FB,
204    0xF8FC, 0xF8FD, 0xF8FE, 0x0000,
205};
206
207const uint16_t ZapfEncoding[256] = {
208    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
209    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
210    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
211    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x2701, 0x2702, 0x2703,
212    0x2704, 0x260E, 0x2706, 0x2707, 0x2708, 0x2709, 0x261B, 0x261E, 0x270C,
213    0x270D, 0x270E, 0x270F, 0x2710, 0x2711, 0x2712, 0x2713, 0x2714, 0x2715,
214    0x2716, 0x2717, 0x2718, 0x2719, 0x271A, 0x271B, 0x271C, 0x271D, 0x271E,
215    0x271F, 0x2720, 0x2721, 0x2722, 0x2723, 0x2724, 0x2725, 0x2726, 0x2727,
216    0x2605, 0x2729, 0x272A, 0x272B, 0x272C, 0x272D, 0x272E, 0x272F, 0x2730,
217    0x2731, 0x2732, 0x2733, 0x2734, 0x2735, 0x2736, 0x2737, 0x2738, 0x2739,
218    0x273A, 0x273B, 0x273C, 0x273D, 0x273E, 0x273F, 0x2740, 0x2741, 0x2742,
219    0x2743, 0x2744, 0x2745, 0x2746, 0x2747, 0x2748, 0x2749, 0x274A, 0x274B,
220    0x25CF, 0x274D, 0x25A0, 0x274F, 0x2750, 0x2751, 0x2752, 0x25B2, 0x25BC,
221    0x25C6, 0x2756, 0x25D7, 0x2758, 0x2759, 0x275A, 0x275B, 0x275C, 0x275D,
222    0x275E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
223    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
224    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
225    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2761,
226    0x2762, 0x2763, 0x2764, 0x2765, 0x2766, 0x2767, 0x2663, 0x2666, 0x2665,
227    0x2660, 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467,
228    0x2468, 0x2469, 0x2776, 0x2777, 0x2778, 0x2779, 0x277A, 0x277B, 0x277C,
229    0x277D, 0x277E, 0x277F, 0x2780, 0x2781, 0x2782, 0x2783, 0x2784, 0x2785,
230    0x2786, 0x2787, 0x2788, 0x2789, 0x278A, 0x278B, 0x278C, 0x278D, 0x278E,
231    0x278F, 0x2790, 0x2791, 0x2792, 0x2793, 0x2794, 0x2192, 0x2194, 0x2195,
232    0x2798, 0x2799, 0x279A, 0x279B, 0x279C, 0x279D, 0x279E, 0x279F, 0x27A0,
233    0x27A1, 0x27A2, 0x27A3, 0x27A4, 0x27A5, 0x27A6, 0x27A7, 0x27A8, 0x27A9,
234    0x27AA, 0x27AB, 0x27AC, 0x27AD, 0x27AE, 0x27AF, 0x0000, 0x27B1, 0x27B2,
235    0x27B3, 0x27B4, 0x27B5, 0x27B6, 0x27B7, 0x27B8, 0x27B9, 0x27BA, 0x27BB,
236    0x27BC, 0x27BD, 0x27BE, 0x0000,
237};
238
239const FX_CHAR* const StandardEncodingNames[224] = {
240    "space",
241    "exclam",
242    "quotedbl",
243    "numbersign",
244    "dollar",
245    "percent",
246    "ampersand",
247    "quoteright",
248    "parenleft",
249    "parenright",
250    "asterisk",
251    "plus",
252    "comma",
253    "hyphen",
254    "period",
255    "slash",
256    "zero",
257    "one",
258    "two",
259    "three",
260    "four",
261    "five",
262    "six",
263    "seven",
264    "eight",
265    "nine",
266    "colon",
267    "semicolon",
268    "less",
269    "equal",
270    "greater",
271    "question",
272    "at",
273    "A",
274    "B",
275    "C",
276    "D",
277    "E",
278    "F",
279    "G",
280    "H",
281    "I",
282    "J",
283    "K",
284    "L",
285    "M",
286    "N",
287    "O",
288    "P",
289    "Q",
290    "R",
291    "S",
292    "T",
293    "U",
294    "V",
295    "W",
296    "X",
297    "Y",
298    "Z",
299    "bracketleft",
300    "backslash",
301    "bracketright",
302    "asciicircum",
303    "underscore",
304    "quoteleft",
305    "a",
306    "b",
307    "c",
308    "d",
309    "e",
310    "f",
311    "g",
312    "h",
313    "i",
314    "j",
315    "k",
316    "l",
317    "m",
318    "n",
319    "o",
320    "p",
321    "q",
322    "r",
323    "s",
324    "t",
325    "u",
326    "v",
327    "w",
328    "x",
329    "y",
330    "z",
331    "braceleft",
332    "bar",
333    "braceright",
334    "asciitilde",
335    nullptr,
336    nullptr,
337    nullptr,
338    nullptr,
339    nullptr,
340    nullptr,
341    nullptr,
342    nullptr,
343    nullptr,
344    nullptr,
345    nullptr,
346    nullptr,
347    nullptr,
348    nullptr,
349    nullptr,
350    nullptr,
351    nullptr,
352    nullptr,
353    nullptr,
354    nullptr,
355    nullptr,
356    nullptr,
357    nullptr,
358    nullptr,
359    nullptr,
360    nullptr,
361    nullptr,
362    nullptr,
363    nullptr,
364    nullptr,
365    nullptr,
366    nullptr,
367    nullptr,
368    nullptr,
369    "exclamdown",
370    "cent",
371    "sterling",
372    "fraction",
373    "yen",
374    "florin",
375    "section",
376    "currency",
377    "quotesingle",
378    "quotedblleft",
379    "guillemotleft",
380    "guilsinglleft",
381    "guilsinglright",
382    "fi",
383    "fl",
384    nullptr,
385    "endash",
386    "dagger",
387    "daggerdbl",
388    "periodcentered",
389    nullptr,
390    "paragraph",
391    "bullet",
392    "quotesinglbase",
393    "quotedblbase",
394    "quotedblright",
395    "guillemotright",
396    "ellipsis",
397    "perthousand",
398    nullptr,
399    "questiondown",
400    nullptr,
401    "grave",
402    "acute",
403    "circumflex",
404    "tilde",
405    "macron",
406    "breve",
407    "dotaccent",
408    "dieresis",
409    nullptr,
410    "ring",
411    "cedilla",
412    nullptr,
413    "hungarumlaut",
414    "ogonek",
415    "caron",
416    "emdash",
417    nullptr,
418    nullptr,
419    nullptr,
420    nullptr,
421    nullptr,
422    nullptr,
423    nullptr,
424    nullptr,
425    nullptr,
426    nullptr,
427    nullptr,
428    nullptr,
429    nullptr,
430    nullptr,
431    nullptr,
432    nullptr,
433    "AE",
434    nullptr,
435    "ordfeminine",
436    nullptr,
437    nullptr,
438    nullptr,
439    nullptr,
440    "Lslash",
441    "Oslash",
442    "OE",
443    "ordmasculine",
444    nullptr,
445    nullptr,
446    nullptr,
447    nullptr,
448    nullptr,
449    "ae",
450    nullptr,
451    nullptr,
452    nullptr,
453    "dotlessi",
454    nullptr,
455    nullptr,
456    "lslash",
457    "oslash",
458    "oe",
459    "germandbls",
460    nullptr,
461    nullptr,
462    nullptr,
463    nullptr,
464};
465
466const FX_CHAR* const AdobeWinAnsiEncodingNames[224] = {
467    "space",
468    "exclam",
469    "quotedbl",
470    "numbersign",
471    "dollar",
472    "percent",
473    "ampersand",
474    "quotesingle",
475    "parenleft",
476    "parenright",
477    "asterisk",
478    "plus",
479    "comma",
480    "hyphen",
481    "period",
482    "slash",
483    "zero",
484    "one",
485    "two",
486    "three",
487    "four",
488    "five",
489    "six",
490    "seven",
491    "eight",
492    "nine",
493    "colon",
494    "semicolon",
495    "less",
496    "equal",
497    "greater",
498    "question",
499    "at",
500    "A",
501    "B",
502    "C",
503    "D",
504    "E",
505    "F",
506    "G",
507    "H",
508    "I",
509    "J",
510    "K",
511    "L",
512    "M",
513    "N",
514    "O",
515    "P",
516    "Q",
517    "R",
518    "S",
519    "T",
520    "U",
521    "V",
522    "W",
523    "X",
524    "Y",
525    "Z",
526    "bracketleft",
527    "backslash",
528    "bracketright",
529    "asciicircum",
530    "underscore",
531    "grave",
532    "a",
533    "b",
534    "c",
535    "d",
536    "e",
537    "f",
538    "g",
539    "h",
540    "i",
541    "j",
542    "k",
543    "l",
544    "m",
545    "n",
546    "o",
547    "p",
548    "q",
549    "r",
550    "s",
551    "t",
552    "u",
553    "v",
554    "w",
555    "x",
556    "y",
557    "z",
558    "braceleft",
559    "bar",
560    "braceright",
561    "asciitilde",
562    "bullet",
563    "Euro",
564    "bullet",
565    "quotesinglbase",
566    "florin",
567    "quotedblbase",
568    "ellipsis",
569    "dagger",
570    "daggerdbl",
571    "circumflex",
572    "perthousand",
573    "Scaron",
574    "guilsinglleft",
575    "OE",
576    "bullet",
577    "Zcaron",
578    "bullet",
579    "bullet",
580    "quoteleft",
581    "quoteright",
582    "quotedblleft",
583    "quotedblright",
584    "bullet",
585    "endash",
586    "emdash",
587    "tilde",
588    "trademark",
589    "scaron",
590    "guilsinglright",
591    "oe",
592    "bullet",
593    "zcaron",
594    "Ydieresis",
595    "space",
596    "exclamdown",
597    "cent",
598    "sterling",
599    "currency",
600    "yen",
601    "brokenbar",
602    "section",
603    "dieresis",
604    "copyright",
605    "ordfeminine",
606    "guillemotleft",
607    "logicalnot",
608    "hyphen",
609    "registered",
610    "macron",
611    "degree",
612    "plusminus",
613    "twosuperior",
614    "threesuperior",
615    "acute",
616    "mu",
617    "paragraph",
618    "periodcentered",
619    "cedilla",
620    "onesuperior",
621    "ordmasculine",
622    "guillemotright",
623    "onequarter",
624    "onehalf",
625    "threequarters",
626    "questiondown",
627    "Agrave",
628    "Aacute",
629    "Acircumflex",
630    "Atilde",
631    "Adieresis",
632    "Aring",
633    "AE",
634    "Ccedilla",
635    "Egrave",
636    "Eacute",
637    "Ecircumflex",
638    "Edieresis",
639    "Igrave",
640    "Iacute",
641    "Icircumflex",
642    "Idieresis",
643    "Eth",
644    "Ntilde",
645    "Ograve",
646    "Oacute",
647    "Ocircumflex",
648    "Otilde",
649    "Odieresis",
650    "multiply",
651    "Oslash",
652    "Ugrave",
653    "Uacute",
654    "Ucircumflex",
655    "Udieresis",
656    "Yacute",
657    "Thorn",
658    "germandbls",
659    "agrave",
660    "aacute",
661    "acircumflex",
662    "atilde",
663    "adieresis",
664    "aring",
665    "ae",
666    "ccedilla",
667    "egrave",
668    "eacute",
669    "ecircumflex",
670    "edieresis",
671    "igrave",
672    "iacute",
673    "icircumflex",
674    "idieresis",
675    "eth",
676    "ntilde",
677    "ograve",
678    "oacute",
679    "ocircumflex",
680    "otilde",
681    "odieresis",
682    "divide",
683    "oslash",
684    "ugrave",
685    "uacute",
686    "ucircumflex",
687    "udieresis",
688    "yacute",
689    "thorn",
690    "ydieresis",
691};
692
693const FX_CHAR* const MacRomanEncodingNames[224] = {
694    "space",
695    "exclam",
696    "quotedbl",
697    "numbersign",
698    "dollar",
699    "percent",
700    "ampersand",
701    "quotesingle",
702    "parenleft",
703    "parenright",
704    "asterisk",
705    "plus",
706    "comma",
707    "hyphen",
708    "period",
709    "slash",
710    "zero",
711    "one",
712    "two",
713    "three",
714    "four",
715    "five",
716    "six",
717    "seven",
718    "eight",
719    "nine",
720    "colon",
721    "semicolon",
722    "less",
723    "equal",
724    "greater",
725    "question",
726    "at",
727    "A",
728    "B",
729    "C",
730    "D",
731    "E",
732    "F",
733    "G",
734    "H",
735    "I",
736    "J",
737    "K",
738    "L",
739    "M",
740    "N",
741    "O",
742    "P",
743    "Q",
744    "R",
745    "S",
746    "T",
747    "U",
748    "V",
749    "W",
750    "X",
751    "Y",
752    "Z",
753    "bracketleft",
754    "backslash",
755    "bracketright",
756    "asciicircum",
757    "underscore",
758    "grave",
759    "a",
760    "b",
761    "c",
762    "d",
763    "e",
764    "f",
765    "g",
766    "h",
767    "i",
768    "j",
769    "k",
770    "l",
771    "m",
772    "n",
773    "o",
774    "p",
775    "q",
776    "r",
777    "s",
778    "t",
779    "u",
780    "v",
781    "w",
782    "x",
783    "y",
784    "z",
785    "braceleft",
786    "bar",
787    "braceright",
788    "asciitilde",
789    nullptr,
790    "Adieresis",
791    "Aring",
792    "Ccedilla",
793    "Eacute",
794    "Ntilde",
795    "Odieresis",
796    "Udieresis",
797    "aacute",
798    "agrave",
799    "acircumflex",
800    "adieresis",
801    "atilde",
802    "aring",
803    "ccedilla",
804    "eacute",
805    "egrave",
806    "ecircumflex",
807    "edieresis",
808    "iacute",
809    "igrave",
810    "icircumflex",
811    "idieresis",
812    "ntilde",
813    "oacute",
814    "ograve",
815    "ocircumflex",
816    "odieresis",
817    "otilde",
818    "uacute",
819    "ugrave",
820    "ucircumflex",
821    "udieresis",
822    "dagger",
823    "degree",
824    "cent",
825    "sterling",
826    "section",
827    "bullet",
828    "paragraph",
829    "germandbls",
830    "registered",
831    "copyright",
832    "trademark",
833    "acute",
834    "dieresis",
835    "notequal",
836    "AE",
837    "Oslash",
838    "infinity",
839    "plusminus",
840    "lessequal",
841    "greaterequal",
842    "yen",
843    "mu",
844    "partialdiff",
845    "summation",
846    "product",
847    "pi",
848    "integral",
849    "ordfeminine",
850    "ordmasculine",
851    "Omega",
852    "ae",
853    "oslash",
854    "questiondown",
855    "exclamdown",
856    "logicalnot",
857    "radical",
858    "florin",
859    "approxequal",
860    "Delta",
861    "guillemotleft",
862    "guillemotright",
863    "ellipsis",
864    "space",
865    "Agrave",
866    "Atilde",
867    "Otilde",
868    "OE",
869    "oe",
870    "endash",
871    "emdash",
872    "quotedblleft",
873    "quotedblright",
874    "quoteleft",
875    "quoteright",
876    "divide",
877    "lozenge",
878    "ydieresis",
879    "Ydieresis",
880    "fraction",
881    "currency",
882    "guilsinglleft",
883    "guilsinglright",
884    "fi",
885    "fl",
886    "daggerdbl",
887    "periodcentered",
888    "quotesinglbase",
889    "quotedblbase",
890    "perthousand",
891    "Acircumflex",
892    "Ecircumflex",
893    "Aacute",
894    "Edieresis",
895    "Egrave",
896    "Iacute",
897    "Icircumflex",
898    "Idieresis",
899    "Igrave",
900    "Oacute",
901    "Ocircumflex",
902    "apple",
903    "Ograve",
904    "Uacute",
905    "Ucircumflex",
906    "Ugrave",
907    "dotlessi",
908    "circumflex",
909    "tilde",
910    "macron",
911    "breve",
912    "dotaccent",
913    "ring",
914    "cedilla",
915    "hungarumlaut",
916    "ogonek",
917    "caron",
918};
919
920const FX_CHAR* const MacExpertEncodingNames[224] = {
921    "space",
922    "exclamsmall",
923    "Hungarumlautsmall",
924    "centoldstyle",
925    "dollaroldstyle",
926    "dollarsuperior",
927    "ampersandsmall",
928    "Acutesmall",
929    "parenleftsuperior",
930    "parenrightsuperior",
931    "twodotenleader",
932    "onedotenleader",
933    "comma",
934    "hyphen",
935    "period",
936    "fraction",
937    "zerooldstyle",
938    "oneoldstyle",
939    "twooldstyle",
940    "threeoldstyle",
941    "fouroldstyle",
942    "fiveoldstyle",
943    "sixoldstyle",
944    "sevenoldstyle",
945    "eightoldstyle",
946    "nineoldstyle",
947    "colon",
948    "semicolon",
949    nullptr,
950    "threequartersemdash",
951    nullptr,
952    "questionsmall",
953    nullptr,
954    nullptr,
955    nullptr,
956    nullptr,
957    "Ethsmall",
958    nullptr,
959    nullptr,
960    "onequarter",
961    "onehalf",
962    "threequarters",
963    "oneeighth",
964    "threeeighths",
965    "fiveeighths",
966    "seveneighths",
967    "onethird",
968    "twothirds",
969    nullptr,
970    nullptr,
971    nullptr,
972    nullptr,
973    nullptr,
974    nullptr,
975    "ff",
976    "fi",
977    "fl",
978    "ffi",
979    "ffl",
980    "parenleftinferior",
981    nullptr,
982    "parenrightinferior",
983    "Circumflexsmall",
984    "hypheninferior",
985    "Gravesmall",
986    "Asmall",
987    "Bsmall",
988    "Csmall",
989    "Dsmall",
990    "Esmall",
991    "Fsmall",
992    "Gsmall",
993    "Hsmall",
994    "Ismall",
995    "Jsmall",
996    "Ksmall",
997    "Lsmall",
998    "Msmall",
999    "Nsmall",
1000    "Osmall",
1001    "Psmall",
1002    "Qsmall",
1003    "Rsmall",
1004    "Ssmall",
1005    "Tsmall",
1006    "Usmall",
1007    "Vsmall",
1008    "Wsmall",
1009    "Xsmall",
1010    "Ysmall",
1011    "Zsmall",
1012    "colonmonetary",
1013    "onefitted",
1014    "rupiah",
1015    "Tildesmall",
1016    nullptr,
1017    nullptr,
1018    "asuperior",
1019    "centsuperior",
1020    nullptr,
1021    nullptr,
1022    nullptr,
1023    nullptr,
1024    "Aacutesmall",
1025    "Agravesmall",
1026    "Acircumflexsmall",
1027    "Adieresissmall",
1028    "Atildesmall",
1029    "Aringsmall",
1030    "Ccedillasmall",
1031    "Eacutesmall",
1032    "Egravesmall",
1033    "Ecircumflexsmall",
1034    "Edieresissmall",
1035    "Iacutesmall",
1036    "Igravesmall",
1037    "Icircumflexsmall",
1038    "Idieresissmall",
1039    "Ntildesmall",
1040    "Oacutesmall",
1041    "Ogravesmall",
1042    "Ocircumflexsmall",
1043    "Odieresissmall",
1044    "Otildesmall",
1045    "Uacutesmall",
1046    "Ugravesmall",
1047    "Ucircumflexsmall",
1048    "Udieresissmall",
1049    nullptr,
1050    "eightsuperior",
1051    "fourinferior",
1052    "threeinferior",
1053    "sixinferior",
1054    "eightinferior",
1055    "seveninferior",
1056    "Scaronsmall",
1057    nullptr,
1058    "centinferior",
1059    "twoinferior",
1060    nullptr,
1061    "Dieresissmall",
1062    nullptr,
1063    "Caronsmall",
1064    "Scaronsmall",
1065    "fiveinferior",
1066    nullptr,
1067    "commainferior",
1068    "periodinferior",
1069    "Yacutesmall",
1070    nullptr,
1071    "dollarinferior",
1072    nullptr,
1073    nullptr,
1074    "Thornsmall",
1075    nullptr,
1076    "nineinferior",
1077    "zeroinferior",
1078    "Zcaronsmall",
1079    "AEsmall",
1080    "Oslashsmall",
1081    "questiondownsmall",
1082    "oneinferior",
1083    "asuperior",
1084    nullptr,
1085    nullptr,
1086    nullptr,
1087    nullptr,
1088    nullptr,
1089    nullptr,
1090    "Cedillasmall",
1091    nullptr,
1092    nullptr,
1093    nullptr,
1094    nullptr,
1095    nullptr,
1096    "OEsmall",
1097    "figuredash",
1098    "hyphensuperior",
1099    nullptr,
1100    nullptr,
1101    nullptr,
1102    nullptr,
1103    "exclamdownsmall",
1104    nullptr,
1105    "Ydieresissmall",
1106    nullptr,
1107    "onesuperior",
1108    "twosuperior",
1109    "threesuperior",
1110    "foursuperior",
1111    "fivesuperior",
1112    "sixsuperior",
1113    "sevensuperior",
1114    "ninesuperior",
1115    "zerosuperior",
1116    nullptr,
1117    "esuperior",
1118    "rsuperior",
1119    nullptr,
1120    nullptr,
1121    nullptr,
1122    "isuperior",
1123    "ssuperior",
1124    "dsuperior",
1125    nullptr,
1126    nullptr,
1127    nullptr,
1128    nullptr,
1129    nullptr,
1130    "lsuperior",
1131    "Ogoneksmall",
1132    "Brevesmall",
1133    "Macronsmall",
1134    "bsuperior",
1135    "nsuperior",
1136    "msuperior",
1137    "commasuperior",
1138    "periodsuperior",
1139    "Dotaccentsmall",
1140    "Ringsmall",
1141    nullptr,
1142    nullptr,
1143    nullptr,
1144    nullptr,
1145};
1146
1147const FX_CHAR* const PDFDocEncodingNames[232] = {
1148    "breve",
1149    "caron",
1150    "circumflex",
1151    "dotaccent",
1152    "hungarumlaut",
1153    "ogonek",
1154    "ring",
1155    "tilde",
1156    "space",
1157    "exclam",
1158    "quotedbl",
1159    "numbersign",
1160    "dollar",
1161    "percent",
1162    "ampersand",
1163    "quotesingle",
1164    "parenleft",
1165    "parenright",
1166    "asterisk",
1167    "plus",
1168    "comma",
1169    "hyphen",
1170    "period",
1171    "slash",
1172    "zero",
1173    "one",
1174    "two",
1175    "three",
1176    "four",
1177    "five",
1178    "six",
1179    "seven",
1180    "eight",
1181    "nine",
1182    "colon",
1183    "semicolon",
1184    "less",
1185    "equal",
1186    "greater",
1187    "question",
1188    "at",
1189    "A",
1190    "B",
1191    "C",
1192    "D",
1193    "E",
1194    "F",
1195    "G",
1196    "H",
1197    "I",
1198    "J",
1199    "K",
1200    "L",
1201    "M",
1202    "N",
1203    "O",
1204    "P",
1205    "Q",
1206    "R",
1207    "S",
1208    "T",
1209    "U",
1210    "V",
1211    "W",
1212    "X",
1213    "Y",
1214    "Z",
1215    "bracketleft",
1216    "backslash",
1217    "bracketright",
1218    "asciicircum",
1219    "underscore",
1220    "grave",
1221    "a",
1222    "b",
1223    "c",
1224    "d",
1225    "e",
1226    "f",
1227    "g",
1228    "h",
1229    "i",
1230    "j",
1231    "k",
1232    "l",
1233    "m",
1234    "n",
1235    "o",
1236    "p",
1237    "q",
1238    "r",
1239    "s",
1240    "t",
1241    "u",
1242    "v",
1243    "w",
1244    "x",
1245    "y",
1246    "z",
1247    "braceleft",
1248    "bar",
1249    "braceright",
1250    "asciitilde",
1251    nullptr,
1252    "bullet3",
1253    "dagger",
1254    "daggerdbl",
1255    "ellipsis",
1256    "emdash",
1257    "endash",
1258    "florin",
1259    "fraction",
1260    "guilsinglleft",
1261    "guilsinglright",
1262    "minus",
1263    "perthousand",
1264    "quotedblbase",
1265    "quotedblleft",
1266    "quotedblright",
1267    "quoteleft",
1268    "quoteright",
1269    "quotesinglbase",
1270    "trademark",
1271    "fi",
1272    "fl",
1273    "Lslash",
1274    "OE",
1275    "Scaron",
1276    "Ydieresis",
1277    "Zcaron2",
1278    "dotlessi",
1279    "lslash",
1280    "oe",
1281    "scaron",
1282    "zcaron2",
1283    nullptr,
1284    "Euro",
1285    "exclamdown",
1286    "cent",
1287    "sterling",
1288    "currency",
1289    "yen",
1290    "brokenbar",
1291    "section",
1292    "dieresis",
1293    "copyright",
1294    "ordfeminine",
1295    "guillemotleft4",
1296    "logicalnot",
1297    nullptr,
1298    "registered",
1299    "macron",
1300    "degree",
1301    "plusminus",
1302    "twosuperior",
1303    "threesuperior",
1304    "acute",
1305    "mu",
1306    "paragraph",
1307    "periodcentered",
1308    "cedilla",
1309    "onesuperior",
1310    "ordmasculine",
1311    "guillemotright4",
1312    "onequarter",
1313    "onehalf",
1314    "threequarters",
1315    "questiondown",
1316    "Agrave",
1317    "Aacute",
1318    "Acircumflex",
1319    "Atilde",
1320    "Adieresis",
1321    "Aring",
1322    "AE",
1323    "Ccedilla",
1324    "Egrave",
1325    "Eacute",
1326    "Ecircumflex",
1327    "Edieresis",
1328    "Igrave",
1329    "Iacute",
1330    "Icircumflex",
1331    "Idieresis",
1332    "Eth",
1333    "Ntilde",
1334    "Ograve",
1335    "Oacute",
1336    "Ocircumflex",
1337    "Otilde",
1338    "Odieresis",
1339    "multiply",
1340    "Oslash",
1341    "Ugrave",
1342    "Uacute",
1343    "Ucircumflex",
1344    "Udieresis",
1345    "Yacute",
1346    "Thorn",
1347    "germandbls",
1348    "agrave",
1349    "aacute",
1350    "acircumflex",
1351    "atilde",
1352    "adieresis",
1353    "aring",
1354    "ae",
1355    "ccedilla",
1356    "egrave",
1357    "eacute",
1358    "ecircumflex",
1359    "edieresis",
1360    "igrave",
1361    "iacute",
1362    "icircumflex",
1363    "idieresis",
1364    "eth",
1365    "ntilde",
1366    "ograve",
1367    "oacute",
1368    "ocircumflex",
1369    "otilde",
1370    "odieresis",
1371    "divide",
1372    "oslash",
1373    "ugrave",
1374    "uacute",
1375    "ucircumflex",
1376    "udieresis",
1377    "yacute",
1378    "thorn",
1379    "ydieresis",
1380};
1381
1382const FX_CHAR* const AdobeSymbolEncodingNames[224] = {
1383    "space",
1384    "exclam",
1385    "universal",
1386    "numbersign",
1387    "existential",
1388    "percent",
1389    "ampersand",
1390    "suchthat",
1391    "parenleft",
1392    "parenright",
1393    "asteriskmath",
1394    "plus",
1395    "comma",
1396    "minus",
1397    "period",
1398    "slash",
1399    "zero",
1400    "one",
1401    "two",
1402    "three",
1403    "four",
1404    "five",
1405    "six",
1406    "seven",
1407    "eight",
1408    "nine",
1409    "colon",
1410    "semicolon",
1411    "less",
1412    "equal",
1413    "greater",
1414    "question",
1415    "congruent",
1416    "Alpha",
1417    "Beta",
1418    "Chi",
1419    "Delta",
1420    "Epsilon",
1421    "Phi",
1422    "Gamma",
1423    "Eta",
1424    "Iota",
1425    "theta1",
1426    "Kappa",
1427    "Lambda",
1428    "Mu",
1429    "Nu",
1430    "Omicron",
1431    "Pi",
1432    "Theta",
1433    "Rho",
1434    "Sigma",
1435    "Tau",
1436    "Upsilon",
1437    "sigma1",
1438    "Omega",
1439    "Xi",
1440    "Psi",
1441    "Zeta",
1442    "bracketleft",
1443    "therefore",
1444    "bracketright",
1445    "perpendicular",
1446    "underscore",
1447    "radicalex",
1448    "alpha",
1449    "beta",
1450    "chi",
1451    "delta",
1452    "epsilon",
1453    "phi",
1454    "gamma",
1455    "eta",
1456    "iota",
1457    "phi1",
1458    "kappa",
1459    "lambda",
1460    "mu",
1461    "nu",
1462    "omicron",
1463    "pi",
1464    "theta",
1465    "rho",
1466    "sigma",
1467    "tau",
1468    "upsilon",
1469    "omega1",
1470    "omega",
1471    "xi",
1472    "psi",
1473    "zeta",
1474    "braceleft",
1475    "bar",
1476    "braceright",
1477    "similar",
1478    nullptr,
1479    nullptr,
1480    nullptr,
1481    nullptr,
1482    nullptr,
1483    nullptr,
1484    nullptr,
1485    nullptr,
1486    nullptr,
1487    nullptr,
1488    nullptr,
1489    nullptr,
1490    nullptr,
1491    nullptr,
1492    nullptr,
1493    nullptr,
1494    nullptr,
1495    nullptr,
1496    nullptr,
1497    nullptr,
1498    nullptr,
1499    nullptr,
1500    nullptr,
1501    nullptr,
1502    nullptr,
1503    nullptr,
1504    nullptr,
1505    nullptr,
1506    nullptr,
1507    nullptr,
1508    nullptr,
1509    nullptr,
1510    nullptr,
1511    "Euro",
1512    "Upsilon1",
1513    "minute",
1514    "lessequal",
1515    "fraction",
1516    "infinity",
1517    "florin",
1518    "club",
1519    "diamond",
1520    "heart",
1521    "spade",
1522    "arrowboth",
1523    "arrowleft",
1524    "arrowup",
1525    "arrowright",
1526    "arrowdown",
1527    "degree",
1528    "plusminus",
1529    "second",
1530    "greaterequal",
1531    "multiply",
1532    "proportional",
1533    "partialdiff",
1534    "bullet",
1535    "divide",
1536    "notequal",
1537    "equivalence",
1538    "approxequal",
1539    "ellipsis",
1540    "arrowvertex",
1541    "arrowhorizex",
1542    "carriagereturn",
1543    "aleph",
1544    "Ifraktur",
1545    "Rfraktur",
1546    "weierstrass",
1547    "circlemultiply",
1548    "circleplus",
1549    "emptyset",
1550    "intersection",
1551    "union",
1552    "propersuperset",
1553    "reflexsuperset",
1554    "notsubset",
1555    "propersubset",
1556    "reflexsubset",
1557    "element",
1558    "notelement",
1559    "angle",
1560    "gradient",
1561    "registerserif",
1562    "copyrightserif",
1563    "trademarkserif",
1564    "product",
1565    "radical",
1566    "dotmath",
1567    "logicalnot",
1568    "logicaland",
1569    "logicalor",
1570    "arrowdblboth",
1571    "arrowdblleft",
1572    "arrowdblup",
1573    "arrowdblright",
1574    "arrowdbldown",
1575    "lozenge",
1576    "angleleft",
1577    "registersans",
1578    "copyrightsans",
1579    "trademarksans",
1580    "summation",
1581    "parenlefttp",
1582    "parenleftex",
1583    "parenleftbt",
1584    "bracketlefttp",
1585    "bracketleftex",
1586    "bracketleftbt",
1587    "bracelefttp",
1588    "braceleftmid",
1589    "braceleftbt",
1590    "braceex",
1591    nullptr,
1592    "angleright",
1593    "integral",
1594    "integraltp",
1595    "integralex",
1596    "integralbt",
1597    "parenrighttp",
1598    "parenrightex",
1599    "parenrightbt",
1600    "bracketrighttp",
1601    "bracketrightex",
1602    "bracketrightbt",
1603    "bracerighttp",
1604    "bracerightmid",
1605    "bracerightbt",
1606    nullptr,
1607};
1608
1609const FX_CHAR* const ZapfEncodingNames[224] = {
1610    "space", "a1",    "a2",    "a202",  "a3",    "a4",    "a5",    "a119",
1611    "a118",  "a117",  "a11",   "a12",   "a13",   "a14",   "a15",   "a16",
1612    "a105",  "a17",   "a18",   "a19",   "a20",   "a21",   "a22",   "a23",
1613    "a24",   "a25",   "a26",   "a27",   "a28",   "a6",    "a7",    "a8",
1614    "a9",    "a10",   "a29",   "a30",   "a31",   "a32",   "a33",   "a34",
1615    "a35",   "a36",   "a37",   "a38",   "a39",   "a40",   "a41",   "a42",
1616    "a43",   "a44",   "a45",   "a46",   "a47",   "a48",   "a49",   "a50",
1617    "a51",   "a52",   "a53",   "a54",   "a55",   "a56",   "a57",   "a58",
1618    "a59",   "a60",   "a61",   "a62",   "a63",   "a64",   "a65",   "a66",
1619    "a67",   "a68",   "a69",   "a70",   "a71",   "a72",   "a73",   "a74",
1620    "a203",  "a75",   "a204",  "a76",   "a77",   "a78",   "a79",   "a81",
1621    "a82",   "a83",   "a84",   "a97",   "a98",   "a99",   "a100",  nullptr,
1622    "a89",   "a90",   "a93",   "a94",   "a91",   "a92",   "a205",  "a85",
1623    "a206",  "a86",   "a87",   "a88",   "a95",   "a96",   nullptr, nullptr,
1624    nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
1625    nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
1626    nullptr, "a101",  "a102",  "a103",  "a104",  "a106",  "a107",  "a108",
1627    "a112",  "a111",  "a110",  "a109",  "a120",  "a121",  "a122",  "a123",
1628    "a124",  "a125",  "a126",  "a127",  "a128",  "a129",  "a130",  "a131",
1629    "a132",  "a133",  "a134",  "a135",  "a136",  "a137",  "a138",  "a139",
1630    "a140",  "a141",  "a142",  "a143",  "a144",  "a145",  "a146",  "a147",
1631    "a148",  "a149",  "a150",  "a151",  "a152",  "a153",  "a154",  "a155",
1632    "a156",  "a157",  "a158",  "a159",  "a160",  "a161",  "a163",  "a164",
1633    "a196",  "a165",  "a192",  "a166",  "a167",  "a168",  "a169",  "a170",
1634    "a171",  "a172",  "a173",  "a162",  "a174",  "a175",  "a176",  "a177",
1635    "a178",  "a179",  "a193",  "a180",  "a199",  "a181",  "a200",  "a182",
1636    nullptr, "a201",  "a183",  "a184",  "a197",  "a185",  "a194",  "a198",
1637    "a186",  "a195",  "a187",  "a188",  "a189",  "a190",  "a191",  nullptr};
1638
1639uint32_t PDF_FindCode(const uint16_t* pCodes, uint16_t unicode) {
1640  for (uint32_t i = 0; i < 256; i++)
1641    if (pCodes[i] == unicode)
1642      return i;
1643  return 0;
1644}
1645
1646}  // namespace
1647
1648CPDF_FontEncoding::CPDF_FontEncoding() {
1649  FXSYS_memset(m_Unicodes, 0, sizeof(m_Unicodes));
1650}
1651
1652int CPDF_FontEncoding::CharCodeFromUnicode(FX_WCHAR unicode) const {
1653  for (int i = 0; i < 256; i++)
1654    if (m_Unicodes[i] == unicode) {
1655      return i;
1656    }
1657  return -1;
1658}
1659
1660CPDF_FontEncoding::CPDF_FontEncoding(int PredefinedEncoding) {
1661  const uint16_t* pSrc = PDF_UnicodesForPredefinedCharSet(PredefinedEncoding);
1662  if (!pSrc) {
1663    FXSYS_memset(m_Unicodes, 0, sizeof(m_Unicodes));
1664  } else {
1665    for (int i = 0; i < 256; i++)
1666      m_Unicodes[i] = pSrc[i];
1667  }
1668}
1669
1670bool CPDF_FontEncoding::IsIdentical(CPDF_FontEncoding* pAnother) const {
1671  return FXSYS_memcmp(m_Unicodes, pAnother->m_Unicodes, sizeof(m_Unicodes)) ==
1672         0;
1673}
1674
1675std::unique_ptr<CPDF_Object> CPDF_FontEncoding::Realize(
1676    CFX_WeakPtr<CFX_ByteStringPool> pPool) {
1677  int predefined = 0;
1678  for (int cs = PDFFONT_ENCODING_WINANSI; cs < PDFFONT_ENCODING_ZAPFDINGBATS;
1679       cs++) {
1680    const uint16_t* pSrc = PDF_UnicodesForPredefinedCharSet(cs);
1681    bool match = true;
1682    for (int i = 0; i < 256; ++i) {
1683      if (m_Unicodes[i] != pSrc[i]) {
1684        match = false;
1685        break;
1686      }
1687    }
1688    if (match) {
1689      predefined = cs;
1690      break;
1691    }
1692  }
1693  if (predefined) {
1694    if (predefined == PDFFONT_ENCODING_WINANSI)
1695      return pdfium::MakeUnique<CPDF_Name>(pPool, "WinAnsiEncoding");
1696    if (predefined == PDFFONT_ENCODING_MACROMAN)
1697      return pdfium::MakeUnique<CPDF_Name>(pPool, "MacRomanEncoding");
1698    if (predefined == PDFFONT_ENCODING_MACEXPERT)
1699      return pdfium::MakeUnique<CPDF_Name>(pPool, "MacExpertEncoding");
1700
1701    return nullptr;
1702  }
1703  const uint16_t* pStandard =
1704      PDF_UnicodesForPredefinedCharSet(PDFFONT_ENCODING_WINANSI);
1705  auto pDiff = pdfium::MakeUnique<CPDF_Array>();
1706  for (int i = 0; i < 256; i++) {
1707    if (pStandard[i] == m_Unicodes[i])
1708      continue;
1709
1710    pDiff->AddNew<CPDF_Number>(i);
1711    pDiff->AddNew<CPDF_Name>(PDF_AdobeNameFromUnicode(m_Unicodes[i]));
1712  }
1713
1714  auto pDict = pdfium::MakeUnique<CPDF_Dictionary>(pPool);
1715  pDict->SetNewFor<CPDF_Name>("BaseEncoding", "WinAnsiEncoding");
1716  pDict->SetFor("Differences", std::move(pDiff));
1717  return std::move(pDict);
1718}
1719
1720uint32_t FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode) {
1721  switch (encoding) {
1722    case FXFT_ENCODING_UNICODE:
1723      return unicode;
1724    case FXFT_ENCODING_ADOBE_STANDARD:
1725      return PDF_FindCode(StandardEncoding, unicode);
1726    case FXFT_ENCODING_ADOBE_EXPERT:
1727      return PDF_FindCode(MacExpertEncoding, unicode);
1728    case FXFT_ENCODING_ADOBE_LATIN_1:
1729      return PDF_FindCode(AdobeWinAnsiEncoding, unicode);
1730    case FXFT_ENCODING_APPLE_ROMAN:
1731      return PDF_FindCode(MacRomanEncoding, unicode);
1732    case FXFT_ENCODING_ADOBE_CUSTOM:
1733      return PDF_FindCode(PDFDocEncoding, unicode);
1734    case FXFT_ENCODING_MS_SYMBOL:
1735      return PDF_FindCode(MSSymbolEncoding, unicode);
1736  }
1737  return 0;
1738}
1739const uint16_t* PDF_UnicodesForPredefinedCharSet(int encoding) {
1740  switch (encoding) {
1741    case PDFFONT_ENCODING_WINANSI:
1742      return AdobeWinAnsiEncoding;
1743    case PDFFONT_ENCODING_MACROMAN:
1744      return MacRomanEncoding;
1745    case PDFFONT_ENCODING_MACEXPERT:
1746      return MacExpertEncoding;
1747    case PDFFONT_ENCODING_STANDARD:
1748      return StandardEncoding;
1749    case PDFFONT_ENCODING_ADOBE_SYMBOL:
1750      return AdobeSymbolEncoding;
1751    case PDFFONT_ENCODING_ZAPFDINGBATS:
1752      return ZapfEncoding;
1753    case PDFFONT_ENCODING_PDFDOC:
1754      return PDFDocEncoding;
1755    case PDFFONT_ENCODING_MS_SYMBOL:
1756      return MSSymbolEncoding;
1757  }
1758  return nullptr;
1759}
1760
1761FX_WCHAR PDF_UnicodeFromAdobeName(const FX_CHAR* name) {
1762  return (FX_WCHAR)(FXFT_unicode_from_adobe_name(name) & 0x7FFFFFFF);
1763}
1764
1765CFX_ByteString PDF_AdobeNameFromUnicode(FX_WCHAR unicode) {
1766  char glyph_name[64];
1767  FXFT_adobe_name_from_unicode(glyph_name, unicode);
1768  return CFX_ByteString(glyph_name);
1769}
1770
1771const FX_CHAR* PDF_CharNameFromPredefinedCharSet(int encoding,
1772                                                 uint8_t charcode) {
1773  if (encoding == PDFFONT_ENCODING_PDFDOC) {
1774    if (charcode < 24)
1775      return nullptr;
1776
1777    charcode -= 24;
1778  } else {
1779    if (charcode < 32)
1780      return nullptr;
1781
1782    charcode -= 32;
1783  }
1784  switch (encoding) {
1785    case PDFFONT_ENCODING_WINANSI:
1786      return AdobeWinAnsiEncodingNames[charcode];
1787    case PDFFONT_ENCODING_MACROMAN:
1788      return MacRomanEncodingNames[charcode];
1789    case PDFFONT_ENCODING_MACEXPERT:
1790      return MacExpertEncodingNames[charcode];
1791    case PDFFONT_ENCODING_STANDARD:
1792      return StandardEncodingNames[charcode];
1793    case PDFFONT_ENCODING_ADOBE_SYMBOL:
1794      return AdobeSymbolEncodingNames[charcode];
1795    case PDFFONT_ENCODING_ZAPFDINGBATS:
1796      return ZapfEncodingNames[charcode];
1797    case PDFFONT_ENCODING_PDFDOC:
1798      return PDFDocEncodingNames[charcode];
1799  }
1800  return nullptr;
1801}
1802
1803FX_WCHAR FT_UnicodeFromCharCode(int encoding, uint32_t charcode) {
1804  switch (encoding) {
1805    case FXFT_ENCODING_UNICODE:
1806      return (uint16_t)charcode;
1807    case FXFT_ENCODING_ADOBE_STANDARD:
1808      return StandardEncoding[(uint8_t)charcode];
1809    case FXFT_ENCODING_ADOBE_EXPERT:
1810      return MacExpertEncoding[(uint8_t)charcode];
1811    case FXFT_ENCODING_ADOBE_LATIN_1:
1812      return AdobeWinAnsiEncoding[(uint8_t)charcode];
1813    case FXFT_ENCODING_APPLE_ROMAN:
1814      return MacRomanEncoding[(uint8_t)charcode];
1815    case PDFFONT_ENCODING_PDFDOC:
1816      return PDFDocEncoding[(uint8_t)charcode];
1817  }
1818  return 0;
1819}
1820