/src/ghostpdl/devices/vector/whitelst.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright (C) 2001-2023 Artifex Software, Inc. |
2 | | All Rights Reserved. |
3 | | |
4 | | This software is provided AS-IS with no warranty, either express or |
5 | | implied. |
6 | | |
7 | | This software is distributed under license and may not be copied, |
8 | | modified or distributed except as expressly authorized under the terms |
9 | | of the license contained in the file LICENSE in this distribution. |
10 | | |
11 | | Refer to licensing information at http://www.artifex.com or contact |
12 | | Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, |
13 | | CA 94129, USA, for further information. |
14 | | */ |
15 | | |
16 | | |
17 | | /* $Id: whitelst.c 11608 2010-08-06 11:11:40Z ken $ */ |
18 | | /* The following font names are taken from the Adobe webs site |
19 | | (http://www.adobe.com/type/browser/legal/embeddingeula.html) |
20 | | and comprise a list of font names for which permission is granted to embed |
21 | | either for preview and print or fully editable. These names are used to |
22 | | override the embedding flags in TrueType fonts for pdfwrite and ps2write. |
23 | | |
24 | | Its not entirely clear whether the font names should include TM and R |
25 | | characters or not, and the only example font we have contains neither. For |
26 | | the moment the fonts are stored without TM and R characters but this may |
27 | | need to be altered. |
28 | | */ |
29 | | #include "whitelst.h" |
30 | | |
31 | 1.21k | #define WHITE_LIST_SIZE 483 |
32 | | |
33 | | static const char EmbeddingWhiteList[][WHITE_LIST_SIZE] = { |
34 | | "Aachen", |
35 | | "Adobe Arabic", |
36 | | "Adobe Caslon", |
37 | | "Adobe Devanagari", |
38 | | "Adobe Fangsong", |
39 | | "Adobe FanHeiti", |
40 | | "Adobe Garamond", |
41 | | "Adobe Gothic", |
42 | | "Adobe Hebrew", |
43 | | "Adobe Heiti", |
44 | | "Adobe Jenson", |
45 | | "Adobe Kaiti", |
46 | | "Adobe Ming", |
47 | | "Adobe Myungjo", |
48 | | "Adobe Naskh", |
49 | | "Adobe Pi", |
50 | | "Adobe Song", |
51 | | "Adobe Text", |
52 | | "Adobe Thai", |
53 | | "Adobe Wood Type", |
54 | | "Albertus", |
55 | | "Aldus", |
56 | | "Alexa", |
57 | | "Americana", |
58 | | "Amigo", |
59 | | "Andreas", |
60 | | "Antique Olive", |
61 | | "Apollo", |
62 | | "Arcadia", |
63 | | "Arcana", |
64 | | "Ariadne", |
65 | | "Arno", |
66 | | "Arnold B\366cklin", /* Arnold Böcklin */ |
67 | | "Ashley Script", |
68 | | "Astrology Pi", |
69 | | "Audio Pi", |
70 | | "Auriol", |
71 | | "Avenir", |
72 | | "Baker", |
73 | | "Baker Signet", |
74 | | "Balzano", |
75 | | "Banco", |
76 | | "Banshee", |
77 | | "Baskerville Cyrillic", |
78 | | "Bauer Bodoni", |
79 | | "Bell", |
80 | | "Bell Centennial", |
81 | | "Bell Gothic", |
82 | | "Belwe", |
83 | | "Bembo", |
84 | | "Berling", |
85 | | "Bermuda", |
86 | | "Bernhard", |
87 | | "Bernhard Modern", |
88 | | "Bickham Script", |
89 | | "Biffo", |
90 | | "Birch", |
91 | | "Blackoak", |
92 | | "Blue Island", |
93 | | "Bodoni", |
94 | | "Border Pi", |
95 | | "Briem Akademi", |
96 | | "Briem Script", |
97 | | "Brioso", |
98 | | "Bruno", |
99 | | "Brush Script", |
100 | | "Bulmer", |
101 | | "Bundesbahn Pi", |
102 | | "Caflisch Script", |
103 | | "Caflisch Script Web", |
104 | | "Calcite", |
105 | | "Caliban", |
106 | | "Calvert", |
107 | | "Candida", |
108 | | "Cantoria", |
109 | | "Caravan Borders", |
110 | | "Carolina", |
111 | | "Carta", |
112 | | "Cascade Script", |
113 | | "Caslon 3", |
114 | | "Caslon 540", |
115 | | "Caslon Open Face", |
116 | | "Castellar", |
117 | | "Caxton", |
118 | | "Centaur", |
119 | | "Century Expanded", |
120 | | "Century Old Style", |
121 | | "Chaparral", |
122 | | "Charlemagne", |
123 | | "Charme", |
124 | | "Cheq", |
125 | | "Clairvaux", |
126 | | "Clarendon", |
127 | | "Clearface Gothic", |
128 | | "Cloister", |
129 | | "Club Type", |
130 | | "Club Type Mercurius", |
131 | | "Cochin", |
132 | | "Conga Brava", |
133 | | "Conga Brava Stencil", |
134 | | "Conga Brava Std Stencil", |
135 | | "Cooper Black", |
136 | | "Copal", |
137 | | "Copperplate Gothic", |
138 | | "Coriander", |
139 | | "Corona", |
140 | | "Coronet", |
141 | | "Cottonwood", |
142 | | "Courier", |
143 | | "Critter", |
144 | | "Cronos", |
145 | | "Cutout", |
146 | | "Dante", |
147 | | "Decoration Pi", |
148 | | "Delphin", |
149 | | "DIN Schriften", |
150 | | "Diotima", |
151 | | "Diskus", |
152 | | "Dom Casual", |
153 | | "Dorchester Script", |
154 | | "Doric", |
155 | | "Duc de Berry", |
156 | | "Eccentric", |
157 | | "Egyptienne F", |
158 | | "Ehrhardt", |
159 | | "Electra", |
160 | | "Ellington", |
161 | | "Else NPL", |
162 | | "Engravers", |
163 | | "European Pi", |
164 | | "Eurostile", |
165 | | "Ex Ponto", |
166 | | "Excelsior", |
167 | | "Excelsior Cyrillic", |
168 | | "Fairfield", |
169 | | "Falstaff", |
170 | | "Fette Fraktur", |
171 | | "Flood", |
172 | | "Florens", |
173 | | "Flyer", |
174 | | "Folio", |
175 | | "Forte", |
176 | | "Fournier", |
177 | | "Franklin Gothic", |
178 | | "Freestyle Script", |
179 | | "Friz Quadrata", |
180 | | "Frutiger", |
181 | | "Fusaka", |
182 | | "Futura", |
183 | | "Galahad", |
184 | | "Game Pi", |
185 | | "Garamond 3", |
186 | | "Garamond Premier", |
187 | | "Garth Graphic", |
188 | | "Gazette", |
189 | | "Giddyup", |
190 | | "Giddyup Web", |
191 | | "Gill Floriated Capitals", |
192 | | "Gill Sans", |
193 | | "Glypha", |
194 | | "Gothic 13", |
195 | | "Goudy", |
196 | | "Goudy Text", |
197 | | "Granjon", |
198 | | "Graphite", |
199 | | "Guardi", |
200 | | "Hadriano", |
201 | | "Hardwood", |
202 | | "Heisei Kaku Gothic", |
203 | | "Heisei Maru Gothic", |
204 | | "Heisei Mincho", |
205 | | "Helvetica", |
206 | | "Helvetica Cyrillic", |
207 | | "Helvetica Inserat", |
208 | | "Helvetica Inserat Cyrillic", |
209 | | "Helvetica Neue", |
210 | | "Helvetica Rounded", |
211 | | "Herculanum", |
212 | | "Hiroshige", |
213 | | "Hobo", |
214 | | "Holiday Pi", |
215 | | "Horley Old Style", |
216 | | "HY Gothic", |
217 | | "HY GungSo", |
218 | | "HY Kak Headline Std", |
219 | | "HY Rounded Gothic", |
220 | | "Hypatia", |
221 | | "Hypatia Sans", |
222 | | "Immi 505", |
223 | | "Impact", |
224 | | "Impressum", |
225 | | "Industria", |
226 | | "Inflex", |
227 | | "Insignia", |
228 | | "Ironwood", |
229 | | "Isabella", |
230 | | "Italia", |
231 | | "ITC American Typewriter", |
232 | | "ITC Anna", |
233 | | "ITC Avant Garde Gothic", |
234 | | "ITC Bauhaus", |
235 | | "ITC Beesknees", |
236 | | "ITC Benguiat", |
237 | | "ITC Benguiat Gothic", |
238 | | "ITC Berkeley Oldstyle", |
239 | | "ITC Bookman", |
240 | | "ITC Caslon 224", |
241 | | "ITC Century", |
242 | | "ITC Century Handtooled", |
243 | | "ITC Cerigo", |
244 | | "ITC Cheltenham", |
245 | | "ITC Cheltenham Handtooled", |
246 | | "ITC Clearface", |
247 | | "ITC Cushing", |
248 | | "ITC Eras", |
249 | | "ITC Esprit", |
250 | | "ITC Fenice", |
251 | | "ITC Flora", |
252 | | "ITC Franklin Gothic", |
253 | | "ITC Galliard", |
254 | | "ITC Garamond", |
255 | | "ITC Garamond Handtooled", |
256 | | "ITC Giovanni", |
257 | | "ITC Goudy Sans", |
258 | | "ITC Highlander", |
259 | | "ITC Isadora", |
260 | | "ITC Kabel", |
261 | | "ITC Korinna", |
262 | | "ITC Leawood", |
263 | | "ITC Legacy Sans", |
264 | | "ITC Legacy Serif", |
265 | | "ITC Lubalin Graph", |
266 | | "ITC Machine", |
267 | | "ITC Mendoza Roman", |
268 | | "ITC Mona Lisa", |
269 | | "ITC Motter Corpus", |
270 | | "ITC New Baskerville", |
271 | | "ITC Novarese", |
272 | | "ITC Officina Sans", |
273 | | "ITC Officina Serif", |
274 | | "ITC Ozwald", |
275 | | "ITC Quorum", |
276 | | "ITC Serif Gothic", |
277 | | "ITC Slimbach", |
278 | | "ITC Souvenir", |
279 | | "ITC Stone Informal", |
280 | | "ITC Stone Sans", |
281 | | "ITC Stone Serif", |
282 | | "ITC Symbol", |
283 | | "ITC Tiepolo", |
284 | | "ITC Tiffany", |
285 | | "ITC Usherwood", |
286 | | "ITC Veljovic", |
287 | | "ITC Weidemann", |
288 | | "ITC Zapf Chancery", |
289 | | "ITC Zapf Dingbats", |
290 | | "Janson Text", |
291 | | "Jimbo", |
292 | | "Joanna", |
293 | | "Juniper", |
294 | | "Kabel", |
295 | | "Kaufmann", |
296 | | "Kazuraki SP2N", |
297 | | "Kepler", |
298 | | "Khaki", |
299 | | "Kigali", |
300 | | "Kinesis", |
301 | | "Kino", |
302 | | "Klang", |
303 | | "Koch Antiqua", |
304 | | "Kolo", |
305 | | "Kompakt", |
306 | | "Kozuka Gothic", |
307 | | "Kozuka Mincho", |
308 | | "K\374nstler Script", /* Künstler Script */ |
309 | | "Latin", |
310 | | "Leander Script", |
311 | | "Legault", |
312 | | "Letter Gothic", |
313 | | "Life", |
314 | | "LinoLetter", |
315 | | "Linoscript", |
316 | | "Linotext", |
317 | | "Linotype Centennial", |
318 | | "Linotype Didot", |
319 | | "Lithos", |
320 | | "LogoArl", |
321 | | "LogoCut", |
322 | | "LogoLine", |
323 | | "Lucida", |
324 | | "Lucida Math", |
325 | | "Lucida Sans", |
326 | | "Lucida Sans Typewriter", |
327 | | "Lucida Typewriter", |
328 | | "Madrone", |
329 | | "Manito", |
330 | | "Marigold", |
331 | | "Mathematical Pi", |
332 | | "Matura", |
333 | | "Maximus", |
334 | | "Medici Script", |
335 | | "Melior", |
336 | | "Memphis", |
337 | | "Mercurius", |
338 | | "Meridien", |
339 | | "Mesquite", |
340 | | "Mezz", |
341 | | "Mezz Web", |
342 | | "MICR", |
343 | | "Minion", |
344 | | "Minion Cyrillic", |
345 | | "Minion Web", |
346 | | "Minister", |
347 | | "Mistral", |
348 | | "Mojo", |
349 | | "Monoline Script", |
350 | | "Monotype Goudy Modern", |
351 | | "Monotype Grotesque", |
352 | | "Monotype Italian Old Style", |
353 | | "Monotype Modern", |
354 | | "Monotype Old Style", |
355 | | "Monotype Scotch Roman", |
356 | | "Monotype Script", |
357 | | "Montara", |
358 | | "Moonglow", |
359 | | "MVB Bossa Nova", |
360 | | "MVB Celestia Antiqua", |
361 | | "MVB Emmascript", |
362 | | "MVB Greymantle", |
363 | | "MVB Magnesium", |
364 | | "MVB Magnolia", |
365 | | "Myriad", |
366 | | "Myriad Arabic", |
367 | | "Myriad Hebrew", |
368 | | "Myriad Hebrew Cursive", |
369 | | "Myriad Web", |
370 | | "Mythos", |
371 | | "National Codes", |
372 | | "National Codes Pi", |
373 | | "Neue Hammer Unziale", |
374 | | "Neuland", |
375 | | "Neuzeit S", |
376 | | "New Aster", |
377 | | "New Berolina", |
378 | | "New Caledonia", |
379 | | "New Century Schoolbook", |
380 | | "News Gothic", |
381 | | "Notre Dame", |
382 | | "Nueva", |
383 | | "Nuptial Script", |
384 | | "Nyx", |
385 | | "Ocean Sans", |
386 | | "OCR-A", |
387 | | "OCR-B", |
388 | | "Octavian", |
389 | | "Old Claude", |
390 | | "Old Style 7", |
391 | | "Olympian", |
392 | | "Omnia", |
393 | | "Ondine", |
394 | | "Onyx", |
395 | | "Optima", |
396 | | "Orator", |
397 | | "Org\321nica GMM", /* Orgánica GMM */ |
398 | | "Origami", |
399 | | "Ouch!", |
400 | | "Oxford", |
401 | | "Palace Script", |
402 | | "Palatino", |
403 | | "Parisian", |
404 | | "Park Avenue", |
405 | | "Peignot", |
406 | | "Pelican", |
407 | | "Penumbra", |
408 | | "Penumbra Flare", |
409 | | "Penumbra Half Serif", |
410 | | "Penumbra Sans", |
411 | | "Penumbra Serif", |
412 | | "Penumbra Web", |
413 | | "Pepita", |
414 | | "Pepperwood", |
415 | | "Perpetua", |
416 | | "Photina", |
417 | | "Plantin", |
418 | | "PMN Caecilia", |
419 | | "Poetica", |
420 | | "Pompeia", |
421 | | "Pompeijana", |
422 | | "Ponderosa", |
423 | | "Poplar", |
424 | | "Postino", |
425 | | "Present", |
426 | | "Prestige Elite", |
427 | | "Quake", |
428 | | "Rad", |
429 | | "Raleigh", |
430 | | "Raphael", |
431 | | "Reliq", |
432 | | "Reporter", |
433 | | "Revue", |
434 | | "Rockwell", |
435 | | "Romic", |
436 | | "Rosewood", |
437 | | "Rotation", |
438 | | "Rotis Sans Serif", |
439 | | "Rotis Semi Sans", |
440 | | "Rotis Semi Serif", |
441 | | "Rotis Serif", |
442 | | "Ruling Script", |
443 | | "Runic", |
444 | | "Russell Oblique", |
445 | | "Russell Square", |
446 | | "Rusticana", |
447 | | "Ruzicka Freehand", |
448 | | "Ryo Display", |
449 | | "Ryo Display PlusN", |
450 | | "Ryo Gothic", |
451 | | "Ryo Gothic PlusN", |
452 | | "Ryo Text", |
453 | | "Ryo Text PlusN", |
454 | | "Sabon", |
455 | | "San Marco", |
456 | | "Sanvito", |
457 | | "Sassafras", |
458 | | "Sava", |
459 | | "Serifa", |
460 | | "Serlio", |
461 | | "Serpentine", |
462 | | "Shannon", |
463 | | "Shelley", |
464 | | "Sho", |
465 | | "Shuriken Boy", |
466 | | "Silentium", |
467 | | "Simoncini Garamond", |
468 | | "Smaragd", |
469 | | "SMGothic", |
470 | | "SMMyungjo", |
471 | | "Snell Roundhand", |
472 | | "Sonata", |
473 | | "Source Sans", |
474 | | "Spartan", |
475 | | "Spectrum", |
476 | | "Spring", |
477 | | "Spumoni", |
478 | | "Stempel Garamond", |
479 | | "Stempel Schneidler", |
480 | | "Stencil", |
481 | | "Strayhorn", |
482 | | "Strumpf", |
483 | | "Studz", |
484 | | "Symbol", |
485 | | "Syntax", |
486 | | "Tekton", |
487 | | "Tempo", |
488 | | "Times", |
489 | | "Times Europa", |
490 | | "Times New Roman", |
491 | | "Times Ten", |
492 | | "Times Ten Cyrillic", |
493 | | "Toolbox", |
494 | | "Trade Gothic", |
495 | | "Trajan", |
496 | | "Trajan Sans", |
497 | | "Trump Medi\324val", /* Trump Mediäval */ |
498 | | "Umbra", |
499 | | "Univers", |
500 | | "Universal", |
501 | | "University", |
502 | | "Utopia", |
503 | | "VAG Rounded", |
504 | | "Vectora", |
505 | | "Versailles", |
506 | | "Verve", |
507 | | "Visigoth", |
508 | | "Viva", |
509 | | "Voluta Script", |
510 | | "Warning Pi", |
511 | | "Warnock", |
512 | | "Waters Titling", |
513 | | "Weiss", |
514 | | "Wendy", |
515 | | "Wiesbaden Swing", |
516 | | "Wilhelm Klingspor Gotisch", |
517 | | "Wilke", |
518 | | "Willow", |
519 | | "Wittenberger Fraktur", |
520 | | "Zebrawood", |
521 | | "Zipty Do" |
522 | | }; |
523 | | |
524 | | static int whitelist_strncmp(const char *s1, const char *s2, int length) |
525 | 2.30k | { |
526 | 2.30k | int s1_index, s2_index, result = 0; |
527 | | |
528 | 2.30k | s1_index = s2_index = 0; |
529 | | |
530 | 2.94k | while (s2_index < length && s1[s1_index] != 0x00) { |
531 | 1.86k | while (s1[s1_index] == ' ') |
532 | 0 | s1_index++; |
533 | 1.86k | while (s2[s2_index] == ' ' && s2_index < length) |
534 | 0 | s2_index++; |
535 | 1.86k | if (s2_index > length) { |
536 | 0 | if (s1[s1_index] == 0x00) |
537 | 0 | return 0; |
538 | 0 | return 1; |
539 | 0 | } |
540 | 1.86k | if (s1[s1_index] == 0x00) { |
541 | 0 | if (s2_index > length) |
542 | 0 | return 0; |
543 | 0 | return -1; |
544 | 0 | } |
545 | 1.86k | if (s1[s1_index] == s2[s2_index]) { |
546 | 644 | s1_index++; |
547 | 644 | s2_index++; |
548 | 644 | continue; |
549 | 644 | } |
550 | 1.22k | if(s1[s1_index] < s2[s2_index]) |
551 | 432 | return -1; |
552 | 789 | if(s1[s1_index] > s2[s2_index]) |
553 | 789 | return 1; |
554 | 789 | } |
555 | 1.08k | return result; |
556 | 2.30k | } |
557 | | |
558 | | int IsInWhiteList (const char *Name, int size) |
559 | 1.21k | { |
560 | 1.21k | int low = 0, mid, high = WHITE_LIST_SIZE, test; |
561 | | |
562 | 2.30k | while (low < high) { |
563 | | /* bisect current range */ |
564 | 2.16k | mid = (low + high) / 2; |
565 | 2.16k | test = whitelist_strncmp(EmbeddingWhiteList[mid], Name, size); |
566 | 2.16k | if (test == 0) |
567 | 1.08k | return 1; |
568 | | /* Not a match, select either upper or lower group and try again */ |
569 | 1.08k | if(test < 0) |
570 | 357 | low = mid + 1; |
571 | 731 | else |
572 | 731 | high = mid - 1; |
573 | 1.08k | } |
574 | 136 | if (low == high) { |
575 | 133 | if (whitelist_strncmp(EmbeddingWhiteList[low], Name, size) == 0) |
576 | 0 | return 1; |
577 | 133 | } |
578 | 136 | return 0; |
579 | 136 | } |