Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
152 / 152
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
StandardEncodingTable
100.00% covered (success)
100.00%
152 / 152
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getTable
100.00% covered (success)
100.00%
152 / 152
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Encoding;
6
7/**
8 * StandardEncoding — the default encoding for Type 1 fonts when no /Encoding is specified.
9 * Per PDF spec ISO 32000-2:2020, Table D.1 / PostScript Language Reference, Appendix E.
10 */
11final class StandardEncodingTable
12{
13    /** @return array<int, string> byte value (0-255) to PostScript glyph name */
14    public static function getTable(): array
15    {
16        $notdef = '.notdef';
17        $table = array_fill(0, 256, $notdef);
18
19        // 32-126: standard printable ASCII (with StandardEncoding-specific differences)
20        $table[32]  = 'space';
21        $table[33]  = 'exclam';
22        $table[34]  = 'quotedbl';
23        $table[35]  = 'numbersign';
24        $table[36]  = 'dollar';
25        $table[37]  = 'percent';
26        $table[38]  = 'ampersand';
27        $table[39]  = 'quoteright';
28        $table[40]  = 'parenleft';
29        $table[41]  = 'parenright';
30        $table[42]  = 'asterisk';
31        $table[43]  = 'plus';
32        $table[44]  = 'comma';
33        $table[45]  = 'hyphen';
34        $table[46]  = 'period';
35        $table[47]  = 'slash';
36        $table[48]  = 'zero';
37        $table[49]  = 'one';
38        $table[50]  = 'two';
39        $table[51]  = 'three';
40        $table[52]  = 'four';
41        $table[53]  = 'five';
42        $table[54]  = 'six';
43        $table[55]  = 'seven';
44        $table[56]  = 'eight';
45        $table[57]  = 'nine';
46        $table[58]  = 'colon';
47        $table[59]  = 'semicolon';
48        $table[60]  = 'less';
49        $table[61]  = 'equal';
50        $table[62]  = 'greater';
51        $table[63]  = 'question';
52        $table[64]  = 'at';
53        $table[65]  = 'A';
54        $table[66]  = 'B';
55        $table[67]  = 'C';
56        $table[68]  = 'D';
57        $table[69]  = 'E';
58        $table[70]  = 'F';
59        $table[71]  = 'G';
60        $table[72]  = 'H';
61        $table[73]  = 'I';
62        $table[74]  = 'J';
63        $table[75]  = 'K';
64        $table[76]  = 'L';
65        $table[77]  = 'M';
66        $table[78]  = 'N';
67        $table[79]  = 'O';
68        $table[80]  = 'P';
69        $table[81]  = 'Q';
70        $table[82]  = 'R';
71        $table[83]  = 'S';
72        $table[84]  = 'T';
73        $table[85]  = 'U';
74        $table[86]  = 'V';
75        $table[87]  = 'W';
76        $table[88]  = 'X';
77        $table[89]  = 'Y';
78        $table[90]  = 'Z';
79        $table[91]  = 'bracketleft';
80        $table[92]  = 'backslash';
81        $table[93]  = 'bracketright';
82        $table[94]  = 'asciicircum';
83        $table[95]  = 'underscore';
84        $table[96]  = 'quoteleft';
85        $table[97]  = 'a';
86        $table[98]  = 'b';
87        $table[99]  = 'c';
88        $table[100] = 'd';
89        $table[101] = 'e';
90        $table[102] = 'f';
91        $table[103] = 'g';
92        $table[104] = 'h';
93        $table[105] = 'i';
94        $table[106] = 'j';
95        $table[107] = 'k';
96        $table[108] = 'l';
97        $table[109] = 'm';
98        $table[110] = 'n';
99        $table[111] = 'o';
100        $table[112] = 'p';
101        $table[113] = 'q';
102        $table[114] = 'r';
103        $table[115] = 's';
104        $table[116] = 't';
105        $table[117] = 'u';
106        $table[118] = 'v';
107        $table[119] = 'w';
108        $table[120] = 'x';
109        $table[121] = 'y';
110        $table[122] = 'z';
111        $table[123] = 'braceleft';
112        $table[124] = 'bar';
113        $table[125] = 'braceright';
114        $table[126] = 'asciitilde';
115
116        // 128-255: StandardEncoding high bytes
117        $table[161] = 'exclamdown';
118        $table[162] = 'cent';
119        $table[163] = 'sterling';
120        $table[164] = 'fraction';
121        $table[165] = 'yen';
122        $table[166] = 'florin';
123        $table[167] = 'section';
124        $table[168] = 'currency';
125        $table[169] = 'quotesingle';
126        $table[170] = 'quotedblleft';
127        $table[171] = 'guillemotleft';
128        $table[172] = 'guilsinglleft';
129        $table[173] = 'guilsinglright';
130        $table[174] = 'fi';
131        $table[175] = 'fl';
132        $table[177] = 'endash';
133        $table[178] = 'dagger';
134        $table[179] = 'daggerdbl';
135        $table[180] = 'periodcentered';
136        $table[182] = 'paragraph';
137        $table[183] = 'bullet';
138        $table[184] = 'quotesinglbase';
139        $table[185] = 'quotedblbase';
140        $table[186] = 'quotedblright';
141        $table[187] = 'guillemotright';
142        $table[188] = 'ellipsis';
143        $table[189] = 'perthousand';
144        $table[191] = 'questiondown';
145        $table[193] = 'grave';
146        $table[194] = 'acute';
147        $table[195] = 'circumflex';
148        $table[196] = 'tilde';
149        $table[197] = 'macron';
150        $table[198] = 'breve';
151        $table[199] = 'dotaccent';
152        $table[200] = 'dieresis';
153        $table[202] = 'ring';
154        $table[203] = 'cedilla';
155        $table[205] = 'hungarumlaut';
156        $table[206] = 'ogonek';
157        $table[207] = 'caron';
158        $table[208] = 'emdash';
159        $table[225] = 'AE';
160        $table[227] = 'ordfeminine';
161        $table[232] = 'Lslash';
162        $table[233] = 'Oslash';
163        $table[234] = 'OE';
164        $table[235] = 'ordmasculine';
165        $table[241] = 'ae';
166        $table[245] = 'dotlessi';
167        $table[248] = 'lslash';
168        $table[249] = 'oslash';
169        $table[250] = 'oe';
170        $table[251] = 'germandbls';
171
172        return $table;
173    }
174}