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/>. */
26 #include <fontconfig/fontconfig.h>
27 #include <fontconfig/fcfreetype.h>
30 #include "dispextern.h"
32 #include "blockinput.h"
33 #include "character.h"
36 #include "composite.h"
41 /* Symbolic type of this font-driver. */
42 Lisp_Object Qfreetype
;
44 /* Fontconfig's generic families and their aliases. */
45 static Lisp_Object Qmonospace
, Qsans_serif
, Qserif
, Qmono
, Qsans
, Qsans__serif
;
47 /* Flag to tell if FcInit is already called or not. */
48 static int fc_initialized
;
50 /* Handle to a FreeType library instance. */
51 static FT_Library ft_library
;
53 /* Cache for FreeType fonts. */
54 static Lisp_Object freetype_font_cache
;
56 /* Cache for FT_Face and FcCharSet. */
57 static Lisp_Object ft_face_cache
;
59 /* The actual structure for FreeType font that can be casted to struct
66 /* The following four members must be here in this order to be
67 compatible with struct xftfont_info (in xftfont.c). */
68 int maybe_otf
; /* Flag to tell if this may be OTF or not. */
70 #endif /* HAVE_LIBOTF */
77 FTFONT_CACHE_FOR_FACE
,
78 FTFONT_CACHE_FOR_CHARSET
,
79 FTFONT_CACHE_FOR_ENTITY
82 static Lisp_Object ftfont_pattern_entity
P_ ((FcPattern
*, Lisp_Object
));
84 static Lisp_Object ftfont_resolve_generic_family
P_ ((Lisp_Object
,
86 static Lisp_Object ftfont_lookup_cache
P_ ((Lisp_Object
,
87 enum ftfont_cache_for
));
89 Lisp_Object ftfont_font_format
P_ ((FcPattern
*, Lisp_Object
));
91 #define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM))
97 /* characters to distinguish the charset from the others */
99 /* additional constraint by language */
102 FcCharSet
*fc_charset
;
103 } fc_charset_table
[] =
104 { { "iso8859-1", { 0x00A0, 0x00A1, 0x00B4, 0x00BC, 0x00D0 } },
105 { "iso8859-2", { 0x00A0, 0x010E }},
106 { "iso8859-3", { 0x00A0, 0x0108 }},
107 { "iso8859-4", { 0x00A0, 0x00AF, 0x0128, 0x0156, 0x02C7 }},
108 { "iso8859-5", { 0x00A0, 0x0401 }},
109 { "iso8859-6", { 0x00A0, 0x060C }},
110 { "iso8859-7", { 0x00A0, 0x0384 }},
111 { "iso8859-8", { 0x00A0, 0x05D0 }},
112 { "iso8859-9", { 0x00A0, 0x00A1, 0x00BC, 0x011E }},
113 { "iso8859-10", { 0x00A0, 0x00D0, 0x0128, 0x2015 }},
114 { "iso8859-11", { 0x00A0, 0x0E01 }},
115 { "iso8859-13", { 0x00A0, 0x201C }},
116 { "iso8859-14", { 0x00A0, 0x0174 }},
117 { "iso8859-15", { 0x00A0, 0x00A1, 0x00D0, 0x0152 }},
118 { "iso8859-16", { 0x00A0, 0x0218}},
119 { "gb2312.1980-0", { 0x4E13 }, "zh-cn"},
120 { "big5-0", { 0xF6B1 }, "zh-tw" },
121 { "jisx0208.1983-0", { 0x4E55 }, "ja"},
122 { "ksc5601.1985-0", { 0xAC00 }, "ko"},
123 { "cns11643.1992-1", { 0xFE32 }, "zh-tw"},
124 { "cns11643.1992-2", { 0x4E33, 0x7934 }},
125 { "cns11643.1992-3", { 0x201A9 }},
126 { "cns11643.1992-4", { 0x20057 }},
127 { "cns11643.1992-5", { 0x20000 }},
128 { "cns11643.1992-6", { 0x20003 }},
129 { "cns11643.1992-7", { 0x20055 }},
130 { "gbk-0", { 0x4E06 }, "zh-cn"},
131 { "jisx0212.1990-0", { 0x4E44 }},
132 { "jisx0213.2000-1", { 0xFA10 }, "ja"},
133 { "jisx0213.2000-2", { 0xFA49 }},
134 { "jisx0213.2004-1", { 0x20B9F }},
135 { "viscii1.1-1", { 0x1EA0, 0x1EAE, 0x1ED2 }, "vi"},
136 { "tis620.2529-1", { 0x0E01 }, "th"},
137 { "windows-1251", { 0x0401, 0x0490 }, "ru"},
138 { "koi8-r", { 0x0401, 0x2219 }, "ru"},
139 { "mulelao-1", { 0x0E81 }, "lo"},
140 { "unicode-sip", { 0x20000 }},
144 extern Lisp_Object Qc
, Qm
, Qp
, Qd
;
146 /* Dirty hack for handing ADSTYLE property.
148 Fontconfig (actually the underlying FreeType) gives such ADSTYLE
149 font property of PCF/BDF fonts in FC_STYLE. And, "Bold",
150 "Oblique", "Italic", or any non-normal SWIDTH property names
151 (e.g. SemiCondensed) are appended. In addition, if there's no
152 ADSTYLE property nor non-normal WEIGHT/SLANT/SWIDTH properties,
153 "Regular" is used for FC_STYLE (see the function
154 pcf_interpret_style in src/pcf/pcfread.c of FreeType).
156 Unfortunately this behavior is not documented, so the following
157 code may fail if FreeType changes the behavior in the future. */
160 get_adstyle_property (FcPattern
*p
)
165 if (FcPatternGetString (p
, FC_STYLE
, 0, (FcChar8
**) &str
) != FcResultMatch
)
167 for (end
= str
; *end
&& *end
!= ' '; end
++);
170 char *p
= alloca (end
- str
+ 1);
171 memcpy (p
, str
, end
- str
);
173 end
= p
+ (end
- str
);
176 if (xstrcasecmp (str
, "Regular") == 0
177 || xstrcasecmp (str
, "Bold") == 0
178 || xstrcasecmp (str
, "Oblique") == 0
179 || xstrcasecmp (str
, "Italic") == 0)
181 adstyle
= font_intern_prop (str
, end
- str
, 1);
182 if (font_style_to_value (FONT_WIDTH_INDEX
, adstyle
, 0) >= 0)
188 ftfont_pattern_entity (p
, extra
)
192 Lisp_Object key
, cache
, entity
;
199 if (FcPatternGetString (p
, FC_FILE
, 0, (FcChar8
**) &file
) != FcResultMatch
)
201 if (FcPatternGetInteger (p
, FC_INDEX
, 0, &index
) != FcResultMatch
)
204 key
= Fcons (make_unibyte_string ((char *) file
, strlen ((char *) file
)),
205 make_number (index
));
206 cache
= ftfont_lookup_cache (key
, FTFONT_CACHE_FOR_ENTITY
);
207 entity
= XCAR (cache
);
210 Lisp_Object val
= font_make_entity ();
213 for (i
= 0; i
< FONT_OBJLIST_INDEX
; i
++)
214 ASET (val
, i
, AREF (entity
, i
));
217 entity
= font_make_entity ();
218 XSETCAR (cache
, entity
);
220 ASET (entity
, FONT_TYPE_INDEX
, Qfreetype
);
221 ASET (entity
, FONT_REGISTRY_INDEX
, Qiso10646_1
);
223 if (FcPatternGetString (p
, FC_FOUNDRY
, 0, (FcChar8
**) &str
) == FcResultMatch
)
224 ASET (entity
, FONT_FOUNDRY_INDEX
, font_intern_prop (str
, strlen (str
), 1));
225 if (FcPatternGetString (p
, FC_FAMILY
, 0, (FcChar8
**) &str
) == FcResultMatch
)
226 ASET (entity
, FONT_FAMILY_INDEX
, font_intern_prop (str
, strlen (str
), 1));
227 if (FcPatternGetInteger (p
, FC_WEIGHT
, 0, &numeric
) == FcResultMatch
)
229 if (numeric
>= FC_WEIGHT_REGULAR
&& numeric
< FC_WEIGHT_MEDIUM
)
230 numeric
= FC_WEIGHT_MEDIUM
;
231 FONT_SET_STYLE (entity
, FONT_WEIGHT_INDEX
, make_number (numeric
));
233 if (FcPatternGetInteger (p
, FC_SLANT
, 0, &numeric
) == FcResultMatch
)
236 FONT_SET_STYLE (entity
, FONT_SLANT_INDEX
, make_number (numeric
));
238 if (FcPatternGetInteger (p
, FC_WIDTH
, 0, &numeric
) == FcResultMatch
)
240 FONT_SET_STYLE (entity
, FONT_WIDTH_INDEX
, make_number (numeric
));
242 if (FcPatternGetDouble (p
, FC_PIXEL_SIZE
, 0, &dbl
) == FcResultMatch
)
244 ASET (entity
, FONT_SIZE_INDEX
, make_number (dbl
));
247 ASET (entity
, FONT_SIZE_INDEX
, make_number (0));
248 if (FcPatternGetInteger (p
, FC_SPACING
, 0, &numeric
) == FcResultMatch
)
249 ASET (entity
, FONT_SPACING_INDEX
, make_number (numeric
));
250 if (FcPatternGetDouble (p
, FC_DPI
, 0, &dbl
) == FcResultMatch
)
253 ASET (entity
, FONT_DPI_INDEX
, make_number (dpi
));
255 if (FcPatternGetBool (p
, FC_SCALABLE
, 0, &b
) == FcResultMatch
258 ASET (entity
, FONT_SIZE_INDEX
, make_number (0));
259 ASET (entity
, FONT_AVGWIDTH_INDEX
, make_number (0));
263 /* As this font is not scalable, parhaps this is a BDF or PCF
267 ASET (entity
, FONT_ADSTYLE_INDEX
, get_adstyle_property (p
));
268 if ((ft_library
|| FT_Init_FreeType (&ft_library
) == 0)
269 && FT_New_Face (ft_library
, file
, index
, &ft_face
) == 0)
273 if (FT_Get_BDF_Property (ft_face
, "AVERAGE_WIDTH", &rec
) == 0
274 && rec
.type
== BDF_PROPERTY_TYPE_INTEGER
)
275 ASET (entity
, FONT_AVGWIDTH_INDEX
, make_number (rec
.u
.integer
));
276 FT_Done_Face (ft_face
);
280 ASET (entity
, FONT_EXTRA_INDEX
, Fcopy_sequence (extra
));
281 font_put_extra (entity
, QCfont_entity
, key
);
286 static Lisp_Object ftfont_generic_family_list
;
289 ftfont_resolve_generic_family (family
, pattern
)
298 family
= Fintern (Fdowncase (SYMBOL_NAME (family
)), Qnil
);
299 if (EQ (family
, Qmono
))
301 else if (EQ (family
, Qsans
) || EQ (family
, Qsans__serif
))
302 family
= Qsans_serif
;
303 slot
= assq_no_quit (family
, ftfont_generic_family_list
);
306 if (! EQ (XCDR (slot
), Qt
))
308 pattern
= FcPatternDuplicate (pattern
);
311 FcPatternDel (pattern
, FC_FOUNDRY
);
312 FcPatternDel (pattern
, FC_FAMILY
);
313 FcPatternAddString (pattern
, FC_FAMILY
, SYMBOL_FcChar8 (family
));
314 if (FcPatternGetLangSet (pattern
, FC_LANG
, 0, &langset
) != FcResultMatch
)
316 /* This is to avoid the effect of locale. */
317 langset
= FcLangSetCreate ();
318 FcLangSetAdd (langset
, "en");
319 FcPatternAddLangSet (pattern
, FC_LANG
, langset
);
320 FcLangSetDestroy (langset
);
322 FcConfigSubstitute (NULL
, pattern
, FcMatchPattern
);
323 FcDefaultSubstitute (pattern
);
324 match
= FcFontMatch (NULL
, pattern
, &result
);
329 if (FcPatternGetString (match
, FC_FAMILY
, 0, &fam
) == FcResultMatch
)
330 family
= intern ((char *) fam
);
334 XSETCDR (slot
, family
);
335 if (match
) FcPatternDestroy (match
);
337 if (pattern
) FcPatternDestroy (pattern
);
341 struct ftfont_cache_data
344 FcCharSet
*fc_charset
;
348 ftfont_lookup_cache (key
, cache_for
)
350 enum ftfont_cache_for cache_for
;
352 Lisp_Object cache
, val
, entity
;
353 struct ftfont_cache_data
*cache_data
;
355 if (FONT_ENTITY_P (key
))
358 val
= assq_no_quit (QCfont_entity
, AREF (entity
, FONT_EXTRA_INDEX
));
359 xassert (CONSP (val
));
365 if (NILP (ft_face_cache
))
368 cache
= Fgethash (key
, ft_face_cache
, Qnil
);
371 if (NILP (ft_face_cache
))
377 ft_face_cache
= Fmake_hash_table (2, args
);
379 cache_data
= xmalloc (sizeof (struct ftfont_cache_data
));
380 cache_data
->ft_face
= NULL
;
381 cache_data
->fc_charset
= NULL
;
382 val
= make_save_value (NULL
, 0);
383 XSAVE_VALUE (val
)->integer
= 0;
384 XSAVE_VALUE (val
)->pointer
= cache_data
;
385 cache
= Fcons (Qnil
, val
);
386 Fputhash (key
, cache
, ft_face_cache
);
391 cache_data
= XSAVE_VALUE (val
)->pointer
;
394 if (cache_for
== FTFONT_CACHE_FOR_ENTITY
)
397 if (cache_for
== FTFONT_CACHE_FOR_FACE
398 ? ! cache_data
->ft_face
: ! cache_data
->fc_charset
)
400 char *filename
= (char *) SDATA (XCAR (key
));
401 int index
= XINT (XCDR (key
));
403 if (cache_for
== FTFONT_CACHE_FOR_FACE
)
406 && FT_Init_FreeType (&ft_library
) != 0)
408 if (FT_New_Face (ft_library
, filename
, index
, &cache_data
->ft_face
)
414 FcPattern
*pat
= NULL
;
415 FcFontSet
*fontset
= NULL
;
416 FcObjectSet
*objset
= NULL
;
417 FcCharSet
*charset
= NULL
;
419 pat
= FcPatternBuild (0, FC_FILE
, FcTypeString
, (FcChar8
*) filename
,
420 FC_INDEX
, FcTypeInteger
, index
, NULL
);
423 objset
= FcObjectSetBuild (FC_CHARSET
, FC_STYLE
, NULL
);
426 fontset
= FcFontList (NULL
, pat
, objset
);
429 if (fontset
&& fontset
->nfont
> 0
430 && (FcPatternGetCharSet (fontset
->fonts
[0], FC_CHARSET
, 0,
433 cache_data
->fc_charset
= FcCharSetCopy (charset
);
435 cache_data
->fc_charset
= FcCharSetCreate ();
439 FcFontSetDestroy (fontset
);
441 FcObjectSetDestroy (objset
);
443 FcPatternDestroy (pat
);
450 ftfont_get_fc_charset (entity
)
453 Lisp_Object val
, cache
;
454 struct ftfont_cache_data
*cache_data
;
456 cache
= ftfont_lookup_cache (entity
, FTFONT_CACHE_FOR_CHARSET
);
458 cache_data
= XSAVE_VALUE (val
)->pointer
;
459 return cache_data
->fc_charset
;
464 ftfont_get_otf (ftfont_info
)
465 struct ftfont_info
*ftfont_info
;
469 if (ftfont_info
->otf
)
470 return ftfont_info
->otf
;
471 if (! ftfont_info
->maybe_otf
)
473 otf
= OTF_open_ft_face (ftfont_info
->ft_size
->face
);
474 if (! otf
|| OTF_get_table (otf
, "head") < 0)
478 ftfont_info
->maybe_otf
= 0;
481 ftfont_info
->otf
= otf
;
484 #endif /* HAVE_LIBOTF */
486 static Lisp_Object ftfont_get_cache
P_ ((FRAME_PTR
));
487 static Lisp_Object ftfont_list
P_ ((Lisp_Object
, Lisp_Object
));
488 static Lisp_Object ftfont_match
P_ ((Lisp_Object
, Lisp_Object
));
489 static Lisp_Object ftfont_list_family
P_ ((Lisp_Object
));
490 static Lisp_Object ftfont_open
P_ ((FRAME_PTR
, Lisp_Object
, int));
491 static void ftfont_close
P_ ((FRAME_PTR
, struct font
*));
492 static int ftfont_has_char
P_ ((Lisp_Object
, int));
493 static unsigned ftfont_encode_char
P_ ((struct font
*, int));
494 static int ftfont_text_extents
P_ ((struct font
*, unsigned *, int,
495 struct font_metrics
*));
496 static int ftfont_get_bitmap
P_ ((struct font
*, unsigned,
497 struct font_bitmap
*, int));
498 static int ftfont_anchor_point
P_ ((struct font
*, unsigned, int,
500 static Lisp_Object ftfont_otf_capability
P_ ((struct font
*));
501 static Lisp_Object ftfont_shape
P_ ((Lisp_Object
));
503 #ifdef HAVE_OTF_GET_VARIATION_GLYPHS
504 static int ftfont_variation_glyphs
P_ ((struct font
*, int c
,
505 unsigned variations
[256]));
506 #endif /* HAVE_OTF_GET_VARIATION_GLYPHS */
508 struct font_driver ftfont_driver
=
511 0, /* case insensitive */
516 NULL
, /* free_entity */
519 /* We can't draw a text without device dependent functions. */
520 NULL
, /* prepare_face */
521 NULL
, /* done_face */
525 /* We can't draw a text without device dependent functions. */
528 NULL
, /* get_bitmap */
529 NULL
, /* free_bitmap */
530 NULL
, /* get_outline */
533 ftfont_otf_capability
,
534 #else /* not HAVE_LIBOTF */
536 #endif /* not HAVE_LIBOTF */
537 NULL
, /* otf_drive */
538 NULL
, /* start_for_frame */
539 NULL
, /* end_for_frame */
540 #if defined (HAVE_M17N_FLT) && defined (HAVE_LIBOTF)
542 #else /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */
544 #endif /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */
547 #ifdef HAVE_OTF_GET_VARIATION_GLYPHS
548 ftfont_variation_glyphs
554 extern Lisp_Object QCname
;
560 return freetype_font_cache
;
564 ftfont_get_charset (registry
)
565 Lisp_Object registry
;
567 char *str
= (char *) SDATA (SYMBOL_NAME (registry
));
568 char *re
= alloca (SBYTES (SYMBOL_NAME (registry
)) * 2 + 1);
572 for (i
= j
= 0; i
< SBYTES (SYMBOL_NAME (registry
)); i
++, j
++)
576 else if (str
[i
] == '*')
583 regexp
= make_unibyte_string (re
, j
);
584 for (i
= 0; fc_charset_table
[i
].name
; i
++)
585 if (fast_c_string_match_ignore_case (regexp
, fc_charset_table
[i
].name
) >= 0)
587 if (! fc_charset_table
[i
].name
)
589 if (! fc_charset_table
[i
].fc_charset
)
591 FcCharSet
*charset
= FcCharSetCreate ();
592 int *uniquifier
= fc_charset_table
[i
].uniquifier
;
596 for (j
= 0; uniquifier
[j
]; j
++)
597 if (! FcCharSetAddChar (charset
, uniquifier
[j
]))
599 FcCharSetDestroy (charset
);
602 fc_charset_table
[i
].fc_charset
= charset
;
610 unsigned int script_tag
, langsys_tag
;
612 unsigned int *features
[2];
615 #define OTF_SYM_TAG(SYM, TAG) \
617 unsigned char *p = SDATA (SYMBOL_NAME (SYM)); \
618 TAG = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; \
621 #define OTF_TAG_STR(TAG, P) \
623 (P)[0] = (char) (TAG >> 24); \
624 (P)[1] = (char) ((TAG >> 16) & 0xFF); \
625 (P)[2] = (char) ((TAG >> 8) & 0xFF); \
626 (P)[3] = (char) (TAG & 0xFF); \
630 #define OTF_TAG_SYM(SYM, TAG) \
634 OTF_TAG_STR (TAG, str); \
635 (SYM) = font_intern_prop (str, 4, 1); \
639 static struct OpenTypeSpec
*
640 ftfont_get_open_type_spec (Lisp_Object otf_spec
)
642 struct OpenTypeSpec
*spec
= malloc (sizeof (struct OpenTypeSpec
));
648 spec
->script
= XCAR (otf_spec
);
649 if (! NILP (spec
->script
))
651 OTF_SYM_TAG (spec
->script
, spec
->script_tag
);
652 val
= assq_no_quit (spec
->script
, Votf_script_alist
);
653 if (CONSP (val
) && SYMBOLP (XCDR (val
)))
654 spec
->script
= XCDR (val
);
659 spec
->script_tag
= 0x44464C54; /* "DFLT" */
660 otf_spec
= XCDR (otf_spec
);
661 val
= XCAR (otf_spec
);
663 OTF_SYM_TAG (val
, spec
->langsys_tag
);
665 spec
->langsys_tag
= 0;
666 spec
->nfeatures
[0] = spec
->nfeatures
[1] = 0;
667 for (i
= 0; i
< 2; i
++)
671 otf_spec
= XCDR (otf_spec
);
674 val
= XCAR (otf_spec
);
678 spec
->features
[i
] = malloc (sizeof (int) * XINT (len
));
679 if (! spec
->features
[i
])
681 if (i
> 0 && spec
->features
[0])
682 free (spec
->features
[0]);
686 for (j
= 0, negative
= 0; CONSP (val
); val
= XCDR (val
))
688 if (NILP (XCAR (val
)))
694 OTF_SYM_TAG (XCAR (val
), tag
);
695 spec
->features
[i
][j
++] = negative
? tag
& 0x80000000 : tag
;
698 spec
->nfeatures
[i
] = j
;
703 static FcPattern
*ftfont_spec_pattern
P_ ((Lisp_Object
, char *,
704 struct OpenTypeSpec
**,
708 ftfont_spec_pattern (spec
, otlayout
, otspec
, langname
)
711 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 *langname
= fc_charset_table
[fc_charset_idx
].lang
;
751 lang
= (FcChar8
*) *langname
;
754 langset
= FcLangSetCreate ();
757 FcLangSetAdd (langset
, lang
);
762 for (extra
= AREF (spec
, FONT_EXTRA_INDEX
);
763 CONSP (extra
); extra
= XCDR (extra
))
765 Lisp_Object key
, val
;
767 key
= XCAR (XCAR (extra
)), val
= XCDR (XCAR (extra
));
770 else if (EQ (key
, QClang
))
773 langset
= FcLangSetCreate ();
778 if (! FcLangSetAdd (langset
, SYMBOL_FcChar8 (val
)))
782 for (; CONSP (val
); val
= XCDR (val
))
783 if (SYMBOLP (XCAR (val
))
784 && ! FcLangSetAdd (langset
, SYMBOL_FcChar8 (XCAR (val
))))
787 else if (EQ (key
, QCotf
))
789 *otspec
= ftfont_get_open_type_spec (val
);
792 strcat (otlayout
, "otlayout:");
793 OTF_TAG_STR ((*otspec
)->script_tag
, otlayout
+ 9);
794 script
= (*otspec
)->script
;
796 else if (EQ (key
, QCscript
))
798 else if (EQ (key
, QCscalable
))
799 scalable
= ! NILP (val
);
802 if (! NILP (script
) && ! charset
)
804 Lisp_Object chars
= assq_no_quit (script
, Vscript_representative_chars
);
806 if (CONSP (chars
) && CONSP (CDR (chars
)))
808 charset
= FcCharSetCreate ();
811 for (chars
= XCDR (chars
); CONSP (chars
); chars
= XCDR (chars
))
812 if (CHARACTERP (XCAR (chars
))
813 && ! FcCharSetAddChar (charset
, XUINT (XCAR (chars
))))
818 pattern
= FcPatternCreate ();
821 tmp
= AREF (spec
, FONT_FOUNDRY_INDEX
);
823 && ! FcPatternAddString (pattern
, FC_FOUNDRY
, SYMBOL_FcChar8 (tmp
)))
825 tmp
= AREF (spec
, FONT_FAMILY_INDEX
);
827 && ! FcPatternAddString (pattern
, FC_FAMILY
, SYMBOL_FcChar8 (tmp
)))
830 && ! FcPatternAddCharSet (pattern
, FC_CHARSET
, charset
))
833 && ! FcPatternAddLangSet (pattern
, FC_LANG
, langset
))
836 && ! FcPatternAddDouble (pattern
, FC_DPI
, dpi
))
839 && ! FcPatternAddBool (pattern
, FC_SCALABLE
, scalable
? FcTrue
: FcFalse
))
845 /* We come here because of unexpected error in fontconfig API call
846 (usually insufficient memory). */
849 FcPatternDestroy (pattern
);
854 if ((*otspec
)->nfeatures
[0] > 0)
855 free ((*otspec
)->features
[0]);
856 if ((*otspec
)->nfeatures
[1] > 0)
857 free ((*otspec
)->features
[1]);
863 if (langset
) FcLangSetDestroy (langset
);
864 if (charset
&& fc_charset_idx
< 0) FcCharSetDestroy (charset
);
869 ftfont_list (frame
, spec
)
870 Lisp_Object frame
, spec
;
872 Lisp_Object val
= Qnil
, family
, adstyle
;
875 FcFontSet
*fontset
= NULL
;
876 FcObjectSet
*objset
= NULL
;
878 Lisp_Object chars
= Qnil
;
880 char otlayout
[15]; /* For "otlayout:XXXX" */
881 struct OpenTypeSpec
*otspec
= NULL
;
883 char *langname
= NULL
;
885 if (! fc_initialized
)
891 pattern
= ftfont_spec_pattern (spec
, otlayout
, &otspec
, &langname
);
894 if (FcPatternGetCharSet (pattern
, FC_CHARSET
, 0, &charset
) != FcResultMatch
)
896 val
= assq_no_quit (QCscript
, AREF (spec
, FONT_EXTRA_INDEX
));
899 val
= assq_no_quit (XCDR (val
), Vscript_representative_chars
);
900 if (CONSP (val
) && VECTORP (XCDR (val
)))
905 if (INTEGERP (AREF (spec
, FONT_SPACING_INDEX
)))
906 spacing
= XINT (AREF (spec
, FONT_SPACING_INDEX
));
907 family
= AREF (spec
, FONT_FAMILY_INDEX
);
910 Lisp_Object resolved
;
912 resolved
= ftfont_resolve_generic_family (family
, pattern
);
913 if (! NILP (resolved
))
915 FcPatternDel (pattern
, FC_FAMILY
);
916 if (! FcPatternAddString (pattern
, FC_FAMILY
,
917 SYMBOL_FcChar8 (resolved
)))
921 adstyle
= AREF (spec
, FONT_ADSTYLE_INDEX
);
922 if (! NILP (adstyle
) && SBYTES (SYMBOL_NAME (adstyle
)) == 0)
924 objset
= FcObjectSetBuild (FC_FOUNDRY
, FC_FAMILY
, FC_WEIGHT
, FC_SLANT
,
925 FC_WIDTH
, FC_PIXEL_SIZE
, FC_SPACING
, FC_SCALABLE
,
926 FC_STYLE
, FC_FILE
, FC_INDEX
,
929 #endif /* FC_CAPABILITY */
937 FcObjectSetAdd (objset
, FC_CHARSET
);
939 fontset
= FcFontList (NULL
, pattern
, objset
);
940 if (! fontset
|| fontset
->nfont
== 0)
943 /* Need fix because this finds any fonts. */
944 if (fontset
->nfont
== 0 && ! NILP (family
))
946 /* Try maching with configuration. For instance, the
947 configuration may specify "Nimbus Mono L" as an alias of
949 FcPattern
*pat
= FcPatternBuild (0, FC_FAMILY
, FcTypeString
,
950 SYMBOL_FcChar8 (family
), NULL
);
953 if (FcConfigSubstitute (NULL
, pat
, FcMatchPattern
) == FcTrue
)
956 FcPatternGetString (pat
, FC_FAMILY
, i
, &fam
) == FcResultMatch
;
959 FcPatternDel (pattern
, FC_FAMILY
);
960 FcPatternAddString (pattern
, FC_FAMILY
, fam
);
961 FcFontSetDestroy (fontset
);
962 fontset
= FcFontList (NULL
, pattern
, objset
);
963 if (fontset
&& fontset
->nfont
> 0)
969 for (i
= 0; i
< fontset
->nfont
; i
++)
977 if ((FcPatternGetInteger (fontset
->fonts
[i
], FC_SPACING
, 0, &this)
988 if (FcPatternGetString (fontset
->fonts
[i
], FC_CAPABILITY
, 0, &this)
990 || ! strstr ((char *) this, otlayout
))
993 #endif /* FC_CAPABILITY */
1000 if (FcPatternGetString (fontset
->fonts
[i
], FC_FILE
, 0, &file
)
1003 otf
= OTF_open ((char *) file
);
1006 if (OTF_check_features (otf
, 1,
1007 otspec
->script_tag
, otspec
->langsys_tag
,
1008 otspec
->features
[0],
1009 otspec
->nfeatures
[0]) != 1
1010 || OTF_check_features (otf
, 0,
1011 otspec
->script_tag
, otspec
->langsys_tag
,
1012 otspec
->features
[1],
1013 otspec
->nfeatures
[1]) != 1)
1016 #endif /* HAVE_LIBOTF */
1017 if (VECTORP (chars
))
1021 if (FcPatternGetCharSet (fontset
->fonts
[i
], FC_CHARSET
, 0, &charset
)
1024 for (j
= 0; j
< ASIZE (chars
); j
++)
1025 if (NATNUMP (AREF (chars
, j
))
1026 && FcCharSetHasChar (charset
, XFASTINT (AREF (chars
, j
))))
1028 if (j
== ASIZE (chars
))
1031 if (! NILP (adstyle
) || langname
)
1033 Lisp_Object this_adstyle
= get_adstyle_property (fontset
->fonts
[i
]);
1035 if (! NILP (adstyle
)
1036 && (NILP (this_adstyle
)
1037 || xstrcasecmp (SDATA (SYMBOL_NAME (adstyle
)),
1038 SDATA (SYMBOL_NAME (this_adstyle
))) != 0))
1041 && ! NILP (this_adstyle
)
1042 && xstrcasecmp (langname
, SDATA (SYMBOL_NAME (this_adstyle
))))
1045 entity
= ftfont_pattern_entity (fontset
->fonts
[i
],
1046 AREF (spec
, FONT_EXTRA_INDEX
));
1047 if (! NILP (entity
))
1048 val
= Fcons (entity
, val
);
1050 val
= Fnreverse (val
);
1054 /* We come here because of unexpected error in fontconfig API call
1055 (usually insufficient memory). */
1059 FONT_ADD_LOG ("ftfont-list", spec
, val
);
1060 if (objset
) FcObjectSetDestroy (objset
);
1061 if (fontset
) FcFontSetDestroy (fontset
);
1062 if (pattern
) FcPatternDestroy (pattern
);
1067 ftfont_match (frame
, spec
)
1068 Lisp_Object frame
, spec
;
1070 Lisp_Object entity
= Qnil
;
1071 FcPattern
*pattern
, *match
= NULL
;
1073 char otlayout
[15]; /* For "otlayout:XXXX" */
1074 struct OpenTypeSpec
*otspec
= NULL
;
1075 char *langname
= NULL
;
1077 if (! fc_initialized
)
1083 pattern
= ftfont_spec_pattern (spec
, otlayout
, &otspec
, &langname
);
1087 if (INTEGERP (AREF (spec
, FONT_SIZE_INDEX
)))
1091 value
.type
= FcTypeDouble
;
1092 value
.u
.d
= XINT (AREF (spec
, FONT_SIZE_INDEX
));
1093 FcPatternAdd (pattern
, FC_PIXEL_SIZE
, value
, FcFalse
);
1095 if (FcConfigSubstitute (NULL
, pattern
, FcMatchPattern
) == FcTrue
)
1097 FcDefaultSubstitute (pattern
);
1098 match
= FcFontMatch (NULL
, pattern
, &result
);
1101 entity
= ftfont_pattern_entity (match
, AREF (spec
, FONT_EXTRA_INDEX
));
1102 FcPatternDestroy (match
);
1103 if (! NILP (AREF (spec
, FONT_FAMILY_INDEX
))
1104 && NILP (assq_no_quit (AREF (spec
, FONT_FAMILY_INDEX
),
1105 ftfont_generic_family_list
))
1106 && NILP (Fstring_equal (AREF (spec
, FONT_FAMILY_INDEX
),
1107 AREF (entity
, FONT_FAMILY_INDEX
))))
1111 FcPatternDestroy (pattern
);
1113 FONT_ADD_LOG ("ftfont-match", spec
, entity
);
1118 ftfont_list_family (frame
)
1121 Lisp_Object list
= Qnil
;
1122 FcPattern
*pattern
= NULL
;
1123 FcFontSet
*fontset
= NULL
;
1124 FcObjectSet
*objset
= NULL
;
1127 if (! fc_initialized
)
1133 pattern
= FcPatternCreate ();
1136 objset
= FcObjectSetBuild (FC_FAMILY
, NULL
);
1139 fontset
= FcFontList (NULL
, pattern
, objset
);
1143 for (i
= 0; i
< fontset
->nfont
; i
++)
1145 FcPattern
*pat
= fontset
->fonts
[i
];
1148 if (FcPatternGetString (pat
, FC_FAMILY
, 0, &str
) == FcResultMatch
)
1149 list
= Fcons (intern ((char *) str
), list
);
1153 if (objset
) FcObjectSetDestroy (objset
);
1154 if (fontset
) FcFontSetDestroy (fontset
);
1155 if (pattern
) FcPatternDestroy (pattern
);
1162 ftfont_open (f
, entity
, pixel_size
)
1167 struct ftfont_info
*ftfont_info
;
1169 struct ftfont_cache_data
*cache_data
;
1173 Lisp_Object val
, filename
, index
, cache
, font_object
;
1180 val
= assq_no_quit (QCfont_entity
, AREF (entity
, FONT_EXTRA_INDEX
));
1184 cache
= ftfont_lookup_cache (entity
, FTFONT_CACHE_FOR_FACE
);
1187 filename
= XCAR (val
);
1190 cache_data
= XSAVE_VALUE (XCDR (cache
))->pointer
;
1191 ft_face
= cache_data
->ft_face
;
1192 if (XSAVE_VALUE (val
)->integer
> 0)
1194 /* FT_Face in this cache is already used by the different size. */
1195 if (FT_New_Size (ft_face
, &ft_size
) != 0)
1197 if (FT_Activate_Size (ft_size
) != 0)
1199 FT_Done_Size (ft_size
);
1203 XSAVE_VALUE (val
)->integer
++;
1204 size
= XINT (AREF (entity
, FONT_SIZE_INDEX
));
1207 if (FT_Set_Pixel_Sizes (ft_face
, size
, size
) != 0)
1209 if (XSAVE_VALUE (val
)->integer
== 0)
1210 FT_Done_Face (ft_face
);
1214 font_object
= font_make_object (VECSIZE (struct ftfont_info
), entity
, size
);
1215 ASET (font_object
, FONT_TYPE_INDEX
, Qfreetype
);
1216 len
= font_unparse_xlfd (entity
, size
, name
, 256);
1218 ASET (font_object
, FONT_NAME_INDEX
, make_string (name
, len
));
1219 len
= font_unparse_fcname (entity
, size
, name
, 256);
1221 ASET (font_object
, FONT_FULLNAME_INDEX
, make_string (name
, len
));
1223 ASET (font_object
, FONT_FULLNAME_INDEX
,
1224 AREF (font_object
, FONT_NAME_INDEX
));
1225 ASET (font_object
, FONT_FILE_INDEX
, filename
);
1226 ASET (font_object
, FONT_FORMAT_INDEX
, ftfont_font_format (NULL
, filename
));
1227 font
= XFONT_OBJECT (font_object
);
1228 ftfont_info
= (struct ftfont_info
*) font
;
1229 ftfont_info
->ft_size
= ft_face
->size
;
1230 ftfont_info
->index
= XINT (index
);
1232 ftfont_info
->maybe_otf
= ft_face
->face_flags
& FT_FACE_FLAG_SFNT
;
1233 ftfont_info
->otf
= NULL
;
1234 #endif /* HAVE_LIBOTF */
1235 font
->pixel_size
= size
;
1236 font
->driver
= &ftfont_driver
;
1237 font
->encoding_charset
= font
->repertory_charset
= -1;
1239 upEM
= ft_face
->units_per_EM
;
1240 scalable
= (INTEGERP (AREF (entity
, FONT_AVGWIDTH_INDEX
))
1241 && XINT (AREF (entity
, FONT_AVGWIDTH_INDEX
)) == 0);
1244 font
->ascent
= ft_face
->ascender
* size
/ upEM
;
1245 font
->descent
= - ft_face
->descender
* size
/ upEM
;
1246 font
->height
= ft_face
->height
* size
/ upEM
;
1250 font
->ascent
= ft_face
->size
->metrics
.ascender
>> 6;
1251 font
->descent
= - ft_face
->size
->metrics
.descender
>> 6;
1252 font
->height
= ft_face
->size
->metrics
.height
>> 6;
1254 if (INTEGERP (AREF (entity
, FONT_SPACING_INDEX
)))
1255 spacing
= XINT (AREF (entity
, FONT_SPACING_INDEX
));
1257 spacing
= FC_PROPORTIONAL
;
1258 if (spacing
!= FC_PROPORTIONAL
)
1259 font
->min_width
= font
->average_width
= font
->space_width
1260 = (scalable
? ft_face
->max_advance_width
* size
/ upEM
1261 : ft_face
->size
->metrics
.max_advance
>> 6);
1266 font
->min_width
= font
->average_width
= font
->space_width
= 0;
1267 for (i
= 32, n
= 0; i
< 127; i
++)
1268 if (FT_Load_Char (ft_face
, i
, FT_LOAD_DEFAULT
) == 0)
1270 int this_width
= ft_face
->glyph
->metrics
.horiAdvance
>> 6;
1273 && (! font
->min_width
|| font
->min_width
> this_width
))
1274 font
->min_width
= this_width
;
1276 font
->space_width
= this_width
;
1277 font
->average_width
+= this_width
;
1281 font
->average_width
/= n
;
1284 font
->baseline_offset
= 0;
1285 font
->relative_compose
= 0;
1286 font
->default_ascent
= 0;
1287 font
->vertical_centering
= 0;
1290 font
->underline_position
= -ft_face
->underline_position
* size
/ upEM
;
1291 font
->underline_thickness
= ft_face
->underline_thickness
* size
/ upEM
;
1295 font
->underline_position
= -1;
1296 font
->underline_thickness
= 0;
1303 ftfont_close (f
, font
)
1307 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
1308 Lisp_Object val
, cache
;
1310 val
= Fcons (font
->props
[FONT_FILE_INDEX
], make_number (ftfont_info
->index
));
1311 cache
= ftfont_lookup_cache (val
, FTFONT_CACHE_FOR_FACE
);
1312 xassert (CONSP (cache
));
1314 (XSAVE_VALUE (val
)->integer
)--;
1315 if (XSAVE_VALUE (val
)->integer
== 0)
1317 struct ftfont_cache_data
*cache_data
= XSAVE_VALUE (val
)->pointer
;
1319 FT_Done_Face (cache_data
->ft_face
);
1321 if (ftfont_info
->otf
)
1322 OTF_close (ftfont_info
->otf
);
1324 cache_data
->ft_face
= NULL
;
1327 FT_Done_Size (ftfont_info
->ft_size
);
1331 ftfont_has_char (font
, c
)
1335 struct charset
*cs
= NULL
;
1337 if (EQ (AREF (font
, FONT_ADSTYLE_INDEX
), Qja
)
1338 && charset_jisx0208
>= 0)
1339 cs
= CHARSET_FROM_ID (charset_jisx0208
);
1340 else if (EQ (AREF (font
, FONT_ADSTYLE_INDEX
), Qko
)
1341 && charset_ksc5601
>= 0)
1342 cs
= CHARSET_FROM_ID (charset_ksc5601
);
1344 return (ENCODE_CHAR (cs
, c
) != CHARSET_INVALID_CODE (cs
));
1346 if (FONT_ENTITY_P (font
))
1348 FcCharSet
*charset
= ftfont_get_fc_charset (font
);
1350 return (FcCharSetHasChar (charset
, c
) == FcTrue
);
1354 struct ftfont_info
*ftfont_info
;
1356 ftfont_info
= (struct ftfont_info
*) XFONT_OBJECT (font
);
1357 return (FT_Get_Char_Index (ftfont_info
->ft_size
->face
, (FT_ULong
) c
)
1363 ftfont_encode_char (font
, c
)
1367 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
1368 FT_Face ft_face
= ftfont_info
->ft_size
->face
;
1369 FT_ULong charcode
= c
;
1370 FT_UInt code
= FT_Get_Char_Index (ft_face
, charcode
);
1372 return (code
> 0 ? code
: FONT_INVALID_CODE
);
1376 ftfont_text_extents (font
, code
, nglyphs
, metrics
)
1380 struct font_metrics
*metrics
;
1382 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
1383 FT_Face ft_face
= ftfont_info
->ft_size
->face
;
1387 if (ftfont_info
->ft_size
!= ft_face
->size
)
1388 FT_Activate_Size (ftfont_info
->ft_size
);
1390 bzero (metrics
, sizeof (struct font_metrics
));
1391 for (i
= 0, first
= 1; i
< nglyphs
; i
++)
1393 if (FT_Load_Glyph (ft_face
, code
[i
], FT_LOAD_DEFAULT
) == 0)
1395 FT_Glyph_Metrics
*m
= &ft_face
->glyph
->metrics
;
1401 metrics
->lbearing
= m
->horiBearingX
>> 6;
1402 metrics
->rbearing
= (m
->horiBearingX
+ m
->width
) >> 6;
1403 metrics
->ascent
= m
->horiBearingY
>> 6;
1404 metrics
->descent
= (m
->height
- m
->horiBearingY
) >> 6;
1410 if (metrics
->lbearing
> width
+ (m
->horiBearingX
>> 6))
1411 metrics
->lbearing
= width
+ (m
->horiBearingX
>> 6);
1412 if (metrics
->rbearing
1413 < width
+ ((m
->horiBearingX
+ m
->width
) >> 6))
1415 = width
+ ((m
->horiBearingX
+ m
->width
) >> 6);
1416 if (metrics
->ascent
< (m
->horiBearingY
>> 6))
1417 metrics
->ascent
= m
->horiBearingY
>> 6;
1418 if (metrics
->descent
> ((m
->height
- m
->horiBearingY
) >> 6))
1419 metrics
->descent
= (m
->height
- m
->horiBearingY
) >> 6;
1421 width
+= m
->horiAdvance
>> 6;
1425 width
+= font
->space_width
;
1429 metrics
->width
= width
;
1435 ftfont_get_bitmap (font
, code
, bitmap
, bits_per_pixel
)
1438 struct font_bitmap
*bitmap
;
1441 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
1442 FT_Face ft_face
= ftfont_info
->ft_size
->face
;
1443 FT_Int32 load_flags
= FT_LOAD_RENDER
;
1445 if (ftfont_info
->ft_size
!= ft_face
->size
)
1446 FT_Activate_Size (ftfont_info
->ft_size
);
1447 if (bits_per_pixel
== 1)
1449 #ifdef FT_LOAD_TARGET_MONO
1450 load_flags
|= FT_LOAD_TARGET_MONO
;
1452 load_flags
|= FT_LOAD_MONOCHROME
;
1455 else if (bits_per_pixel
!= 8)
1456 /* We don't support such a rendering. */
1459 if (FT_Load_Glyph (ft_face
, code
, load_flags
) != 0)
1461 bitmap
->bits_per_pixel
1462 = (ft_face
->glyph
->bitmap
.pixel_mode
== FT_PIXEL_MODE_MONO
? 1
1463 : ft_face
->glyph
->bitmap
.pixel_mode
== FT_PIXEL_MODE_GRAY
? 8
1464 : ft_face
->glyph
->bitmap
.pixel_mode
== FT_PIXEL_MODE_LCD
? 8
1465 : ft_face
->glyph
->bitmap
.pixel_mode
== FT_PIXEL_MODE_LCD_V
? 8
1467 if (bitmap
->bits_per_pixel
< 0)
1468 /* We don't suport that kind of pixel mode. */
1470 bitmap
->rows
= ft_face
->glyph
->bitmap
.rows
;
1471 bitmap
->width
= ft_face
->glyph
->bitmap
.width
;
1472 bitmap
->pitch
= ft_face
->glyph
->bitmap
.pitch
;
1473 bitmap
->buffer
= ft_face
->glyph
->bitmap
.buffer
;
1474 bitmap
->left
= ft_face
->glyph
->bitmap_left
;
1475 bitmap
->top
= ft_face
->glyph
->bitmap_top
;
1476 bitmap
->advance
= ft_face
->glyph
->metrics
.horiAdvance
>> 6;
1477 bitmap
->extra
= NULL
;
1483 ftfont_anchor_point (font
, code
, index
, x
, y
)
1489 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
1490 FT_Face ft_face
= ftfont_info
->ft_size
->face
;
1492 if (ftfont_info
->ft_size
!= ft_face
->size
)
1493 FT_Activate_Size (ftfont_info
->ft_size
);
1494 if (FT_Load_Glyph (ft_face
, code
, FT_LOAD_DEFAULT
) != 0)
1496 if (ft_face
->glyph
->format
!= FT_GLYPH_FORMAT_OUTLINE
)
1498 if (index
>= ft_face
->glyph
->outline
.n_points
)
1500 *x
= ft_face
->glyph
->outline
.points
[index
].x
;
1501 *y
= ft_face
->glyph
->outline
.points
[index
].y
;
1508 ftfont_otf_features (gsub_gpos
)
1509 OTF_GSUB_GPOS
*gsub_gpos
;
1511 Lisp_Object scripts
, langsyses
, features
, sym
;
1514 for (scripts
= Qnil
, i
= gsub_gpos
->ScriptList
.ScriptCount
- 1; i
>= 0; i
--)
1516 OTF_Script
*otf_script
= gsub_gpos
->ScriptList
.Script
+ i
;
1518 for (langsyses
= Qnil
, j
= otf_script
->LangSysCount
- 1; j
>= -1; j
--)
1520 OTF_LangSys
*otf_langsys
;
1523 otf_langsys
= otf_script
->LangSys
+ j
;
1524 else if (otf_script
->DefaultLangSysOffset
)
1525 otf_langsys
= &otf_script
->DefaultLangSys
;
1529 for (features
= Qnil
, k
= otf_langsys
->FeatureCount
- 1; k
>= 0; k
--)
1531 l
= otf_langsys
->FeatureIndex
[k
];
1532 if (l
>= gsub_gpos
->FeatureList
.FeatureCount
)
1534 OTF_TAG_SYM (sym
, gsub_gpos
->FeatureList
.Feature
[l
].FeatureTag
);
1535 features
= Fcons (sym
, features
);
1538 OTF_TAG_SYM (sym
, otf_script
->LangSysRecord
[j
].LangSysTag
);
1541 langsyses
= Fcons (Fcons (sym
, features
), langsyses
);
1544 OTF_TAG_SYM (sym
, gsub_gpos
->ScriptList
.Script
[i
].ScriptTag
);
1545 scripts
= Fcons (Fcons (sym
, langsyses
), scripts
);
1553 ftfont_otf_capability (font
)
1556 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
1557 OTF
*otf
= ftfont_get_otf (ftfont_info
);
1558 Lisp_Object gsub_gpos
;
1562 gsub_gpos
= Fcons (Qnil
, Qnil
);
1563 if (OTF_get_table (otf
, "GSUB") == 0
1564 && otf
->gsub
->FeatureList
.FeatureCount
> 0)
1565 XSETCAR (gsub_gpos
, ftfont_otf_features (otf
->gsub
));
1566 if (OTF_get_table (otf
, "GPOS") == 0
1567 && otf
->gpos
->FeatureList
.FeatureCount
> 0)
1568 XSETCDR (gsub_gpos
, ftfont_otf_features (otf
->gpos
));
1572 #ifdef HAVE_M17N_FLT
1583 ftfont_get_glyph_id (font
, gstring
, from
, to
)
1585 MFLTGlyphString
*gstring
;
1588 struct MFLTFontFT
*flt_font_ft
= (struct MFLTFontFT
*) font
;
1589 FT_Face ft_face
= flt_font_ft
->ft_face
;
1592 for (g
= gstring
->glyphs
+ from
; from
< to
; g
++, from
++)
1595 FT_UInt code
= FT_Get_Char_Index (ft_face
, g
->code
);
1597 g
->code
= code
> 0 ? code
: FONT_INVALID_CODE
;
1604 ftfont_get_metrics (font
, gstring
, from
, to
)
1606 MFLTGlyphString
*gstring
;
1609 struct MFLTFontFT
*flt_font_ft
= (struct MFLTFontFT
*) font
;
1610 FT_Face ft_face
= flt_font_ft
->ft_face
;
1613 for (g
= gstring
->glyphs
+ from
; from
< to
; g
++, from
++)
1616 if (g
->code
!= FONT_INVALID_CODE
)
1618 FT_Glyph_Metrics
*m
;
1620 if (FT_Load_Glyph (ft_face
, g
->code
, FT_LOAD_DEFAULT
) != 0)
1622 m
= &ft_face
->glyph
->metrics
;
1624 g
->lbearing
= m
->horiBearingX
;
1625 g
->rbearing
= m
->horiBearingX
+ m
->width
;
1626 g
->ascent
= m
->horiBearingY
;
1627 g
->descent
= m
->height
- m
->horiBearingY
;
1628 g
->xadv
= m
->horiAdvance
;
1633 g
->rbearing
= g
->xadv
= flt_font_ft
->font
->space_width
<< 6;
1634 g
->ascent
= flt_font_ft
->font
->ascent
<< 6;
1635 g
->descent
= flt_font_ft
->font
->descent
<< 6;
1644 ftfont_check_otf (MFLTFont
*font
, MFLTOtfSpec
*spec
)
1646 struct MFLTFontFT
*flt_font_ft
= (struct MFLTFontFT
*) font
;
1647 OTF
*otf
= flt_font_ft
->otf
;
1651 for (i
= 0; i
< 2; i
++)
1653 if (! spec
->features
[i
])
1655 for (n
= 0; spec
->features
[i
][n
]; n
++);
1656 tags
= alloca (sizeof (OTF_Tag
) * n
);
1657 for (n
= 0, negative
= 0; spec
->features
[i
][n
]; n
++)
1659 if (spec
->features
[i
][n
] == 0xFFFFFFFF)
1662 tags
[n
- 1] = spec
->features
[i
][n
] | 0x80000000;
1664 tags
[n
] = spec
->features
[i
][n
];
1666 if (n
- negative
> 0
1667 && OTF_check_features (otf
, i
== 0, spec
->script
, spec
->langsys
,
1668 tags
, n
- negative
) != 1)
1674 #define DEVICE_DELTA(table, size) \
1675 (((size) >= (table).StartSize && (size) <= (table).EndSize) \
1676 ? (table).DeltaValue[(size) - (table).StartSize] << 6 \
1680 adjust_anchor (FT_Face ft_face
, OTF_Anchor
*anchor
,
1681 unsigned code
, int x_ppem
, int y_ppem
, int *x
, int *y
)
1683 if (anchor
->AnchorFormat
== 2)
1685 FT_Outline
*outline
;
1686 int ap
= anchor
->f
.f1
.AnchorPoint
;
1688 FT_Load_Glyph (ft_face
, (FT_UInt
) code
, FT_LOAD_MONOCHROME
);
1689 outline
= &ft_face
->glyph
->outline
;
1690 if (ap
< outline
->n_points
)
1692 *x
= outline
->points
[ap
].x
<< 6;
1693 *y
= outline
->points
[ap
].y
<< 6;
1696 else if (anchor
->AnchorFormat
== 3)
1698 if (anchor
->f
.f2
.XDeviceTable
.offset
1699 && anchor
->f
.f2
.XDeviceTable
.DeltaValue
)
1700 *x
+= DEVICE_DELTA (anchor
->f
.f2
.XDeviceTable
, x_ppem
);
1701 if (anchor
->f
.f2
.YDeviceTable
.offset
1702 && anchor
->f
.f2
.YDeviceTable
.DeltaValue
)
1703 *y
+= DEVICE_DELTA (anchor
->f
.f2
.YDeviceTable
, y_ppem
);
1707 static OTF_GlyphString otf_gstring
;
1710 setup_otf_gstring (int size
)
1712 if (otf_gstring
.size
== 0)
1714 otf_gstring
.glyphs
= (OTF_Glyph
*) xmalloc (sizeof (OTF_Glyph
) * size
);
1715 otf_gstring
.size
= size
;
1717 else if (otf_gstring
.size
< size
)
1719 otf_gstring
.glyphs
= xrealloc (otf_gstring
.glyphs
,
1720 sizeof (OTF_Glyph
) * size
);
1721 otf_gstring
.size
= size
;
1723 otf_gstring
.used
= size
;
1724 memset (otf_gstring
.glyphs
, 0, sizeof (OTF_Glyph
) * size
);
1729 ftfont_drive_otf (font
, spec
, in
, from
, to
, out
, adjustment
)
1732 MFLTGlyphString
*in
;
1734 MFLTGlyphString
*out
;
1735 MFLTGlyphAdjustment
*adjustment
;
1737 struct MFLTFontFT
*flt_font_ft
= (struct MFLTFontFT
*) font
;
1738 FT_Face ft_face
= flt_font_ft
->ft_face
;
1739 OTF
*otf
= flt_font_ft
->otf
;
1740 int len
= to
- from
;
1743 char script
[5], *langsys
= NULL
;
1744 char *gsub_features
= NULL
, *gpos_features
= NULL
;
1748 OTF_tag_name (spec
->script
, script
);
1751 langsys
= alloca (5);
1752 OTF_tag_name (spec
->langsys
, langsys
);
1754 for (i
= 0; i
< 2; i
++)
1758 if (spec
->features
[i
] && spec
->features
[i
][1] != 0xFFFFFFFF)
1760 for (j
= 0; spec
->features
[i
][j
]; j
++);
1762 p
= gsub_features
= alloca (6 * j
);
1764 p
= gpos_features
= alloca (6 * j
);
1765 for (j
= 0; spec
->features
[i
][j
]; j
++)
1767 if (spec
->features
[i
][j
] == 0xFFFFFFFF)
1768 *p
++ = '*', *p
++ = ',';
1771 OTF_tag_name (spec
->features
[i
][j
], p
);
1780 setup_otf_gstring (len
);
1781 for (i
= 0; i
< len
; i
++)
1783 otf_gstring
.glyphs
[i
].c
= in
->glyphs
[from
+ i
].c
;
1784 otf_gstring
.glyphs
[i
].glyph_id
= in
->glyphs
[from
+ i
].code
;
1787 OTF_drive_gdef (otf
, &otf_gstring
);
1792 if (OTF_drive_gsub (otf
, &otf_gstring
, script
, langsys
, gsub_features
)
1795 if (out
->allocated
< out
->used
+ otf_gstring
.used
)
1797 for (i
= 0, otfg
= otf_gstring
.glyphs
; i
< otf_gstring
.used
; )
1800 int min_from
, max_to
;
1803 g
= out
->glyphs
+ out
->used
;
1804 *g
= in
->glyphs
[from
+ otfg
->f
.index
.from
];
1805 if (g
->code
!= otfg
->glyph_id
)
1808 g
->code
= otfg
->glyph_id
;
1814 if (otfg
->f
.index
.from
< otfg
->f
.index
.to
)
1816 /* OTFG substitutes multiple glyphs in IN. */
1817 for (j
= from
+ otfg
->f
.index
.from
+ 1;
1818 j
<= from
+ otfg
->f
.index
.to
; j
++)
1820 if (min_from
> in
->glyphs
[j
].from
)
1821 min_from
= in
->glyphs
[j
].from
;
1822 if (max_to
< in
->glyphs
[j
].to
)
1823 max_to
= in
->glyphs
[j
].to
;
1828 for (i
++, otfg
++; (i
< otf_gstring
.used
1829 && otfg
->f
.index
.from
== otfg
[-1].f
.index
.from
);
1832 g
= out
->glyphs
+ out
->used
;
1833 *g
= in
->glyphs
[from
+ otfg
->f
.index
.to
];
1834 if (g
->code
!= otfg
->glyph_id
)
1837 g
->code
= otfg
->glyph_id
;
1846 if (out
->allocated
< out
->used
+ len
)
1848 for (i
= 0; i
< len
; i
++)
1849 out
->glyphs
[out
->used
++] = in
->glyphs
[from
+ i
];
1854 MFLTGlyph
*base
= NULL
, *mark
= NULL
, *g
;
1855 int x_ppem
, y_ppem
, x_scale
, y_scale
;
1857 if (OTF_drive_gpos (otf
, &otf_gstring
, script
, langsys
, gpos_features
)
1861 x_ppem
= ft_face
->size
->metrics
.x_ppem
;
1862 y_ppem
= ft_face
->size
->metrics
.y_ppem
;
1863 x_scale
= ft_face
->size
->metrics
.x_scale
;
1864 y_scale
= ft_face
->size
->metrics
.y_scale
;
1866 for (i
= 0, otfg
= otf_gstring
.glyphs
, g
= out
->glyphs
+ gidx
;
1867 i
< otf_gstring
.used
; i
++, otfg
++, g
++)
1871 if (! otfg
->glyph_id
)
1873 switch (otfg
->positioning_type
)
1877 case 1: /* Single */
1880 int format
= otfg
->f
.f1
.format
;
1882 if (format
& OTF_XPlacement
)
1884 = otfg
->f
.f1
.value
->XPlacement
* x_scale
/ 0x10000;
1885 if (format
& OTF_XPlaDevice
)
1887 += DEVICE_DELTA (otfg
->f
.f1
.value
->XPlaDevice
, x_ppem
);
1888 if (format
& OTF_YPlacement
)
1890 = - (otfg
->f
.f1
.value
->YPlacement
* y_scale
/ 0x10000);
1891 if (format
& OTF_YPlaDevice
)
1893 -= DEVICE_DELTA (otfg
->f
.f1
.value
->YPlaDevice
, y_ppem
);
1894 if (format
& OTF_XAdvance
)
1896 += otfg
->f
.f1
.value
->XAdvance
* x_scale
/ 0x10000;
1897 if (format
& OTF_XAdvDevice
)
1899 += DEVICE_DELTA (otfg
->f
.f1
.value
->XAdvDevice
, x_ppem
);
1900 if (format
& OTF_YAdvance
)
1902 += otfg
->f
.f1
.value
->YAdvance
* y_scale
/ 0x10000;
1903 if (format
& OTF_YAdvDevice
)
1905 += DEVICE_DELTA (otfg
->f
.f1
.value
->YAdvDevice
, y_ppem
);
1906 adjustment
[i
].set
= 1;
1909 case 3: /* Cursive */
1910 /* Not yet supported. */
1912 case 4: /* Mark-to-Base */
1913 case 5: /* Mark-to-Ligature */
1917 goto label_adjust_anchor
;
1918 default: /* i.e. case 6 Mark-to-Mark */
1923 label_adjust_anchor
:
1925 int base_x
, base_y
, mark_x
, mark_y
;
1926 int this_from
, this_to
;
1928 base_x
= otfg
->f
.f4
.base_anchor
->XCoordinate
* x_scale
/ 0x10000;
1929 base_y
= otfg
->f
.f4
.base_anchor
->YCoordinate
* y_scale
/ 0x10000;
1930 mark_x
= otfg
->f
.f4
.mark_anchor
->XCoordinate
* x_scale
/ 0x10000;
1931 mark_y
= otfg
->f
.f4
.mark_anchor
->YCoordinate
* y_scale
/ 0x10000;
1933 if (otfg
->f
.f4
.base_anchor
->AnchorFormat
!= 1)
1934 adjust_anchor (ft_face
, otfg
->f
.f4
.base_anchor
,
1935 prev
->code
, x_ppem
, y_ppem
, &base_x
, &base_y
);
1936 if (otfg
->f
.f4
.mark_anchor
->AnchorFormat
!= 1)
1937 adjust_anchor (ft_face
, otfg
->f
.f4
.mark_anchor
, g
->code
,
1938 x_ppem
, y_ppem
, &mark_x
, &mark_y
);
1939 adjustment
[i
].xoff
= (base_x
- mark_x
);
1940 adjustment
[i
].yoff
= - (base_y
- mark_y
);
1941 adjustment
[i
].back
= (g
- prev
);
1942 adjustment
[i
].xadv
= 0;
1943 adjustment
[i
].advance_is_absolute
= 1;
1944 adjustment
[i
].set
= 1;
1945 this_from
= g
->from
;
1947 for (j
= 0; prev
+ j
< g
; j
++)
1949 if (this_from
> prev
[j
].from
)
1950 this_from
= prev
[j
].from
;
1951 if (this_to
< prev
[j
].to
)
1952 this_to
= prev
[j
].to
;
1954 for (; prev
<= g
; prev
++)
1956 prev
->from
= this_from
;
1961 if (otfg
->GlyphClass
== OTF_GlyphClass0
)
1963 else if (otfg
->GlyphClass
== OTF_GlyphClassMark
)
1972 if (out
->allocated
< out
->used
+ len
)
1974 font
->get_metrics (font
, in
, from
, to
);
1975 memcpy (out
->glyphs
+ out
->used
, in
->glyphs
+ from
,
1976 sizeof (MFLTGlyph
) * len
);
1981 static MFLTGlyphString gstring
;
1983 static int m17n_flt_initialized
;
1985 extern Lisp_Object QCfamily
;
1988 ftfont_shape_by_flt (lgstring
, font
, ft_face
, otf
)
1989 Lisp_Object lgstring
;
1994 EMACS_UINT len
= LGSTRING_GLYPH_LEN (lgstring
);
1996 struct MFLTFontFT flt_font_ft
;
1998 int with_variation_selector
= 0;
2000 if (! m17n_flt_initialized
)
2003 m17n_flt_initialized
= 1;
2006 for (i
= 0; i
< len
; i
++)
2008 Lisp_Object g
= LGSTRING_GLYPH (lgstring
, i
);
2013 c
= LGLYPH_CHAR (g
);
2014 if (CHAR_VARIATION_SELECTOR_P (c
))
2015 with_variation_selector
++;
2018 if (with_variation_selector
)
2020 setup_otf_gstring (len
);
2021 for (i
= 0; i
< len
; i
++)
2023 Lisp_Object g
= LGSTRING_GLYPH (lgstring
, i
);
2025 otf_gstring
.glyphs
[i
].c
= LGLYPH_CHAR (g
);
2026 otf_gstring
.glyphs
[i
].f
.index
.from
= LGLYPH_FROM (g
);
2027 otf_gstring
.glyphs
[i
].f
.index
.to
= LGLYPH_TO (g
);
2029 OTF_drive_cmap (otf
, &otf_gstring
);
2030 for (i
= 0; i
< otf_gstring
.used
; i
++)
2032 OTF_Glyph
*otfg
= otf_gstring
.glyphs
+ i
;
2033 Lisp_Object g0
= LGSTRING_GLYPH (lgstring
, otfg
->f
.index
.from
);
2034 Lisp_Object g1
= LGSTRING_GLYPH (lgstring
, otfg
->f
.index
.to
);
2036 LGLYPH_SET_CODE (g0
, otfg
->glyph_id
);
2037 LGLYPH_SET_TO (g0
, LGLYPH_TO (g1
));
2038 LGSTRING_SET_GLYPH (lgstring
, i
, g0
);
2040 if (len
> otf_gstring
.used
)
2042 len
= otf_gstring
.used
;
2043 LGSTRING_SET_GLYPH (lgstring
, len
, Qnil
);
2047 if (gstring
.allocated
== 0)
2049 gstring
.allocated
= len
* 2;
2050 gstring
.glyph_size
= sizeof (MFLTGlyph
);
2051 gstring
.glyphs
= xmalloc (sizeof (MFLTGlyph
) * gstring
.allocated
);
2053 else if (gstring
.allocated
< len
* 2)
2055 gstring
.allocated
= len
* 2;
2056 gstring
.glyphs
= xrealloc (gstring
.glyphs
,
2057 sizeof (MFLTGlyph
) * gstring
.allocated
);
2059 memset (gstring
.glyphs
, 0, sizeof (MFLTGlyph
) * len
);
2060 for (i
= 0; i
< len
; i
++)
2062 Lisp_Object g
= LGSTRING_GLYPH (lgstring
, i
);
2064 gstring
.glyphs
[i
].c
= LGLYPH_CHAR (g
);
2065 if (with_variation_selector
)
2067 gstring
.glyphs
[i
].code
= LGLYPH_CODE (g
);
2068 gstring
.glyphs
[i
].encoded
= 1;
2076 Lisp_Object family
= Ffont_get (LGSTRING_FONT (lgstring
), QCfamily
);
2079 flt_font_ft
.flt_font
.family
= Mnil
;
2081 flt_font_ft
.flt_font
.family
2082 = msymbol ((char *) SDATA (Fdowncase (SYMBOL_NAME (family
))));
2084 flt_font_ft
.flt_font
.x_ppem
= ft_face
->size
->metrics
.x_ppem
;
2085 flt_font_ft
.flt_font
.y_ppem
= ft_face
->size
->metrics
.y_ppem
;
2086 flt_font_ft
.flt_font
.get_glyph_id
= ftfont_get_glyph_id
;
2087 flt_font_ft
.flt_font
.get_metrics
= ftfont_get_metrics
;
2088 flt_font_ft
.flt_font
.check_otf
= ftfont_check_otf
;
2089 flt_font_ft
.flt_font
.drive_otf
= ftfont_drive_otf
;
2090 flt_font_ft
.flt_font
.internal
= NULL
;
2091 flt_font_ft
.font
= font
;
2092 flt_font_ft
.ft_face
= ft_face
;
2093 flt_font_ft
.otf
= otf
;
2095 && gstring
.glyphs
[1].c
>= 0x300 && gstring
.glyphs
[1].c
<= 0x36F)
2096 /* A little bit ad hoc. Perhaps, shaper must get script and
2097 language information, and select a proper flt for them
2099 flt
= mflt_get (msymbol ("combining"));
2100 for (i
= 0; i
< 3; i
++)
2102 int result
= mflt_run (&gstring
, 0, len
, &flt_font_ft
.flt_font
, flt
);
2105 gstring
.allocated
+= gstring
.allocated
;
2106 gstring
.glyphs
= xrealloc (gstring
.glyphs
,
2107 sizeof (MFLTGlyph
) * gstring
.allocated
);
2109 if (gstring
.used
> LGSTRING_GLYPH_LEN (lgstring
))
2111 for (i
= 0; i
< gstring
.used
; i
++)
2113 MFLTGlyph
*g
= gstring
.glyphs
+ i
;
2115 g
->from
= LGLYPH_FROM (LGSTRING_GLYPH (lgstring
, g
->from
));
2116 g
->to
= LGLYPH_TO (LGSTRING_GLYPH (lgstring
, g
->to
));
2119 for (i
= 0; i
< gstring
.used
; i
++)
2121 Lisp_Object lglyph
= LGSTRING_GLYPH (lgstring
, i
);
2122 MFLTGlyph
*g
= gstring
.glyphs
+ i
;
2126 lglyph
= Fmake_vector (make_number (LGLYPH_SIZE
), Qnil
);
2127 LGSTRING_SET_GLYPH (lgstring
, i
, lglyph
);
2129 LGLYPH_SET_FROM (lglyph
, g
->from
);
2130 LGLYPH_SET_TO (lglyph
, g
->to
);
2131 LGLYPH_SET_CHAR (lglyph
, g
->c
);
2132 LGLYPH_SET_CODE (lglyph
, g
->code
);
2133 LGLYPH_SET_WIDTH (lglyph
, g
->xadv
>> 6);
2134 LGLYPH_SET_LBEARING (lglyph
, g
->lbearing
>> 6);
2135 LGLYPH_SET_RBEARING (lglyph
, g
->rbearing
>> 6);
2136 LGLYPH_SET_ASCENT (lglyph
, g
->ascent
>> 6);
2137 LGLYPH_SET_DESCENT (lglyph
, g
->descent
>> 6);
2142 vec
= Fmake_vector (make_number (3), Qnil
);
2143 ASET (vec
, 0, make_number (g
->xoff
>> 6));
2144 ASET (vec
, 1, make_number (g
->yoff
>> 6));
2145 ASET (vec
, 2, make_number (g
->xadv
>> 6));
2146 LGLYPH_SET_ADJUSTMENT (lglyph
, vec
);
2149 return make_number (i
);
2153 ftfont_shape (lgstring
)
2154 Lisp_Object lgstring
;
2157 struct ftfont_info
*ftfont_info
;
2160 CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring
), font
);
2161 ftfont_info
= (struct ftfont_info
*) font
;
2162 otf
= ftfont_get_otf (ftfont_info
);
2164 return make_number (0);
2165 return ftfont_shape_by_flt (lgstring
, font
, ftfont_info
->ft_size
->face
, otf
);
2168 #endif /* HAVE_M17N_FLT */
2170 #ifdef HAVE_OTF_GET_VARIATION_GLYPHS
2173 ftfont_variation_glyphs (font
, c
, variations
)
2176 unsigned variations
[256];
2178 struct ftfont_info
*ftfont_info
= (struct ftfont_info
*) font
;
2179 OTF
*otf
= ftfont_get_otf (ftfont_info
);
2183 return OTF_get_variation_glyphs (otf
, c
, variations
);
2186 #endif /* HAVE_OTF_GET_VARIATION_GLYPHS */
2187 #endif /* HAVE_LIBOTF */
2190 ftfont_font_format (FcPattern
*pattern
, Lisp_Object filename
)
2194 #ifdef FC_FONTFORMAT
2197 if (FcPatternGetString (pattern
, FC_FONTFORMAT
, 0, &str
) != FcResultMatch
)
2199 if (strcmp ((char *) str
, "TrueType") == 0)
2200 return intern ("truetype");
2201 if (strcmp ((char *) str
, "Type 1") == 0)
2202 return intern ("type1");
2203 if (strcmp ((char *) str
, "PCF") == 0)
2204 return intern ("pcf");
2205 if (strcmp ((char *) str
, "BDF") == 0)
2206 return intern ("bdf");
2208 #endif /* FC_FONTFORMAT */
2209 if (STRINGP (filename
))
2211 int len
= SBYTES (filename
);
2215 str
= (FcChar8
*) (SDATA (filename
) + len
- 4);
2216 if (xstrcasecmp ((char *) str
, ".ttf") == 0)
2217 return intern ("truetype");
2218 if (xstrcasecmp ((char *) str
, ".pfb") == 0)
2219 return intern ("type1");
2220 if (xstrcasecmp ((char *) str
, ".pcf") == 0)
2221 return intern ("pcf");
2222 if (xstrcasecmp ((char *) str
, ".bdf") == 0)
2223 return intern ("bdf");
2226 return intern ("unknown");
2233 DEFSYM (Qfreetype
, "freetype");
2234 DEFSYM (Qmonospace
, "monospace");
2235 DEFSYM (Qsans_serif
, "sans-serif");
2236 DEFSYM (Qserif
, "serif");
2237 DEFSYM (Qmono
, "mono");
2238 DEFSYM (Qsans
, "sans");
2239 DEFSYM (Qsans__serif
, "sans serif");
2241 staticpro (&freetype_font_cache
);
2242 freetype_font_cache
= Fcons (Qt
, Qnil
);
2244 staticpro (&ftfont_generic_family_list
);
2245 ftfont_generic_family_list
2246 = Fcons (Fcons (Qmonospace
, Qt
),
2247 Fcons (Fcons (Qsans_serif
, Qt
),
2248 Fcons (Fcons (Qsans
, Qt
), Qnil
)));
2250 staticpro (&ft_face_cache
);
2251 ft_face_cache
= Qnil
;
2253 ftfont_driver
.type
= Qfreetype
;
2254 register_font_driver (&ftfont_driver
, NULL
);
2257 /* arch-tag: 7cfa432c-33a6-4988-83d2-a82ed8604aca
2258 (do not change this comment) */