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 "core/fpdfapi/parser/cpdf_array.h"
10 #include "core/fpdfapi/parser/cpdf_dictionary.h"
11 #include "core/fpdfapi/parser/cpdf_name.h"
12 #include "core/fpdfapi/parser/cpdf_number.h"
13 #include "core/fpdfapi/parser/fpdf_parser_decode.h"
14 #include "core/fxge/fx_font.h"
15 #include "core/fxge/fx_freetype.h"
16 #include "third_party/base/stl_util.h"
17
18 namespace {
19
20 const uint16_t MSSymbolEncoding[CPDF_FontEncoding::kEncodingTableSize] = {
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, 0x0020, 0x0021, 0x2200, 0x0023,
25 0x2203, 0x0025, 0x0026, 0x220b, 0x0028, 0x0029, 0x2217, 0x002b, 0x002c,
26 0x2212, 0x002e, 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035,
27 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e,
28 0x003f, 0x2245, 0x0391, 0x0392, 0x03a7, 0x0394, 0x0395, 0x03a6, 0x0393,
29 0x0397, 0x0399, 0x03d1, 0x039a, 0x039b, 0x039c, 0x039d, 0x039f, 0x03a0,
30 0x0398, 0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03c2, 0x03a9, 0x039e, 0x03a8,
31 0x0396, 0x005b, 0x2234, 0x005d, 0x22a5, 0x005f, 0x203e, 0x03b1, 0x03b2,
32 0x03c7, 0x03b4, 0x03b5, 0x03c6, 0x03b3, 0x03b7, 0x03b9, 0x03d5, 0x03ba,
33 0x03bb, 0x03bc, 0x03bd, 0x03bf, 0x03c0, 0x03b8, 0x03c1, 0x03c3, 0x03c4,
34 0x03c5, 0x03d6, 0x03c9, 0x03be, 0x03c8, 0x03b6, 0x007b, 0x007c, 0x007d,
35 0x223c, 0x0000, 0x0000, 0x0000, 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, 0x03d2,
39 0x2032, 0x2264, 0x2215, 0x221e, 0x0192, 0x2663, 0x2666, 0x2664, 0x2660,
40 0x2194, 0x2190, 0x2191, 0x2192, 0x2193, 0x00b0, 0x00b1, 0x2033, 0x2265,
41 0x00d7, 0x221d, 0x2202, 0x2219, 0x00f7, 0x2260, 0x2261, 0x2248, 0x22ef,
42 0x0000, 0x0000, 0x21b5, 0x0000, 0x2111, 0x211c, 0x2118, 0x2297, 0x2295,
43 0x2205, 0x2229, 0x222a, 0x2283, 0x2287, 0x2284, 0x2282, 0x2286, 0x2208,
44 0x2209, 0x2220, 0x2207, 0x00ae, 0x00a9, 0x2122, 0x220f, 0x221a, 0x22c5,
45 0x00ac, 0x2227, 0x2228, 0x21d4, 0x21d0, 0x21d1, 0x21d2, 0x21d3, 0x25ca,
46 0x2329, 0x0000, 0x0000, 0x0000, 0x2211, 0x0000, 0x0000, 0x0000, 0x0000,
47 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x232a, 0x222b,
48 0x2320, 0x0000, 0x2321, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
49 0x0000, 0x0000, 0x0000, 0x0000};
50
51 const uint16_t StandardEncoding[CPDF_FontEncoding::kEncodingTableSize] = {
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
82 const uint16_t MacRomanEncoding[CPDF_FontEncoding::kEncodingTableSize] = {
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
113 const uint16_t AdobeWinAnsiEncoding[CPDF_FontEncoding::kEncodingTableSize] = {
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
144 const uint16_t MacExpertEncoding[CPDF_FontEncoding::kEncodingTableSize] = {
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
175 const uint16_t AdobeSymbolEncoding[CPDF_FontEncoding::kEncodingTableSize] = {
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
207 const uint16_t ZapfEncoding[CPDF_FontEncoding::kEncodingTableSize] = {
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
239 constexpr size_t kEncodingTableFirstChar = 32;
240 constexpr size_t kEncodingNamesTableSize =
241 CPDF_FontEncoding::kEncodingTableSize - kEncodingTableFirstChar;
242 constexpr size_t kPDFDocEncodingTableFirstChar = 24;
243 constexpr size_t kPDFDocEncodingNamesTableSize =
244 CPDF_FontEncoding::kEncodingTableSize - kPDFDocEncodingTableFirstChar;
245
246 const char* const StandardEncodingNames[kEncodingNamesTableSize] = {
247 "space",
248 "exclam",
249 "quotedbl",
250 "numbersign",
251 "dollar",
252 "percent",
253 "ampersand",
254 "quoteright",
255 "parenleft",
256 "parenright",
257 "asterisk",
258 "plus",
259 "comma",
260 "hyphen",
261 "period",
262 "slash",
263 "zero",
264 "one",
265 "two",
266 "three",
267 "four",
268 "five",
269 "six",
270 "seven",
271 "eight",
272 "nine",
273 "colon",
274 "semicolon",
275 "less",
276 "equal",
277 "greater",
278 "question",
279 "at",
280 "A",
281 "B",
282 "C",
283 "D",
284 "E",
285 "F",
286 "G",
287 "H",
288 "I",
289 "J",
290 "K",
291 "L",
292 "M",
293 "N",
294 "O",
295 "P",
296 "Q",
297 "R",
298 "S",
299 "T",
300 "U",
301 "V",
302 "W",
303 "X",
304 "Y",
305 "Z",
306 "bracketleft",
307 "backslash",
308 "bracketright",
309 "asciicircum",
310 "underscore",
311 "quoteleft",
312 "a",
313 "b",
314 "c",
315 "d",
316 "e",
317 "f",
318 "g",
319 "h",
320 "i",
321 "j",
322 "k",
323 "l",
324 "m",
325 "n",
326 "o",
327 "p",
328 "q",
329 "r",
330 "s",
331 "t",
332 "u",
333 "v",
334 "w",
335 "x",
336 "y",
337 "z",
338 "braceleft",
339 "bar",
340 "braceright",
341 "asciitilde",
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 nullptr,
370 nullptr,
371 nullptr,
372 nullptr,
373 nullptr,
374 nullptr,
375 nullptr,
376 "exclamdown",
377 "cent",
378 "sterling",
379 "fraction",
380 "yen",
381 "florin",
382 "section",
383 "currency",
384 "quotesingle",
385 "quotedblleft",
386 "guillemotleft",
387 "guilsinglleft",
388 "guilsinglright",
389 "fi",
390 "fl",
391 nullptr,
392 "endash",
393 "dagger",
394 "daggerdbl",
395 "periodcentered",
396 nullptr,
397 "paragraph",
398 "bullet",
399 "quotesinglbase",
400 "quotedblbase",
401 "quotedblright",
402 "guillemotright",
403 "ellipsis",
404 "perthousand",
405 nullptr,
406 "questiondown",
407 nullptr,
408 "grave",
409 "acute",
410 "circumflex",
411 "tilde",
412 "macron",
413 "breve",
414 "dotaccent",
415 "dieresis",
416 nullptr,
417 "ring",
418 "cedilla",
419 nullptr,
420 "hungarumlaut",
421 "ogonek",
422 "caron",
423 "emdash",
424 nullptr,
425 nullptr,
426 nullptr,
427 nullptr,
428 nullptr,
429 nullptr,
430 nullptr,
431 nullptr,
432 nullptr,
433 nullptr,
434 nullptr,
435 nullptr,
436 nullptr,
437 nullptr,
438 nullptr,
439 nullptr,
440 "AE",
441 nullptr,
442 "ordfeminine",
443 nullptr,
444 nullptr,
445 nullptr,
446 nullptr,
447 "Lslash",
448 "Oslash",
449 "OE",
450 "ordmasculine",
451 nullptr,
452 nullptr,
453 nullptr,
454 nullptr,
455 nullptr,
456 "ae",
457 nullptr,
458 nullptr,
459 nullptr,
460 "dotlessi",
461 nullptr,
462 nullptr,
463 "lslash",
464 "oslash",
465 "oe",
466 "germandbls",
467 nullptr,
468 nullptr,
469 nullptr,
470 nullptr,
471 };
472
473 const char* const AdobeWinAnsiEncodingNames[kEncodingNamesTableSize] = {
474 "space",
475 "exclam",
476 "quotedbl",
477 "numbersign",
478 "dollar",
479 "percent",
480 "ampersand",
481 "quotesingle",
482 "parenleft",
483 "parenright",
484 "asterisk",
485 "plus",
486 "comma",
487 "hyphen",
488 "period",
489 "slash",
490 "zero",
491 "one",
492 "two",
493 "three",
494 "four",
495 "five",
496 "six",
497 "seven",
498 "eight",
499 "nine",
500 "colon",
501 "semicolon",
502 "less",
503 "equal",
504 "greater",
505 "question",
506 "at",
507 "A",
508 "B",
509 "C",
510 "D",
511 "E",
512 "F",
513 "G",
514 "H",
515 "I",
516 "J",
517 "K",
518 "L",
519 "M",
520 "N",
521 "O",
522 "P",
523 "Q",
524 "R",
525 "S",
526 "T",
527 "U",
528 "V",
529 "W",
530 "X",
531 "Y",
532 "Z",
533 "bracketleft",
534 "backslash",
535 "bracketright",
536 "asciicircum",
537 "underscore",
538 "grave",
539 "a",
540 "b",
541 "c",
542 "d",
543 "e",
544 "f",
545 "g",
546 "h",
547 "i",
548 "j",
549 "k",
550 "l",
551 "m",
552 "n",
553 "o",
554 "p",
555 "q",
556 "r",
557 "s",
558 "t",
559 "u",
560 "v",
561 "w",
562 "x",
563 "y",
564 "z",
565 "braceleft",
566 "bar",
567 "braceright",
568 "asciitilde",
569 "bullet",
570 "Euro",
571 "bullet",
572 "quotesinglbase",
573 "florin",
574 "quotedblbase",
575 "ellipsis",
576 "dagger",
577 "daggerdbl",
578 "circumflex",
579 "perthousand",
580 "Scaron",
581 "guilsinglleft",
582 "OE",
583 "bullet",
584 "Zcaron",
585 "bullet",
586 "bullet",
587 "quoteleft",
588 "quoteright",
589 "quotedblleft",
590 "quotedblright",
591 "bullet",
592 "endash",
593 "emdash",
594 "tilde",
595 "trademark",
596 "scaron",
597 "guilsinglright",
598 "oe",
599 "bullet",
600 "zcaron",
601 "Ydieresis",
602 "space",
603 "exclamdown",
604 "cent",
605 "sterling",
606 "currency",
607 "yen",
608 "brokenbar",
609 "section",
610 "dieresis",
611 "copyright",
612 "ordfeminine",
613 "guillemotleft",
614 "logicalnot",
615 "hyphen",
616 "registered",
617 "macron",
618 "degree",
619 "plusminus",
620 "twosuperior",
621 "threesuperior",
622 "acute",
623 "mu",
624 "paragraph",
625 "periodcentered",
626 "cedilla",
627 "onesuperior",
628 "ordmasculine",
629 "guillemotright",
630 "onequarter",
631 "onehalf",
632 "threequarters",
633 "questiondown",
634 "Agrave",
635 "Aacute",
636 "Acircumflex",
637 "Atilde",
638 "Adieresis",
639 "Aring",
640 "AE",
641 "Ccedilla",
642 "Egrave",
643 "Eacute",
644 "Ecircumflex",
645 "Edieresis",
646 "Igrave",
647 "Iacute",
648 "Icircumflex",
649 "Idieresis",
650 "Eth",
651 "Ntilde",
652 "Ograve",
653 "Oacute",
654 "Ocircumflex",
655 "Otilde",
656 "Odieresis",
657 "multiply",
658 "Oslash",
659 "Ugrave",
660 "Uacute",
661 "Ucircumflex",
662 "Udieresis",
663 "Yacute",
664 "Thorn",
665 "germandbls",
666 "agrave",
667 "aacute",
668 "acircumflex",
669 "atilde",
670 "adieresis",
671 "aring",
672 "ae",
673 "ccedilla",
674 "egrave",
675 "eacute",
676 "ecircumflex",
677 "edieresis",
678 "igrave",
679 "iacute",
680 "icircumflex",
681 "idieresis",
682 "eth",
683 "ntilde",
684 "ograve",
685 "oacute",
686 "ocircumflex",
687 "otilde",
688 "odieresis",
689 "divide",
690 "oslash",
691 "ugrave",
692 "uacute",
693 "ucircumflex",
694 "udieresis",
695 "yacute",
696 "thorn",
697 "ydieresis",
698 };
699
700 const char* const MacRomanEncodingNames[kEncodingNamesTableSize] = {
701 "space",
702 "exclam",
703 "quotedbl",
704 "numbersign",
705 "dollar",
706 "percent",
707 "ampersand",
708 "quotesingle",
709 "parenleft",
710 "parenright",
711 "asterisk",
712 "plus",
713 "comma",
714 "hyphen",
715 "period",
716 "slash",
717 "zero",
718 "one",
719 "two",
720 "three",
721 "four",
722 "five",
723 "six",
724 "seven",
725 "eight",
726 "nine",
727 "colon",
728 "semicolon",
729 "less",
730 "equal",
731 "greater",
732 "question",
733 "at",
734 "A",
735 "B",
736 "C",
737 "D",
738 "E",
739 "F",
740 "G",
741 "H",
742 "I",
743 "J",
744 "K",
745 "L",
746 "M",
747 "N",
748 "O",
749 "P",
750 "Q",
751 "R",
752 "S",
753 "T",
754 "U",
755 "V",
756 "W",
757 "X",
758 "Y",
759 "Z",
760 "bracketleft",
761 "backslash",
762 "bracketright",
763 "asciicircum",
764 "underscore",
765 "grave",
766 "a",
767 "b",
768 "c",
769 "d",
770 "e",
771 "f",
772 "g",
773 "h",
774 "i",
775 "j",
776 "k",
777 "l",
778 "m",
779 "n",
780 "o",
781 "p",
782 "q",
783 "r",
784 "s",
785 "t",
786 "u",
787 "v",
788 "w",
789 "x",
790 "y",
791 "z",
792 "braceleft",
793 "bar",
794 "braceright",
795 "asciitilde",
796 nullptr,
797 "Adieresis",
798 "Aring",
799 "Ccedilla",
800 "Eacute",
801 "Ntilde",
802 "Odieresis",
803 "Udieresis",
804 "aacute",
805 "agrave",
806 "acircumflex",
807 "adieresis",
808 "atilde",
809 "aring",
810 "ccedilla",
811 "eacute",
812 "egrave",
813 "ecircumflex",
814 "edieresis",
815 "iacute",
816 "igrave",
817 "icircumflex",
818 "idieresis",
819 "ntilde",
820 "oacute",
821 "ograve",
822 "ocircumflex",
823 "odieresis",
824 "otilde",
825 "uacute",
826 "ugrave",
827 "ucircumflex",
828 "udieresis",
829 "dagger",
830 "degree",
831 "cent",
832 "sterling",
833 "section",
834 "bullet",
835 "paragraph",
836 "germandbls",
837 "registered",
838 "copyright",
839 "trademark",
840 "acute",
841 "dieresis",
842 "notequal",
843 "AE",
844 "Oslash",
845 "infinity",
846 "plusminus",
847 "lessequal",
848 "greaterequal",
849 "yen",
850 "mu",
851 "partialdiff",
852 "summation",
853 "product",
854 "pi",
855 "integral",
856 "ordfeminine",
857 "ordmasculine",
858 "Omega",
859 "ae",
860 "oslash",
861 "questiondown",
862 "exclamdown",
863 "logicalnot",
864 "radical",
865 "florin",
866 "approxequal",
867 "Delta",
868 "guillemotleft",
869 "guillemotright",
870 "ellipsis",
871 "space",
872 "Agrave",
873 "Atilde",
874 "Otilde",
875 "OE",
876 "oe",
877 "endash",
878 "emdash",
879 "quotedblleft",
880 "quotedblright",
881 "quoteleft",
882 "quoteright",
883 "divide",
884 "lozenge",
885 "ydieresis",
886 "Ydieresis",
887 "fraction",
888 "currency",
889 "guilsinglleft",
890 "guilsinglright",
891 "fi",
892 "fl",
893 "daggerdbl",
894 "periodcentered",
895 "quotesinglbase",
896 "quotedblbase",
897 "perthousand",
898 "Acircumflex",
899 "Ecircumflex",
900 "Aacute",
901 "Edieresis",
902 "Egrave",
903 "Iacute",
904 "Icircumflex",
905 "Idieresis",
906 "Igrave",
907 "Oacute",
908 "Ocircumflex",
909 "apple",
910 "Ograve",
911 "Uacute",
912 "Ucircumflex",
913 "Ugrave",
914 "dotlessi",
915 "circumflex",
916 "tilde",
917 "macron",
918 "breve",
919 "dotaccent",
920 "ring",
921 "cedilla",
922 "hungarumlaut",
923 "ogonek",
924 "caron",
925 };
926
927 const char* const MacExpertEncodingNames[kEncodingNamesTableSize] = {
928 "space",
929 "exclamsmall",
930 "Hungarumlautsmall",
931 "centoldstyle",
932 "dollaroldstyle",
933 "dollarsuperior",
934 "ampersandsmall",
935 "Acutesmall",
936 "parenleftsuperior",
937 "parenrightsuperior",
938 "twodotenleader",
939 "onedotenleader",
940 "comma",
941 "hyphen",
942 "period",
943 "fraction",
944 "zerooldstyle",
945 "oneoldstyle",
946 "twooldstyle",
947 "threeoldstyle",
948 "fouroldstyle",
949 "fiveoldstyle",
950 "sixoldstyle",
951 "sevenoldstyle",
952 "eightoldstyle",
953 "nineoldstyle",
954 "colon",
955 "semicolon",
956 nullptr,
957 "threequartersemdash",
958 nullptr,
959 "questionsmall",
960 nullptr,
961 nullptr,
962 nullptr,
963 nullptr,
964 "Ethsmall",
965 nullptr,
966 nullptr,
967 "onequarter",
968 "onehalf",
969 "threequarters",
970 "oneeighth",
971 "threeeighths",
972 "fiveeighths",
973 "seveneighths",
974 "onethird",
975 "twothirds",
976 nullptr,
977 nullptr,
978 nullptr,
979 nullptr,
980 nullptr,
981 nullptr,
982 "ff",
983 "fi",
984 "fl",
985 "ffi",
986 "ffl",
987 "parenleftinferior",
988 nullptr,
989 "parenrightinferior",
990 "Circumflexsmall",
991 "hypheninferior",
992 "Gravesmall",
993 "Asmall",
994 "Bsmall",
995 "Csmall",
996 "Dsmall",
997 "Esmall",
998 "Fsmall",
999 "Gsmall",
1000 "Hsmall",
1001 "Ismall",
1002 "Jsmall",
1003 "Ksmall",
1004 "Lsmall",
1005 "Msmall",
1006 "Nsmall",
1007 "Osmall",
1008 "Psmall",
1009 "Qsmall",
1010 "Rsmall",
1011 "Ssmall",
1012 "Tsmall",
1013 "Usmall",
1014 "Vsmall",
1015 "Wsmall",
1016 "Xsmall",
1017 "Ysmall",
1018 "Zsmall",
1019 "colonmonetary",
1020 "onefitted",
1021 "rupiah",
1022 "Tildesmall",
1023 nullptr,
1024 nullptr,
1025 "asuperior",
1026 "centsuperior",
1027 nullptr,
1028 nullptr,
1029 nullptr,
1030 nullptr,
1031 "Aacutesmall",
1032 "Agravesmall",
1033 "Acircumflexsmall",
1034 "Adieresissmall",
1035 "Atildesmall",
1036 "Aringsmall",
1037 "Ccedillasmall",
1038 "Eacutesmall",
1039 "Egravesmall",
1040 "Ecircumflexsmall",
1041 "Edieresissmall",
1042 "Iacutesmall",
1043 "Igravesmall",
1044 "Icircumflexsmall",
1045 "Idieresissmall",
1046 "Ntildesmall",
1047 "Oacutesmall",
1048 "Ogravesmall",
1049 "Ocircumflexsmall",
1050 "Odieresissmall",
1051 "Otildesmall",
1052 "Uacutesmall",
1053 "Ugravesmall",
1054 "Ucircumflexsmall",
1055 "Udieresissmall",
1056 nullptr,
1057 "eightsuperior",
1058 "fourinferior",
1059 "threeinferior",
1060 "sixinferior",
1061 "eightinferior",
1062 "seveninferior",
1063 "Scaronsmall",
1064 nullptr,
1065 "centinferior",
1066 "twoinferior",
1067 nullptr,
1068 "Dieresissmall",
1069 nullptr,
1070 "Caronsmall",
1071 "Scaronsmall",
1072 "fiveinferior",
1073 nullptr,
1074 "commainferior",
1075 "periodinferior",
1076 "Yacutesmall",
1077 nullptr,
1078 "dollarinferior",
1079 nullptr,
1080 nullptr,
1081 "Thornsmall",
1082 nullptr,
1083 "nineinferior",
1084 "zeroinferior",
1085 "Zcaronsmall",
1086 "AEsmall",
1087 "Oslashsmall",
1088 "questiondownsmall",
1089 "oneinferior",
1090 "asuperior",
1091 nullptr,
1092 nullptr,
1093 nullptr,
1094 nullptr,
1095 nullptr,
1096 nullptr,
1097 "Cedillasmall",
1098 nullptr,
1099 nullptr,
1100 nullptr,
1101 nullptr,
1102 nullptr,
1103 "OEsmall",
1104 "figuredash",
1105 "hyphensuperior",
1106 nullptr,
1107 nullptr,
1108 nullptr,
1109 nullptr,
1110 "exclamdownsmall",
1111 nullptr,
1112 "Ydieresissmall",
1113 nullptr,
1114 "onesuperior",
1115 "twosuperior",
1116 "threesuperior",
1117 "foursuperior",
1118 "fivesuperior",
1119 "sixsuperior",
1120 "sevensuperior",
1121 "ninesuperior",
1122 "zerosuperior",
1123 nullptr,
1124 "esuperior",
1125 "rsuperior",
1126 nullptr,
1127 nullptr,
1128 nullptr,
1129 "isuperior",
1130 "ssuperior",
1131 "dsuperior",
1132 nullptr,
1133 nullptr,
1134 nullptr,
1135 nullptr,
1136 nullptr,
1137 "lsuperior",
1138 "Ogoneksmall",
1139 "Brevesmall",
1140 "Macronsmall",
1141 "bsuperior",
1142 "nsuperior",
1143 "msuperior",
1144 "commasuperior",
1145 "periodsuperior",
1146 "Dotaccentsmall",
1147 "Ringsmall",
1148 nullptr,
1149 nullptr,
1150 nullptr,
1151 nullptr,
1152 };
1153
1154 const char* const PDFDocEncodingNames[kPDFDocEncodingNamesTableSize] = {
1155 "breve",
1156 "caron",
1157 "circumflex",
1158 "dotaccent",
1159 "hungarumlaut",
1160 "ogonek",
1161 "ring",
1162 "tilde",
1163 "space",
1164 "exclam",
1165 "quotedbl",
1166 "numbersign",
1167 "dollar",
1168 "percent",
1169 "ampersand",
1170 "quotesingle",
1171 "parenleft",
1172 "parenright",
1173 "asterisk",
1174 "plus",
1175 "comma",
1176 "hyphen",
1177 "period",
1178 "slash",
1179 "zero",
1180 "one",
1181 "two",
1182 "three",
1183 "four",
1184 "five",
1185 "six",
1186 "seven",
1187 "eight",
1188 "nine",
1189 "colon",
1190 "semicolon",
1191 "less",
1192 "equal",
1193 "greater",
1194 "question",
1195 "at",
1196 "A",
1197 "B",
1198 "C",
1199 "D",
1200 "E",
1201 "F",
1202 "G",
1203 "H",
1204 "I",
1205 "J",
1206 "K",
1207 "L",
1208 "M",
1209 "N",
1210 "O",
1211 "P",
1212 "Q",
1213 "R",
1214 "S",
1215 "T",
1216 "U",
1217 "V",
1218 "W",
1219 "X",
1220 "Y",
1221 "Z",
1222 "bracketleft",
1223 "backslash",
1224 "bracketright",
1225 "asciicircum",
1226 "underscore",
1227 "grave",
1228 "a",
1229 "b",
1230 "c",
1231 "d",
1232 "e",
1233 "f",
1234 "g",
1235 "h",
1236 "i",
1237 "j",
1238 "k",
1239 "l",
1240 "m",
1241 "n",
1242 "o",
1243 "p",
1244 "q",
1245 "r",
1246 "s",
1247 "t",
1248 "u",
1249 "v",
1250 "w",
1251 "x",
1252 "y",
1253 "z",
1254 "braceleft",
1255 "bar",
1256 "braceright",
1257 "asciitilde",
1258 nullptr,
1259 "bullet3",
1260 "dagger",
1261 "daggerdbl",
1262 "ellipsis",
1263 "emdash",
1264 "endash",
1265 "florin",
1266 "fraction",
1267 "guilsinglleft",
1268 "guilsinglright",
1269 "minus",
1270 "perthousand",
1271 "quotedblbase",
1272 "quotedblleft",
1273 "quotedblright",
1274 "quoteleft",
1275 "quoteright",
1276 "quotesinglbase",
1277 "trademark",
1278 "fi",
1279 "fl",
1280 "Lslash",
1281 "OE",
1282 "Scaron",
1283 "Ydieresis",
1284 "Zcaron2",
1285 "dotlessi",
1286 "lslash",
1287 "oe",
1288 "scaron",
1289 "zcaron2",
1290 nullptr,
1291 "Euro",
1292 "exclamdown",
1293 "cent",
1294 "sterling",
1295 "currency",
1296 "yen",
1297 "brokenbar",
1298 "section",
1299 "dieresis",
1300 "copyright",
1301 "ordfeminine",
1302 "guillemotleft4",
1303 "logicalnot",
1304 nullptr,
1305 "registered",
1306 "macron",
1307 "degree",
1308 "plusminus",
1309 "twosuperior",
1310 "threesuperior",
1311 "acute",
1312 "mu",
1313 "paragraph",
1314 "periodcentered",
1315 "cedilla",
1316 "onesuperior",
1317 "ordmasculine",
1318 "guillemotright4",
1319 "onequarter",
1320 "onehalf",
1321 "threequarters",
1322 "questiondown",
1323 "Agrave",
1324 "Aacute",
1325 "Acircumflex",
1326 "Atilde",
1327 "Adieresis",
1328 "Aring",
1329 "AE",
1330 "Ccedilla",
1331 "Egrave",
1332 "Eacute",
1333 "Ecircumflex",
1334 "Edieresis",
1335 "Igrave",
1336 "Iacute",
1337 "Icircumflex",
1338 "Idieresis",
1339 "Eth",
1340 "Ntilde",
1341 "Ograve",
1342 "Oacute",
1343 "Ocircumflex",
1344 "Otilde",
1345 "Odieresis",
1346 "multiply",
1347 "Oslash",
1348 "Ugrave",
1349 "Uacute",
1350 "Ucircumflex",
1351 "Udieresis",
1352 "Yacute",
1353 "Thorn",
1354 "germandbls",
1355 "agrave",
1356 "aacute",
1357 "acircumflex",
1358 "atilde",
1359 "adieresis",
1360 "aring",
1361 "ae",
1362 "ccedilla",
1363 "egrave",
1364 "eacute",
1365 "ecircumflex",
1366 "edieresis",
1367 "igrave",
1368 "iacute",
1369 "icircumflex",
1370 "idieresis",
1371 "eth",
1372 "ntilde",
1373 "ograve",
1374 "oacute",
1375 "ocircumflex",
1376 "otilde",
1377 "odieresis",
1378 "divide",
1379 "oslash",
1380 "ugrave",
1381 "uacute",
1382 "ucircumflex",
1383 "udieresis",
1384 "yacute",
1385 "thorn",
1386 "ydieresis",
1387 };
1388
1389 const char* const AdobeSymbolEncodingNames[kEncodingNamesTableSize] = {
1390 "space",
1391 "exclam",
1392 "universal",
1393 "numbersign",
1394 "existential",
1395 "percent",
1396 "ampersand",
1397 "suchthat",
1398 "parenleft",
1399 "parenright",
1400 "asteriskmath",
1401 "plus",
1402 "comma",
1403 "minus",
1404 "period",
1405 "slash",
1406 "zero",
1407 "one",
1408 "two",
1409 "three",
1410 "four",
1411 "five",
1412 "six",
1413 "seven",
1414 "eight",
1415 "nine",
1416 "colon",
1417 "semicolon",
1418 "less",
1419 "equal",
1420 "greater",
1421 "question",
1422 "congruent",
1423 "Alpha",
1424 "Beta",
1425 "Chi",
1426 "Delta",
1427 "Epsilon",
1428 "Phi",
1429 "Gamma",
1430 "Eta",
1431 "Iota",
1432 "theta1",
1433 "Kappa",
1434 "Lambda",
1435 "Mu",
1436 "Nu",
1437 "Omicron",
1438 "Pi",
1439 "Theta",
1440 "Rho",
1441 "Sigma",
1442 "Tau",
1443 "Upsilon",
1444 "sigma1",
1445 "Omega",
1446 "Xi",
1447 "Psi",
1448 "Zeta",
1449 "bracketleft",
1450 "therefore",
1451 "bracketright",
1452 "perpendicular",
1453 "underscore",
1454 "radicalex",
1455 "alpha",
1456 "beta",
1457 "chi",
1458 "delta",
1459 "epsilon",
1460 "phi",
1461 "gamma",
1462 "eta",
1463 "iota",
1464 "phi1",
1465 "kappa",
1466 "lambda",
1467 "mu",
1468 "nu",
1469 "omicron",
1470 "pi",
1471 "theta",
1472 "rho",
1473 "sigma",
1474 "tau",
1475 "upsilon",
1476 "omega1",
1477 "omega",
1478 "xi",
1479 "psi",
1480 "zeta",
1481 "braceleft",
1482 "bar",
1483 "braceright",
1484 "similar",
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 nullptr,
1512 nullptr,
1513 nullptr,
1514 nullptr,
1515 nullptr,
1516 nullptr,
1517 nullptr,
1518 "Euro",
1519 "Upsilon1",
1520 "minute",
1521 "lessequal",
1522 "fraction",
1523 "infinity",
1524 "florin",
1525 "club",
1526 "diamond",
1527 "heart",
1528 "spade",
1529 "arrowboth",
1530 "arrowleft",
1531 "arrowup",
1532 "arrowright",
1533 "arrowdown",
1534 "degree",
1535 "plusminus",
1536 "second",
1537 "greaterequal",
1538 "multiply",
1539 "proportional",
1540 "partialdiff",
1541 "bullet",
1542 "divide",
1543 "notequal",
1544 "equivalence",
1545 "approxequal",
1546 "ellipsis",
1547 "arrowvertex",
1548 "arrowhorizex",
1549 "carriagereturn",
1550 "aleph",
1551 "Ifraktur",
1552 "Rfraktur",
1553 "weierstrass",
1554 "circlemultiply",
1555 "circleplus",
1556 "emptyset",
1557 "intersection",
1558 "union",
1559 "propersuperset",
1560 "reflexsuperset",
1561 "notsubset",
1562 "propersubset",
1563 "reflexsubset",
1564 "element",
1565 "notelement",
1566 "angle",
1567 "gradient",
1568 "registerserif",
1569 "copyrightserif",
1570 "trademarkserif",
1571 "product",
1572 "radical",
1573 "dotmath",
1574 "logicalnot",
1575 "logicaland",
1576 "logicalor",
1577 "arrowdblboth",
1578 "arrowdblleft",
1579 "arrowdblup",
1580 "arrowdblright",
1581 "arrowdbldown",
1582 "lozenge",
1583 "angleleft",
1584 "registersans",
1585 "copyrightsans",
1586 "trademarksans",
1587 "summation",
1588 "parenlefttp",
1589 "parenleftex",
1590 "parenleftbt",
1591 "bracketlefttp",
1592 "bracketleftex",
1593 "bracketleftbt",
1594 "bracelefttp",
1595 "braceleftmid",
1596 "braceleftbt",
1597 "braceex",
1598 nullptr,
1599 "angleright",
1600 "integral",
1601 "integraltp",
1602 "integralex",
1603 "integralbt",
1604 "parenrighttp",
1605 "parenrightex",
1606 "parenrightbt",
1607 "bracketrighttp",
1608 "bracketrightex",
1609 "bracketrightbt",
1610 "bracerighttp",
1611 "bracerightmid",
1612 "bracerightbt",
1613 nullptr,
1614 };
1615
1616 const char* const ZapfEncodingNames[kEncodingNamesTableSize] = {
1617 "space", "a1", "a2", "a202", "a3", "a4", "a5", "a119",
1618 "a118", "a117", "a11", "a12", "a13", "a14", "a15", "a16",
1619 "a105", "a17", "a18", "a19", "a20", "a21", "a22", "a23",
1620 "a24", "a25", "a26", "a27", "a28", "a6", "a7", "a8",
1621 "a9", "a10", "a29", "a30", "a31", "a32", "a33", "a34",
1622 "a35", "a36", "a37", "a38", "a39", "a40", "a41", "a42",
1623 "a43", "a44", "a45", "a46", "a47", "a48", "a49", "a50",
1624 "a51", "a52", "a53", "a54", "a55", "a56", "a57", "a58",
1625 "a59", "a60", "a61", "a62", "a63", "a64", "a65", "a66",
1626 "a67", "a68", "a69", "a70", "a71", "a72", "a73", "a74",
1627 "a203", "a75", "a204", "a76", "a77", "a78", "a79", "a81",
1628 "a82", "a83", "a84", "a97", "a98", "a99", "a100", nullptr,
1629 "a89", "a90", "a93", "a94", "a91", "a92", "a205", "a85",
1630 "a206", "a86", "a87", "a88", "a95", "a96", nullptr, nullptr,
1631 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
1632 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
1633 nullptr, "a101", "a102", "a103", "a104", "a106", "a107", "a108",
1634 "a112", "a111", "a110", "a109", "a120", "a121", "a122", "a123",
1635 "a124", "a125", "a126", "a127", "a128", "a129", "a130", "a131",
1636 "a132", "a133", "a134", "a135", "a136", "a137", "a138", "a139",
1637 "a140", "a141", "a142", "a143", "a144", "a145", "a146", "a147",
1638 "a148", "a149", "a150", "a151", "a152", "a153", "a154", "a155",
1639 "a156", "a157", "a158", "a159", "a160", "a161", "a163", "a164",
1640 "a196", "a165", "a192", "a166", "a167", "a168", "a169", "a170",
1641 "a171", "a172", "a173", "a162", "a174", "a175", "a176", "a177",
1642 "a178", "a179", "a193", "a180", "a199", "a181", "a200", "a182",
1643 nullptr, "a201", "a183", "a184", "a197", "a185", "a194", "a198",
1644 "a186", "a195", "a187", "a188", "a189", "a190", "a191", nullptr};
1645
PDF_FindCode(const uint16_t * pCodes,uint16_t unicode)1646 uint32_t PDF_FindCode(const uint16_t* pCodes, uint16_t unicode) {
1647 for (size_t i = 0; i < CPDF_FontEncoding::kEncodingTableSize; i++) {
1648 if (pCodes[i] == unicode)
1649 return i;
1650 }
1651 return 0;
1652 }
1653
1654 } // namespace
1655
CharCodeFromUnicode(wchar_t unicode) const1656 int CPDF_FontEncoding::CharCodeFromUnicode(wchar_t unicode) const {
1657 for (size_t i = 0; i < pdfium::size(m_Unicodes); i++) {
1658 if (m_Unicodes[i] == unicode)
1659 return i;
1660 }
1661 return -1;
1662 }
1663
CPDF_FontEncoding(int PredefinedEncoding)1664 CPDF_FontEncoding::CPDF_FontEncoding(int PredefinedEncoding) {
1665 const uint16_t* pSrc = PDF_UnicodesForPredefinedCharSet(PredefinedEncoding);
1666 if (pSrc) {
1667 for (size_t i = 0; i < pdfium::size(m_Unicodes); i++)
1668 m_Unicodes[i] = pSrc[i];
1669 } else {
1670 memset(m_Unicodes, 0, sizeof(m_Unicodes));
1671 }
1672 }
1673
IsIdentical(const CPDF_FontEncoding * pAnother) const1674 bool CPDF_FontEncoding::IsIdentical(const CPDF_FontEncoding* pAnother) const {
1675 return memcmp(m_Unicodes, pAnother->m_Unicodes, sizeof(m_Unicodes)) == 0;
1676 }
1677
Realize(WeakPtr<ByteStringPool> pPool) const1678 RetainPtr<CPDF_Object> CPDF_FontEncoding::Realize(
1679 WeakPtr<ByteStringPool> pPool) const {
1680 int predefined = 0;
1681 for (int cs = PDFFONT_ENCODING_WINANSI; cs < PDFFONT_ENCODING_ZAPFDINGBATS;
1682 cs++) {
1683 const uint16_t* pSrc = PDF_UnicodesForPredefinedCharSet(cs);
1684 bool match = true;
1685 for (size_t i = 0; i < pdfium::size(m_Unicodes); i++) {
1686 if (m_Unicodes[i] != pSrc[i]) {
1687 match = false;
1688 break;
1689 }
1690 }
1691 if (match) {
1692 predefined = cs;
1693 break;
1694 }
1695 }
1696 if (predefined) {
1697 const char* pName;
1698 if (predefined == PDFFONT_ENCODING_WINANSI)
1699 pName = "WinAnsiEncoding";
1700 else if (predefined == PDFFONT_ENCODING_MACROMAN)
1701 pName = "MacRomanEncoding";
1702 else if (predefined == PDFFONT_ENCODING_MACEXPERT)
1703 pName = "MacExpertEncoding";
1704 else
1705 return nullptr;
1706
1707 return pdfium::MakeRetain<CPDF_Name>(pPool, pName);
1708 }
1709 const uint16_t* pStandard =
1710 PDF_UnicodesForPredefinedCharSet(PDFFONT_ENCODING_WINANSI);
1711 auto pDiff = pdfium::MakeRetain<CPDF_Array>();
1712 for (size_t i = 0; i < pdfium::size(m_Unicodes); i++) {
1713 if (pStandard[i] == m_Unicodes[i])
1714 continue;
1715
1716 pDiff->AppendNew<CPDF_Number>(static_cast<int>(i));
1717 pDiff->AppendNew<CPDF_Name>(PDF_AdobeNameFromUnicode(m_Unicodes[i]));
1718 }
1719
1720 auto pDict = pdfium::MakeRetain<CPDF_Dictionary>(pPool);
1721 pDict->SetNewFor<CPDF_Name>("BaseEncoding", "WinAnsiEncoding");
1722 pDict->SetFor("Differences", pDiff);
1723 return pDict;
1724 }
1725
FT_CharCodeFromUnicode(int encoding,wchar_t unicode)1726 uint32_t FT_CharCodeFromUnicode(int encoding, wchar_t unicode) {
1727 switch (encoding) {
1728 case FT_ENCODING_UNICODE:
1729 return unicode;
1730 case FT_ENCODING_ADOBE_STANDARD:
1731 return PDF_FindCode(StandardEncoding, unicode);
1732 case FT_ENCODING_ADOBE_EXPERT:
1733 return PDF_FindCode(MacExpertEncoding, unicode);
1734 case FT_ENCODING_ADOBE_LATIN_1:
1735 return PDF_FindCode(AdobeWinAnsiEncoding, unicode);
1736 case FT_ENCODING_APPLE_ROMAN:
1737 return PDF_FindCode(MacRomanEncoding, unicode);
1738 case FT_ENCODING_ADOBE_CUSTOM:
1739 return PDF_FindCode(PDFDocEncoding, unicode);
1740 case FT_ENCODING_MS_SYMBOL:
1741 return PDF_FindCode(MSSymbolEncoding, unicode);
1742 }
1743 return 0;
1744 }
PDF_UnicodesForPredefinedCharSet(int encoding)1745 const uint16_t* PDF_UnicodesForPredefinedCharSet(int encoding) {
1746 switch (encoding) {
1747 case PDFFONT_ENCODING_WINANSI:
1748 return AdobeWinAnsiEncoding;
1749 case PDFFONT_ENCODING_MACROMAN:
1750 return MacRomanEncoding;
1751 case PDFFONT_ENCODING_MACEXPERT:
1752 return MacExpertEncoding;
1753 case PDFFONT_ENCODING_STANDARD:
1754 return StandardEncoding;
1755 case PDFFONT_ENCODING_ADOBE_SYMBOL:
1756 return AdobeSymbolEncoding;
1757 case PDFFONT_ENCODING_ZAPFDINGBATS:
1758 return ZapfEncoding;
1759 case PDFFONT_ENCODING_PDFDOC:
1760 return PDFDocEncoding;
1761 case PDFFONT_ENCODING_MS_SYMBOL:
1762 return MSSymbolEncoding;
1763 }
1764 return nullptr;
1765 }
1766
PDF_CharNameFromPredefinedCharSet(int encoding,uint8_t charcode)1767 const char* PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcode) {
1768 if (encoding == PDFFONT_ENCODING_PDFDOC) {
1769 if (charcode < kPDFDocEncodingTableFirstChar)
1770 return nullptr;
1771
1772 charcode -= kPDFDocEncodingTableFirstChar;
1773 } else {
1774 if (charcode < kEncodingTableFirstChar)
1775 return nullptr;
1776
1777 charcode -= kEncodingTableFirstChar;
1778 }
1779 switch (encoding) {
1780 case PDFFONT_ENCODING_WINANSI:
1781 return AdobeWinAnsiEncodingNames[charcode];
1782 case PDFFONT_ENCODING_MACROMAN:
1783 return MacRomanEncodingNames[charcode];
1784 case PDFFONT_ENCODING_MACEXPERT:
1785 return MacExpertEncodingNames[charcode];
1786 case PDFFONT_ENCODING_STANDARD:
1787 return StandardEncodingNames[charcode];
1788 case PDFFONT_ENCODING_ADOBE_SYMBOL:
1789 return AdobeSymbolEncodingNames[charcode];
1790 case PDFFONT_ENCODING_ZAPFDINGBATS:
1791 return ZapfEncodingNames[charcode];
1792 case PDFFONT_ENCODING_PDFDOC:
1793 return PDFDocEncodingNames[charcode];
1794 }
1795 return nullptr;
1796 }
1797
FT_UnicodeFromCharCode(int encoding,uint32_t charcode)1798 wchar_t FT_UnicodeFromCharCode(int encoding, uint32_t charcode) {
1799 switch (encoding) {
1800 case FT_ENCODING_UNICODE:
1801 return (uint16_t)charcode;
1802 case FT_ENCODING_ADOBE_STANDARD:
1803 return StandardEncoding[(uint8_t)charcode];
1804 case FT_ENCODING_ADOBE_EXPERT:
1805 return MacExpertEncoding[(uint8_t)charcode];
1806 case FT_ENCODING_ADOBE_LATIN_1:
1807 return AdobeWinAnsiEncoding[(uint8_t)charcode];
1808 case FT_ENCODING_APPLE_ROMAN:
1809 return MacRomanEncoding[(uint8_t)charcode];
1810 case PDFFONT_ENCODING_PDFDOC:
1811 return PDFDocEncoding[(uint8_t)charcode];
1812 }
1813 return 0;
1814 }
1815