]> git.wh0rd.org - fontconfig.git/blob - src/fcfreetype.c
Add instructions for doing a release
[fontconfig.git] / src / fcfreetype.c
1 /*
2 * $RCSId: xc/lib/fontconfig/src/fcfreetype.c,v 1.11 2002/08/31 22:17:32 keithp Exp $
3 *
4 * Copyright © 2001 Keith Packard
5 *
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of Keith Packard not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. Keith Packard makes no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
15 *
16 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
23 */
24
25 /*
26 Copyright © 2002-2003 by Juliusz Chroboczek
27
28 Permission is hereby granted, free of charge, to any person obtaining a copy
29 of this software and associated documentation files (the "Software"), to deal
30 in the Software without restriction, including without limitation the rights
31 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
32 copies of the Software, and to permit persons to whom the Software is
33 furnished to do so, subject to the following conditions:
34
35 The above copyright notice and this permission notice shall be included in
36 all copies or substantial portions of the Software.
37
38 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
41 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
42 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
44 THE SOFTWARE.
45 */
46
47 #include <stdlib.h>
48 #include <stdio.h>
49 #include <string.h>
50 #include "fcint.h"
51 #include <ft2build.h>
52 #include FT_FREETYPE_H
53 #include FT_INTERNAL_OBJECTS_H
54 #include FT_TRUETYPE_TABLES_H
55 #include FT_SFNT_NAMES_H
56 #include FT_TRUETYPE_IDS_H
57 #include FT_TYPE1_TABLES_H
58
59 #if HAVE_FT_GET_BDF_PROPERTY
60 #include FT_BDF_H
61 #include FT_MODULE_H
62 #define HAS_BDF_PROPERTY(f) ((f) && (f)->driver && \
63 (f)->driver->root.clazz->get_interface)
64 #define MY_Get_BDF_Property(f,n,p) (HAS_BDF_PROPERTY(f) ? \
65 FT_Get_BDF_Property(f,n,p) : \
66 FT_Err_Invalid_Argument)
67 #endif
68
69 #if !HAVE_FT_GET_BDF_PROPERTY
70 #warning "No FT_Get_BDF_Property"
71 #endif
72
73 #if !HAVE_FT_GET_PS_FONT_INFO
74 #warning "No FT_Get_Font_Info"
75 #endif
76
77 /*
78 * Keep Han languages separated by eliminating languages
79 * that the codePageRange bits says aren't supported
80 */
81
82 static const struct {
83 int bit;
84 const FcChar8 *lang;
85 } FcCodePageRange[] = {
86 { 17, (const FcChar8 *) "ja" },
87 { 18, (const FcChar8 *) "zh-cn" },
88 { 19, (const FcChar8 *) "ko" },
89 { 20, (const FcChar8 *) "zh-tw" },
90 };
91
92 #define NUM_CODE_PAGE_RANGE (sizeof FcCodePageRange / sizeof FcCodePageRange[0])
93
94 FcBool
95 FcFreeTypeIsExclusiveLang (const FcChar8 *lang)
96 {
97 int i;
98
99 for (i = 0; i < NUM_CODE_PAGE_RANGE; i++)
100 {
101 if (FcLangCompare (lang, FcCodePageRange[i].lang) != FcLangDifferentLang)
102 return FcTrue;
103 }
104 return FcFalse;
105 }
106
107 #define FC_NAME_PRIO_LANG 0x0f00
108 #define FC_NAME_PRIO_LANG_ENGLISH 0x0200
109 #define FC_NAME_PRIO_LANG_LATIN 0x0100
110 #define FC_NAME_PRIO_LANG_NONE 0x0000
111
112 #define FC_NAME_PRIO_ENC 0x00f0
113 #define FC_NAME_PRIO_ENC_UNICODE 0x0010
114 #define FC_NAME_PRIO_ENC_NONE 0x0000
115
116 #define FC_NAME_PRIO_NAME 0x000f
117 #define FC_NAME_PRIO_NAME_FAMILY 0x0002
118 #define FC_NAME_PRIO_NAME_PS 0x0001
119 #define FC_NAME_PRIO_NAME_NONE 0x0000
120
121 static FcBool
122 FcUcs4IsLatin (FcChar32 ucs4)
123 {
124 FcChar32 page = ucs4 >> 8;
125
126 if (page <= 2)
127 return FcTrue;
128 if (page == 0x1e)
129 return FcTrue;
130 if (0x20 <= page && page <= 0x23)
131 return FcTrue;
132 if (page == 0xfb)
133 return FcTrue;
134 /* halfwidth forms, don't include kana or white parens */
135 if (0xff01 <= ucs4 && ucs4 <= 0xff5e)
136 return FcTrue;
137 return FcFalse;
138 }
139
140 static FcBool
141 FcUtf8IsLatin (FcChar8 *str, int len)
142 {
143 while (len)
144 {
145 FcChar32 ucs4;
146 int clen = FcUtf8ToUcs4 (str, &ucs4, len);
147 if (clen <= 0)
148 return FcFalse;
149 if (!FcUcs4IsLatin (ucs4))
150 return FcFalse;
151 len -= clen;
152 str += clen;
153 }
154 return FcTrue;
155 }
156
157 /* Order is significant. For example, some B&H fonts are hinted by
158 URW++, and both strings appear in the notice. */
159
160 static const struct {
161 const FT_String *notice;
162 const FcChar8 *foundry;
163 } FcNoticeFoundries[] = {
164 { (const FT_String *) "Bigelow", (const FcChar8 *) "b&h" },
165 { (const FT_String *) "Adobe", (const FcChar8 *) "adobe" },
166 { (const FT_String *) "Bitstream", (const FcChar8 *) "bitstream" },
167 { (const FT_String *) "Monotype", (const FcChar8 *) "monotype" },
168 { (const FT_String *) "Linotype", (const FcChar8 *) "linotype" },
169 { (const FT_String *) "LINOTYPE-HELL",
170 (const FcChar8 *) "linotype" },
171 { (const FT_String *) "IBM", (const FcChar8 *) "ibm" },
172 { (const FT_String *) "URW", (const FcChar8 *) "urw" },
173 { (const FT_String *) "International Typeface Corporation",
174 (const FcChar8 *) "itc" },
175 { (const FT_String *) "Tiro Typeworks",
176 (const FcChar8 *) "tiro" },
177 { (const FT_String *) "XFree86", (const FcChar8 *) "xfree86" },
178 { (const FT_String *) "Microsoft", (const FcChar8 *) "microsoft" },
179 { (const FT_String *) "Omega", (const FcChar8 *) "omega" },
180 { (const FT_String *) "Font21", (const FcChar8 *) "hwan" },
181 { (const FT_String *) "HanYang System",
182 (const FcChar8 *) "hanyang" }
183 };
184
185 #define NUM_NOTICE_FOUNDRIES (sizeof (FcNoticeFoundries) / sizeof (FcNoticeFoundries[0]))
186
187 static const FcChar8 *
188 FcNoticeFoundry(const FT_String *notice)
189 {
190 int i;
191
192 if (notice)
193 for(i = 0; i < NUM_NOTICE_FOUNDRIES; i++)
194 if (strstr ((const char *) notice, (const char *) FcNoticeFoundries[i].notice))
195 return FcNoticeFoundries[i].foundry;
196 return 0;
197 }
198
199 static FcBool
200 FcVendorMatch(const FT_Char vendor[4], const FT_Char *vendor_string)
201 {
202 /* vendor is not necessarily NUL-terminated. */
203 int i, len;
204
205 len = strlen(vendor_string);
206 if (memcmp(vendor, vendor_string, len) != 0)
207 return FcFalse;
208 for (i = len; i < 4; i++)
209 if (vendor[i] != ' ' && vendor[i] != '\0')
210 return FcFalse;
211 return FcTrue;
212 }
213
214 /* This table is partly taken from ttmkfdir by Joerg Pommnitz. */
215
216 /* It should not contain useless entries (such as UNKN) nor duplicate
217 entries for padding both with spaces and NULs. */
218
219 static const struct {
220 const FT_Char *vendor;
221 const FcChar8 *foundry;
222 } FcVendorFoundries[] = {
223 { (const FT_Char *) "ADBE", (const FcChar8 *) "adobe"},
224 { (const FT_Char *) "AGFA", (const FcChar8 *) "agfa"},
225 { (const FT_Char *) "ALTS", (const FcChar8 *) "altsys"},
226 { (const FT_Char *) "APPL", (const FcChar8 *) "apple"},
227 { (const FT_Char *) "ARPH", (const FcChar8 *) "arphic"},
228 { (const FT_Char *) "ATEC", (const FcChar8 *) "alltype"},
229 { (const FT_Char *) "B&H", (const FcChar8 *) "b&h"},
230 { (const FT_Char *) "BITS", (const FcChar8 *) "bitstream"},
231 { (const FT_Char *) "CANO", (const FcChar8 *) "cannon"},
232 { (const FT_Char *) "DYNA", (const FcChar8 *) "dynalab"},
233 { (const FT_Char *) "EPSN", (const FcChar8 *) "epson"},
234 { (const FT_Char *) "FJ", (const FcChar8 *) "fujitsu"},
235 { (const FT_Char *) "IBM", (const FcChar8 *) "ibm"},
236 { (const FT_Char *) "ITC", (const FcChar8 *) "itc"},
237 { (const FT_Char *) "IMPR", (const FcChar8 *) "impress"},
238 { (const FT_Char *) "LARA", (const FcChar8 *) "larabiefonts"},
239 { (const FT_Char *) "LEAF", (const FcChar8 *) "interleaf"},
240 { (const FT_Char *) "LETR", (const FcChar8 *) "letraset"},
241 { (const FT_Char *) "LINO", (const FcChar8 *) "linotype"},
242 { (const FT_Char *) "MACR", (const FcChar8 *) "macromedia"},
243 { (const FT_Char *) "MONO", (const FcChar8 *) "monotype"},
244 { (const FT_Char *) "MS", (const FcChar8 *) "microsoft"},
245 { (const FT_Char *) "MT", (const FcChar8 *) "monotype"},
246 { (const FT_Char *) "NEC", (const FcChar8 *) "nec"},
247 { (const FT_Char *) "PARA", (const FcChar8 *) "paratype"},
248 { (const FT_Char *) "QMSI", (const FcChar8 *) "qms"},
249 { (const FT_Char *) "RICO", (const FcChar8 *) "ricoh"},
250 { (const FT_Char *) "URW", (const FcChar8 *) "urw"},
251 { (const FT_Char *) "Y&Y", (const FcChar8 *) "y&y"}
252 };
253
254 #define NUM_VENDOR_FOUNDRIES (sizeof (FcVendorFoundries) / sizeof (FcVendorFoundries[0]))
255
256 static const FcChar8 *
257 FcVendorFoundry(const FT_Char vendor[4])
258 {
259 int i;
260
261 if (vendor)
262 for(i = 0; i < NUM_VENDOR_FOUNDRIES; i++)
263 if (FcVendorMatch (vendor, FcVendorFoundries[i].vendor))
264 return FcVendorFoundries[i].foundry;
265 return 0;
266 }
267
268 typedef struct _FcStringConst {
269 const FcChar8 *name;
270 int value;
271 } FcStringConst;
272
273 static int
274 FcStringIsConst (const FcChar8 *string,
275 const FcStringConst *c,
276 int nc)
277 {
278 int i;
279
280 for (i = 0; i < nc; i++)
281 if (FcStrCmpIgnoreBlanksAndCase (string, c[i].name) == 0)
282 return c[i].value;
283 return -1;
284 }
285
286 static int
287 FcStringContainsConst (const FcChar8 *string,
288 const FcStringConst *c,
289 int nc)
290 {
291 int i;
292
293 for (i = 0; i < nc; i++)
294 if (FcStrContainsIgnoreBlanksAndCase (string, c[i].name))
295 return c[i].value;
296 return -1;
297 }
298
299 static const FcStringConst weightConsts[] = {
300 { "thin", FC_WEIGHT_THIN },
301 { "extralight", FC_WEIGHT_EXTRALIGHT },
302 { "ultralight", FC_WEIGHT_ULTRALIGHT },
303 { "light", FC_WEIGHT_LIGHT },
304 { "book", FC_WEIGHT_BOOK },
305 { "regular", FC_WEIGHT_REGULAR },
306 { "normal", FC_WEIGHT_NORMAL },
307 { "medium", FC_WEIGHT_MEDIUM },
308 { "demibold", FC_WEIGHT_DEMIBOLD },
309 { "demi", FC_WEIGHT_DEMIBOLD },
310 { "semibold", FC_WEIGHT_SEMIBOLD },
311 { "bold", FC_WEIGHT_BOLD },
312 { "extrabold", FC_WEIGHT_EXTRABOLD },
313 { "ultrabold", FC_WEIGHT_ULTRABOLD },
314 { "black", FC_WEIGHT_BLACK },
315 { "heavy", FC_WEIGHT_HEAVY },
316 };
317
318 #define NUM_WEIGHT_CONSTS (sizeof (weightConsts) / sizeof (weightConsts[0]))
319
320 #define FcIsWeight(s) FcStringIsConst(s,weightConsts,NUM_WEIGHT_CONSTS)
321 #define FcContainsWeight(s) FcStringContainsConst (s,weightConsts,NUM_WEIGHT_CONSTS)
322
323 static const FcStringConst widthConsts[] = {
324 { "ultracondensed", FC_WIDTH_ULTRACONDENSED },
325 { "extracondensed", FC_WIDTH_EXTRACONDENSED },
326 { "semicondensed", FC_WIDTH_SEMICONDENSED },
327 { "condensed", FC_WIDTH_CONDENSED }, /* must be after *condensed */
328 { "normal", FC_WIDTH_NORMAL },
329 { "semiexpanded", FC_WIDTH_SEMIEXPANDED },
330 { "extraexpanded", FC_WIDTH_EXTRAEXPANDED },
331 { "ultraexpanded", FC_WIDTH_ULTRAEXPANDED },
332 { "expanded", FC_WIDTH_EXPANDED }, /* must be after *expanded */
333 };
334
335 #define NUM_WIDTH_CONSTS (sizeof (widthConsts) / sizeof (widthConsts[0]))
336
337 #define FcIsWidth(s) FcStringIsConst(s,widthConsts,NUM_WIDTH_CONSTS)
338 #define FcContainsWidth(s) FcStringContainsConst (s,widthConsts,NUM_WIDTH_CONSTS)
339
340 static const FcStringConst slantConsts[] = {
341 { "italic", FC_SLANT_ITALIC },
342 { "oblique", FC_SLANT_OBLIQUE },
343 };
344
345 #define NUM_SLANT_CONSTS (sizeof (slantConsts) / sizeof (slantConsts[0]))
346
347 #define FcIsSlant(s) FcStringIsConst(s,slantConsts,NUM_SLANT_CONSTS)
348 #define FcContainsSlant(s) FcStringContainsConst (s,slantConsts,NUM_SLANT_CONSTS)
349
350 static double
351 FcGetPixelSize (FT_Face face, int i)
352 {
353 #if HAVE_FT_GET_BDF_PROPERTY
354 if (face->num_fixed_sizes == 1)
355 {
356 BDF_PropertyRec prop;
357 int rc;
358
359 rc = MY_Get_BDF_Property (face, "PIXEL_SIZE", &prop);
360 if (rc == 0 && prop.type == BDF_PROPERTY_TYPE_INTEGER)
361 return (double) prop.u.integer;
362 }
363 #endif
364 #if HAVE_FT_BITMAP_SIZE_Y_PPEM
365 return (double) face->available_sizes[i].y_ppem / 64.0;
366 #else
367 return (double) face->available_sizes[i].height;
368 #endif
369 }
370
371 FcPattern *
372 FcFreeTypeQuery (const FcChar8 *file,
373 int id,
374 FcBlanks *blanks,
375 int *count)
376 {
377 FT_Face face;
378 FcPattern *pat;
379 int slant = -1;
380 int weight = -1;
381 int width = -1;
382 int i;
383 FcCharSet *cs;
384 FcLangSet *ls;
385 FT_Library ftLibrary;
386 FcChar8 *family = 0;
387 FcChar8 *style = 0;
388 const FcChar8 *foundry = 0;
389 int spacing;
390 TT_OS2 *os2;
391 #if HAVE_FT_GET_PS_FONT_INFO
392 PS_FontInfoRec psfontinfo;
393 #endif
394 #if HAVE_FT_GET_BDF_PROPERTY
395 BDF_PropertyRec prop;
396 #endif
397 TT_Header *head;
398 const FcChar8 *exclusiveLang = 0;
399 FT_SfntName sname;
400 FT_UInt snamei, snamec;
401 FcBool family_allocated = FcFalse;
402 FcBool style_allocated = FcFalse;
403 int family_prio = 0;
404 int style_prio = 0;
405
406 if (FT_Init_FreeType (&ftLibrary))
407 return 0;
408
409 if (FT_New_Face (ftLibrary, (char *) file, id, &face))
410 goto bail;
411
412 *count = face->num_faces;
413
414 pat = FcPatternCreate ();
415 if (!pat)
416 goto bail0;
417
418 if (!FcPatternAddBool (pat, FC_OUTLINE,
419 (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
420 goto bail1;
421
422 if (!FcPatternAddBool (pat, FC_SCALABLE,
423 (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
424 goto bail1;
425
426
427 /*
428 * Get the OS/2 table
429 */
430 os2 = (TT_OS2 *) FT_Get_Sfnt_Table (face, ft_sfnt_os2);
431
432 /*
433 * Look first in the OS/2 table for the foundry, if
434 * not found here, the various notices will be searched for
435 * that information, either from the sfnt name tables or
436 * the Postscript FontInfo dictionary. Finally, the
437 * BDF properties will queried.
438 */
439
440 if (os2 && os2->version >= 0x0001 && os2->version != 0xffff)
441 foundry = FcVendorFoundry(os2->achVendID);
442
443 /*
444 * Grub through the name table looking for family
445 * and style names. FreeType makes quite a hash
446 * of them
447 */
448 snamec = FT_Get_Sfnt_Name_Count (face);
449 for (snamei = 0; snamei < snamec; snamei++)
450 {
451 FcChar8 *utf8;
452 int len;
453 int wchar;
454 FcChar8 *src;
455 int src_len;
456 FcChar8 *u8;
457 FcChar32 ucs4;
458 int ilen, olen;
459 int prio = 0;
460
461 const FcCharMap *map;
462 enum {
463 FcNameEncodingUtf16,
464 FcNameEncodingAppleRoman,
465 FcNameEncodingLatin1
466 } encoding;
467
468
469 if (FT_Get_Sfnt_Name (face, snamei, &sname) != 0)
470 break;
471
472 /*
473 * Look for Unicode strings
474 */
475 switch (sname.platform_id) {
476 case TT_PLATFORM_APPLE_UNICODE:
477 /*
478 * All APPLE_UNICODE encodings are Utf16 BE
479 *
480 * Because there's no language id for Unicode,
481 * assume it's English
482 */
483 prio |= FC_NAME_PRIO_LANG_ENGLISH;
484 prio |= FC_NAME_PRIO_ENC_UNICODE;
485 encoding = FcNameEncodingUtf16;
486 break;
487 case TT_PLATFORM_MACINTOSH:
488 switch (sname.encoding_id) {
489 case TT_MAC_ID_ROMAN:
490 encoding = FcNameEncodingAppleRoman;
491 break;
492 default:
493 continue;
494 }
495 switch (sname.language_id) {
496 case TT_MAC_LANGID_ENGLISH:
497 prio |= FC_NAME_PRIO_LANG_ENGLISH;
498 break;
499 default:
500 /*
501 * Sometimes Microsoft language ids
502 * end up in the macintosh table. This
503 * is often accompanied by data in
504 * some mystic encoding. Ignore these names
505 */
506 if (sname.language_id >= 0x100)
507 continue;
508 break;
509 }
510 break;
511 case TT_PLATFORM_MICROSOFT:
512 switch (sname.encoding_id) {
513 case TT_MS_ID_UNICODE_CS:
514 encoding = FcNameEncodingUtf16;
515 prio |= FC_NAME_PRIO_ENC_UNICODE;
516 break;
517 default:
518 continue;
519 }
520 switch (sname.language_id & 0xff) {
521 case 0x09:
522 prio |= FC_NAME_PRIO_LANG_ENGLISH;
523 break;
524 default:
525 break;
526 }
527 break;
528 case TT_PLATFORM_ISO:
529 switch (sname.encoding_id) {
530 case TT_ISO_ID_10646:
531 encoding = FcNameEncodingUtf16;
532 prio |= FC_NAME_PRIO_ENC_UNICODE;
533 break;
534 case TT_ISO_ID_7BIT_ASCII:
535 case TT_ISO_ID_8859_1:
536 encoding = FcNameEncodingLatin1;
537 break;
538 default:
539 continue;
540 }
541 break;
542 default:
543 continue;
544 }
545
546 /*
547 * Look for family and style names
548 */
549 switch (sname.name_id) {
550 case TT_NAME_ID_FONT_FAMILY:
551 prio |= FC_NAME_PRIO_NAME_FAMILY;
552 break;
553 case TT_NAME_ID_PS_NAME:
554 prio |= FC_NAME_PRIO_NAME_PS;
555 break;
556 case TT_NAME_ID_FONT_SUBFAMILY:
557 case TT_NAME_ID_TRADEMARK:
558 case TT_NAME_ID_MANUFACTURER:
559 break;
560 default:
561 continue;
562 }
563
564 src = (FcChar8 *) sname.string;
565 src_len = sname.string_len;
566
567 switch (encoding) {
568 case FcNameEncodingUtf16:
569 /*
570 * Convert Utf16 to Utf8
571 */
572
573 if (!FcUtf16Len (src, FcEndianBig, src_len, &len, &wchar))
574 continue;
575
576 /*
577 * Allocate plenty of space. Freed below
578 */
579 utf8 = malloc (len * FC_UTF8_MAX_LEN + 1);
580 if (!utf8)
581 continue;
582
583 u8 = utf8;
584
585 while ((ilen = FcUtf16ToUcs4 (src, FcEndianBig, &ucs4, src_len)) > 0)
586 {
587 src_len -= ilen;
588 src += ilen;
589 olen = FcUcs4ToUtf8 (ucs4, u8);
590 u8 += olen;
591 }
592 *u8 = '\0';
593 break;
594 case FcNameEncodingLatin1:
595 /*
596 * Convert Latin1 to Utf8. Freed below
597 */
598 utf8 = malloc (src_len * 2 + 1);
599 if (!utf8)
600 continue;
601
602 u8 = utf8;
603 while (src_len > 0)
604 {
605 ucs4 = *src++;
606 src_len--;
607 olen = FcUcs4ToUtf8 (ucs4, u8);
608 u8 += olen;
609 }
610 *u8 = '\0';
611 break;
612 case FcNameEncodingAppleRoman:
613 /*
614 * Convert AppleRoman to Utf8
615 */
616 map = FcFreeTypeGetPrivateMap (ft_encoding_apple_roman);
617 if (!map)
618 continue;
619
620 /* freed below */
621 utf8 = malloc (src_len * 3 + 1);
622 if (!utf8)
623 continue;
624
625 u8 = utf8;
626 while (src_len > 0)
627 {
628 ucs4 = FcFreeTypePrivateToUcs4 (*src++, map);
629 src_len--;
630 olen = FcUcs4ToUtf8 (ucs4, u8);
631 u8 += olen;
632 }
633 *u8 = '\0';
634 break;
635 default:
636 continue;
637 }
638 if ((prio & FC_NAME_PRIO_LANG) == FC_NAME_PRIO_LANG_NONE)
639 if (FcUtf8IsLatin (utf8, strlen ((char *) utf8)))
640 prio |= FC_NAME_PRIO_LANG_LATIN;
641
642 if (FcDebug () & FC_DBG_SCANV)
643 printf ("\nfound name (name %d platform %d encoding %d language 0x%x prio 0x%x) %s\n",
644 sname.name_id, sname.platform_id,
645 sname.encoding_id, sname.language_id,
646 prio, utf8);
647
648 switch (sname.name_id) {
649 case TT_NAME_ID_FONT_FAMILY:
650 case TT_NAME_ID_PS_NAME:
651 if (!family || prio > family_prio)
652 {
653 if (family)
654 free (family);
655 family = utf8;
656 utf8 = 0;
657 family_allocated = FcTrue;
658 family_prio = prio;
659 }
660 break;
661 case TT_NAME_ID_FONT_SUBFAMILY:
662 if (!style || prio > style_prio)
663 {
664 if (style)
665 free (style);
666 style = utf8;
667 utf8 = 0;
668 style_allocated = FcTrue;
669 style_prio = prio;
670 }
671 break;
672 case TT_NAME_ID_TRADEMARK:
673 case TT_NAME_ID_MANUFACTURER:
674 /* If the foundry wasn't found in the OS/2 table, look here */
675 if(!foundry)
676 foundry = FcNoticeFoundry((FT_String *) utf8);
677 break;
678 }
679 if (utf8)
680 free (utf8);
681 }
682
683 if (!family)
684 family = (FcChar8 *) face->family_name;
685
686 if (!style)
687 style = (FcChar8 *) face->style_name;
688
689 if (!family)
690 {
691 FcChar8 *start, *end;
692
693 start = (FcChar8 *) strrchr ((char *) file, '/');
694 if (start)
695 start++;
696 else
697 start = (FcChar8 *) file;
698 end = (FcChar8 *) strrchr ((char *) start, '.');
699 if (!end)
700 end = start + strlen ((char *) start);
701 /* freed below */
702 family = malloc (end - start + 1);
703 strncpy ((char *) family, (char *) start, end - start);
704 family[end - start] = '\0';
705 family_allocated = FcTrue;
706 }
707
708 if (FcDebug() & FC_DBG_SCAN)
709 printf ("\n\"%s\" \"%s\"\n", family, style ? style : (FcChar8 *) "<none>");
710
711 if (!FcPatternAddString (pat, FC_FAMILY, family))
712 goto bail1;
713
714 if (style)
715 {
716 if (!FcPatternAddString (pat, FC_STYLE, style))
717 goto bail1;
718 }
719
720 if (!FcPatternAddString (pat, FC_FILE, file))
721 goto bail1;
722
723 if (!FcPatternAddInteger (pat, FC_INDEX, id))
724 goto bail1;
725
726 if (!FcPatternAddString (pat, FC_SOURCE, (FcChar8 *) "FreeType"))
727 goto bail1;
728
729 #if 0
730 /*
731 * don't even try this -- CJK 'monospace' fonts are really
732 * dual width, and most other fonts don't bother to set
733 * the attribute. Sigh.
734 */
735 if ((face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) != 0)
736 if (!FcPatternAddInteger (pat, FC_SPACING, FC_MONO))
737 goto bail1;
738 #endif
739
740 /*
741 * Find the font revision (if available)
742 */
743 head = (TT_Header *) FT_Get_Sfnt_Table (face, ft_sfnt_head);
744 if (head)
745 {
746 if (!FcPatternAddInteger (pat, FC_FONTVERSION, head->Font_Revision))
747 goto bail1;
748 }
749 else
750 {
751 if (!FcPatternAddInteger (pat, FC_FONTVERSION, 0))
752 goto bail1;
753 }
754
755 if (os2 && os2->version >= 0x0001 && os2->version != 0xffff)
756 {
757 for (i = 0; i < NUM_CODE_PAGE_RANGE; i++)
758 {
759 FT_ULong bits;
760 int bit;
761 if (FcCodePageRange[i].bit < 32)
762 {
763 bits = os2->ulCodePageRange1;
764 bit = FcCodePageRange[i].bit;
765 }
766 else
767 {
768 bits = os2->ulCodePageRange2;
769 bit = FcCodePageRange[i].bit - 32;
770 }
771 if (bits & (1 << bit))
772 {
773 /*
774 * If the font advertises support for multiple
775 * "exclusive" languages, then include support
776 * for any language found to have coverage
777 */
778 if (exclusiveLang)
779 {
780 exclusiveLang = 0;
781 break;
782 }
783 exclusiveLang = FcCodePageRange[i].lang;
784 }
785 }
786 }
787
788 if (os2 && os2->version != 0xffff)
789 {
790 if (os2->usWeightClass == 0)
791 ;
792 else if (os2->usWeightClass < 150)
793 weight = FC_WEIGHT_THIN;
794 else if (os2->usWeightClass < 250)
795 weight = FC_WEIGHT_EXTRALIGHT;
796 else if (os2->usWeightClass < 350)
797 weight = FC_WEIGHT_LIGHT;
798 else if (os2->usWeightClass < 450)
799 weight = FC_WEIGHT_REGULAR;
800 else if (os2->usWeightClass < 550)
801 weight = FC_WEIGHT_MEDIUM;
802 else if (os2->usWeightClass < 650)
803 weight = FC_WEIGHT_SEMIBOLD;
804 else if (os2->usWeightClass < 750)
805 weight = FC_WEIGHT_BOLD;
806 else if (os2->usWeightClass < 850)
807 weight = FC_WEIGHT_EXTRABOLD;
808 else if (os2->usWeightClass < 950)
809 weight = FC_WEIGHT_BLACK;
810
811 switch (os2->usWidthClass) {
812 case 1: width = FC_WIDTH_ULTRACONDENSED; break;
813 case 2: width = FC_WIDTH_EXTRACONDENSED; break;
814 case 3: width = FC_WIDTH_CONDENSED; break;
815 case 4: width = FC_WIDTH_SEMICONDENSED; break;
816 case 5: width = FC_WIDTH_NORMAL; break;
817 case 6: width = FC_WIDTH_SEMIEXPANDED; break;
818 case 7: width = FC_WIDTH_EXPANDED; break;
819 case 8: width = FC_WIDTH_EXTRAEXPANDED; break;
820 case 9: width = FC_WIDTH_ULTRAEXPANDED; break;
821 }
822 }
823
824 /*
825 * Type 1: Check for FontInfo dictionary information
826 * Code from g2@magestudios.net (Gerard Escalante)
827 */
828
829 #if HAVE_FT_GET_PS_FONT_INFO
830 if (FT_Get_PS_Font_Info(face, &psfontinfo) == 0)
831 {
832 if (weight == -1 && psfontinfo.weight)
833 {
834 weight = FcIsWeight (psfontinfo.weight);
835 if (FcDebug() & FC_DBG_SCANV)
836 printf ("\tType1 weight %s maps to %d\n",
837 psfontinfo.weight, weight);
838 }
839
840 #if 0
841 /*
842 * Don't bother with italic_angle; FreeType already extracts that
843 * information for us and sticks it into style_flags
844 */
845 if (psfontinfo.italic_angle)
846 slant = FC_SLANT_ITALIC;
847 else
848 slant = FC_SLANT_ROMAN;
849 #endif
850
851 if(!foundry)
852 foundry = FcNoticeFoundry(psfontinfo.notice);
853 }
854 #endif /* HAVE_FT_GET_PS_FONT_INFO */
855
856 #if HAVE_FT_GET_BDF_PROPERTY
857 /*
858 * Finally, look for a FOUNDRY BDF property if no other
859 * mechanism has managed to locate a foundry
860 */
861
862 if (!foundry)
863 {
864 int rc;
865 BDF_PropertyRec prop;
866 rc = MY_Get_BDF_Property(face, "FOUNDRY", &prop);
867 if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM)
868 foundry = prop.u.atom;
869 }
870
871 if (width == -1)
872 {
873 if (MY_Get_BDF_Property(face, "RELATIVE_SETWIDTH", &prop) == 0 &&
874 (prop.type == BDF_PROPERTY_TYPE_INTEGER ||
875 prop.type == BDF_PROPERTY_TYPE_CARDINAL))
876 {
877 FT_Int32 value;
878
879 if (prop.type == BDF_PROPERTY_TYPE_INTEGER)
880 value = prop.u.integer;
881 else
882 value = (FT_Int32) prop.u.cardinal;
883 switch ((value + 5) / 10) {
884 case 1: width = FC_WIDTH_ULTRACONDENSED; break;
885 case 2: width = FC_WIDTH_EXTRACONDENSED; break;
886 case 3: width = FC_WIDTH_CONDENSED; break;
887 case 4: width = FC_WIDTH_SEMICONDENSED; break;
888 case 5: width = FC_WIDTH_NORMAL; break;
889 case 6: width = FC_WIDTH_SEMIEXPANDED; break;
890 case 7: width = FC_WIDTH_EXPANDED; break;
891 case 8: width = FC_WIDTH_EXTRAEXPANDED; break;
892 case 9: width = FC_WIDTH_ULTRAEXPANDED; break;
893 }
894 }
895 if (width == -1 &&
896 MY_Get_BDF_Property (face, "SETWIDTH_NAME", &prop) == 0 &&
897 prop.type == BDF_PROPERTY_TYPE_ATOM)
898 {
899 width = FcIsWidth (prop.u.atom);
900 if (FcDebug () & FC_DBG_SCANV)
901 printf ("\tsetwidth %s maps to %d\n", prop.u.atom, width);
902 }
903 }
904 #endif
905
906 /*
907 * Look for weight, width and slant names in the style value
908 */
909 if (style)
910 {
911 if (weight == -1)
912 {
913 weight = FcContainsWeight (style);
914 if (FcDebug() & FC_DBG_SCANV)
915 printf ("\tStyle %s maps to weight %d\n", style, weight);
916 }
917 if (width == -1)
918 {
919 width = FcContainsWidth (style);
920 if (FcDebug() & FC_DBG_SCANV)
921 printf ("\tStyle %s maps to width %d\n", style, width);
922 }
923 if (slant == -1)
924 {
925 slant = FcContainsSlant (style);
926 if (FcDebug() & FC_DBG_SCANV)
927 printf ("\tStyle %s maps to slant %d\n", style, slant);
928 }
929 }
930 /*
931 * Pull default values from the FreeType flags if more
932 * specific values not found above
933 */
934 if (slant == -1)
935 {
936 slant = FC_SLANT_ROMAN;
937 if (face->style_flags & FT_STYLE_FLAG_ITALIC)
938 slant = FC_SLANT_ITALIC;
939 }
940
941 if (weight == -1)
942 {
943 weight = FC_WEIGHT_MEDIUM;
944 if (face->style_flags & FT_STYLE_FLAG_BOLD)
945 weight = FC_WEIGHT_BOLD;
946 }
947
948 if (width == -1)
949 width = FC_WIDTH_NORMAL;
950
951 if (foundry == 0)
952 foundry = "unknown";
953
954 if (!FcPatternAddInteger (pat, FC_SLANT, slant))
955 goto bail1;
956
957 if (!FcPatternAddInteger (pat, FC_WEIGHT, weight))
958 goto bail1;
959
960 if (!FcPatternAddInteger (pat, FC_WIDTH, width))
961 goto bail1;
962
963 if (!FcPatternAddString (pat, FC_FOUNDRY, foundry))
964 goto bail1;
965
966 /*
967 * Compute the unicode coverage for the font
968 */
969 cs = FcFreeTypeCharSetAndSpacing (face, blanks, &spacing);
970 if (!cs)
971 goto bail1;
972
973 #if HAVE_FT_GET_BDF_PROPERTY
974 /* For PCF fonts, override the computed spacing with the one from
975 the property */
976 if(MY_Get_BDF_Property(face, "SPACING", &prop) == 0 &&
977 prop.type == BDF_PROPERTY_TYPE_ATOM) {
978 if(!strcmp(prop.u.atom, "c") || !strcmp(prop.u.atom, "C"))
979 spacing = FC_CHARCELL;
980 else if(!strcmp(prop.u.atom, "m") || !strcmp(prop.u.atom, "M"))
981 spacing = FC_MONO;
982 else if(!strcmp(prop.u.atom, "p") || !strcmp(prop.u.atom, "P"))
983 spacing = FC_PROPORTIONAL;
984 }
985 #endif
986
987 /*
988 * Skip over PCF fonts that have no encoded characters; they're
989 * usually just Unicode fonts transcoded to some legacy encoding
990 */
991 if (FcCharSetCount (cs) == 0)
992 {
993 if (!strcmp(FT_MODULE_CLASS(&face->driver->root)->module_name, "pcf"))
994 goto bail2;
995 }
996
997 if (!FcPatternAddCharSet (pat, FC_CHARSET, cs))
998 goto bail2;
999
1000 ls = FcFreeTypeLangSet (cs, exclusiveLang);
1001 if (!ls)
1002 goto bail2;
1003
1004 if (!FcPatternAddLangSet (pat, FC_LANG, ls))
1005 {
1006 FcLangSetDestroy (ls);
1007 goto bail2;
1008 }
1009
1010 FcLangSetDestroy (ls);
1011
1012 if (spacing != FC_PROPORTIONAL)
1013 if (!FcPatternAddInteger (pat, FC_SPACING, spacing))
1014 goto bail2;
1015
1016 if (!(face->face_flags & FT_FACE_FLAG_SCALABLE))
1017 {
1018 for (i = 0; i < face->num_fixed_sizes; i++)
1019 if (!FcPatternAddDouble (pat, FC_PIXEL_SIZE,
1020 FcGetPixelSize (face, i)))
1021 goto bail1;
1022 if (!FcPatternAddBool (pat, FC_ANTIALIAS, FcFalse))
1023 goto bail1;
1024 #if HAVE_FT_GET_BDF_PROPERTY
1025 if(face->num_fixed_sizes == 1) {
1026 int rc;
1027 int value;
1028 BDF_PropertyRec prop;
1029
1030 rc = MY_Get_BDF_Property(face, "POINT_SIZE", &prop);
1031 if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_INTEGER)
1032 value = prop.u.integer;
1033 else if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_CARDINAL)
1034 value = prop.u.cardinal;
1035 else
1036 goto nevermind;
1037 if(!FcPatternAddDouble(pat, FC_SIZE, value / 10.0))
1038 goto nevermind;
1039
1040 rc = MY_Get_BDF_Property(face, "RESOLUTION_Y", &prop);
1041 if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_INTEGER)
1042 value = prop.u.integer;
1043 else if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_CARDINAL)
1044 value = prop.u.cardinal;
1045 else
1046 goto nevermind;
1047 if(!FcPatternAddDouble(pat, FC_DPI, (double)value))
1048 goto nevermind;
1049
1050 }
1051 nevermind:
1052 ;
1053 #endif
1054 }
1055
1056 /*
1057 * Drop our reference to the charset
1058 */
1059 FcCharSetDestroy (cs);
1060
1061 /*
1062 * Deallocate family/style values
1063 */
1064
1065 if (family_allocated)
1066 free (family);
1067 if (style_allocated)
1068 free (style);
1069
1070 FT_Done_Face (face);
1071 FT_Done_FreeType (ftLibrary);
1072 return pat;
1073
1074 bail2:
1075 FcCharSetDestroy (cs);
1076 bail1:
1077 FcPatternDestroy (pat);
1078 if (family_allocated)
1079 free (family);
1080 if (style_allocated)
1081 free (style);
1082 bail0:
1083 FT_Done_Face (face);
1084 bail:
1085 FT_Done_FreeType (ftLibrary);
1086 return 0;
1087 }
1088
1089
1090 /*
1091 * For our purposes, this approximation is sufficient
1092 */
1093 #if !HAVE_FT_GET_NEXT_CHAR
1094 #define FT_Get_Next_Char(face, ucs4, gi) ((ucs4) >= 0xffffff ? \
1095 (*(gi) = 0), 0 : \
1096 (*(gi) = 1), (ucs4) + 1)
1097 #warning "No FT_Get_Next_Char"
1098 #endif
1099
1100 typedef struct _FcCharEnt {
1101 FcChar16 bmp;
1102 unsigned char encode;
1103 } FcCharEnt;
1104
1105 struct _FcCharMap {
1106 const FcCharEnt *ent;
1107 int nent;
1108 };
1109
1110 typedef struct _FcFontDecode {
1111 FT_Encoding encoding;
1112 const FcCharMap *map;
1113 FcChar32 max;
1114 } FcFontDecode;
1115
1116 static const FcCharEnt AppleRomanEnt[] = {
1117 { 0x0020, 0x20 }, /* SPACE */
1118 { 0x0021, 0x21 }, /* EXCLAMATION MARK */
1119 { 0x0022, 0x22 }, /* QUOTATION MARK */
1120 { 0x0023, 0x23 }, /* NUMBER SIGN */
1121 { 0x0024, 0x24 }, /* DOLLAR SIGN */
1122 { 0x0025, 0x25 }, /* PERCENT SIGN */
1123 { 0x0026, 0x26 }, /* AMPERSAND */
1124 { 0x0027, 0x27 }, /* APOSTROPHE */
1125 { 0x0028, 0x28 }, /* LEFT PARENTHESIS */
1126 { 0x0029, 0x29 }, /* RIGHT PARENTHESIS */
1127 { 0x002A, 0x2A }, /* ASTERISK */
1128 { 0x002B, 0x2B }, /* PLUS SIGN */
1129 { 0x002C, 0x2C }, /* COMMA */
1130 { 0x002D, 0x2D }, /* HYPHEN-MINUS */
1131 { 0x002E, 0x2E }, /* FULL STOP */
1132 { 0x002F, 0x2F }, /* SOLIDUS */
1133 { 0x0030, 0x30 }, /* DIGIT ZERO */
1134 { 0x0031, 0x31 }, /* DIGIT ONE */
1135 { 0x0032, 0x32 }, /* DIGIT TWO */
1136 { 0x0033, 0x33 }, /* DIGIT THREE */
1137 { 0x0034, 0x34 }, /* DIGIT FOUR */
1138 { 0x0035, 0x35 }, /* DIGIT FIVE */
1139 { 0x0036, 0x36 }, /* DIGIT SIX */
1140 { 0x0037, 0x37 }, /* DIGIT SEVEN */
1141 { 0x0038, 0x38 }, /* DIGIT EIGHT */
1142 { 0x0039, 0x39 }, /* DIGIT NINE */
1143 { 0x003A, 0x3A }, /* COLON */
1144 { 0x003B, 0x3B }, /* SEMICOLON */
1145 { 0x003C, 0x3C }, /* LESS-THAN SIGN */
1146 { 0x003D, 0x3D }, /* EQUALS SIGN */
1147 { 0x003E, 0x3E }, /* GREATER-THAN SIGN */
1148 { 0x003F, 0x3F }, /* QUESTION MARK */
1149 { 0x0040, 0x40 }, /* COMMERCIAL AT */
1150 { 0x0041, 0x41 }, /* LATIN CAPITAL LETTER A */
1151 { 0x0042, 0x42 }, /* LATIN CAPITAL LETTER B */
1152 { 0x0043, 0x43 }, /* LATIN CAPITAL LETTER C */
1153 { 0x0044, 0x44 }, /* LATIN CAPITAL LETTER D */
1154 { 0x0045, 0x45 }, /* LATIN CAPITAL LETTER E */
1155 { 0x0046, 0x46 }, /* LATIN CAPITAL LETTER F */
1156 { 0x0047, 0x47 }, /* LATIN CAPITAL LETTER G */
1157 { 0x0048, 0x48 }, /* LATIN CAPITAL LETTER H */
1158 { 0x0049, 0x49 }, /* LATIN CAPITAL LETTER I */
1159 { 0x004A, 0x4A }, /* LATIN CAPITAL LETTER J */
1160 { 0x004B, 0x4B }, /* LATIN CAPITAL LETTER K */
1161 { 0x004C, 0x4C }, /* LATIN CAPITAL LETTER L */
1162 { 0x004D, 0x4D }, /* LATIN CAPITAL LETTER M */
1163 { 0x004E, 0x4E }, /* LATIN CAPITAL LETTER N */
1164 { 0x004F, 0x4F }, /* LATIN CAPITAL LETTER O */
1165 { 0x0050, 0x50 }, /* LATIN CAPITAL LETTER P */
1166 { 0x0051, 0x51 }, /* LATIN CAPITAL LETTER Q */
1167 { 0x0052, 0x52 }, /* LATIN CAPITAL LETTER R */
1168 { 0x0053, 0x53 }, /* LATIN CAPITAL LETTER S */
1169 { 0x0054, 0x54 }, /* LATIN CAPITAL LETTER T */
1170 { 0x0055, 0x55 }, /* LATIN CAPITAL LETTER U */
1171 { 0x0056, 0x56 }, /* LATIN CAPITAL LETTER V */
1172 { 0x0057, 0x57 }, /* LATIN CAPITAL LETTER W */
1173 { 0x0058, 0x58 }, /* LATIN CAPITAL LETTER X */
1174 { 0x0059, 0x59 }, /* LATIN CAPITAL LETTER Y */
1175 { 0x005A, 0x5A }, /* LATIN CAPITAL LETTER Z */
1176 { 0x005B, 0x5B }, /* LEFT SQUARE BRACKET */
1177 { 0x005C, 0x5C }, /* REVERSE SOLIDUS */
1178 { 0x005D, 0x5D }, /* RIGHT SQUARE BRACKET */
1179 { 0x005E, 0x5E }, /* CIRCUMFLEX ACCENT */
1180 { 0x005F, 0x5F }, /* LOW LINE */
1181 { 0x0060, 0x60 }, /* GRAVE ACCENT */
1182 { 0x0061, 0x61 }, /* LATIN SMALL LETTER A */
1183 { 0x0062, 0x62 }, /* LATIN SMALL LETTER B */
1184 { 0x0063, 0x63 }, /* LATIN SMALL LETTER C */
1185 { 0x0064, 0x64 }, /* LATIN SMALL LETTER D */
1186 { 0x0065, 0x65 }, /* LATIN SMALL LETTER E */
1187 { 0x0066, 0x66 }, /* LATIN SMALL LETTER F */
1188 { 0x0067, 0x67 }, /* LATIN SMALL LETTER G */
1189 { 0x0068, 0x68 }, /* LATIN SMALL LETTER H */
1190 { 0x0069, 0x69 }, /* LATIN SMALL LETTER I */
1191 { 0x006A, 0x6A }, /* LATIN SMALL LETTER J */
1192 { 0x006B, 0x6B }, /* LATIN SMALL LETTER K */
1193 { 0x006C, 0x6C }, /* LATIN SMALL LETTER L */
1194 { 0x006D, 0x6D }, /* LATIN SMALL LETTER M */
1195 { 0x006E, 0x6E }, /* LATIN SMALL LETTER N */
1196 { 0x006F, 0x6F }, /* LATIN SMALL LETTER O */
1197 { 0x0070, 0x70 }, /* LATIN SMALL LETTER P */
1198 { 0x0071, 0x71 }, /* LATIN SMALL LETTER Q */
1199 { 0x0072, 0x72 }, /* LATIN SMALL LETTER R */
1200 { 0x0073, 0x73 }, /* LATIN SMALL LETTER S */
1201 { 0x0074, 0x74 }, /* LATIN SMALL LETTER T */
1202 { 0x0075, 0x75 }, /* LATIN SMALL LETTER U */
1203 { 0x0076, 0x76 }, /* LATIN SMALL LETTER V */
1204 { 0x0077, 0x77 }, /* LATIN SMALL LETTER W */
1205 { 0x0078, 0x78 }, /* LATIN SMALL LETTER X */
1206 { 0x0079, 0x79 }, /* LATIN SMALL LETTER Y */
1207 { 0x007A, 0x7A }, /* LATIN SMALL LETTER Z */
1208 { 0x007B, 0x7B }, /* LEFT CURLY BRACKET */
1209 { 0x007C, 0x7C }, /* VERTICAL LINE */
1210 { 0x007D, 0x7D }, /* RIGHT CURLY BRACKET */
1211 { 0x007E, 0x7E }, /* TILDE */
1212 { 0x00A0, 0xCA }, /* NO-BREAK SPACE */
1213 { 0x00A1, 0xC1 }, /* INVERTED EXCLAMATION MARK */
1214 { 0x00A2, 0xA2 }, /* CENT SIGN */
1215 { 0x00A3, 0xA3 }, /* POUND SIGN */
1216 { 0x00A5, 0xB4 }, /* YEN SIGN */
1217 { 0x00A7, 0xA4 }, /* SECTION SIGN */
1218 { 0x00A8, 0xAC }, /* DIAERESIS */
1219 { 0x00A9, 0xA9 }, /* COPYRIGHT SIGN */
1220 { 0x00AA, 0xBB }, /* FEMININE ORDINAL INDICATOR */
1221 { 0x00AB, 0xC7 }, /* LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */
1222 { 0x00AC, 0xC2 }, /* NOT SIGN */
1223 { 0x00AE, 0xA8 }, /* REGISTERED SIGN */
1224 { 0x00AF, 0xF8 }, /* MACRON */
1225 { 0x00B0, 0xA1 }, /* DEGREE SIGN */
1226 { 0x00B1, 0xB1 }, /* PLUS-MINUS SIGN */
1227 { 0x00B4, 0xAB }, /* ACUTE ACCENT */
1228 { 0x00B5, 0xB5 }, /* MICRO SIGN */
1229 { 0x00B6, 0xA6 }, /* PILCROW SIGN */
1230 { 0x00B7, 0xE1 }, /* MIDDLE DOT */
1231 { 0x00B8, 0xFC }, /* CEDILLA */
1232 { 0x00BA, 0xBC }, /* MASCULINE ORDINAL INDICATOR */
1233 { 0x00BB, 0xC8 }, /* RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */
1234 { 0x00BF, 0xC0 }, /* INVERTED QUESTION MARK */
1235 { 0x00C0, 0xCB }, /* LATIN CAPITAL LETTER A WITH GRAVE */
1236 { 0x00C1, 0xE7 }, /* LATIN CAPITAL LETTER A WITH ACUTE */
1237 { 0x00C2, 0xE5 }, /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */
1238 { 0x00C3, 0xCC }, /* LATIN CAPITAL LETTER A WITH TILDE */
1239 { 0x00C4, 0x80 }, /* LATIN CAPITAL LETTER A WITH DIAERESIS */
1240 { 0x00C5, 0x81 }, /* LATIN CAPITAL LETTER A WITH RING ABOVE */
1241 { 0x00C6, 0xAE }, /* LATIN CAPITAL LETTER AE */
1242 { 0x00C7, 0x82 }, /* LATIN CAPITAL LETTER C WITH CEDILLA */
1243 { 0x00C8, 0xE9 }, /* LATIN CAPITAL LETTER E WITH GRAVE */
1244 { 0x00C9, 0x83 }, /* LATIN CAPITAL LETTER E WITH ACUTE */
1245 { 0x00CA, 0xE6 }, /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */
1246 { 0x00CB, 0xE8 }, /* LATIN CAPITAL LETTER E WITH DIAERESIS */
1247 { 0x00CC, 0xED }, /* LATIN CAPITAL LETTER I WITH GRAVE */
1248 { 0x00CD, 0xEA }, /* LATIN CAPITAL LETTER I WITH ACUTE */
1249 { 0x00CE, 0xEB }, /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */
1250 { 0x00CF, 0xEC }, /* LATIN CAPITAL LETTER I WITH DIAERESIS */
1251 { 0x00D1, 0x84 }, /* LATIN CAPITAL LETTER N WITH TILDE */
1252 { 0x00D2, 0xF1 }, /* LATIN CAPITAL LETTER O WITH GRAVE */
1253 { 0x00D3, 0xEE }, /* LATIN CAPITAL LETTER O WITH ACUTE */
1254 { 0x00D4, 0xEF }, /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */
1255 { 0x00D5, 0xCD }, /* LATIN CAPITAL LETTER O WITH TILDE */
1256 { 0x00D6, 0x85 }, /* LATIN CAPITAL LETTER O WITH DIAERESIS */
1257 { 0x00D8, 0xAF }, /* LATIN CAPITAL LETTER O WITH STROKE */
1258 { 0x00D9, 0xF4 }, /* LATIN CAPITAL LETTER U WITH GRAVE */
1259 { 0x00DA, 0xF2 }, /* LATIN CAPITAL LETTER U WITH ACUTE */
1260 { 0x00DB, 0xF3 }, /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */
1261 { 0x00DC, 0x86 }, /* LATIN CAPITAL LETTER U WITH DIAERESIS */
1262 { 0x00DF, 0xA7 }, /* LATIN SMALL LETTER SHARP S */
1263 { 0x00E0, 0x88 }, /* LATIN SMALL LETTER A WITH GRAVE */
1264 { 0x00E1, 0x87 }, /* LATIN SMALL LETTER A WITH ACUTE */
1265 { 0x00E2, 0x89 }, /* LATIN SMALL LETTER A WITH CIRCUMFLEX */
1266 { 0x00E3, 0x8B }, /* LATIN SMALL LETTER A WITH TILDE */
1267 { 0x00E4, 0x8A }, /* LATIN SMALL LETTER A WITH DIAERESIS */
1268 { 0x00E5, 0x8C }, /* LATIN SMALL LETTER A WITH RING ABOVE */
1269 { 0x00E6, 0xBE }, /* LATIN SMALL LETTER AE */
1270 { 0x00E7, 0x8D }, /* LATIN SMALL LETTER C WITH CEDILLA */
1271 { 0x00E8, 0x8F }, /* LATIN SMALL LETTER E WITH GRAVE */
1272 { 0x00E9, 0x8E }, /* LATIN SMALL LETTER E WITH ACUTE */
1273 { 0x00EA, 0x90 }, /* LATIN SMALL LETTER E WITH CIRCUMFLEX */
1274 { 0x00EB, 0x91 }, /* LATIN SMALL LETTER E WITH DIAERESIS */
1275 { 0x00EC, 0x93 }, /* LATIN SMALL LETTER I WITH GRAVE */
1276 { 0x00ED, 0x92 }, /* LATIN SMALL LETTER I WITH ACUTE */
1277 { 0x00EE, 0x94 }, /* LATIN SMALL LETTER I WITH CIRCUMFLEX */
1278 { 0x00EF, 0x95 }, /* LATIN SMALL LETTER I WITH DIAERESIS */
1279 { 0x00F1, 0x96 }, /* LATIN SMALL LETTER N WITH TILDE */
1280 { 0x00F2, 0x98 }, /* LATIN SMALL LETTER O WITH GRAVE */
1281 { 0x00F3, 0x97 }, /* LATIN SMALL LETTER O WITH ACUTE */
1282 { 0x00F4, 0x99 }, /* LATIN SMALL LETTER O WITH CIRCUMFLEX */
1283 { 0x00F5, 0x9B }, /* LATIN SMALL LETTER O WITH TILDE */
1284 { 0x00F6, 0x9A }, /* LATIN SMALL LETTER O WITH DIAERESIS */
1285 { 0x00F7, 0xD6 }, /* DIVISION SIGN */
1286 { 0x00F8, 0xBF }, /* LATIN SMALL LETTER O WITH STROKE */
1287 { 0x00F9, 0x9D }, /* LATIN SMALL LETTER U WITH GRAVE */
1288 { 0x00FA, 0x9C }, /* LATIN SMALL LETTER U WITH ACUTE */
1289 { 0x00FB, 0x9E }, /* LATIN SMALL LETTER U WITH CIRCUMFLEX */
1290 { 0x00FC, 0x9F }, /* LATIN SMALL LETTER U WITH DIAERESIS */
1291 { 0x00FF, 0xD8 }, /* LATIN SMALL LETTER Y WITH DIAERESIS */
1292 { 0x0131, 0xF5 }, /* LATIN SMALL LETTER DOTLESS I */
1293 { 0x0152, 0xCE }, /* LATIN CAPITAL LIGATURE OE */
1294 { 0x0153, 0xCF }, /* LATIN SMALL LIGATURE OE */
1295 { 0x0178, 0xD9 }, /* LATIN CAPITAL LETTER Y WITH DIAERESIS */
1296 { 0x0192, 0xC4 }, /* LATIN SMALL LETTER F WITH HOOK */
1297 { 0x02C6, 0xF6 }, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
1298 { 0x02C7, 0xFF }, /* CARON */
1299 { 0x02D8, 0xF9 }, /* BREVE */
1300 { 0x02D9, 0xFA }, /* DOT ABOVE */
1301 { 0x02DA, 0xFB }, /* RING ABOVE */
1302 { 0x02DB, 0xFE }, /* OGONEK */
1303 { 0x02DC, 0xF7 }, /* SMALL TILDE */
1304 { 0x02DD, 0xFD }, /* DOUBLE ACUTE ACCENT */
1305 { 0x03A9, 0xBD }, /* GREEK CAPITAL LETTER OMEGA */
1306 { 0x03C0, 0xB9 }, /* GREEK SMALL LETTER PI */
1307 { 0x2013, 0xD0 }, /* EN DASH */
1308 { 0x2014, 0xD1 }, /* EM DASH */
1309 { 0x2018, 0xD4 }, /* LEFT SINGLE QUOTATION MARK */
1310 { 0x2019, 0xD5 }, /* RIGHT SINGLE QUOTATION MARK */
1311 { 0x201A, 0xE2 }, /* SINGLE LOW-9 QUOTATION MARK */
1312 { 0x201C, 0xD2 }, /* LEFT DOUBLE QUOTATION MARK */
1313 { 0x201D, 0xD3 }, /* RIGHT DOUBLE QUOTATION MARK */
1314 { 0x201E, 0xE3 }, /* DOUBLE LOW-9 QUOTATION MARK */
1315 { 0x2020, 0xA0 }, /* DAGGER */
1316 { 0x2021, 0xE0 }, /* DOUBLE DAGGER */
1317 { 0x2022, 0xA5 }, /* BULLET */
1318 { 0x2026, 0xC9 }, /* HORIZONTAL ELLIPSIS */
1319 { 0x2030, 0xE4 }, /* PER MILLE SIGN */
1320 { 0x2039, 0xDC }, /* SINGLE LEFT-POINTING ANGLE QUOTATION MARK */
1321 { 0x203A, 0xDD }, /* SINGLE RIGHT-POINTING ANGLE QUOTATION MARK */
1322 { 0x2044, 0xDA }, /* FRACTION SLASH */
1323 { 0x20AC, 0xDB }, /* EURO SIGN */
1324 { 0x2122, 0xAA }, /* TRADE MARK SIGN */
1325 { 0x2202, 0xB6 }, /* PARTIAL DIFFERENTIAL */
1326 { 0x2206, 0xC6 }, /* INCREMENT */
1327 { 0x220F, 0xB8 }, /* N-ARY PRODUCT */
1328 { 0x2211, 0xB7 }, /* N-ARY SUMMATION */
1329 { 0x221A, 0xC3 }, /* SQUARE ROOT */
1330 { 0x221E, 0xB0 }, /* INFINITY */
1331 { 0x222B, 0xBA }, /* INTEGRAL */
1332 { 0x2248, 0xC5 }, /* ALMOST EQUAL TO */
1333 { 0x2260, 0xAD }, /* NOT EQUAL TO */
1334 { 0x2264, 0xB2 }, /* LESS-THAN OR EQUAL TO */
1335 { 0x2265, 0xB3 }, /* GREATER-THAN OR EQUAL TO */
1336 { 0x25CA, 0xD7 }, /* LOZENGE */
1337 { 0xF8FF, 0xF0 }, /* Apple logo */
1338 { 0xFB01, 0xDE }, /* LATIN SMALL LIGATURE FI */
1339 { 0xFB02, 0xDF }, /* LATIN SMALL LIGATURE FL */
1340 };
1341
1342 static const FcCharMap AppleRoman = {
1343 AppleRomanEnt,
1344 sizeof (AppleRomanEnt) / sizeof (AppleRomanEnt[0])
1345 };
1346
1347 static const FcCharEnt AdobeSymbolEnt[] = {
1348 { 0x0020, 0x20 }, /* SPACE # space */
1349 { 0x0021, 0x21 }, /* EXCLAMATION MARK # exclam */
1350 { 0x0023, 0x23 }, /* NUMBER SIGN # numbersign */
1351 { 0x0025, 0x25 }, /* PERCENT SIGN # percent */
1352 { 0x0026, 0x26 }, /* AMPERSAND # ampersand */
1353 { 0x0028, 0x28 }, /* LEFT PARENTHESIS # parenleft */
1354 { 0x0029, 0x29 }, /* RIGHT PARENTHESIS # parenright */
1355 { 0x002B, 0x2B }, /* PLUS SIGN # plus */
1356 { 0x002C, 0x2C }, /* COMMA # comma */
1357 { 0x002E, 0x2E }, /* FULL STOP # period */
1358 { 0x002F, 0x2F }, /* SOLIDUS # slash */
1359 { 0x0030, 0x30 }, /* DIGIT ZERO # zero */
1360 { 0x0031, 0x31 }, /* DIGIT ONE # one */
1361 { 0x0032, 0x32 }, /* DIGIT TWO # two */
1362 { 0x0033, 0x33 }, /* DIGIT THREE # three */
1363 { 0x0034, 0x34 }, /* DIGIT FOUR # four */
1364 { 0x0035, 0x35 }, /* DIGIT FIVE # five */
1365 { 0x0036, 0x36 }, /* DIGIT SIX # six */
1366 { 0x0037, 0x37 }, /* DIGIT SEVEN # seven */
1367 { 0x0038, 0x38 }, /* DIGIT EIGHT # eight */
1368 { 0x0039, 0x39 }, /* DIGIT NINE # nine */
1369 { 0x003A, 0x3A }, /* COLON # colon */
1370 { 0x003B, 0x3B }, /* SEMICOLON # semicolon */
1371 { 0x003C, 0x3C }, /* LESS-THAN SIGN # less */
1372 { 0x003D, 0x3D }, /* EQUALS SIGN # equal */
1373 { 0x003E, 0x3E }, /* GREATER-THAN SIGN # greater */
1374 { 0x003F, 0x3F }, /* QUESTION MARK # question */
1375 { 0x005B, 0x5B }, /* LEFT SQUARE BRACKET # bracketleft */
1376 { 0x005D, 0x5D }, /* RIGHT SQUARE BRACKET # bracketright */
1377 { 0x005F, 0x5F }, /* LOW LINE # underscore */
1378 { 0x007B, 0x7B }, /* LEFT CURLY BRACKET # braceleft */
1379 { 0x007C, 0x7C }, /* VERTICAL LINE # bar */
1380 { 0x007D, 0x7D }, /* RIGHT CURLY BRACKET # braceright */
1381 { 0x00A0, 0x20 }, /* NO-BREAK SPACE # space */
1382 { 0x00AC, 0xD8 }, /* NOT SIGN # logicalnot */
1383 { 0x00B0, 0xB0 }, /* DEGREE SIGN # degree */
1384 { 0x00B1, 0xB1 }, /* PLUS-MINUS SIGN # plusminus */
1385 { 0x00B5, 0x6D }, /* MICRO SIGN # mu */
1386 { 0x00D7, 0xB4 }, /* MULTIPLICATION SIGN # multiply */
1387 { 0x00F7, 0xB8 }, /* DIVISION SIGN # divide */
1388 { 0x0192, 0xA6 }, /* LATIN SMALL LETTER F WITH HOOK # florin */
1389 { 0x0391, 0x41 }, /* GREEK CAPITAL LETTER ALPHA # Alpha */
1390 { 0x0392, 0x42 }, /* GREEK CAPITAL LETTER BETA # Beta */
1391 { 0x0393, 0x47 }, /* GREEK CAPITAL LETTER GAMMA # Gamma */
1392 { 0x0394, 0x44 }, /* GREEK CAPITAL LETTER DELTA # Delta */
1393 { 0x0395, 0x45 }, /* GREEK CAPITAL LETTER EPSILON # Epsilon */
1394 { 0x0396, 0x5A }, /* GREEK CAPITAL LETTER ZETA # Zeta */
1395 { 0x0397, 0x48 }, /* GREEK CAPITAL LETTER ETA # Eta */
1396 { 0x0398, 0x51 }, /* GREEK CAPITAL LETTER THETA # Theta */
1397 { 0x0399, 0x49 }, /* GREEK CAPITAL LETTER IOTA # Iota */
1398 { 0x039A, 0x4B }, /* GREEK CAPITAL LETTER KAPPA # Kappa */
1399 { 0x039B, 0x4C }, /* GREEK CAPITAL LETTER LAMDA # Lambda */
1400 { 0x039C, 0x4D }, /* GREEK CAPITAL LETTER MU # Mu */
1401 { 0x039D, 0x4E }, /* GREEK CAPITAL LETTER NU # Nu */
1402 { 0x039E, 0x58 }, /* GREEK CAPITAL LETTER XI # Xi */
1403 { 0x039F, 0x4F }, /* GREEK CAPITAL LETTER OMICRON # Omicron */
1404 { 0x03A0, 0x50 }, /* GREEK CAPITAL LETTER PI # Pi */
1405 { 0x03A1, 0x52 }, /* GREEK CAPITAL LETTER RHO # Rho */
1406 { 0x03A3, 0x53 }, /* GREEK CAPITAL LETTER SIGMA # Sigma */
1407 { 0x03A4, 0x54 }, /* GREEK CAPITAL LETTER TAU # Tau */
1408 { 0x03A5, 0x55 }, /* GREEK CAPITAL LETTER UPSILON # Upsilon */
1409 { 0x03A6, 0x46 }, /* GREEK CAPITAL LETTER PHI # Phi */
1410 { 0x03A7, 0x43 }, /* GREEK CAPITAL LETTER CHI # Chi */
1411 { 0x03A8, 0x59 }, /* GREEK CAPITAL LETTER PSI # Psi */
1412 { 0x03A9, 0x57 }, /* GREEK CAPITAL LETTER OMEGA # Omega */
1413 { 0x03B1, 0x61 }, /* GREEK SMALL LETTER ALPHA # alpha */
1414 { 0x03B2, 0x62 }, /* GREEK SMALL LETTER BETA # beta */
1415 { 0x03B3, 0x67 }, /* GREEK SMALL LETTER GAMMA # gamma */
1416 { 0x03B4, 0x64 }, /* GREEK SMALL LETTER DELTA # delta */
1417 { 0x03B5, 0x65 }, /* GREEK SMALL LETTER EPSILON # epsilon */
1418 { 0x03B6, 0x7A }, /* GREEK SMALL LETTER ZETA # zeta */
1419 { 0x03B7, 0x68 }, /* GREEK SMALL LETTER ETA # eta */
1420 { 0x03B8, 0x71 }, /* GREEK SMALL LETTER THETA # theta */
1421 { 0x03B9, 0x69 }, /* GREEK SMALL LETTER IOTA # iota */
1422 { 0x03BA, 0x6B }, /* GREEK SMALL LETTER KAPPA # kappa */
1423 { 0x03BB, 0x6C }, /* GREEK SMALL LETTER LAMDA # lambda */
1424 { 0x03BC, 0x6D }, /* GREEK SMALL LETTER MU # mu */
1425 { 0x03BD, 0x6E }, /* GREEK SMALL LETTER NU # nu */
1426 { 0x03BE, 0x78 }, /* GREEK SMALL LETTER XI # xi */
1427 { 0x03BF, 0x6F }, /* GREEK SMALL LETTER OMICRON # omicron */
1428 { 0x03C0, 0x70 }, /* GREEK SMALL LETTER PI # pi */
1429 { 0x03C1, 0x72 }, /* GREEK SMALL LETTER RHO # rho */
1430 { 0x03C2, 0x56 }, /* GREEK SMALL LETTER FINAL SIGMA # sigma1 */
1431 { 0x03C3, 0x73 }, /* GREEK SMALL LETTER SIGMA # sigma */
1432 { 0x03C4, 0x74 }, /* GREEK SMALL LETTER TAU # tau */
1433 { 0x03C5, 0x75 }, /* GREEK SMALL LETTER UPSILON # upsilon */
1434 { 0x03C6, 0x66 }, /* GREEK SMALL LETTER PHI # phi */
1435 { 0x03C7, 0x63 }, /* GREEK SMALL LETTER CHI # chi */
1436 { 0x03C8, 0x79 }, /* GREEK SMALL LETTER PSI # psi */
1437 { 0x03C9, 0x77 }, /* GREEK SMALL LETTER OMEGA # omega */
1438 { 0x03D1, 0x4A }, /* GREEK THETA SYMBOL # theta1 */
1439 { 0x03D2, 0xA1 }, /* GREEK UPSILON WITH HOOK SYMBOL # Upsilon1 */
1440 { 0x03D5, 0x6A }, /* GREEK PHI SYMBOL # phi1 */
1441 { 0x03D6, 0x76 }, /* GREEK PI SYMBOL # omega1 */
1442 { 0x2022, 0xB7 }, /* BULLET # bullet */
1443 { 0x2026, 0xBC }, /* HORIZONTAL ELLIPSIS # ellipsis */
1444 { 0x2032, 0xA2 }, /* PRIME # minute */
1445 { 0x2033, 0xB2 }, /* DOUBLE PRIME # second */
1446 { 0x2044, 0xA4 }, /* FRACTION SLASH # fraction */
1447 { 0x20AC, 0xA0 }, /* EURO SIGN # Euro */
1448 { 0x2111, 0xC1 }, /* BLACK-LETTER CAPITAL I # Ifraktur */
1449 { 0x2118, 0xC3 }, /* SCRIPT CAPITAL P # weierstrass */
1450 { 0x211C, 0xC2 }, /* BLACK-LETTER CAPITAL R # Rfraktur */
1451 { 0x2126, 0x57 }, /* OHM SIGN # Omega */
1452 { 0x2135, 0xC0 }, /* ALEF SYMBOL # aleph */
1453 { 0x2190, 0xAC }, /* LEFTWARDS ARROW # arrowleft */
1454 { 0x2191, 0xAD }, /* UPWARDS ARROW # arrowup */
1455 { 0x2192, 0xAE }, /* RIGHTWARDS ARROW # arrowright */
1456 { 0x2193, 0xAF }, /* DOWNWARDS ARROW # arrowdown */
1457 { 0x2194, 0xAB }, /* LEFT RIGHT ARROW # arrowboth */
1458 { 0x21B5, 0xBF }, /* DOWNWARDS ARROW WITH CORNER LEFTWARDS # carriagereturn */
1459 { 0x21D0, 0xDC }, /* LEFTWARDS DOUBLE ARROW # arrowdblleft */
1460 { 0x21D1, 0xDD }, /* UPWARDS DOUBLE ARROW # arrowdblup */
1461 { 0x21D2, 0xDE }, /* RIGHTWARDS DOUBLE ARROW # arrowdblright */
1462 { 0x21D3, 0xDF }, /* DOWNWARDS DOUBLE ARROW # arrowdbldown */
1463 { 0x21D4, 0xDB }, /* LEFT RIGHT DOUBLE ARROW # arrowdblboth */
1464 { 0x2200, 0x22 }, /* FOR ALL # universal */
1465 { 0x2202, 0xB6 }, /* PARTIAL DIFFERENTIAL # partialdiff */
1466 { 0x2203, 0x24 }, /* THERE EXISTS # existential */
1467 { 0x2205, 0xC6 }, /* EMPTY SET # emptyset */
1468 { 0x2206, 0x44 }, /* INCREMENT # Delta */
1469 { 0x2207, 0xD1 }, /* NABLA # gradient */
1470 { 0x2208, 0xCE }, /* ELEMENT OF # element */
1471 { 0x2209, 0xCF }, /* NOT AN ELEMENT OF # notelement */
1472 { 0x220B, 0x27 }, /* CONTAINS AS MEMBER # suchthat */
1473 { 0x220F, 0xD5 }, /* N-ARY PRODUCT # product */
1474 { 0x2211, 0xE5 }, /* N-ARY SUMMATION # summation */
1475 { 0x2212, 0x2D }, /* MINUS SIGN # minus */
1476 { 0x2215, 0xA4 }, /* DIVISION SLASH # fraction */
1477 { 0x2217, 0x2A }, /* ASTERISK OPERATOR # asteriskmath */
1478 { 0x221A, 0xD6 }, /* SQUARE ROOT # radical */
1479 { 0x221D, 0xB5 }, /* PROPORTIONAL TO # proportional */
1480 { 0x221E, 0xA5 }, /* INFINITY # infinity */
1481 { 0x2220, 0xD0 }, /* ANGLE # angle */
1482 { 0x2227, 0xD9 }, /* LOGICAL AND # logicaland */
1483 { 0x2228, 0xDA }, /* LOGICAL OR # logicalor */
1484 { 0x2229, 0xC7 }, /* INTERSECTION # intersection */
1485 { 0x222A, 0xC8 }, /* UNION # union */
1486 { 0x222B, 0xF2 }, /* INTEGRAL # integral */
1487 { 0x2234, 0x5C }, /* THEREFORE # therefore */
1488 { 0x223C, 0x7E }, /* TILDE OPERATOR # similar */
1489 { 0x2245, 0x40 }, /* APPROXIMATELY EQUAL TO # congruent */
1490 { 0x2248, 0xBB }, /* ALMOST EQUAL TO # approxequal */
1491 { 0x2260, 0xB9 }, /* NOT EQUAL TO # notequal */
1492 { 0x2261, 0xBA }, /* IDENTICAL TO # equivalence */
1493 { 0x2264, 0xA3 }, /* LESS-THAN OR EQUAL TO # lessequal */
1494 { 0x2265, 0xB3 }, /* GREATER-THAN OR EQUAL TO # greaterequal */
1495 { 0x2282, 0xCC }, /* SUBSET OF # propersubset */
1496 { 0x2283, 0xC9 }, /* SUPERSET OF # propersuperset */
1497 { 0x2284, 0xCB }, /* NOT A SUBSET OF # notsubset */
1498 { 0x2286, 0xCD }, /* SUBSET OF OR EQUAL TO # reflexsubset */
1499 { 0x2287, 0xCA }, /* SUPERSET OF OR EQUAL TO # reflexsuperset */
1500 { 0x2295, 0xC5 }, /* CIRCLED PLUS # circleplus */
1501 { 0x2297, 0xC4 }, /* CIRCLED TIMES # circlemultiply */
1502 { 0x22A5, 0x5E }, /* UP TACK # perpendicular */
1503 { 0x22C5, 0xD7 }, /* DOT OPERATOR # dotmath */
1504 { 0x2320, 0xF3 }, /* TOP HALF INTEGRAL # integraltp */
1505 { 0x2321, 0xF5 }, /* BOTTOM HALF INTEGRAL # integralbt */
1506 { 0x2329, 0xE1 }, /* LEFT-POINTING ANGLE BRACKET # angleleft */
1507 { 0x232A, 0xF1 }, /* RIGHT-POINTING ANGLE BRACKET # angleright */
1508 { 0x25CA, 0xE0 }, /* LOZENGE # lozenge */
1509 { 0x2660, 0xAA }, /* BLACK SPADE SUIT # spade */
1510 { 0x2663, 0xA7 }, /* BLACK CLUB SUIT # club */
1511 { 0x2665, 0xA9 }, /* BLACK HEART SUIT # heart */
1512 { 0x2666, 0xA8 }, /* BLACK DIAMOND SUIT # diamond */
1513 { 0xF6D9, 0xD3 }, /* COPYRIGHT SIGN SERIF # copyrightserif (CUS) */
1514 { 0xF6DA, 0xD2 }, /* REGISTERED SIGN SERIF # registerserif (CUS) */
1515 { 0xF6DB, 0xD4 }, /* TRADE MARK SIGN SERIF # trademarkserif (CUS) */
1516 { 0xF8E5, 0x60 }, /* RADICAL EXTENDER # radicalex (CUS) */
1517 { 0xF8E6, 0xBD }, /* VERTICAL ARROW EXTENDER # arrowvertex (CUS) */
1518 { 0xF8E7, 0xBE }, /* HORIZONTAL ARROW EXTENDER # arrowhorizex (CUS) */
1519 { 0xF8E8, 0xE2 }, /* REGISTERED SIGN SANS SERIF # registersans (CUS) */
1520 { 0xF8E9, 0xE3 }, /* COPYRIGHT SIGN SANS SERIF # copyrightsans (CUS) */
1521 { 0xF8EA, 0xE4 }, /* TRADE MARK SIGN SANS SERIF # trademarksans (CUS) */
1522 { 0xF8EB, 0xE6 }, /* LEFT PAREN TOP # parenlefttp (CUS) */
1523 { 0xF8EC, 0xE7 }, /* LEFT PAREN EXTENDER # parenleftex (CUS) */
1524 { 0xF8ED, 0xE8 }, /* LEFT PAREN BOTTOM # parenleftbt (CUS) */
1525 { 0xF8EE, 0xE9 }, /* LEFT SQUARE BRACKET TOP # bracketlefttp (CUS) */
1526 { 0xF8EF, 0xEA }, /* LEFT SQUARE BRACKET EXTENDER # bracketleftex (CUS) */
1527 { 0xF8F0, 0xEB }, /* LEFT SQUARE BRACKET BOTTOM # bracketleftbt (CUS) */
1528 { 0xF8F1, 0xEC }, /* LEFT CURLY BRACKET TOP # bracelefttp (CUS) */
1529 { 0xF8F2, 0xED }, /* LEFT CURLY BRACKET MID # braceleftmid (CUS) */
1530 { 0xF8F3, 0xEE }, /* LEFT CURLY BRACKET BOTTOM # braceleftbt (CUS) */
1531 { 0xF8F4, 0xEF }, /* CURLY BRACKET EXTENDER # braceex (CUS) */
1532 { 0xF8F5, 0xF4 }, /* INTEGRAL EXTENDER # integralex (CUS) */
1533 { 0xF8F6, 0xF6 }, /* RIGHT PAREN TOP # parenrighttp (CUS) */
1534 { 0xF8F7, 0xF7 }, /* RIGHT PAREN EXTENDER # parenrightex (CUS) */
1535 { 0xF8F8, 0xF8 }, /* RIGHT PAREN BOTTOM # parenrightbt (CUS) */
1536 { 0xF8F9, 0xF9 }, /* RIGHT SQUARE BRACKET TOP # bracketrighttp (CUS) */
1537 { 0xF8FA, 0xFA }, /* RIGHT SQUARE BRACKET EXTENDER # bracketrightex (CUS) */
1538 { 0xF8FB, 0xFB }, /* RIGHT SQUARE BRACKET BOTTOM # bracketrightbt (CUS) */
1539 { 0xF8FC, 0xFC }, /* RIGHT CURLY BRACKET TOP # bracerighttp (CUS) */
1540 { 0xF8FD, 0xFD }, /* RIGHT CURLY BRACKET MID # bracerightmid (CUS) */
1541 { 0xF8FE, 0xFE }, /* RIGHT CURLY BRACKET BOTTOM # bracerightbt (CUS) */
1542 };
1543
1544 static const FcCharMap AdobeSymbol = {
1545 AdobeSymbolEnt,
1546 sizeof (AdobeSymbolEnt) / sizeof (AdobeSymbolEnt[0]),
1547 };
1548
1549 static const FcFontDecode fcFontDecoders[] = {
1550 { ft_encoding_unicode, 0, (1 << 21) - 1 },
1551 { ft_encoding_symbol, &AdobeSymbol, (1 << 16) - 1 },
1552 { ft_encoding_apple_roman, &AppleRoman, (1 << 16) - 1 },
1553 };
1554
1555 #define NUM_DECODE (sizeof (fcFontDecoders) / sizeof (fcFontDecoders[0]))
1556
1557 FcChar32
1558 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map)
1559 {
1560 int low, high, mid;
1561 FcChar16 bmp;
1562
1563 low = 0;
1564 high = map->nent - 1;
1565 if (ucs4 < map->ent[low].bmp || map->ent[high].bmp < ucs4)
1566 return ~0;
1567 while (low <= high)
1568 {
1569 mid = (high + low) >> 1;
1570 bmp = map->ent[mid].bmp;
1571 if (ucs4 == bmp)
1572 return (FT_ULong) map->ent[mid].encode;
1573 if (ucs4 < bmp)
1574 high = mid - 1;
1575 else
1576 low = mid + 1;
1577 }
1578 return ~0;
1579 }
1580
1581 FcChar32
1582 FcFreeTypePrivateToUcs4 (FcChar32 private, const FcCharMap *map)
1583 {
1584 int i;
1585
1586 for (i = 0; i < map->nent; i++)
1587 if (map->ent[i].encode == private)
1588 return (FcChar32) map->ent[i].bmp;
1589 return ~0;
1590 }
1591
1592 const FcCharMap *
1593 FcFreeTypeGetPrivateMap (FT_Encoding encoding)
1594 {
1595 int i;
1596
1597 for (i = 0; i < NUM_DECODE; i++)
1598 if (fcFontDecoders[i].encoding == encoding)
1599 return fcFontDecoders[i].map;
1600 return 0;
1601 }
1602
1603 #include "../fc-glyphname/fcglyphname.h"
1604
1605 static FcChar32
1606 FcHashGlyphName (const FcChar8 *name)
1607 {
1608 FcChar32 h = 0;
1609 FcChar8 c;
1610
1611 while ((c = *name++))
1612 {
1613 h = ((h << 1) | (h >> 31)) ^ c;
1614 }
1615 return h;
1616 }
1617
1618 #if HAVE_FT_HAS_PS_GLYPH_NAMES
1619 /*
1620 * Use Type1 glyph names for fonts which have reliable names
1621 * and which export an Adobe Custom mapping
1622 */
1623 static FcBool
1624 FcFreeTypeUseNames (FT_Face face)
1625 {
1626 FT_Int map;
1627
1628 if (!FT_Has_PS_Glyph_Names (face))
1629 return FcFalse;
1630 for (map = 0; map < face->num_charmaps; map++)
1631 if (face->charmaps[map]->encoding == ft_encoding_adobe_custom)
1632 return FcTrue;
1633 return FcFalse;
1634 }
1635
1636 static FcChar8 *
1637 FcUcs4ToGlyphName (FcChar32 ucs4)
1638 {
1639 int i = (int) (ucs4 % FC_GLYPHNAME_HASH);
1640 int r = 0;
1641 FcGlyphName *gn;
1642
1643 while ((gn = ucs_to_name[i]))
1644 {
1645 if (gn->ucs == ucs4)
1646 return gn->name;
1647 if (!r)
1648 {
1649 r = (int) (ucs4 % FC_GLYPHNAME_REHASH);
1650 if (!r)
1651 r = 1;
1652 }
1653 i += r;
1654 if (i >= FC_GLYPHNAME_HASH)
1655 i -= FC_GLYPHNAME_HASH;
1656 }
1657 return 0;
1658 }
1659
1660 static FcChar32
1661 FcGlyphNameToUcs4 (FcChar8 *name)
1662 {
1663 FcChar32 h = FcHashGlyphName (name);
1664 int i = (int) (h % FC_GLYPHNAME_HASH);
1665 int r = 0;
1666 FcGlyphName *gn;
1667
1668 while ((gn = name_to_ucs[i]))
1669 {
1670 if (!strcmp ((char *) name, (char *) gn->name))
1671 return gn->ucs;
1672 if (!r)
1673 {
1674 r = (int) (h % FC_GLYPHNAME_REHASH);
1675 if (!r)
1676 r = 1;
1677 }
1678 i += r;
1679 if (i >= FC_GLYPHNAME_HASH)
1680 i -= FC_GLYPHNAME_HASH;
1681 }
1682 return 0xffff;
1683 }
1684
1685 /*
1686 * Search through a font for a glyph by name. This is
1687 * currently a linear search as there doesn't appear to be
1688 * any defined order within the font
1689 */
1690 static FT_UInt
1691 FcFreeTypeGlyphNameIndex (FT_Face face, FcChar8 *name)
1692 {
1693 FT_UInt gindex;
1694 FcChar8 name_buf[FC_GLYPHNAME_MAXLEN + 2];
1695
1696 for (gindex = 0; gindex < face->num_glyphs; gindex++)
1697 {
1698 if (FT_Get_Glyph_Name (face, gindex, name_buf, FC_GLYPHNAME_MAXLEN+1) == 0)
1699 if (!strcmp ((char *) name, (char *) name_buf))
1700 return gindex;
1701 }
1702 return 0;
1703 }
1704 #endif
1705
1706 /*
1707 * Map a UCS4 glyph to a glyph index. Use all available encoding
1708 * tables to try and find one that works. This information is expected
1709 * to be cached by higher levels, so performance isn't critical
1710 */
1711
1712 FT_UInt
1713 FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4)
1714 {
1715 int initial, offset, decode;
1716 FT_UInt glyphindex;
1717 FcChar32 charcode;
1718
1719 initial = 0;
1720 /*
1721 * Find the current encoding
1722 */
1723 if (face->charmap)
1724 {
1725 for (; initial < NUM_DECODE; initial++)
1726 if (fcFontDecoders[initial].encoding == face->charmap->encoding)
1727 break;
1728 if (initial == NUM_DECODE)
1729 initial = 0;
1730 }
1731 /*
1732 * Check each encoding for the glyph, starting with the current one
1733 */
1734 for (offset = 0; offset < NUM_DECODE; offset++)
1735 {
1736 decode = (initial + offset) % NUM_DECODE;
1737 if (!face->charmap || face->charmap->encoding != fcFontDecoders[decode].encoding)
1738 if (FT_Select_Charmap (face, fcFontDecoders[decode].encoding) != 0)
1739 continue;
1740 if (fcFontDecoders[decode].map)
1741 {
1742 charcode = FcFreeTypeUcs4ToPrivate (ucs4, fcFontDecoders[decode].map);
1743 if (charcode == ~0)
1744 continue;
1745 }
1746 else
1747 charcode = ucs4;
1748 glyphindex = FT_Get_Char_Index (face, (FT_ULong) charcode);
1749 if (glyphindex)
1750 return glyphindex;
1751 }
1752 #if HAVE_FT_HAS_PS_GLYPH_NAMES
1753 /*
1754 * Check postscript name table if present
1755 */
1756 if (FcFreeTypeUseNames (face))
1757 {
1758 FcChar8 *name = FcUcs4ToGlyphName (ucs4);
1759 if (name)
1760 {
1761 glyphindex = FcFreeTypeGlyphNameIndex (face, name);
1762 if (glyphindex)
1763 return glyphindex;
1764 }
1765 }
1766 #endif
1767 return 0;
1768 }
1769
1770 static FcBool
1771 FcFreeTypeCheckGlyph (FT_Face face, FcChar32 ucs4,
1772 FT_UInt glyph, FcBlanks *blanks,
1773 FT_Pos *advance)
1774 {
1775 FT_Int load_flags = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH | FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
1776 FT_GlyphSlot slot;
1777
1778 /*
1779 * For bitmap-only fonts, assume that they're OK.
1780 */
1781 if ((face->face_flags & FT_FACE_FLAG_SCALABLE) == 0)
1782 return FcTrue;
1783
1784 /*
1785 * When using scalable fonts, only report those glyphs
1786 * which can be scaled; otherwise those fonts will
1787 * only be available at some sizes, and never when
1788 * transformed. Avoid this by simply reporting bitmap-only
1789 * glyphs as missing
1790 */
1791 if (face->face_flags & FT_FACE_FLAG_SCALABLE)
1792 load_flags |= FT_LOAD_NO_BITMAP;
1793
1794 if (FT_Load_Glyph (face, glyph, load_flags))
1795 return FcFalse;
1796
1797 slot = face->glyph;
1798 if (!glyph)
1799 return FcFalse;
1800
1801 *advance = slot->metrics.horiAdvance;
1802
1803 switch (slot->format) {
1804 case ft_glyph_format_bitmap:
1805 /*
1806 * Bitmaps are assumed to be reasonable; if
1807 * this proves to be a rash assumption, this
1808 * code can be easily modified
1809 */
1810 return FcTrue;
1811 case ft_glyph_format_outline:
1812 /*
1813 * Glyphs with contours are always OK
1814 */
1815 if (slot->outline.n_contours != 0)
1816 return FcTrue;
1817 /*
1818 * Glyphs with no contours are only OK if
1819 * they're members of the Blanks set specified
1820 * in the configuration. If blanks isn't set,
1821 * then allow any glyph to be blank
1822 */
1823 if (!blanks || FcBlanksIsMember (blanks, ucs4))
1824 return FcTrue;
1825 /* fall through ... */
1826 default:
1827 break;
1828 }
1829 return FcFalse;
1830 }
1831
1832 #define APPROXIMATELY_EQUAL(x,y) (ABS ((x) - (y)) <= MAX (ABS (x), ABS (y)) / 33)
1833
1834 FcCharSet *
1835 FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
1836 {
1837 FcChar32 page, off, max, ucs4;
1838 #ifdef CHECK
1839 FcChar32 font_max = 0;
1840 #endif
1841 FcCharSet *fcs;
1842 FcCharLeaf *leaf;
1843 const FcCharMap *map;
1844 int o;
1845 int i;
1846 FT_UInt glyph;
1847 FT_Pos advance, advance_one = 0, advance_two = 0;
1848 FcBool has_advance = FcFalse, fixed_advance = FcTrue, dual_advance = FcFalse;
1849
1850 fcs = FcCharSetCreate ();
1851 if (!fcs)
1852 goto bail0;
1853
1854 #ifdef CHECK
1855 printf ("Family %s style %s\n", face->family_name, face->style_name);
1856 #endif
1857 for (o = 0; o < NUM_DECODE; o++)
1858 {
1859 if (FT_Select_Charmap (face, fcFontDecoders[o].encoding) != 0)
1860 continue;
1861 map = fcFontDecoders[o].map;
1862 if (map)
1863 {
1864 /*
1865 * Non-Unicode tables are easy; there's a list of all possible
1866 * characters
1867 */
1868 for (i = 0; i < map->nent; i++)
1869 {
1870 ucs4 = map->ent[i].bmp;
1871 glyph = FT_Get_Char_Index (face, map->ent[i].encode);
1872 if (glyph &&
1873 FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance))
1874 {
1875 if (!has_advance)
1876 {
1877 has_advance = FcTrue;
1878 advance_one = advance;
1879 }
1880 else if (!APPROXIMATELY_EQUAL (advance, advance_one))
1881 {
1882 if (fixed_advance)
1883 {
1884 dual_advance = FcTrue;
1885 fixed_advance = FcFalse;
1886 advance_two = advance;
1887 }
1888 else if (!APPROXIMATELY_EQUAL (advance, advance_two))
1889 dual_advance = FcFalse;
1890 }
1891
1892 leaf = FcCharSetFindLeafCreate (fcs, ucs4);
1893 if (!leaf)
1894 goto bail1;
1895 leaf->map[(ucs4 & 0xff) >> 5] |= (1 << (ucs4 & 0x1f));
1896 #ifdef CHECK
1897 if (ucs4 > font_max)
1898 font_max = ucs4;
1899 #endif
1900 }
1901 }
1902 }
1903 else
1904 {
1905 FT_UInt gindex;
1906
1907 max = fcFontDecoders[o].max;
1908 /*
1909 * Find the first encoded character in the font
1910 */
1911 if (FT_Get_Char_Index (face, 0))
1912 {
1913 ucs4 = 0;
1914 gindex = 1;
1915 }
1916 else
1917 {
1918 ucs4 = FT_Get_Next_Char (face, 0, &gindex);
1919 if (!ucs4)
1920 gindex = 0;
1921 }
1922
1923 while (gindex)
1924 {
1925 page = ucs4 >> 8;
1926 leaf = 0;
1927 while ((ucs4 >> 8) == page)
1928 {
1929 glyph = FT_Get_Char_Index (face, ucs4);
1930 if (glyph && FcFreeTypeCheckGlyph (face, ucs4,
1931 glyph, blanks, &advance))
1932 {
1933 if (!has_advance)
1934 {
1935 has_advance = FcTrue;
1936 advance_one = advance;
1937 }
1938 else if (!APPROXIMATELY_EQUAL (advance, advance_one))
1939 {
1940 if (fixed_advance)
1941 {
1942 dual_advance = FcTrue;
1943 fixed_advance = FcFalse;
1944 advance_two = advance;
1945 }
1946 else if (!APPROXIMATELY_EQUAL (advance, advance_two))
1947 dual_advance = FcFalse;
1948 }
1949
1950 if (!leaf)
1951 {
1952 leaf = FcCharSetFindLeafCreate (fcs, ucs4);
1953 if (!leaf)
1954 goto bail1;
1955 }
1956 off = ucs4 & 0xff;
1957 leaf->map[off >> 5] |= (1 << (off & 0x1f));
1958 #ifdef CHECK
1959 if (ucs4 > font_max)
1960 font_max = ucs4;
1961 #endif
1962 }
1963 ucs4++;
1964 }
1965 ucs4 = FT_Get_Next_Char (face, ucs4 - 1, &gindex);
1966 if (!ucs4)
1967 gindex = 0;
1968 }
1969 #ifdef CHECK
1970 for (ucs4 = 0; ucs4 < 0x10000; ucs4++)
1971 {
1972 FcBool FT_Has, FC_Has;
1973
1974 FT_Has = FT_Get_Char_Index (face, ucs4) != 0;
1975 FC_Has = FcCharSetHasChar (fcs, ucs4);
1976 if (FT_Has != FC_Has)
1977 {
1978 printf ("0x%08x FT says %d FC says %d\n", ucs4, FT_Has, FC_Has);
1979 }
1980 }
1981 #endif
1982 }
1983 }
1984 #if HAVE_FT_HAS_PS_GLYPH_NAMES
1985 /*
1986 * Add mapping from PS glyph names if available
1987 */
1988 if (FcFreeTypeUseNames (face))
1989 {
1990 FcChar8 name_buf[FC_GLYPHNAME_MAXLEN + 2];
1991
1992 for (glyph = 0; glyph < face->num_glyphs; glyph++)
1993 {
1994 if (FT_Get_Glyph_Name (face, glyph, name_buf, FC_GLYPHNAME_MAXLEN+1) == 0)
1995 {
1996 ucs4 = FcGlyphNameToUcs4 (name_buf);
1997 if (ucs4 != 0xffff &&
1998 FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance))
1999 {
2000 if (!has_advance)
2001 {
2002 has_advance = FcTrue;
2003 advance_one = advance;
2004 }
2005 else if (!APPROXIMATELY_EQUAL (advance, advance_one))
2006 {
2007 if (fixed_advance)
2008 {
2009 dual_advance = FcTrue;
2010 fixed_advance = FcFalse;
2011 advance_two = advance;
2012 }
2013 else if (!APPROXIMATELY_EQUAL (advance, advance_two))
2014 dual_advance = FcFalse;
2015 }
2016 leaf = FcCharSetFindLeafCreate (fcs, ucs4);
2017 if (!leaf)
2018 goto bail1;
2019 leaf->map[(ucs4 & 0xff) >> 5] |= (1 << (ucs4 & 0x1f));
2020 #ifdef CHECK
2021 if (ucs4 > font_max)
2022 font_max = ucs4;
2023 #endif
2024 }
2025 }
2026 }
2027 }
2028 #endif
2029 #ifdef CHECK
2030 printf ("%d glyphs %d encoded\n", (int) face->num_glyphs, FcCharSetCount (fcs));
2031 for (ucs4 = 0; ucs4 <= font_max; ucs4++)
2032 {
2033 FcBool has_char = (glyph = FcFreeTypeCharIndex (face, ucs4)) != 0;
2034 FcBool has_bit = FcCharSetHasChar (fcs, ucs4);
2035
2036 if (has_char && !has_bit)
2037 {
2038 if (!FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance))
2039 printf ("Bitmap missing broken char 0x%x\n", ucs4);
2040 else
2041 printf ("Bitmap missing char 0x%x\n", ucs4);
2042 }
2043 else if (!has_char && has_bit)
2044 printf ("Bitmap extra char 0x%x\n", ucs4);
2045 }
2046 #endif
2047 if (fixed_advance)
2048 *spacing = FC_MONO;
2049 else if (dual_advance && APPROXIMATELY_EQUAL (2 * MIN (advance_one, advance_two), MAX (advance_one, advance_two)))
2050 *spacing = FC_DUAL;
2051 else
2052 *spacing = FC_PROPORTIONAL;
2053 return fcs;
2054 bail1:
2055 FcCharSetDestroy (fcs);
2056 bail0:
2057 return 0;
2058 }
2059
2060 FcCharSet *
2061 FcFreeTypeCharSet (FT_Face face, FcBlanks *blanks)
2062 {
2063 int spacing;
2064
2065 return FcFreeTypeCharSetAndSpacing (face, blanks, &spacing);
2066 }