1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2006 Red Hat, Inc
5 * This library is free software; you can redistribute it and/or
6 * modify it either under the terms of the GNU Lesser General Public
7 * License version 2.1 as published by the Free Software Foundation
8 * (the "LGPL") or, at your option, under the terms of the Mozilla
9 * Public License Version 1.1 (the "MPL"). If you do not alter this
10 * notice, a recipient may use your version of this file under either
11 * the MPL or the LGPL.
13 * You should have received a copy of the LGPL along with this library
14 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
16 * You should have received a copy of the MPL along with this library
17 * in the file COPYING-MPL-1.1
19 * The contents of this file are subject to the Mozilla Public License
20 * Version 1.1 (the "License"); you may not use this file except in
21 * compliance with the License. You may obtain a copy of the License at
22 * http://www.mozilla.org/MPL/
24 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
26 * the specific language governing rights and limitations.
28 * The Original Code is the cairo graphics library.
30 * The Initial Developer of the Original Code is Red Hat, Inc.
33 * Kristian Høgsberg <krh@redhat.com>
38 #if CAIRO_HAS_FONT_SUBSET
40 #include "cairo-type1-private.h"
41 #include "cairo-scaled-font-subsets-private.h"
45 * The three tables that follow are generated using this perl code:
48 @ps_standard_encoding = (
50 NULL, NULL, NULL, NULL,
51 NULL, NULL, NULL, NULL,
52 NULL, NULL, NULL, NULL,
53 NULL, NULL, NULL, NULL,
55 NULL, NULL, NULL, NULL,
56 NULL, NULL, NULL, NULL,
57 NULL, NULL, NULL, NULL,
58 NULL, NULL, NULL, NULL,
60 "space", "exclam", "quotedbl", "numbersign",
61 "dollar", "percent", "ampersand", "quoteright",
62 "parenleft", "parenright", "asterisk", "plus",
63 "comma", "hyphen", "period", "slash",
65 "zero", "one", "two", "three",
66 "four", "five", "six", "seven",
67 "eight", "nine", "colon", "semicolon",
68 "less", "equal", "greater", "question",
77 "X", "Y", "Z", "bracketleft",
78 "backslash", "bracketright", "asciicircum", "underscore",
80 "quoteleft", "a", "b", "c",
87 "x", "y", "z", "braceleft",
88 "bar", "braceright", "asciitilde", NULL,
90 NULL, NULL, NULL, NULL,
91 NULL, NULL, NULL, NULL,
92 NULL, NULL, NULL, NULL,
93 NULL, NULL, NULL, NULL,
95 NULL, NULL, NULL, NULL,
96 NULL, NULL, NULL, NULL,
97 NULL, NULL, NULL, NULL,
98 NULL, NULL, NULL, NULL,
100 NULL, "exclamdown", "cent", "sterling",
101 "fraction", "yen", "florin", "section",
102 "currency", "quotesingle", "quotedblleft", "guillemotleft",
103 "guilsinglleft","guilsinglright","fi", "fl",
105 NULL, "endash", "dagger", "daggerdbl",
106 "periodcentered",NULL, "paragraph", "bullet",
107 "quotesinglbase","quotedblbase","quotedblright","guillemotright",
108 "ellipsis", "perthousand", NULL, "questiondown",
110 NULL, "grave", "acute", "circumflex",
111 "tilde", "macron", "breve", "dotaccent",
112 "dieresis", NULL, "ring", "cedilla",
113 NULL, "hungarumlaut", "ogonek", "caron",
115 "emdash", NULL, NULL, NULL,
116 NULL, NULL, NULL, NULL,
117 NULL, NULL, NULL, NULL,
118 NULL, NULL, NULL, NULL,
120 NULL, "AE", NULL, "ordfeminine",
121 NULL, NULL, NULL, NULL,
122 "Lslash", "Oslash", "OE", "ordmasculine",
123 NULL, NULL, NULL, NULL,
125 NULL, "ae", NULL, NULL,
126 NULL, "dotlessi", NULL, NULL,
127 "lslash", "oslash", "oe", "germandbls",
128 NULL, NULL, NULL, NULL
131 @winansi_encoding = (
133 NULL, NULL, NULL, NULL,
134 NULL, NULL, NULL, NULL,
135 NULL, NULL, NULL, NULL,
136 NULL, NULL, NULL, NULL,
138 NULL, NULL, NULL, NULL,
139 NULL, NULL, NULL, NULL,
140 NULL, NULL, NULL, NULL,
141 NULL, NULL, NULL, NULL,
143 "space", "exclam", "quotedbl", "numbersign",
144 "dollar", "percent", "ampersand", "quotesingle",
145 "parenleft", "parenright", "asterisk", "plus",
146 "comma", "hyphen", "period", "slash",
148 "zero", "one", "two", "three",
149 "four", "five", "six", "seven",
150 "eight", "nine", "colon", "semicolon",
151 "less", "equal", "greater", "question",
160 "X", "Y", "Z", "bracketleft",
161 "backslash", "bracketright", "asciicircum", "underscore",
163 "grave", "a", "b", "c",
170 "x", "y", "z", "braceleft",
171 "bar", "braceright", "asciitilde", NULL,
173 "Euro", NULL, "quotesinglbase","florin",
174 "quotedblbase", "ellipsis", "dagger", "daggerdbl",
175 "circumflex", "perthousand", "Scaron", "guilsinglleft",
176 "OE", NULL, "Zcaron", NULL,
178 NULL, "quoteleft", "quoteright", "quotedblleft",
179 "quotedblright","bullet", "endash", "emdash",
180 "tilde", "trademark", "scaron", "guilsinglright",
181 "oe", NULL, "zcaron", "Ydieresis",
183 NULL, "exclamdown", "cent", "sterling",
184 "currency", "yen", "brokenbar", "section",
185 "dieresis", "copyright", "ordfeminine", "guillemotleft",
186 # 173 is also "hyphen" but we leave this NULL to avoid duplicate names
187 "logicalnot", NULL, "registered", "macron",
189 "degree", "plusminus", "twosuperior", "threesuperior",
190 "acute", "mu", "paragraph", "periodcentered",
191 "cedilla", "onesuperior", "ordmasculine", "guillemotright",
192 "onequarter", "onehalf", "threequarters","questiondown",
194 "Agrave", "Aacute", "Acircumflex", "Atilde",
195 "Adieresis", "Aring", "AE", "Ccedilla",
196 "Egrave", "Eacute", "Ecircumflex", "Edieresis",
197 "Igrave", "Iacute", "Icircumflex", "Idieresis",
199 "Eth", "Ntilde", "Ograve", "Oacute",
200 "Ocircumflex", "Otilde", "Odieresis", "multiply",
201 "Oslash", "Ugrave", "Uacute", "Ucircumflex",
202 "Udieresis", "Yacute", "Thorn", "germandbls",
204 "agrave", "aacute", "acircumflex", "atilde",
205 "adieresis", "aring", "ae", "ccedilla",
206 "egrave", "eacute", "ecircumflex", "edieresis",
207 "igrave", "iacute", "icircumflex", "idieresis",
209 "eth", "ntilde", "ograve", "oacute",
210 "ocircumflex", "otilde", "odieresis", "divide",
211 "oslash", "ugrave", "uacute", "ucircumflex",
212 "udieresis", "yacute", "thorn", "ydieresis"
218 if (! ($sym eq NULL)) {
219 $ss = qq( $hash{$sym}/*$sym*/,);
223 if (length($s) + length($ss) > 78) {
232 @combined = (@ps_standard_encoding, @winansi_encoding);
233 print "static const char glyph_name_symbol[] = {\n";
237 for $sym (@combined) {
238 if (! ($sym eq NULL)) {
239 if (! exists $hash{$sym}) {
240 $hash{$sym} = $offset;
241 $offset += length($sym) + 1;
242 $ss = qq( "$sym\\0");
243 if (length($s) + length($ss) > 78) {
254 print "static const int16_t ps_standard_encoding_offset[256] = {\n";
255 print_offsets(@ps_standard_encoding);
258 print "static const int16_t winansi_encoding_offset[256] = {\n";
259 print_offsets(@winansi_encoding);
265 static const char glyph_name_symbol[] = {
266 "\0" "space\0" "exclam\0" "quotedbl\0" "numbersign\0" "dollar\0" "percent\0"
267 "ampersand\0" "quoteright\0" "parenleft\0" "parenright\0" "asterisk\0"
268 "plus\0" "comma\0" "hyphen\0" "period\0" "slash\0" "zero\0" "one\0" "two\0"
269 "three\0" "four\0" "five\0" "six\0" "seven\0" "eight\0" "nine\0" "colon\0"
270 "semicolon\0" "less\0" "equal\0" "greater\0" "question\0" "at\0" "A\0" "B\0"
271 "C\0" "D\0" "E\0" "F\0" "G\0" "H\0" "I\0" "J\0" "K\0" "L\0" "M\0" "N\0" "O\0"
272 "P\0" "Q\0" "R\0" "S\0" "T\0" "U\0" "V\0" "W\0" "X\0" "Y\0" "Z\0"
273 "bracketleft\0" "backslash\0" "bracketright\0" "asciicircum\0" "underscore\0"
274 "quoteleft\0" "a\0" "b\0" "c\0" "d\0" "e\0" "f\0" "g\0" "h\0" "i\0" "j\0"
275 "k\0" "l\0" "m\0" "n\0" "o\0" "p\0" "q\0" "r\0" "s\0" "t\0" "u\0" "v\0" "w\0"
276 "x\0" "y\0" "z\0" "braceleft\0" "bar\0" "braceright\0" "asciitilde\0"
277 "exclamdown\0" "cent\0" "sterling\0" "fraction\0" "yen\0" "florin\0"
278 "section\0" "currency\0" "quotesingle\0" "quotedblleft\0" "guillemotleft\0"
279 "guilsinglleft\0" "guilsinglright\0" "fi\0" "fl\0" "endash\0" "dagger\0"
280 "daggerdbl\0" "periodcentered\0" "paragraph\0" "bullet\0" "quotesinglbase\0"
281 "quotedblbase\0" "quotedblright\0" "guillemotright\0" "ellipsis\0"
282 "perthousand\0" "questiondown\0" "grave\0" "acute\0" "circumflex\0" "tilde\0"
283 "macron\0" "breve\0" "dotaccent\0" "dieresis\0" "ring\0" "cedilla\0"
284 "hungarumlaut\0" "ogonek\0" "caron\0" "emdash\0" "AE\0" "ordfeminine\0"
285 "Lslash\0" "Oslash\0" "OE\0" "ordmasculine\0" "ae\0" "dotlessi\0" "lslash\0"
286 "oslash\0" "oe\0" "germandbls\0" "Euro\0" "Scaron\0" "Zcaron\0" "trademark\0"
287 "scaron\0" "zcaron\0" "Ydieresis\0" "brokenbar\0" "copyright\0"
288 "logicalnot\0" "registered\0" "degree\0" "plusminus\0" "twosuperior\0"
289 "threesuperior\0" "mu\0" "onesuperior\0" "onequarter\0" "onehalf\0"
290 "threequarters\0" "Agrave\0" "Aacute\0" "Acircumflex\0" "Atilde\0"
291 "Adieresis\0" "Aring\0" "Ccedilla\0" "Egrave\0" "Eacute\0" "Ecircumflex\0"
292 "Edieresis\0" "Igrave\0" "Iacute\0" "Icircumflex\0" "Idieresis\0" "Eth\0"
293 "Ntilde\0" "Ograve\0" "Oacute\0" "Ocircumflex\0" "Otilde\0" "Odieresis\0"
294 "multiply\0" "Ugrave\0" "Uacute\0" "Ucircumflex\0" "Udieresis\0" "Yacute\0"
295 "Thorn\0" "agrave\0" "aacute\0" "acircumflex\0" "atilde\0" "adieresis\0"
296 "aring\0" "ccedilla\0" "egrave\0" "eacute\0" "ecircumflex\0" "edieresis\0"
297 "igrave\0" "iacute\0" "icircumflex\0" "idieresis\0" "eth\0" "ntilde\0"
298 "ograve\0" "oacute\0" "ocircumflex\0" "otilde\0" "odieresis\0" "divide\0"
299 "ugrave\0" "uacute\0" "ucircumflex\0" "udieresis\0" "yacute\0" "thorn\0"
303 static const int16_t ps_standard_encoding_offset[256] = {
304 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
305 0, 0, 0, 0, 0, 0, 1/*space*/, 7/*exclam*/, 14/*quotedbl*/, 23/*numbersign*/,
306 34/*dollar*/, 41/*percent*/, 49/*ampersand*/, 59/*quoteright*/,
307 70/*parenleft*/, 80/*parenright*/, 91/*asterisk*/, 100/*plus*/, 105/*comma*/,
308 111/*hyphen*/, 118/*period*/, 125/*slash*/, 131/*zero*/, 136/*one*/,
309 140/*two*/, 144/*three*/, 150/*four*/, 155/*five*/, 160/*six*/, 164/*seven*/,
310 170/*eight*/, 176/*nine*/, 181/*colon*/, 187/*semicolon*/, 197/*less*/,
311 202/*equal*/, 208/*greater*/, 216/*question*/, 225/*at*/, 228/*A*/, 230/*B*/,
312 232/*C*/, 234/*D*/, 236/*E*/, 238/*F*/, 240/*G*/, 242/*H*/, 244/*I*/,
313 246/*J*/, 248/*K*/, 250/*L*/, 252/*M*/, 254/*N*/, 256/*O*/, 258/*P*/,
314 260/*Q*/, 262/*R*/, 264/*S*/, 266/*T*/, 268/*U*/, 270/*V*/, 272/*W*/,
315 274/*X*/, 276/*Y*/, 278/*Z*/, 280/*bracketleft*/, 292/*backslash*/,
316 302/*bracketright*/, 315/*asciicircum*/, 327/*underscore*/, 338/*quoteleft*/,
317 348/*a*/, 350/*b*/, 352/*c*/, 354/*d*/, 356/*e*/, 358/*f*/, 360/*g*/,
318 362/*h*/, 364/*i*/, 366/*j*/, 368/*k*/, 370/*l*/, 372/*m*/, 374/*n*/,
319 376/*o*/, 378/*p*/, 380/*q*/, 382/*r*/, 384/*s*/, 386/*t*/, 388/*u*/,
320 390/*v*/, 392/*w*/, 394/*x*/, 396/*y*/, 398/*z*/, 400/*braceleft*/,
321 410/*bar*/, 414/*braceright*/, 425/*asciitilde*/, 0, 0, 0, 0, 0, 0, 0, 0, 0,
322 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
323 436/*exclamdown*/, 447/*cent*/, 452/*sterling*/, 461/*fraction*/, 470/*yen*/,
324 474/*florin*/, 481/*section*/, 489/*currency*/, 498/*quotesingle*/,
325 510/*quotedblleft*/, 523/*guillemotleft*/, 537/*guilsinglleft*/,
326 551/*guilsinglright*/, 566/*fi*/, 569/*fl*/, 0, 572/*endash*/, 579/*dagger*/,
327 586/*daggerdbl*/, 596/*periodcentered*/, 0, 611/*paragraph*/, 621/*bullet*/,
328 628/*quotesinglbase*/, 643/*quotedblbase*/, 656/*quotedblright*/,
329 670/*guillemotright*/, 685/*ellipsis*/, 694/*perthousand*/, 0,
330 706/*questiondown*/, 0, 719/*grave*/, 725/*acute*/, 731/*circumflex*/,
331 742/*tilde*/, 748/*macron*/, 755/*breve*/, 761/*dotaccent*/, 771/*dieresis*/,
332 0, 780/*ring*/, 785/*cedilla*/, 0, 793/*hungarumlaut*/, 806/*ogonek*/,
333 813/*caron*/, 819/*emdash*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
334 826/*AE*/, 0, 829/*ordfeminine*/, 0, 0, 0, 0, 841/*Lslash*/, 848/*Oslash*/,
335 855/*OE*/, 858/*ordmasculine*/, 0, 0, 0, 0, 0, 871/*ae*/, 0, 0, 0,
336 874/*dotlessi*/, 0, 0, 883/*lslash*/, 890/*oslash*/, 897/*oe*/,
337 900/*germandbls*/, 0, 0, 0, 0,
340 static const int16_t winansi_encoding_offset[256] = {
341 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
342 0, 0, 0, 0, 0, 0, 1/*space*/, 7/*exclam*/, 14/*quotedbl*/, 23/*numbersign*/,
343 34/*dollar*/, 41/*percent*/, 49/*ampersand*/, 498/*quotesingle*/,
344 70/*parenleft*/, 80/*parenright*/, 91/*asterisk*/, 100/*plus*/, 105/*comma*/,
345 111/*hyphen*/, 118/*period*/, 125/*slash*/, 131/*zero*/, 136/*one*/,
346 140/*two*/, 144/*three*/, 150/*four*/, 155/*five*/, 160/*six*/, 164/*seven*/,
347 170/*eight*/, 176/*nine*/, 181/*colon*/, 187/*semicolon*/, 197/*less*/,
348 202/*equal*/, 208/*greater*/, 216/*question*/, 225/*at*/, 228/*A*/, 230/*B*/,
349 232/*C*/, 234/*D*/, 236/*E*/, 238/*F*/, 240/*G*/, 242/*H*/, 244/*I*/,
350 246/*J*/, 248/*K*/, 250/*L*/, 252/*M*/, 254/*N*/, 256/*O*/, 258/*P*/,
351 260/*Q*/, 262/*R*/, 264/*S*/, 266/*T*/, 268/*U*/, 270/*V*/, 272/*W*/,
352 274/*X*/, 276/*Y*/, 278/*Z*/, 280/*bracketleft*/, 292/*backslash*/,
353 302/*bracketright*/, 315/*asciicircum*/, 327/*underscore*/, 719/*grave*/,
354 348/*a*/, 350/*b*/, 352/*c*/, 354/*d*/, 356/*e*/, 358/*f*/, 360/*g*/,
355 362/*h*/, 364/*i*/, 366/*j*/, 368/*k*/, 370/*l*/, 372/*m*/, 374/*n*/,
356 376/*o*/, 378/*p*/, 380/*q*/, 382/*r*/, 384/*s*/, 386/*t*/, 388/*u*/,
357 390/*v*/, 392/*w*/, 394/*x*/, 396/*y*/, 398/*z*/, 400/*braceleft*/,
358 410/*bar*/, 414/*braceright*/, 425/*asciitilde*/, 0, 911/*Euro*/, 0,
359 628/*quotesinglbase*/, 474/*florin*/, 643/*quotedblbase*/, 685/*ellipsis*/,
360 579/*dagger*/, 586/*daggerdbl*/, 731/*circumflex*/, 694/*perthousand*/,
361 916/*Scaron*/, 537/*guilsinglleft*/, 855/*OE*/, 0, 923/*Zcaron*/, 0, 0,
362 338/*quoteleft*/, 59/*quoteright*/, 510/*quotedblleft*/,
363 656/*quotedblright*/, 621/*bullet*/, 572/*endash*/, 819/*emdash*/,
364 742/*tilde*/, 930/*trademark*/, 940/*scaron*/, 551/*guilsinglright*/,
365 897/*oe*/, 0, 947/*zcaron*/, 954/*Ydieresis*/, 0, 436/*exclamdown*/,
366 447/*cent*/, 452/*sterling*/, 489/*currency*/, 470/*yen*/, 964/*brokenbar*/,
367 481/*section*/, 771/*dieresis*/, 974/*copyright*/, 829/*ordfeminine*/,
368 523/*guillemotleft*/, 984/*logicalnot*/, 0, 995/*registered*/, 748/*macron*/,
369 1006/*degree*/, 1013/*plusminus*/, 1023/*twosuperior*/,
370 1035/*threesuperior*/, 725/*acute*/, 1049/*mu*/, 611/*paragraph*/,
371 596/*periodcentered*/, 785/*cedilla*/, 1052/*onesuperior*/,
372 858/*ordmasculine*/, 670/*guillemotright*/, 1064/*onequarter*/,
373 1075/*onehalf*/, 1083/*threequarters*/, 706/*questiondown*/, 1097/*Agrave*/,
374 1104/*Aacute*/, 1111/*Acircumflex*/, 1123/*Atilde*/, 1130/*Adieresis*/,
375 1140/*Aring*/, 826/*AE*/, 1146/*Ccedilla*/, 1155/*Egrave*/, 1162/*Eacute*/,
376 1169/*Ecircumflex*/, 1181/*Edieresis*/, 1191/*Igrave*/, 1198/*Iacute*/,
377 1205/*Icircumflex*/, 1217/*Idieresis*/, 1227/*Eth*/, 1231/*Ntilde*/,
378 1238/*Ograve*/, 1245/*Oacute*/, 1252/*Ocircumflex*/, 1264/*Otilde*/,
379 1271/*Odieresis*/, 1281/*multiply*/, 848/*Oslash*/, 1290/*Ugrave*/,
380 1297/*Uacute*/, 1304/*Ucircumflex*/, 1316/*Udieresis*/, 1326/*Yacute*/,
381 1333/*Thorn*/, 900/*germandbls*/, 1339/*agrave*/, 1346/*aacute*/,
382 1353/*acircumflex*/, 1365/*atilde*/, 1372/*adieresis*/, 1382/*aring*/,
383 871/*ae*/, 1388/*ccedilla*/, 1397/*egrave*/, 1404/*eacute*/,
384 1411/*ecircumflex*/, 1423/*edieresis*/, 1433/*igrave*/, 1440/*iacute*/,
385 1447/*icircumflex*/, 1459/*idieresis*/, 1469/*eth*/, 1473/*ntilde*/,
386 1480/*ograve*/, 1487/*oacute*/, 1494/*ocircumflex*/, 1506/*otilde*/,
387 1513/*odieresis*/, 1523/*divide*/, 890/*oslash*/, 1530/*ugrave*/,
388 1537/*uacute*/, 1544/*ucircumflex*/, 1556/*udieresis*/, 1566/*yacute*/,
389 1573/*thorn*/, 1579/*ydieresis*/,
393 _cairo_ps_standard_encoding_to_glyphname (int glyph)
395 if (ps_standard_encoding_offset[glyph])
396 return glyph_name_symbol + ps_standard_encoding_offset[glyph];
402 _cairo_winansi_to_glyphname (int glyph)
404 if (winansi_encoding_offset[glyph])
405 return glyph_name_symbol + winansi_encoding_offset[glyph];
410 #endif /* CAIRO_HAS_FONT_SUBSET */