1 /* ftfont.c -- FreeType font driver.
2 Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
3 Copyright (C) 2006, 2007, 2008, 2009
4 National Institute of Advanced Industrial Science and Technology (AIST)
5 Registration Number H13PRO009
7 This file is part of GNU Emacs.
9 GNU Emacs is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 GNU Emacs is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25 #include <fontconfig/fontconfig.h>
26 #include <fontconfig/fcfreetype.h>
29 #include "dispextern.h"
31 #include "blockinput.h"
32 #include "character.h"
35 #include "composite.h"
40 /* Symbolic type of this font-driver. */
41 Lisp_Object Qfreetype
;
43 /* Fontconfig's generic families and their aliases. */
44 static Lisp_Object Qmonospace
, Qsans_serif
, Qserif
, Qmono
, Qsans
, Qsans__serif
;
46 /* Special ADSTYLE properties to avoid fonts used for Latin characters. */
49 /* Flag to tell if FcInit is already called or not. */
50 static int fc_initialized
;
52 /* Handle to a FreeType library instance. */
53 static FT_Library ft_library
;
55 /* Cache for FreeType fonts. */
56 static Lisp_Object freetype_font_cache
;
58 /* Cache for FT_Face and FcCharSet. */
59 static Lisp_Object ft_face_cache
;
61 /* The actual structure for FreeType font that can be casted to struct
68 /* The following four members must be here in this order to be
69 compatible with struct xftfont_info (in xftfont.c). */
70 int maybe_otf
; /* Flag to tell if this may be OTF or not. */
72 #endif /* HAVE_LIBOTF */
79 FTFONT_CACHE_FOR_FACE
,
80 FTFONT_CACHE_FOR_CHARSET
,
81 FTFONT_CACHE_FOR_ENTITY
84 static Lisp_Object ftfont_pattern_entity
P_ ((FcPattern
*, Lisp_Object
));
86 static Lisp_Object ftfont_resolve_generic_family
P_ ((Lisp_Object
,
88 static Lisp_Object ftfont_lookup_cache
P_ ((Lisp_Object
,
89 enum ftfont_cache_for
));
91 Lisp_Object ftfont_font_format
P_ ((FcPattern
*, Lisp_Object
));
93 #define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM))
99 /* characters to distinguish the charset from the others */
101 /* additional constraint by language */
104 FcCharSet
*fc_charset
;
105 } fc_charset_table
[] =
106 { { "iso8859-1", { 0x00A0, 0x00A1, 0x00B4, 0x00BC, 0x00D0 } },
107 { "iso8859-2", { 0x00A0, 0x010E }},
108 { "iso8859-3", { 0x00A0, 0x0108 }},
109 { "iso8859-4", { 0x00A0, 0x00AF, 0x0128, 0x0156, 0x02C7 }},
110 { "iso8859-5", { 0x00A0, 0x0401 }},
111 { "iso8859-6", { 0x00A0, 0x060C }},
112 { "iso8859-7", { 0x00A0, 0x0384 }},
113 { "iso8859-8", { 0x00A0, 0x05D0 }},
114 { "iso8859-9", { 0x00A0, 0x00A1, 0x00BC, 0x011E }},
115 { "iso8859-10", { 0x00A0, 0x00D0, 0x0128, 0x2015 }},
116 { "iso8859-11", { 0x00A0, 0x0E01 }},
117 { "iso8859-13", { 0x00A0, 0x201C }},
118 { "iso8859-14", { 0x00A0, 0x0174 }},
119 { "iso8859-15", { 0x00A0, 0x00A1, 0x00D0, 0x0152 }},
120 { "iso8859-16", { 0x00A0, 0x0218}},
121 { "gb2312.1980-0", { 0x4E13 }, "zh-cn"},
122 { "big5-0", { 0xF6B1 }, "zh-tw" },
123 { "jisx0208.1983-0", { 0x4E55 }, "ja"},
124 { "ksc5601.1985-0", { 0xAC00 }, "ko"},
125 { "cns11643.1992-1", { 0xFE32 }, "zh-tw"},
126 { "cns11643.1992-2", { 0x4E33, 0x7934 }},
127 { "cns11643.1992-3", { 0x201A9 }},
128 { "cns11643.1992-4", { 0x20057 }},
129 { "cns11643.1992-5", { 0x20000 }},
130 { "cns11643.1992-6", { 0x20003 }},
131 { "cns11643.1992-7", { 0x20055 }},
132 { "gbk-0", { 0x4E06 }, "zh-cn"},
133 { "jisx0212.1990-0", { 0x4E44 }},
134 { "jisx0213.2000-1", { 0xFA10 }, "ja"},
135 { "jisx0213.2000-2", { 0xFA49 }},
136 { "jisx0213.2004-1", { 0x20B9F }},
137 { "viscii1.1-1", { 0x1EA0, 0x1EAE, 0x1ED2 }, "vi"},
138 { "tis620.2529-1", { 0x0E01 }, "th"},
139 { "windows-1251", { 0x0401, 0x0490 }, "ru"},
140 { "koi8-r", { 0x0401, 0x2219 }, "ru"},
141 { "mulelao-1", { 0x0E81 }, "lo"},
142 { "unicode-sip", { 0x20000 }},
146 extern Lisp_Object Qc
, Qm
, Qp
, Qd
;
148 /* Dirty hack for handing ADSTYLE property.
150 Fontconfig (actually the underlying FreeType) gives such ADSTYLE
151 font property of PCF/BDF fonts in FC_STYLE. And, "Bold",
152 "Oblique", "Italic", or any non-normal SWIDTH property names
153 (e.g. SemiCondensed) are appended. In addition, if there's no
154 ADSTYLE property nor non-normal WEIGHT/SLANT/SWIDTH properties,
155 "Regular" is used for FC_STYLE (see the function
156 pcf_interpret_style in src/pcf/pcfread.c of FreeType).
158 Unfortunately this behavior is not documented, so the following
159 code may fail if FreeType changes the behavior in the future. */
162 get_adstyle_property (FcPattern
*p
)
167 if (FcPatternGetString (p
, FC_STYLE
, 0, (FcChar8
**) &str
) != FcResultMatch
)
169 for (end
= str
; *end
&& *end
!= ' '; end
++);
172 char *p
= alloca (end
- str
+ 1);
173 memcpy (p
, str
, end
- str
);
175 end
= p
+ (end
- str
);
178 if (xstrcasecmp (str
, "Regular") == 0
179 || xstrcasecmp (str
, "Bold") == 0
180 || xstrcasecmp (str
, "Oblique") == 0
181 || xstrcasecmp (str
, "Italic") == 0)
183 adstyle
= font_intern_prop (str
, end
- str
, 0);
184 if (font_style_to_value (FONT_WIDTH_INDEX
, adstyle
, 0) >= 0)
190 ftfont_pattern_entity (p
, extra
)
194 Lisp_Object key
, cache
, entity
;
201 if (FcPatternGetString (p
, FC_FILE
, 0, (FcChar8
**) &file
) != FcResultMatch
)
203 if (FcPatternGetInteger (p
, FC_INDEX
, 0, &index
) != FcResultMatch
)
206 key
= Fcons (make_unibyte_string ((char *) file
, strlen ((char *) file
)),
207 make_number (index
));
208 cache
= ftfont_lookup_cache (key
, FTFONT_CACHE_FOR_ENTITY
);
209 entity
= XCAR (cache
);
212 Lisp_Object val
= font_make_entity ();
215 for (i
= 0; i
< FONT_OBJLIST_INDEX
; i
++)
216 ASET (val
, i
, AREF (entity
, i
));
219 entity
= font_make_entity ();
220 XSETCAR (cache
, entity
);
222 ASET (entity
, FONT_TYPE_INDEX
, Qfreetype
);
223 ASET (entity
, FONT_REGISTRY_INDEX
, Qiso10646_1
);
225 if (FcPatternGetString (p
, FC_FOUNDRY
, 0, (FcChar8
**) &str
) == FcResultMatch
)
226 ASET (entity
, FONT_FOUNDRY_INDEX
, font_intern_prop (str
, strlen (str
), 1));
227 if (FcPatternGetString (p
, FC_FAMILY
, 0, (FcChar8
**) &str
) == FcResultMatch
)
228 ASET (entity
, FONT_FAMILY_INDEX
, font_intern_prop (str
, strlen (str
), 1));
229 if (FcPatternGetInteger (p
, FC_WEIGHT
, 0, &numeric
) == FcResultMatch
)
231 if (numeric
>= FC_WEIGHT_REGULAR
&& numeric
< FC_WEIGHT_MEDIUM
)
232 numeric
= FC_WEIGHT_MEDIUM
;
233 FONT_SET_STYLE (entity
, FONT_WEIGHT_INDEX
, make_number (numeric
));
235 if (FcPatternGetInteger (p
, FC_SLANT
, 0, &numeric
) == FcResultMatch
)
238 FONT_SET_STYLE (entity
, FONT_SLANT_INDEX
, make_number (numeric
));
240 if (FcPatternGetInteger (p
, FC_WIDTH
, 0, &numeric
) == FcResultMatch
)
242 FONT_SET_STYLE (entity
, FONT_WIDTH_INDEX
, make_number (numeric
));
244 if (FcPatternGetDouble (p
, FC_PIXEL_SIZE
, 0, &dbl
) == FcResultMatch
)
246 ASET (entity
, FONT_SIZE_INDEX
, make_number (dbl
));
249 ASET (entity
, FONT_SIZE_INDEX
, make_number (0));
250 if (FcPatternGetInteger (p
, FC_SPACING
, 0, &numeric
) == FcResultMatch
)
251 ASET (entity
, FONT_SPACING_INDEX
, make_number (numeric
));
252 if (FcPatternGetDouble (p
, FC_DPI
, 0, &dbl
) == FcResultMatch
)
255 ASET (entity
, FONT_DPI_INDEX
, make_number (dpi
));
257 if (FcPatternGetBool (p
, FC_SCALABLE
, 0, &b
) == FcResultMatch
260 ASET (entity
, FONT_SIZE_INDEX
, make_number (0));
261 ASET (entity
, FONT_AVGWIDTH_INDEX
, make_number (0));
265 /* As this font is not scalable, parhaps this is a BDF or PCF
269 ASET (entity
, FONT_ADSTYLE_INDEX
, get_adstyle_property (p
));
270 if ((ft_library
|| FT_Init_FreeType (&ft_library
) == 0)
271 && FT_New_Face (ft_library
, file
, index
, &ft_face
) == 0)
275 if (FT_Get_BDF_Property (ft_face
, "AVERAGE_WIDTH", &rec
) == 0
276 && rec
.type
== BDF_PROPERTY_TYPE_INTEGER
)
277 ASET (entity
, FONT_AVGWIDTH_INDEX
, make_number (rec
.u
.integer
));
278 FT_Done_Face (ft_face
);
282 ASET (entity
, FONT_EXTRA_INDEX
, Fcopy_sequence (extra
));
283 font_put_extra (entity
, QCfont_entity
, key
);
288 static Lisp_Object ftfont_generic_family_list
;
291 ftfont_resolve_generic_family (family
, pattern
)
300 family
= Fintern (Fdowncase (SYMBOL_NAME (family
)), Qnil
);
301 if (EQ (family
, Qmono
))
303 else if (EQ (family
, Qsans
) || EQ (family
, Qsans__serif
))
304 family
= Qsans_serif
;
305 slot
= assq_no_quit (family
, ftfont_generic_family_list
);
308 if (! EQ (XCDR (slot
), Qt
))
310 pattern
= FcPatternDuplicate (pattern
);
313 FcPatternDel (pattern
, FC_FOUNDRY
);
314 FcPatternDel (pattern
, FC_FAMILY
);
315 FcPatternAddString (pattern
, FC_FAMILY
, SYMBOL_FcChar8 (family
));
316 if (FcPatternGetLangSet (pattern
, FC_LANG
, 0, &langset
) != FcResultMatch
)
318 /* This is to avoid the effect of locale. */
319 langset
= FcLangSetCreate ();
320 FcLangSetAdd (langset
, "en");
321 FcPatternAddLangSet (pattern
, FC_LANG
, langset
);
322 FcLangSetDestroy (langset
);
324 FcConfigSubstitute (NULL
, pattern
, FcMatchPattern
);
325 FcDefaultSubstitute (pattern
);
326 match
= FcFontMatch (NULL
, pattern
, &result
);
331 if (FcPatternGetString (match
, FC_FAMILY
, 0, &fam
) == FcResultMatch
)
332 family
= intern ((char *) fam
);
336 XSETCDR (slot
, family
);
337 if (match
) FcPatternDestroy (match
);
339 if (pattern
) FcPatternDestroy (pattern
);
343 struct ftfont_cache_data
346 FcCharSet
*fc_charset
;
350 ftfont_lookup_cache (key
, cache_for
)
352 enum ftfont_cache_for cache_for
;
354 Lisp_Object cache
, val
, entity
;
355 struct ftfont_cache_data
*cache_data
;
357 if (FONT_ENTITY_P (key
))
360 val
= assq_no_quit (QCfont_entity
, AREF (entity
, FONT_EXTRA_INDEX
));
361 xassert (CONSP (val
));
367 if (NILP (ft_face_cache
))
370 cache
= Fgethash (key
, ft_face_cache
, Qnil
);
373 if (NILP (ft_face_cache
))
379 ft_face_cache
= Fmake_hash_table (2, args
);
381 cache_data
= xmalloc (sizeof (struct ftfont_cache_data
));
382 cache_data
->ft_face
= NULL
;
383 cache_data
->fc_charset
= NULL
;
384 val
= make_save_value (NULL
, 0);
385 XSAVE_VALUE (val
)->integer
= 0;
386 XSAVE_VALUE (val
)->pointer
= cache_data
;
387 cache
= Fcons (Qnil
, val
);
388 Fputhash (key
, cache
, ft_face_cache
);
393 cache_data
= XSAVE_VALUE (val
)->pointer
;
396 if (cache_for
== FTFONT_CACHE_FOR_ENTITY
)
399 if (cache_for
== FTFONT_CACHE_FOR_FACE
400 ? ! cache_data
->ft_face
: ! cache_data
->fc_charset
)
402 char *filename
= (char *) SDATA (XCAR (key
));
403 int index
= XINT (XCDR (key
));
405 if (cache_for
== FTFONT_CACHE_FOR_FACE
)
408 && FT_Init_FreeType (&ft_library
) != 0)
410 if (FT_New_Face (ft_library
, filename
, index
, &cache_data
->ft_face
)
416 FcPattern
*pat
= NULL
;
417 FcFontSet
*fontset
= NULL
;
418 FcObjectSet
*objset
= NULL
;
419 FcCharSet
*charset
= NULL
;
421 pat
= FcPatternBuild (0, FC_FILE
, FcTypeString
, (FcChar8
*) filename
,
422 FC_INDEX
, FcTypeInteger
, index
, NULL
);
425 objset
= FcObjectSetBuild (FC_CHARSET
, FC_STYLE
, NULL
);
428 fontset
= FcFontList (NULL
, pat
, objset
);
431 if (fontset
&& fontset
->nfont
> 0
432 && (FcPatternGetCharSet (fontset
->fonts
[0], FC_CHARSET
, 0,
435 cache_data
->fc_charset
= FcCharSetCopy (charset
);
437 cache_data
->fc_charset
= FcCharSetCreate ();
441 FcFontSetDestroy (fontset
);
443 FcObjectSetDestroy (objset
);
445 FcPatternDestroy (pat
);
452 ftfont_get_fc_charset (entity
)
455 Lisp_Object val
, cache
;
456 struct ftfont_cache_data
*cache_data
;
458 cache
= ftfont_lookup_cache (entity
, FTFONT_CACHE_FOR_CHARSET
);
460 cache_data
= XSAVE_VALUE (val
)->pointer
;
461 return cache_data
->fc_charset
;
466 ftfont_get_otf (ftfont_info
)
467 struct ftfont_info
*ftfont_info
;
471 if (ftfont_info
->otf
)
472 return ftfont_info
->otf
;
473 if (! ftfont_info
->maybe_otf
)
475 otf
= OTF_open_ft_face (ftfont_info
->ft_size
->face
);
476 if (! otf
|| OTF_get_table (otf
, "head") < 0)
480 ftfont_info
->maybe_otf
= 0;
483 ftfont_info
->otf
= otf
;
486 #endif /* HAVE_LIBOTF */
488 static Lisp_Object ftfont_get_cache
P_ ((FRAME_PTR
));
489 static Lisp_Object ftfont_list
P_ ((Lisp_Object
, Lisp_Object
));
490 static Lisp_Object ftfont_match
P_ ((Lisp_Object
, Lisp_Object
));
491 static Lisp_Object ftfont_list_family
P_ ((Lisp_Object
));
492 static Lisp_Object ftfont_open
P_ ((FRAME_PTR
, Lisp_Object
, int));
493 static void ftfont_close
P_ ((FRAME_PTR
, struct font
*));
494 static int ftfont_has_char
P_ ((Lisp_Object
, int));
495 static unsigned ftfont_encode_char
P_ ((struct font
*, int));
496 static int ftfont_text_extents
P_ ((struct font
*, unsigned *, int,
497 struct font_metrics
*));
498 static int ftfont_get_bitmap
P_ ((struct font
*, unsigned,
499 struct font_bitmap
*, int));
500 static int ftfont_anchor_point
P_ ((struct font
*, unsigned, int,
502 static Lisp_Object ftfont_otf_capability
P_ ((struct font
*));
503 static Lisp_Object ftfont_shape
P_ ((Lisp_Object
));
505 #ifdef HAVE_OTF_GET_VARIATION_GLYPHS
506 static int ftfont_variation_glyphs
P_ ((struct font
*, int c
,
507 unsigned variations
[256]));
508 #endif /* HAVE_OTF_GET_VARIATION_GLYPHS */
510 struct font_driver ftfont_driver
=
513 0, /* case insensitive */
518 NULL
, /* free_entity */
521 /* We can't draw a text without device dependent functions. */
522 NULL
, /* prepare_face */
523 NULL
, /* done_face */
527 /* We can't draw a text without device dependent functions. */
530 NULL
, /* get_bitmap */
531 NULL
, /* free_bitmap */
532 NULL
, /* get_outline */
535 ftfont_otf_capability
,
536 #else /* not HAVE_LIBOTF */
538 #endif /* not HAVE_LIBOTF */
539 NULL
, /* otf_drive */
540 NULL
, /* start_for_frame */
541 NULL
, /* end_for_frame */
542 #if defined (HAVE_M17N_FLT) && defined (HAVE_LIBOTF)
544 #else /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */
546 #endif /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */
549 #ifdef HAVE_OTF_GET_VARIATION_GLYPHS
550 ftfont_variation_glyphs
556 extern Lisp_Object QCname
;
562 return freetype_font_cache
;
566 ftfont_get_charset (registry
)
567 Lisp_Object registry
;
569 char *str
= (char *) SDATA (SYMBOL_NAME (registry
));
570 char *re
= alloca (SBYTES (SYMBOL_NAME (registry
)) * 2 + 1);
574 for (i
= j
= 0; i
< SBYTES (SYMBOL_NAME (registry
)); i
++, j
++)
578 else if (str
[i
] == '*')
585 regexp
= make_unibyte_string (re
, j
);
586 for (i
= 0; fc_charset_table
[i
].name
; i
++)
587 if (fast_c_string_match_ignore_case (regexp
, fc_charset_table
[i
].name
) >= 0)
589 if (! fc_charset_table
[i
].name
)
591 if (! fc_charset_table
[i
].fc_charset
)
593 FcCharSet
*charset
= FcCharSetCreate ();
594 int *uniquifier
= fc_charset_table
[i
].uniquifier
;
598 for (j
= 0; uniquifier
[j
]; j
++)
599 if (! FcCharSetAddChar (charset
, uniquifier
[j
]))
601 FcCharSetDestroy (charset
);
604 fc_charset_table
[i
].fc_charset
= charset
;
612 unsigned int script_tag
, langsys_tag
;
614 unsigned int *features
[2];
617 #define OTF_SYM_TAG(SYM, TAG) \
619 unsigned char *p = SDATA (SYMBOL_NAME (SYM)); \
620 TAG = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; \
623 #define OTF_TAG_STR(TAG, P) \
625 (P)[0] = (char) (TAG >> 24); \
626 (P)[1] = (char) ((TAG >> 16) & 0xFF); \
627 (P)[2] = (char) ((TAG >> 8) & 0xFF); \
628 (P)[3] = (char) (TAG & 0xFF); \
632 #define OTF_TAG_SYM(SYM, TAG) \
636 OTF_TAG_STR (TAG, str); \
637 (SYM) = font_intern_prop (str, 4, 1); \
641 static struct OpenTypeSpec
*
642 ftfont_get_open_type_spec (Lisp_Object otf_spec
)
644 struct OpenTypeSpec
*spec
= malloc (sizeof (struct OpenTypeSpec
));
650 spec
->script
= XCAR (otf_spec
);
651 if (! NILP (spec
->script
))
653 OTF_SYM_TAG (spec
->script
, spec
->script_tag
);
654 val
= assq_no_quit (spec
->script
, Votf_script_alist
);
655 if (CONSP (val
) && SYMBOLP (XCDR (val
)))
656 spec
->script
= XCDR (val
);
661 spec
->script_tag
= 0x44464C54; /* "DFLT" */
662 otf_spec
= XCDR (otf_spec
);
663 val
= XCAR (otf_spec
);
665 OTF_SYM_TAG (val
, spec
->langsys_tag
);
667 spec
->langsys_tag
= 0;
668 spec
->nfeatures
[0] = spec
->nfeatures
[1] = 0;
669 for (i
= 0; i
< 2; i
++)
673 otf_spec
= XCDR (otf_spec
);
676 val
= XCAR (otf_spec
);
680 spec
->features
[i
] = malloc (sizeof (int) * XINT (len
));
681 if (! spec
->features
[i
])
683 if (i
> 0 && spec
->features
[0])
684 free (spec
->features
[0]);
688 for (j
= 0, negative
= 0; CONSP (val
); val
= XCDR (val
))
690 if (NILP (XCAR (val
)))
696 OTF_SYM_TAG (XCAR (val
), tag
);
697 spec
->features
[i
][j
++] = negative
? tag
& 0x80000000 : tag
;
700 spec
->nfeatures
[i
] = j
;
705 static FcPattern
*ftfont_spec_pattern
P_ ((Lisp_Object
, char *,
706 struct OpenTypeSpec
**));
709 ftfont_spec_pattern (spec
, otlayout
, otspec
)
712 struct OpenTypeSpec
**otspec
;
714 Lisp_Object tmp
, extra
;
715 FcPattern
*pattern
= NULL
;
716 FcCharSet
*charset
= NULL
;
717 FcLangSet
*langset
= NULL
;
721 Lisp_Object script
= Qnil
;
722 Lisp_Object registry
;
725 if ((n
= FONT_SLANT_NUMERIC (spec
)) >= 0
727 /* Fontconfig doesn't support reverse-italic/obligue. */
730 if (INTEGERP (AREF (spec
, FONT_DPI_INDEX
)))
731 dpi
= XINT (AREF (spec
, FONT_DPI_INDEX
));
732 if (INTEGERP (AREF (spec
, FONT_AVGWIDTH_INDEX
))
733 && XINT (AREF (spec
, FONT_AVGWIDTH_INDEX
)) == 0)
736 registry
= AREF (spec
, FONT_REGISTRY_INDEX
);
738 || EQ (registry
, Qascii_0
)
739 || EQ (registry
, Qiso10646_1
)
740 || EQ (registry
, Qunicode_bmp
))
746 fc_charset_idx
= ftfont_get_charset (registry
);
747 if (fc_charset_idx
< 0)
749 charset
= fc_charset_table
[fc_charset_idx
].fc_charset
;
750 lang
= (FcChar8
*) fc_charset_table
[fc_charset_idx
].lang
;
753 langset
= FcLangSetCreate ();
756 FcLangSetAdd (langset
, lang
);
761 for (extra
= AREF (spec
, FONT_EXTRA_INDEX
);
762 CONSP (extra
); extra
= XCDR (extra
))
764 Lisp_Object key
, val
;
766 key
= XCAR (XCAR (extra
)), val
= XCDR (XCAR (extra
));
769 else if (EQ (key
, QClang
))
772 langset
= FcLangSetCreate ();
777 if (! FcLangSetAdd (langset
, SYMBOL_FcChar8 (val
)))
781 for (; CONSP (val
); val
= XCDR (val
))
782 if (SYMBOLP (XCAR (val
))
783 && ! FcLangSetAdd (langset
, SYMBOL_FcChar8 (XCAR (val
))))
786 else if (EQ (key
, QCotf
))
788 *otspec
= ftfont_get_open_type_spec (val
);
791 strcat (otlayout
, "otlayout:");
792 OTF_TAG_STR ((*otspec
)->script_tag
, otlayout
+ 9);
793 script
= (*otspec
)->script
;
795 else if (EQ (key
, QCscript
))
797 else if (EQ (key
, QCscalable
))
798 scalable
= ! NILP (val
);
801 if (! NILP (script
) && ! charset
)
803 Lisp_Object chars
= assq_no_quit (script
, Vscript_representative_chars
);
805 if (CONSP (chars
) && CONSP (CDR (chars
)))
807 charset
= FcCharSetCreate ();
810 for (chars
= XCDR (chars
); CONSP (chars
); chars
= XCDR (chars
))
811 if (CHARACTERP (XCAR (chars
))
812 && ! FcCharSetAddChar (charset
, XUINT (XCAR (chars
))))
817 pattern
= FcPatternCreate ();
820 tmp
= AREF (spec
, FONT_FOUNDRY_INDEX
);
822 && ! FcPatternAddString (pattern
, FC_FOUNDRY
, SYMBOL_FcChar8 (tmp
)))
824 tmp
= AREF (spec
, FONT_FAMILY_INDEX
);
826 && ! FcPatternAddString (pattern
, FC_FAMILY
, SYMBOL_FcChar8 (tmp
)))
829 && ! FcPatternAddCharSet (pattern
, FC_CHARSET
, charset
))
832 && ! FcPatternAddLangSet (pattern
, FC_LANG
, langset
))
835 && ! FcPatternAddDouble (pattern
, FC_DPI
, dpi
))
838 && ! FcPatternAddBool (pattern
, FC_SCALABLE
, scalable
? FcTrue
: FcFalse
))
844 /* We come here because of unexpected error in fontconfig API call
845 (usually insufficient memory). */
848 FcPatternDestroy (pattern
);
853 if ((*otspec
)->nfeatures
[0] > 0)
854 free ((*otspec
)->features
[0]);
855 if ((*otspec
)->nfeatures
[1] > 0)
856 free ((*otspec
)->features
[1]);
862 if (langset
) FcLangSetDestroy (langset
);
863 if (charset
&& fc_charset_idx
< 0) FcCharSetDestroy (charset
);
868 ftfont_list (frame
, spec
)
869 Lisp_Object frame
, spec
;
871 Lisp_Object val
= Qnil
, family
, adstyle
;
874 FcFontSet
*fontset
= NULL
;
875 FcObjectSet
*objset
= NULL
;
877 Lisp_Object chars
= Qnil
;
879 char otlayout
[15]; /* For "otlayout:XXXX" */
880 struct OpenTypeSpec
*otspec
= NULL
;
883 if (! fc_initialized
)
889 pattern
= ftfont_spec_pattern (spec
, otlayout
, &otspec
);
892 if (FcPatternGetCharSet (pattern
, FC_CHARSET
, 0, &charset
) != FcResultMatch
)
894 val
= assq_no_quit (QCscript
, AREF (spec
, FONT_EXTRA_INDEX
));
897 val
= assq_no_quit (XCDR (val
), Vscript_representative_chars
);
898 if (CONSP (val
) && VECTORP (XCDR (val
)))
903 if (INTEGERP (AREF (spec
, FONT_SPACING_INDEX
)))
904 spacing
= XINT (AREF (spec
, FONT_SPACING_INDEX
));
905 family
= AREF (spec
, FONT_FAMILY_INDEX
);
908 Lisp_Object resolved
;
910 resolved
= ftfont_resolve_generic_family (family
, pattern
);
911 if (! NILP (resolved
))
913 FcPatternDel (pattern
, FC_FAMILY
);
914 if (! FcPatternAddString (pattern
, FC_FAMILY
,
915 SYMBOL_FcChar8 (resolved
)))
919 adstyle
= AREF (spec
, FONT_ADSTYLE_INDEX
);
920 if (! NILP (adstyle
) && SBYTES (SYMBOL_NAME (adstyle
)) == 0)
922 objset
= FcObjectSetBuild (FC_FOUNDRY
, FC_FAMILY
, FC_WEIGHT
, FC_SLANT
,
923 FC_WIDTH
, FC_PIXEL_SIZE
, FC_SPACING
, FC_SCALABLE
,
924 FC_STYLE
, FC_FILE
, FC_INDEX
,
927 #endif /* FC_CAPABILITY */
935 FcObjectSetAdd (objset
, FC_CHARSET
);
937 fontset
= FcFontList (NULL
, pattern
, objset
);
938 if (! fontset
|| fontset
->nfont
== 0)
941 /* Need fix because this finds any fonts. */
942 if (fontset
->nfont
== 0 && ! NILP (family
))
944 /* Try maching with configuration. For instance, the
945 configuration may specify "Nimbus Mono L" as an alias of
947 FcPattern
*pat
= FcPatternBuild (0, FC_FAMILY
, FcTypeString
,
948 SYMBOL_FcChar8 (family
), NULL
);
951 if (FcConfigSubstitute (NULL
, pat
, FcMatchPattern
) == FcTrue
)
954 FcPatternGetString (pat
, FC_FAMILY
, i
, &fam
) == FcResultMatch
;
957 FcPatternDel (pattern
, FC_FAMILY
);
958 FcPatternAddString (pattern
, FC_FAMILY
, fam
);
959 FcFontSetDestroy (fontset
);
960 fontset
= FcFontList (NULL
, pattern
, objset
);
961 if (fontset
&& fontset
->nfont
> 0)
967 for (i
= 0; i
< fontset
->nfont
; i
++)
975 if ((FcPatternGetInteger (fontset
->fonts
[i
], FC_SPACING
, 0, &this)
986 if (FcPatternGetString (fontset
->fonts
[i
], FC_CAPABILITY
, 0, &this)
988 || ! strstr ((char *) this, otlayout
))
991 #endif /* FC_CAPABILITY */
998 if (FcPatternGetString (fontset
->fonts
[i
], FC_FILE
, 0, &file
)
1001 otf
= OTF_open ((char *) file
);
1004 if (OTF_check_features (otf
, 1,
1005 otspec
->script_tag
, otspec
->langsys_tag
,
1006 otspec
->features
[0],
1007 otspec
->nfeatures
[0]) != 1
1008 || OTF_check_features (otf
, 0,
1009 otspec
->script_tag
, otspec
->langsys_tag
,
1010 otspec
->features
[1],
1011 otspec
->nfeatures
[1]) != 1)
1014 #endif /* HAVE_LIBOTF */
1015 if (VECTORP (chars
))
1019 if (FcPatternGetCharSet (fontset
->fonts
[i
], FC_CHARSET
, 0, &charset
)
1022 for (j
= 0; j
< ASIZE (chars
); j
++)
1023 if (NATNUMP (AREF (chars
, j
))
1024 && FcCharSetHasChar (charset
, XFASTINT (AREF (chars
, j
))))
1026 if (j
== ASIZE (chars
))
1029 if (! NILP (adstyle
))
1031 Lisp_Object this_adstyle
= get_adstyle_property (fontset
->fonts
[i
]);
1033 if (NILP (this_adstyle
)
1034 || xstrcasecmp (SDATA (SYMBOL_NAME (adstyle
)),
1035 SDATA (SYMBOL_NAME (this_adstyle
))) != 0)
1038 entity
= ftfont_pattern_entity (fontset
->fonts
[i
],
1039 AREF (spec
, FONT_EXTRA_INDEX
));
1040 if (! NILP (entity
))
1041 val
= Fcons (entity
, val
);
1043 val
= Fnreverse (val
);
1047 /* We come here because of unexpected error in fontconfig API call
1048 (usually insufficient memory). */
1052 font_add_log ("ftfont-list", spec
, val
);
1053 if (objset
) FcObjectSetDestroy (objset
);
1054 if (fontset
) FcFontSetDestroy (fontset
);
1055 if (pattern
) FcPatternDestroy (pattern
);
1060 ftfont_match (frame
, spec
)
1061 Lisp_Object frame
, spec
;
1063 Lisp_Object entity
= Qnil
;
1064 FcPattern
*pattern
, *match
= NULL
;
1066 char otlayout
[15]; /* For "otlayout:XXXX" */
1067 struct OpenTypeSpec
*otspec
= NULL
;
1069 if (! fc_initialized
)
1075 pattern
= ftfont_spec_pattern (spec
, otlayout
, &otspec
);
1079 if (INTEGERP (AREF (spec
, FONT_SIZE_INDEX
)))
1083 value
.type
= FcTypeDouble
;
1084 value
.u
.d
= XINT (AREF (spec
, FONT_SIZE_INDEX
));
1085 FcPatternAdd (pattern
, FC_PIXEL_SIZE
, value
, FcFalse
);
1087 if (FcConfigSubstitute (NULL
, pattern
, FcMatchPattern
) == FcTrue
)
1089 FcDefaultSubstitute (pattern
);
1090 match
= FcFontMatch (NULL
, pattern
, &result
);
1093 entity
= ftfont_pattern_entity (match
, AREF (spec
, FONT_EXTRA_INDEX
));
1094 FcPatternDestroy (match
);
1095 if (! NILP (AREF (spec
, FONT_FAMILY_INDEX
))
1096 && NILP (assq_no_quit (AREF (spec
, FONT_FAMILY_INDEX
),
1097 ftfont_generic_family_list
))
1098 && NILP (Fstring_equal (AREF (spec
, FONT_FAMILY_INDEX
),
1099 AREF (entity
, FONT_FAMILY_INDEX
))))
1103 FcPatternDestroy (pattern
);
1105 font_add_log ("ftfont-match", spec
, entity
);
1110 ftfont_list_family (frame
)
1113 Lisp_Object list
= Qnil
;
1114 FcPattern
*pattern
= NULL
;
1115 FcFontSet
*fontset
= NULL
;
1116 FcObjectSet
*objset
= NULL
;
1119 if (! fc_initialized
)
1125 pattern
= FcPatternCreate ();
1128 objset
= FcObjectSetBuild (FC_FAMILY
, NULL
);
1131 fontset
= FcFontList (NULL
, pattern
, objset
);
1135 for (i
= 0; i
< fontset
->nfont
; i
++)
1137 FcPattern
*pat
= fontset
->fonts
[i
];
1140 if (FcPatternGetString (pat
, FC_FAMILY
, 0, &str
) == FcResultMatch
)
1141 list
= Fcons (intern ((char *) str
), list
);
1145 if (objset
) FcObjectSetDestroy (objset
);
1146 if (fontset
) FcFontSetDestroy (fontset
);
1147 if (pattern
) FcPatternDestroy (pattern
);
1154 ftfont_open (f
, entity
, pixel_size
)
1159 struct ftfont_info
*ftfont_info
;
1161 struct ftfont_cache_data
*cache_data
;
1165 Lisp_Object val
, filename
, index
, cache
, font_object
;
1172 val
= assq_no_quit (QCfont_entity
, AREF (entity
, FONT_EXTRA_INDEX
));
1176 cache
= ftfont_lookup_cache (entity
, FTFONT_CACHE_FOR_FACE
);
1179 filename
= XCAR (val
);
1182 cache_data
= XSAVE_VALUE (XCDR (cache
))->pointer
;
1183 ft_face
= cache_data
->ft_face
;
1184 if (XSAVE_VALUE (val
)->integer
> 0)
1186 /* FT_Face in this cache is already used by the different size. */
1187 if (FT_New_Size (ft_face
, &ft_size
) != 0)
1189 if (FT_Activate_Size (ft_size
) != 0)
1191 FT_Done_Size (ft_size
);
1195 XSAVE_VALUE (val
)->integer
++;
1196 size
= XINT (AREF (entity
, FONT_SIZE_INDEX
));
1199 if (FT_Set_Pixel_Sizes (ft_face
, size
, size
) != 0)
1201 if (XSAVE_VALUE (val
)->integer
== 0)
1202 FT_Done_Face (ft_face
);
1206 font_object
= font_make_object (VECSIZE (struct ftfont_info
), entity
, size
);
1207 ASET (font_object
, FONT_TYPE_INDEX
, Qfreetype
);
1208 len
= font_unparse_xlfd (entity
, size
, name
, 256);
1210 ASET (font_object
, FONT_NAME_INDEX
, make_string (name
, len
));
1211 len
= font_unparse_fcname (entity
, size
, name
, 256);
1213 ASET (font_object
, FONT_FULLNAME_INDEX
, make_string (name
, len
));
1215 ASET (font_object
, FONT_FULLNAME_INDEX
,
1216 AREF (font_object
, FONT_NAME_INDEX
));
1217 ASET (font_object
, FONT_FILE_INDEX
, filename
);
1218 ASET (font_object
, FONT_FORMAT_INDEX
, ftfont_font_format (NULL
, filename
));
1219 font
= XFONT_OBJECT (font_object
);
1220 ftfont_info
= (struct ftfont_info
*) font
;
1221 ftfont_info
->ft_size
= ft_face
->size
;
1222 ftfont_info
->index
= XINT (index
);
1224 ftfont_info
->maybe_otf
= ft_face
->face_flags
& FT_FACE_FLAG_SFNT
;
1225 ftfont_info
->otf
= NULL
;
1226 #endif /* HAVE_LIBOTF */
1227 font
->pixel_size
= size
;
1228 font
->driver
= &ftfont_driver
;
1229 font
->encoding_charset
= font
->repertory_charset
= -1;
1231 upEM
= ft_face
->units_per_EM
;
1232 scalable
= (INTEGERP (AREF (entity
, FONT_AVGWIDTH_INDEX
))
1233 && XINT (AREF (entity
, FONT_AVGWIDTH_INDEX
)) == 0);
1236 font
->ascent
= ft_face
->ascender
* size
/ upEM
;
1237 font
->descent
= - ft_face
->descender
* size
/ upEM
;
1238 font
->height
= ft_face
->height
* size
/ upEM
;
1242 font
->ascent
= ft_face
->size
->metrics
.ascender
>> 6;
1243 font
->descent
= - ft_face
->size
->metrics
.descender
>> 6;
1244 font
->height
= ft_face
->size
->metrics
.height
>> 6;
1246 if (INTEGERP (AREF (entity
, FONT_SPACING_INDEX
)))
1247 spacing
= XINT (AREF (entity
, FONT_SPACING_INDEX
));
1249 spacing
= FC_PROPORTIONAL
;
1250 if (spacing
!= FC_PROPORTIONAL
)
1251 font
->min_width
= font
->average_width
= font
->space_width
1252 = (scalable
? ft_face
->max_advance_width
* size
/ upEM
1253 : ft_face
->size
->metrics
.max_advance
>> 6);
1258 font
->min_width
= font
->average_width
= font
->space_width
= 0;
1259 for (i
= 32, n
= 0; i
< 127; i
++)
1260 if (FT_Load_Char (ft_face
, i
, FT_LOAD_DEFAULT
) == 0)
1262 int this_width
= ft_face
->glyph
->metrics
.horiAdvance
>> 6;
1265 && (! font
->min_width
|| font
->min_width
> this_width
))
1266 font
->min_width
= this_width
;
1268 font
->space_width
= this_width
;
1269 font
->average_width
+= this_width
;
1273 font
->average_width
/= n
;
1276 font
->baseline_offset
= 0;
1277 font
->relative_compose
= 0;
1278 font
->default_ascent
= 0;
1279 font
->vertical_centering
= 0;
1282 font
->underline_position
= -ft_face
->underline_position
* size
/ upEM
;
1283 font
->underline_thickness
= ft_face
->underline_thickness
* size
/ upEM
;
1287 font
->underline_position
= -1;
1288 font
->underline_thickness
= 0;
1295 ftfont_close (f
, font
)
1299 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
1300 Lisp_Object val
, cache
;
1302 val
= Fcons (font
->props
[FONT_FILE_INDEX
], make_number (ftfont_info
->index
));
1303 cache
= ftfont_lookup_cache (val
, FTFONT_CACHE_FOR_FACE
);
1304 xassert (CONSP (cache
));
1306 (XSAVE_VALUE (val
)->integer
)--;
1307 if (XSAVE_VALUE (val
)->integer
== 0)
1309 struct ftfont_cache_data
*cache_data
= XSAVE_VALUE (val
)->pointer
;
1311 FT_Done_Face (cache_data
->ft_face
);
1313 if (ftfont_info
->otf
)
1314 OTF_close (ftfont_info
->otf
);
1316 cache_data
->ft_face
= NULL
;
1319 FT_Done_Size (ftfont_info
->ft_size
);
1323 ftfont_has_char (font
, c
)
1327 struct charset
*cs
= NULL
;
1329 if (EQ (AREF (font
, FONT_ADSTYLE_INDEX
), Qja
)
1330 && charset_jisx0208
>= 0)
1331 cs
= CHARSET_FROM_ID (charset_jisx0208
);
1332 else if (EQ (AREF (font
, FONT_ADSTYLE_INDEX
), Qko
)
1333 && charset_ksc5601
>= 0)
1334 cs
= CHARSET_FROM_ID (charset_ksc5601
);
1336 return (ENCODE_CHAR (cs
, c
) != CHARSET_INVALID_CODE (cs
));
1338 if (FONT_ENTITY_P (font
))
1340 FcCharSet
*charset
= ftfont_get_fc_charset (font
);
1342 return (FcCharSetHasChar (charset
, c
) == FcTrue
);
1346 struct ftfont_info
*ftfont_info
;
1348 ftfont_info
= (struct ftfont_info
*) XFONT_OBJECT (font
);
1349 return (FT_Get_Char_Index (ftfont_info
->ft_size
->face
, (FT_ULong
) c
)
1355 ftfont_encode_char (font
, c
)
1359 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
1360 FT_Face ft_face
= ftfont_info
->ft_size
->face
;
1361 FT_ULong charcode
= c
;
1362 FT_UInt code
= FT_Get_Char_Index (ft_face
, charcode
);
1364 return (code
> 0 ? code
: FONT_INVALID_CODE
);
1368 ftfont_text_extents (font
, code
, nglyphs
, metrics
)
1372 struct font_metrics
*metrics
;
1374 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
1375 FT_Face ft_face
= ftfont_info
->ft_size
->face
;
1379 if (ftfont_info
->ft_size
!= ft_face
->size
)
1380 FT_Activate_Size (ftfont_info
->ft_size
);
1382 bzero (metrics
, sizeof (struct font_metrics
));
1383 for (i
= 0, first
= 1; i
< nglyphs
; i
++)
1385 if (FT_Load_Glyph (ft_face
, code
[i
], FT_LOAD_DEFAULT
) == 0)
1387 FT_Glyph_Metrics
*m
= &ft_face
->glyph
->metrics
;
1393 metrics
->lbearing
= m
->horiBearingX
>> 6;
1394 metrics
->rbearing
= (m
->horiBearingX
+ m
->width
) >> 6;
1395 metrics
->ascent
= m
->horiBearingY
>> 6;
1396 metrics
->descent
= (m
->height
- m
->horiBearingY
) >> 6;
1402 if (metrics
->lbearing
> width
+ (m
->horiBearingX
>> 6))
1403 metrics
->lbearing
= width
+ (m
->horiBearingX
>> 6);
1404 if (metrics
->rbearing
1405 < width
+ ((m
->horiBearingX
+ m
->width
) >> 6))
1407 = width
+ ((m
->horiBearingX
+ m
->width
) >> 6);
1408 if (metrics
->ascent
< (m
->horiBearingY
>> 6))
1409 metrics
->ascent
= m
->horiBearingY
>> 6;
1410 if (metrics
->descent
> ((m
->height
- m
->horiBearingY
) >> 6))
1411 metrics
->descent
= (m
->height
- m
->horiBearingY
) >> 6;
1413 width
+= m
->horiAdvance
>> 6;
1417 width
+= font
->space_width
;
1421 metrics
->width
= width
;
1427 ftfont_get_bitmap (font
, code
, bitmap
, bits_per_pixel
)
1430 struct font_bitmap
*bitmap
;
1433 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
1434 FT_Face ft_face
= ftfont_info
->ft_size
->face
;
1435 FT_Int32 load_flags
= FT_LOAD_RENDER
;
1437 if (ftfont_info
->ft_size
!= ft_face
->size
)
1438 FT_Activate_Size (ftfont_info
->ft_size
);
1439 if (bits_per_pixel
== 1)
1441 #ifdef FT_LOAD_TARGET_MONO
1442 load_flags
|= FT_LOAD_TARGET_MONO
;
1444 load_flags
|= FT_LOAD_MONOCHROME
;
1447 else if (bits_per_pixel
!= 8)
1448 /* We don't support such a rendering. */
1451 if (FT_Load_Glyph (ft_face
, code
, load_flags
) != 0)
1453 bitmap
->bits_per_pixel
1454 = (ft_face
->glyph
->bitmap
.pixel_mode
== FT_PIXEL_MODE_MONO
? 1
1455 : ft_face
->glyph
->bitmap
.pixel_mode
== FT_PIXEL_MODE_GRAY
? 8
1456 : ft_face
->glyph
->bitmap
.pixel_mode
== FT_PIXEL_MODE_LCD
? 8
1457 : ft_face
->glyph
->bitmap
.pixel_mode
== FT_PIXEL_MODE_LCD_V
? 8
1459 if (bitmap
->bits_per_pixel
< 0)
1460 /* We don't suport that kind of pixel mode. */
1462 bitmap
->rows
= ft_face
->glyph
->bitmap
.rows
;
1463 bitmap
->width
= ft_face
->glyph
->bitmap
.width
;
1464 bitmap
->pitch
= ft_face
->glyph
->bitmap
.pitch
;
1465 bitmap
->buffer
= ft_face
->glyph
->bitmap
.buffer
;
1466 bitmap
->left
= ft_face
->glyph
->bitmap_left
;
1467 bitmap
->top
= ft_face
->glyph
->bitmap_top
;
1468 bitmap
->advance
= ft_face
->glyph
->metrics
.horiAdvance
>> 6;
1469 bitmap
->extra
= NULL
;
1475 ftfont_anchor_point (font
, code
, index
, x
, y
)
1481 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
1482 FT_Face ft_face
= ftfont_info
->ft_size
->face
;
1484 if (ftfont_info
->ft_size
!= ft_face
->size
)
1485 FT_Activate_Size (ftfont_info
->ft_size
);
1486 if (FT_Load_Glyph (ft_face
, code
, FT_LOAD_DEFAULT
) != 0)
1488 if (ft_face
->glyph
->format
!= FT_GLYPH_FORMAT_OUTLINE
)
1490 if (index
>= ft_face
->glyph
->outline
.n_points
)
1492 *x
= ft_face
->glyph
->outline
.points
[index
].x
;
1493 *y
= ft_face
->glyph
->outline
.points
[index
].y
;
1500 ftfont_otf_features (gsub_gpos
)
1501 OTF_GSUB_GPOS
*gsub_gpos
;
1503 Lisp_Object scripts
, langsyses
, features
, sym
;
1506 for (scripts
= Qnil
, i
= gsub_gpos
->ScriptList
.ScriptCount
- 1; i
>= 0; i
--)
1508 OTF_Script
*otf_script
= gsub_gpos
->ScriptList
.Script
+ i
;
1510 for (langsyses
= Qnil
, j
= otf_script
->LangSysCount
- 1; j
>= -1; j
--)
1512 OTF_LangSys
*otf_langsys
;
1515 otf_langsys
= otf_script
->LangSys
+ j
;
1516 else if (otf_script
->DefaultLangSysOffset
)
1517 otf_langsys
= &otf_script
->DefaultLangSys
;
1521 for (features
= Qnil
, k
= otf_langsys
->FeatureCount
- 1; k
>= 0; k
--)
1523 l
= otf_langsys
->FeatureIndex
[k
];
1524 if (l
>= gsub_gpos
->FeatureList
.FeatureCount
)
1526 OTF_TAG_SYM (sym
, gsub_gpos
->FeatureList
.Feature
[l
].FeatureTag
);
1527 features
= Fcons (sym
, features
);
1530 OTF_TAG_SYM (sym
, otf_script
->LangSysRecord
[j
].LangSysTag
);
1533 langsyses
= Fcons (Fcons (sym
, features
), langsyses
);
1536 OTF_TAG_SYM (sym
, gsub_gpos
->ScriptList
.Script
[i
].ScriptTag
);
1537 scripts
= Fcons (Fcons (sym
, langsyses
), scripts
);
1545 ftfont_otf_capability (font
)
1548 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
1549 OTF
*otf
= ftfont_get_otf (ftfont_info
);
1550 Lisp_Object gsub_gpos
;
1554 gsub_gpos
= Fcons (Qnil
, Qnil
);
1555 if (OTF_get_table (otf
, "GSUB") == 0
1556 && otf
->gsub
->FeatureList
.FeatureCount
> 0)
1557 XSETCAR (gsub_gpos
, ftfont_otf_features (otf
->gsub
));
1558 if (OTF_get_table (otf
, "GPOS") == 0
1559 && otf
->gpos
->FeatureList
.FeatureCount
> 0)
1560 XSETCDR (gsub_gpos
, ftfont_otf_features (otf
->gpos
));
1564 #ifdef HAVE_M17N_FLT
1575 ftfont_get_glyph_id (font
, gstring
, from
, to
)
1577 MFLTGlyphString
*gstring
;
1580 struct MFLTFontFT
*flt_font_ft
= (struct MFLTFontFT
*) font
;
1581 FT_Face ft_face
= flt_font_ft
->ft_face
;
1584 for (g
= gstring
->glyphs
+ from
; from
< to
; g
++, from
++)
1587 FT_UInt code
= FT_Get_Char_Index (ft_face
, g
->code
);
1589 g
->code
= code
> 0 ? code
: FONT_INVALID_CODE
;
1596 ftfont_get_metrics (font
, gstring
, from
, to
)
1598 MFLTGlyphString
*gstring
;
1601 struct MFLTFontFT
*flt_font_ft
= (struct MFLTFontFT
*) font
;
1602 FT_Face ft_face
= flt_font_ft
->ft_face
;
1605 for (g
= gstring
->glyphs
+ from
; from
< to
; g
++, from
++)
1608 if (g
->code
!= FONT_INVALID_CODE
)
1610 FT_Glyph_Metrics
*m
;
1612 if (FT_Load_Glyph (ft_face
, g
->code
, FT_LOAD_DEFAULT
) != 0)
1614 m
= &ft_face
->glyph
->metrics
;
1616 g
->lbearing
= m
->horiBearingX
;
1617 g
->rbearing
= m
->horiBearingX
+ m
->width
;
1618 g
->ascent
= m
->horiBearingY
;
1619 g
->descent
= m
->height
- m
->horiBearingY
;
1620 g
->xadv
= m
->horiAdvance
;
1625 g
->rbearing
= g
->xadv
= flt_font_ft
->font
->space_width
<< 6;
1626 g
->ascent
= flt_font_ft
->font
->ascent
<< 6;
1627 g
->descent
= flt_font_ft
->font
->descent
<< 6;
1636 ftfont_check_otf (MFLTFont
*font
, MFLTOtfSpec
*spec
)
1638 struct MFLTFontFT
*flt_font_ft
= (struct MFLTFontFT
*) font
;
1639 OTF
*otf
= flt_font_ft
->otf
;
1643 for (i
= 0; i
< 2; i
++)
1645 if (! spec
->features
[i
])
1647 for (n
= 0; spec
->features
[i
][n
]; n
++);
1648 tags
= alloca (sizeof (OTF_Tag
) * n
);
1649 for (n
= 0, negative
= 0; spec
->features
[i
][n
]; n
++)
1651 if (spec
->features
[i
][n
] == 0xFFFFFFFF)
1654 tags
[n
- 1] = spec
->features
[i
][n
] | 0x80000000;
1656 tags
[n
] = spec
->features
[i
][n
];
1658 if (n
- negative
> 0
1659 && OTF_check_features (otf
, i
== 0, spec
->script
, spec
->langsys
,
1660 tags
, n
- negative
) != 1)
1666 #define DEVICE_DELTA(table, size) \
1667 (((size) >= (table).StartSize && (size) <= (table).EndSize) \
1668 ? (table).DeltaValue[(size) - (table).StartSize] << 6 \
1672 adjust_anchor (FT_Face ft_face
, OTF_Anchor
*anchor
,
1673 unsigned code
, int x_ppem
, int y_ppem
, int *x
, int *y
)
1675 if (anchor
->AnchorFormat
== 2)
1677 FT_Outline
*outline
;
1678 int ap
= anchor
->f
.f1
.AnchorPoint
;
1680 FT_Load_Glyph (ft_face
, (FT_UInt
) code
, FT_LOAD_MONOCHROME
);
1681 outline
= &ft_face
->glyph
->outline
;
1682 if (ap
< outline
->n_points
)
1684 *x
= outline
->points
[ap
].x
<< 6;
1685 *y
= outline
->points
[ap
].y
<< 6;
1688 else if (anchor
->AnchorFormat
== 3)
1690 if (anchor
->f
.f2
.XDeviceTable
.offset
1691 && anchor
->f
.f2
.XDeviceTable
.DeltaValue
)
1692 *x
+= DEVICE_DELTA (anchor
->f
.f2
.XDeviceTable
, x_ppem
);
1693 if (anchor
->f
.f2
.YDeviceTable
.offset
1694 && anchor
->f
.f2
.YDeviceTable
.DeltaValue
)
1695 *y
+= DEVICE_DELTA (anchor
->f
.f2
.YDeviceTable
, y_ppem
);
1699 static OTF_GlyphString otf_gstring
;
1702 setup_otf_gstring (int size
)
1704 if (otf_gstring
.size
== 0)
1706 otf_gstring
.glyphs
= (OTF_Glyph
*) malloc (sizeof (OTF_Glyph
) * size
);
1707 otf_gstring
.size
= size
;
1709 else if (otf_gstring
.size
< size
)
1711 otf_gstring
.glyphs
= (OTF_Glyph
*) realloc (otf_gstring
.glyphs
,
1712 sizeof (OTF_Glyph
) * size
);
1713 otf_gstring
.size
= size
;
1715 otf_gstring
.used
= size
;
1716 memset (otf_gstring
.glyphs
, 0, sizeof (OTF_Glyph
) * size
);
1721 ftfont_drive_otf (font
, spec
, in
, from
, to
, out
, adjustment
)
1724 MFLTGlyphString
*in
;
1726 MFLTGlyphString
*out
;
1727 MFLTGlyphAdjustment
*adjustment
;
1729 struct MFLTFontFT
*flt_font_ft
= (struct MFLTFontFT
*) font
;
1730 FT_Face ft_face
= flt_font_ft
->ft_face
;
1731 OTF
*otf
= flt_font_ft
->otf
;
1732 int len
= to
- from
;
1735 char script
[5], *langsys
= NULL
;
1736 char *gsub_features
= NULL
, *gpos_features
= NULL
;
1740 OTF_tag_name (spec
->script
, script
);
1743 langsys
= alloca (5);
1744 OTF_tag_name (spec
->langsys
, langsys
);
1746 for (i
= 0; i
< 2; i
++)
1750 if (spec
->features
[i
] && spec
->features
[i
][1] != 0xFFFFFFFF)
1752 for (j
= 0; spec
->features
[i
][j
]; j
++);
1754 p
= gsub_features
= alloca (6 * j
);
1756 p
= gpos_features
= alloca (6 * j
);
1757 for (j
= 0; spec
->features
[i
][j
]; j
++)
1759 if (spec
->features
[i
][j
] == 0xFFFFFFFF)
1760 *p
++ = '*', *p
++ = ',';
1763 OTF_tag_name (spec
->features
[i
][j
], p
);
1772 setup_otf_gstring (len
);
1773 for (i
= 0; i
< len
; i
++)
1775 otf_gstring
.glyphs
[i
].c
= in
->glyphs
[from
+ i
].c
;
1776 otf_gstring
.glyphs
[i
].glyph_id
= in
->glyphs
[from
+ i
].code
;
1779 OTF_drive_gdef (otf
, &otf_gstring
);
1784 if (OTF_drive_gsub (otf
, &otf_gstring
, script
, langsys
, gsub_features
)
1787 if (out
->allocated
< out
->used
+ otf_gstring
.used
)
1789 for (i
= 0, otfg
= otf_gstring
.glyphs
; i
< otf_gstring
.used
; )
1792 int min_from
, max_to
;
1795 g
= out
->glyphs
+ out
->used
;
1796 *g
= in
->glyphs
[from
+ otfg
->f
.index
.from
];
1797 if (g
->code
!= otfg
->glyph_id
)
1800 g
->code
= otfg
->glyph_id
;
1806 if (otfg
->f
.index
.from
< otfg
->f
.index
.to
)
1808 /* OTFG substitutes multiple glyphs in IN. */
1809 for (j
= from
+ otfg
->f
.index
.from
+ 1;
1810 j
<= from
+ otfg
->f
.index
.to
; j
++)
1812 if (min_from
> in
->glyphs
[j
].from
)
1813 min_from
= in
->glyphs
[j
].from
;
1814 if (max_to
< in
->glyphs
[j
].to
)
1815 max_to
= in
->glyphs
[j
].to
;
1820 for (i
++, otfg
++; (i
< otf_gstring
.used
1821 && otfg
->f
.index
.from
== otfg
[-1].f
.index
.from
);
1824 g
= out
->glyphs
+ out
->used
;
1825 *g
= in
->glyphs
[from
+ otfg
->f
.index
.to
];
1826 if (g
->code
!= otfg
->glyph_id
)
1829 g
->code
= otfg
->glyph_id
;
1838 if (out
->allocated
< out
->used
+ len
)
1840 for (i
= 0; i
< len
; i
++)
1841 out
->glyphs
[out
->used
++] = in
->glyphs
[from
+ i
];
1846 MFLTGlyph
*base
= NULL
, *mark
= NULL
, *g
;
1847 int x_ppem
, y_ppem
, x_scale
, y_scale
;
1849 if (OTF_drive_gpos (otf
, &otf_gstring
, script
, langsys
, gpos_features
)
1853 x_ppem
= ft_face
->size
->metrics
.x_ppem
;
1854 y_ppem
= ft_face
->size
->metrics
.y_ppem
;
1855 x_scale
= ft_face
->size
->metrics
.x_scale
;
1856 y_scale
= ft_face
->size
->metrics
.y_scale
;
1858 for (i
= 0, otfg
= otf_gstring
.glyphs
, g
= out
->glyphs
+ gidx
;
1859 i
< otf_gstring
.used
; i
++, otfg
++, g
++)
1863 if (! otfg
->glyph_id
)
1865 switch (otfg
->positioning_type
)
1869 case 1: /* Single */
1872 int format
= otfg
->f
.f1
.format
;
1874 if (format
& OTF_XPlacement
)
1876 = otfg
->f
.f1
.value
->XPlacement
* x_scale
/ 0x10000;
1877 if (format
& OTF_XPlaDevice
)
1879 += DEVICE_DELTA (otfg
->f
.f1
.value
->XPlaDevice
, x_ppem
);
1880 if (format
& OTF_YPlacement
)
1882 = - (otfg
->f
.f1
.value
->YPlacement
* y_scale
/ 0x10000);
1883 if (format
& OTF_YPlaDevice
)
1885 -= DEVICE_DELTA (otfg
->f
.f1
.value
->YPlaDevice
, y_ppem
);
1886 if (format
& OTF_XAdvance
)
1888 += otfg
->f
.f1
.value
->XAdvance
* x_scale
/ 0x10000;
1889 if (format
& OTF_XAdvDevice
)
1891 += DEVICE_DELTA (otfg
->f
.f1
.value
->XAdvDevice
, x_ppem
);
1892 if (format
& OTF_YAdvance
)
1894 += otfg
->f
.f1
.value
->YAdvance
* y_scale
/ 0x10000;
1895 if (format
& OTF_YAdvDevice
)
1897 += DEVICE_DELTA (otfg
->f
.f1
.value
->YAdvDevice
, y_ppem
);
1898 adjustment
[i
].set
= 1;
1901 case 3: /* Cursive */
1902 /* Not yet supported. */
1904 case 4: /* Mark-to-Base */
1905 case 5: /* Mark-to-Ligature */
1909 goto label_adjust_anchor
;
1910 default: /* i.e. case 6 Mark-to-Mark */
1915 label_adjust_anchor
:
1917 int base_x
, base_y
, mark_x
, mark_y
;
1918 int this_from
, this_to
;
1920 base_x
= otfg
->f
.f4
.base_anchor
->XCoordinate
* x_scale
/ 0x10000;
1921 base_y
= otfg
->f
.f4
.base_anchor
->YCoordinate
* y_scale
/ 0x10000;
1922 mark_x
= otfg
->f
.f4
.mark_anchor
->XCoordinate
* x_scale
/ 0x10000;
1923 mark_y
= otfg
->f
.f4
.mark_anchor
->YCoordinate
* y_scale
/ 0x10000;
1925 if (otfg
->f
.f4
.base_anchor
->AnchorFormat
!= 1)
1926 adjust_anchor (ft_face
, otfg
->f
.f4
.base_anchor
,
1927 prev
->code
, x_ppem
, y_ppem
, &base_x
, &base_y
);
1928 if (otfg
->f
.f4
.mark_anchor
->AnchorFormat
!= 1)
1929 adjust_anchor (ft_face
, otfg
->f
.f4
.mark_anchor
, g
->code
,
1930 x_ppem
, y_ppem
, &mark_x
, &mark_y
);
1931 adjustment
[i
].xoff
= (base_x
- mark_x
);
1932 adjustment
[i
].yoff
= - (base_y
- mark_y
);
1933 adjustment
[i
].back
= (g
- prev
);
1934 adjustment
[i
].xadv
= 0;
1935 adjustment
[i
].advance_is_absolute
= 1;
1936 adjustment
[i
].set
= 1;
1937 this_from
= g
->from
;
1939 for (j
= 0; prev
+ j
< g
; j
++)
1941 if (this_from
> prev
[j
].from
)
1942 this_from
= prev
[j
].from
;
1943 if (this_to
< prev
[j
].to
)
1944 this_to
= prev
[j
].to
;
1946 for (; prev
<= g
; prev
++)
1948 prev
->from
= this_from
;
1953 if (otfg
->GlyphClass
== OTF_GlyphClass0
)
1955 else if (otfg
->GlyphClass
== OTF_GlyphClassMark
)
1964 if (out
->allocated
< out
->used
+ len
)
1966 font
->get_metrics (font
, in
, from
, to
);
1967 memcpy (out
->glyphs
+ out
->used
, in
->glyphs
+ from
,
1968 sizeof (MFLTGlyph
) * len
);
1973 static MFLTGlyphString gstring
;
1975 static int m17n_flt_initialized
;
1977 extern Lisp_Object QCfamily
;
1980 ftfont_shape_by_flt (lgstring
, font
, ft_face
, otf
)
1981 Lisp_Object lgstring
;
1986 EMACS_UINT len
= LGSTRING_GLYPH_LEN (lgstring
);
1988 struct MFLTFontFT flt_font_ft
;
1990 int with_variation_selector
= 0;
1992 if (! m17n_flt_initialized
)
1995 m17n_flt_initialized
= 1;
1998 for (i
= 0; i
< len
; i
++)
2000 Lisp_Object g
= LGSTRING_GLYPH (lgstring
, i
);
2005 c
= LGLYPH_CHAR (g
);
2006 if (CHAR_VARIATION_SELECTOR_P (c
))
2007 with_variation_selector
++;
2010 if (with_variation_selector
)
2012 setup_otf_gstring (len
);
2013 for (i
= 0; i
< len
; i
++)
2015 Lisp_Object g
= LGSTRING_GLYPH (lgstring
, i
);
2017 otf_gstring
.glyphs
[i
].c
= LGLYPH_CHAR (g
);
2018 otf_gstring
.glyphs
[i
].f
.index
.from
= LGLYPH_FROM (g
);
2019 otf_gstring
.glyphs
[i
].f
.index
.to
= LGLYPH_TO (g
);
2021 OTF_drive_cmap (otf
, &otf_gstring
);
2022 for (i
= 0; i
< otf_gstring
.used
; i
++)
2024 OTF_Glyph
*otfg
= otf_gstring
.glyphs
+ i
;
2025 Lisp_Object g0
= LGSTRING_GLYPH (lgstring
, otfg
->f
.index
.from
);
2026 Lisp_Object g1
= LGSTRING_GLYPH (lgstring
, otfg
->f
.index
.to
);
2028 LGLYPH_SET_CODE (g0
, otfg
->glyph_id
);
2029 LGLYPH_SET_TO (g0
, LGLYPH_TO (g1
));
2030 LGSTRING_SET_GLYPH (lgstring
, i
, g0
);
2032 if (len
> otf_gstring
.used
)
2034 len
= otf_gstring
.used
;
2035 LGSTRING_SET_GLYPH (lgstring
, len
, Qnil
);
2039 if (gstring
.allocated
== 0)
2041 gstring
.allocated
= len
* 2;
2042 gstring
.glyph_size
= sizeof (MFLTGlyph
);
2043 gstring
.glyphs
= malloc (sizeof (MFLTGlyph
) * gstring
.allocated
);
2045 else if (gstring
.allocated
< len
* 2)
2047 gstring
.allocated
= len
* 2;
2048 gstring
.glyphs
= realloc (gstring
.glyphs
,
2049 sizeof (MFLTGlyph
) * gstring
.allocated
);
2051 memset (gstring
.glyphs
, 0, sizeof (MFLTGlyph
) * len
);
2052 for (i
= 0; i
< len
; i
++)
2054 Lisp_Object g
= LGSTRING_GLYPH (lgstring
, i
);
2056 gstring
.glyphs
[i
].c
= LGLYPH_CHAR (g
);
2057 if (with_variation_selector
)
2059 gstring
.glyphs
[i
].code
= LGLYPH_CODE (g
);
2060 gstring
.glyphs
[i
].encoded
= 1;
2068 Lisp_Object family
= Ffont_get (LGSTRING_FONT (lgstring
), QCfamily
);
2071 flt_font_ft
.flt_font
.family
= Mnil
;
2073 flt_font_ft
.flt_font
.family
2074 = msymbol ((char *) SDATA (Fdowncase (SYMBOL_NAME (family
))));
2076 flt_font_ft
.flt_font
.x_ppem
= ft_face
->size
->metrics
.x_ppem
;
2077 flt_font_ft
.flt_font
.y_ppem
= ft_face
->size
->metrics
.y_ppem
;
2078 flt_font_ft
.flt_font
.get_glyph_id
= ftfont_get_glyph_id
;
2079 flt_font_ft
.flt_font
.get_metrics
= ftfont_get_metrics
;
2080 flt_font_ft
.flt_font
.check_otf
= ftfont_check_otf
;
2081 flt_font_ft
.flt_font
.drive_otf
= ftfont_drive_otf
;
2082 flt_font_ft
.flt_font
.internal
= NULL
;
2083 flt_font_ft
.font
= font
;
2084 flt_font_ft
.ft_face
= ft_face
;
2085 flt_font_ft
.otf
= otf
;
2087 && gstring
.glyphs
[1].c
>= 0x300 && gstring
.glyphs
[1].c
<= 0x36F)
2088 /* A little bit ad hoc. Perhaps, shaper must get script and
2089 language information, and select a proper flt for them
2091 flt
= mflt_get (msymbol ("combining"));
2092 for (i
= 0; i
< 3; i
++)
2094 int result
= mflt_run (&gstring
, 0, len
, &flt_font_ft
.flt_font
, flt
);
2097 gstring
.allocated
+= gstring
.allocated
;
2098 gstring
.glyphs
= realloc (gstring
.glyphs
,
2099 sizeof (MFLTGlyph
) * gstring
.allocated
);
2101 if (gstring
.used
> LGSTRING_GLYPH_LEN (lgstring
))
2103 for (i
= 0; i
< gstring
.used
; i
++)
2105 MFLTGlyph
*g
= gstring
.glyphs
+ i
;
2107 g
->from
= LGLYPH_FROM (LGSTRING_GLYPH (lgstring
, g
->from
));
2108 g
->to
= LGLYPH_TO (LGSTRING_GLYPH (lgstring
, g
->to
));
2111 for (i
= 0; i
< gstring
.used
; i
++)
2113 Lisp_Object lglyph
= LGSTRING_GLYPH (lgstring
, i
);
2114 MFLTGlyph
*g
= gstring
.glyphs
+ i
;
2118 lglyph
= Fmake_vector (make_number (LGLYPH_SIZE
), Qnil
);
2119 LGSTRING_SET_GLYPH (lgstring
, i
, lglyph
);
2121 LGLYPH_SET_FROM (lglyph
, g
->from
);
2122 LGLYPH_SET_TO (lglyph
, g
->to
);
2123 LGLYPH_SET_CHAR (lglyph
, g
->c
);
2124 LGLYPH_SET_CODE (lglyph
, g
->code
);
2125 LGLYPH_SET_WIDTH (lglyph
, g
->xadv
>> 6);
2126 LGLYPH_SET_LBEARING (lglyph
, g
->lbearing
>> 6);
2127 LGLYPH_SET_RBEARING (lglyph
, g
->rbearing
>> 6);
2128 LGLYPH_SET_ASCENT (lglyph
, g
->ascent
>> 6);
2129 LGLYPH_SET_DESCENT (lglyph
, g
->descent
>> 6);
2134 vec
= Fmake_vector (make_number (3), Qnil
);
2135 ASET (vec
, 0, make_number (g
->xoff
>> 6));
2136 ASET (vec
, 1, make_number (g
->yoff
>> 6));
2137 ASET (vec
, 2, make_number (g
->xadv
>> 6));
2138 LGLYPH_SET_ADJUSTMENT (lglyph
, vec
);
2141 return make_number (i
);
2145 ftfont_shape (lgstring
)
2146 Lisp_Object lgstring
;
2149 struct ftfont_info
*ftfont_info
;
2152 CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring
), font
);
2153 ftfont_info
= (struct ftfont_info
*) font
;
2154 otf
= ftfont_get_otf (ftfont_info
);
2156 return make_number (0);
2157 return ftfont_shape_by_flt (lgstring
, font
, ftfont_info
->ft_size
->face
, otf
);
2160 #endif /* HAVE_M17N_FLT */
2162 #ifdef HAVE_OTF_GET_VARIATION_GLYPHS
2165 ftfont_variation_glyphs (font
, c
, variations
)
2168 unsigned variations
[256];
2170 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
2171 OTF
*otf
= ftfont_get_otf (ftfont_info
);
2175 return OTF_get_variation_glyphs (otf
, c
, variations
);
2178 #endif /* HAVE_OTF_GET_VARIATION_GLYPHS */
2179 #endif /* HAVE_LIBOTF */
2182 ftfont_font_format (FcPattern
*pattern
, Lisp_Object filename
)
2186 #ifdef FC_FONTFORMAT
2189 if (FcPatternGetString (pattern
, FC_FONTFORMAT
, 0, &str
) != FcResultMatch
)
2191 if (strcmp ((char *) str
, "TrueType") == 0)
2192 return intern ("truetype");
2193 if (strcmp ((char *) str
, "Type 1") == 0)
2194 return intern ("type1");
2195 if (strcmp ((char *) str
, "PCF") == 0)
2196 return intern ("pcf");
2197 if (strcmp ((char *) str
, "BDF") == 0)
2198 return intern ("bdf");
2200 #endif /* FC_FONTFORMAT */
2201 if (STRINGP (filename
))
2203 int len
= SBYTES (filename
);
2207 str
= (FcChar8
*) (SDATA (filename
) + len
- 4);
2208 if (xstrcasecmp ((char *) str
, ".ttf") == 0)
2209 return intern ("truetype");
2210 if (xstrcasecmp ((char *) str
, ".pfb") == 0)
2211 return intern ("type1");
2212 if (xstrcasecmp ((char *) str
, ".pcf") == 0)
2213 return intern ("pcf");
2214 if (xstrcasecmp ((char *) str
, ".bdf") == 0)
2215 return intern ("bdf");
2218 return intern ("unknown");
2225 DEFSYM (Qfreetype
, "freetype");
2226 DEFSYM (Qmonospace
, "monospace");
2227 DEFSYM (Qsans_serif
, "sans-serif");
2228 DEFSYM (Qserif
, "serif");
2229 DEFSYM (Qmono
, "mono");
2230 DEFSYM (Qsans
, "sans");
2231 DEFSYM (Qsans__serif
, "sans serif");
2235 staticpro (&freetype_font_cache
);
2236 freetype_font_cache
= Fcons (Qt
, Qnil
);
2238 staticpro (&ftfont_generic_family_list
);
2239 ftfont_generic_family_list
2240 = Fcons (Fcons (Qmonospace
, Qt
),
2241 Fcons (Fcons (Qsans_serif
, Qt
),
2242 Fcons (Fcons (Qsans
, Qt
), Qnil
)));
2244 staticpro (&ft_face_cache
);
2245 ft_face_cache
= Qnil
;
2247 ftfont_driver
.type
= Qfreetype
;
2248 register_font_driver (&ftfont_driver
, NULL
);
2251 /* arch-tag: 7cfa432c-33a6-4988-83d2-a82ed8604aca
2252 (do not change this comment) */