annotate src/ftfont.c @ 90607:23b035bbd7be

(iso-8859-6): New coding system.
author Kenichi Handa <handa@m17n.org>
date Mon, 02 Oct 2006 08:05:16 +0000
parents 3762a2cc74de
children 4978b2cb6a9e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1 /* ftfont.c -- FreeType font driver.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2 Copyright (C) 2006 Free Software Foundation, Inc.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3 Copyright (C) 2006
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
4 National Institute of Advanced Industrial Science and Technology (AIST)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
5 Registration Number H13PRO009
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
6
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
7 This file is part of GNU Emacs.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
8
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
9 GNU Emacs is free software; you can redistribute it and/or modify
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
11 the Free Software Foundation; either version 2, or (at your option)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
12 any later version.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
13
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
14 GNU Emacs is distributed in the hope that it will be useful,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17 GNU General Public License for more details.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
20 along with GNU Emacs; see the file COPYING. If not, write to
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 Boston, MA 02110-1301, USA. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
23
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
24 #include <config.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
25 #include <stdio.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27 #include <ft2build.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28 #include FT_FREETYPE_H
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29 #include FT_SIZES_H
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 #include <fontconfig/fontconfig.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31 #include <fontconfig/fcfreetype.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 #include "lisp.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 #include "dispextern.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 #include "frame.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36 #include "blockinput.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 #include "character.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38 #include "charset.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39 #include "coding.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40 #include "fontset.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41 #include "font.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
42
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
43 /* Symbolic type of this font-driver. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
44 Lisp_Object Qfreetype;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
46 /* Fontconfig's generic families and their aliases. */
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
47 static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
48
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
49 /* Flag to tell if FcInit is areadly called or not. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50 static int fc_initialized;
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
51
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
52 /* Handle to a FreeType library instance. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53 static FT_Library ft_library;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
54
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
55 /* Cache for FreeType fonts. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
56 static Lisp_Object freetype_font_cache;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
57
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
58 /* Fontconfig's charset used for finding fonts of registry
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
59 "iso8859-1". */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
60 static FcCharSet *cs_iso8859_1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
61
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
62 /* The actual structure for FreeType font that can be casted to struct
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
63 font. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
64
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
65 struct ftfont_info
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
66 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
67 struct font font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
68 FT_Size ft_size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
69 };
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
70
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
71 static int ftfont_build_basic_charsets P_ ((void));
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
72 static Lisp_Object ftfont_pattern_entity P_ ((FcPattern *,
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
73 Lisp_Object, Lisp_Object));
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
74 static Lisp_Object ftfont_list_generic_family P_ ((Lisp_Object, Lisp_Object,
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
75 Lisp_Object));
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
76
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
77 #define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
78
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
79 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
80 ftfont_build_basic_charsets ()
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
81 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
82 FcChar32 c;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
83
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
84 cs_iso8859_1 = FcCharSetCreate ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
85 if (! cs_iso8859_1)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
86 return -1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
87 for (c = ' '; c < 127; c++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
88 if (! FcCharSetAddChar (cs_iso8859_1, c))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
89 return -1;
90524
b7bcc590bab5 (ftfont_list): Fix typo.
Kenichi Handa <handa@m17n.org>
parents: 90522
diff changeset
90 #if 0
b7bcc590bab5 (ftfont_list): Fix typo.
Kenichi Handa <handa@m17n.org>
parents: 90522
diff changeset
91 /* This part is currently disabled. Should be fixed later. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
92 for (c = 192; c < 256; c++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
93 if (! FcCharSetAddChar (cs_iso8859_1, c))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
94 return -1;
90524
b7bcc590bab5 (ftfont_list): Fix typo.
Kenichi Handa <handa@m17n.org>
parents: 90522
diff changeset
95 #endif
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
96 return 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
97 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
98
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
99 static Lisp_Object
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
100 ftfont_pattern_entity (p, frame, registry)
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
101 FcPattern *p;
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
102 Lisp_Object frame, registry;
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
103 {
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
104 Lisp_Object entity;
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
105 FcChar8 *file;
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
106 FcCharSet *charset;
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
107 char *str;
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
108 int numeric;
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
109 double dbl;
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
110
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
111 if (FcPatternGetString (p, FC_FILE, 0, &file) != FcResultMatch)
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
112 return Qnil;
90450
5c96354daf9e (ftfont_pattern_entity): Fix typo.
Kenichi Handa <handa@m17n.org>
parents: 90441
diff changeset
113 if (FcPatternGetCharSet (p, FC_CHARSET, 0, &charset) != FcResultMatch)
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
114 charset = NULL;
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
115
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
116 entity = Fmake_vector (make_number (FONT_ENTITY_MAX), null_string);
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
117
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
118 ASET (entity, FONT_TYPE_INDEX, Qfreetype);
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
119 ASET (entity, FONT_REGISTRY_INDEX, registry);
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
120 ASET (entity, FONT_FRAME_INDEX, frame);
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
121 ASET (entity, FONT_OBJLIST_INDEX, Qnil);
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
122
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
123 if (FcPatternGetString (p, FC_FOUNDRY, 0, (FcChar8 **) &str) == FcResultMatch)
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
124 ASET (entity, FONT_FOUNDRY_INDEX, intern_downcase (str, strlen (str)));
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
125 if (FcPatternGetString (p, FC_FAMILY, 0, (FcChar8 **) &str) == FcResultMatch)
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
126 ASET (entity, FONT_FAMILY_INDEX, intern_downcase (str, strlen (str)));
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
127 if (FcPatternGetInteger (p, FC_WEIGHT, 0, &numeric) == FcResultMatch)
90474
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
128 {
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
129 if (numeric == FC_WEIGHT_REGULAR)
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
130 numeric = 100;
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
131 ASET (entity, FONT_WEIGHT_INDEX, make_number (numeric));
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
132 }
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
133 if (FcPatternGetInteger (p, FC_SLANT, 0, &numeric) == FcResultMatch)
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
134 ASET (entity, FONT_SLANT_INDEX, make_number (numeric + 100));
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
135 if (FcPatternGetInteger (p, FC_WIDTH, 0, &numeric) == FcResultMatch)
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
136 ASET (entity, FONT_WIDTH_INDEX, make_number (numeric));
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
137 if (FcPatternGetDouble (p, FC_PIXEL_SIZE, 0, &dbl) == FcResultMatch)
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
138 ASET (entity, FONT_SIZE_INDEX, make_number (dbl));
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
139 else
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
140 ASET (entity, FONT_SIZE_INDEX, make_number (0));
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
141
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
142 if (FcPatternGetInteger (p, FC_SPACING, 0, &numeric) != FcResultMatch)
90568
3762a2cc74de (ftfont_pattern_entity): If the pattern doesn't contain
Kenichi Handa <handa@m17n.org>
parents: 90567
diff changeset
143 numeric = -1;
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
144 file = FcStrCopy (file);
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
145 if (! file)
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
146 return Qnil;
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
147
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
148 p = FcPatternCreate ();
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
149 if (! p)
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
150 return Qnil;
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
151
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
152 if (FcPatternAddString (p, FC_FILE, file) == FcFalse
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
153 || (charset && FcPatternAddCharSet (p, FC_CHARSET, charset) == FcFalse)
90568
3762a2cc74de (ftfont_pattern_entity): If the pattern doesn't contain
Kenichi Handa <handa@m17n.org>
parents: 90567
diff changeset
154 || (numeric >= 0
3762a2cc74de (ftfont_pattern_entity): If the pattern doesn't contain
Kenichi Handa <handa@m17n.org>
parents: 90567
diff changeset
155 && FcPatternAddInteger (p, FC_SPACING, numeric) == FcFalse))
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
156 {
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
157 FcPatternDestroy (p);
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
158 return Qnil;
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
159 }
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
160 ASET (entity, FONT_EXTRA_INDEX, make_save_value (p, 0));
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
161 return entity;
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
162 }
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
163
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
164 static Lisp_Object ftfont_generic_family_list;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
165
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
166 static Lisp_Object
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
167 ftfont_list_generic_family (spec, frame, registry)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
168 Lisp_Object spec, frame, registry;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
169 {
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
170 Lisp_Object family = AREF (spec, FONT_FAMILY_INDEX);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
171 Lisp_Object slot, list, val;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
172
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
173 if (EQ (family, Qmono))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
174 family = Qmonospace;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
175 else if (EQ (family, Qsans) || EQ (family, Qsans__serif))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
176 family = Qsans_serif;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
177 slot = assq_no_quit (family, ftfont_generic_family_list);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
178 if (! CONSP (slot))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
179 return null_vector;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
180 list = XCDR (slot);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
181 if (EQ (list, Qt))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
182 {
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
183 /* Not yet listed. */
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
184 FcObjectSet *objset = NULL;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
185 FcPattern *pattern = NULL, *pat = NULL;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
186 FcFontSet *fontset = NULL;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
187 FcChar8 *fam;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
188 int i, j;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
189
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
190 objset = FcObjectSetBuild (FC_FOUNDRY, FC_FAMILY, FC_WEIGHT, FC_SLANT,
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
191 FC_WIDTH, FC_PIXEL_SIZE, FC_SPACING,
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
192 FC_CHARSET, FC_FILE, NULL);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
193 if (! objset)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
194 goto err;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
195 pattern = FcPatternBuild (NULL, FC_FAMILY, FcTypeString,
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
196 SYMBOL_FcChar8 (family), (char *) 0);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
197 if (! pattern)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
198 goto err;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
199 pat = FcPatternCreate ();
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
200 if (! pat)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
201 goto err;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
202 FcConfigSubstitute (NULL, pattern, FcMatchPattern);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
203 for (i = 0, val = Qnil;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
204 FcPatternGetString (pattern, FC_FAMILY, i, &fam) == FcResultMatch;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
205 i++)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
206 {
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
207 if (strcmp ((char *) fam, (char *) SYMBOL_FcChar8 (family)) == 0)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
208 continue;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
209 if (! FcPatternAddString (pat, FC_FAMILY, fam))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
210 goto err;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
211 fontset = FcFontList (NULL, pat, objset);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
212 if (! fontset)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
213 goto err;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
214 /* Here we build the list in reverse order so that the last
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
215 loop in this function build a list in the correct
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
216 order. */
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
217 for (j = 0; j < fontset->nfont; j++)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
218 {
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
219 Lisp_Object entity;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
220
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
221 entity = ftfont_pattern_entity (fontset->fonts[j],
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
222 frame, registry);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
223 if (! NILP (entity))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
224 val = Fcons (entity, val);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
225 }
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
226 FcFontSetDestroy (fontset);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
227 fontset = NULL;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
228 FcPatternDel (pat, FC_FAMILY);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
229 }
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
230 list = val;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
231 XSETCDR (slot, list);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
232 err:
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
233 if (pat) FcPatternDestroy (pat);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
234 if (pattern) FcPatternDestroy (pattern);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
235 if (fontset) FcFontSetDestroy (fontset);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
236 if (objset) FcObjectSetDestroy (objset);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
237 if (EQ (list, Qt))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
238 return Qnil;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
239 }
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
240 ASET (spec, FONT_FAMILY_INDEX, Qnil);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
241 for (val = Qnil; CONSP (list); list = XCDR (list))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
242 if (font_match_p (spec, XCAR (list)))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
243 val = Fcons (XCAR (list), val);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
244 ASET (spec, FONT_FAMILY_INDEX, family);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
245 return Fvconcat (1, &val);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
246 }
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
247
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
248
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
249 static Lisp_Object ftfont_get_cache P_ ((Lisp_Object));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
250 static Lisp_Object ftfont_list P_ ((Lisp_Object, Lisp_Object));
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
251 static Lisp_Object ftfont_match P_ ((Lisp_Object, Lisp_Object));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
252 static Lisp_Object ftfont_list_family P_ ((Lisp_Object));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
253 static void ftfont_free_entity P_ ((Lisp_Object));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
254 static struct font *ftfont_open P_ ((FRAME_PTR, Lisp_Object, int));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
255 static void ftfont_close P_ ((FRAME_PTR, struct font *));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
256 static int ftfont_has_char P_ ((Lisp_Object, int));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
257 static unsigned ftfont_encode_char P_ ((struct font *, int));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
258 static int ftfont_text_extents P_ ((struct font *, unsigned *, int,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
259 struct font_metrics *));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
260 static int ftfont_get_bitmap P_ ((struct font *, unsigned,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
261 struct font_bitmap *, int));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
262 static int ftfont_anchor_point P_ ((struct font *, unsigned, int,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
263 int *, int *));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
264
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
265 struct font_driver ftfont_driver =
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
266 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
267 (Lisp_Object) NULL, /* Qfreetype */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
268 ftfont_get_cache,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
269 ftfont_list,
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
270 ftfont_match,
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
271 ftfont_list_family,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
272 ftfont_free_entity,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
273 ftfont_open,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
274 ftfont_close,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
275 /* We can't draw a text without device dependent functions. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
276 NULL,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
277 NULL,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
278 ftfont_has_char,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
279 ftfont_encode_char,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
280 ftfont_text_extents,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
281 /* We can't draw a text without device dependent functions. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
282 NULL,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
283 ftfont_get_bitmap,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
284 NULL,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
285 NULL,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
286 NULL,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
287 ftfont_anchor_point,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
288 #ifdef HAVE_LIBOTF
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
289 font_otf_capability,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
290 font_otf_gsub,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
291 font_otf_gpos
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
292 #else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
293 NULL,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
294 NULL,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
295 NULL
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
296 #endif /* HAVE_LIBOTF */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
297 };
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
298
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
299 extern Lisp_Object QCname;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
300
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
301 static Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
302 ftfont_get_cache (frame)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
303 Lisp_Object frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
304 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
305 return freetype_font_cache;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
306 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
307
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
308 static Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
309 ftfont_list (frame, spec)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
310 Lisp_Object frame, spec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
311 {
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
312 Lisp_Object val, tmp, extra;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
313 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
314 FcPattern *pattern = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
315 FcCharSet *charset = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
316 FcLangSet *langset = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
317 FcFontSet *fontset = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
318 FcObjectSet *objset = NULL;
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
319 Lisp_Object script;
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
320 Lisp_Object registry = Qunicode_bmp;
90480
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
321 int weight = 0;
90500
60e0667ab709 (ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents: 90480
diff changeset
322 double dpi = -1;
60e0667ab709 (ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents: 90480
diff changeset
323 int spacing = -1;
60e0667ab709 (ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents: 90480
diff changeset
324 int scalable = -1;
90510
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
325 char otf_script[15]; /* For "otlayout\:XXXX" */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
326
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
327 val = null_vector;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
328
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
329 if (! fc_initialized)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
330 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
331 FcInit ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
332 fc_initialized = 1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
333 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
334
90480
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
335 if (! NILP (AREF (spec, FONT_ADSTYLE_INDEX))
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
336 && ! EQ (AREF (spec, FONT_ADSTYLE_INDEX), null_string))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
337 return val;
90480
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
338 if (! NILP (AREF (spec, FONT_SLANT_INDEX))
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
339 && XINT (AREF (spec, FONT_SLANT_INDEX)) < 100)
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
340 /* Fontconfig doesn't support reverse-italic/obligue. */
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
341 return val;
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
342
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
343 if (! NILP (AREF (spec, FONT_REGISTRY_INDEX)))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
344 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
345 registry = AREF (spec, FONT_REGISTRY_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
346 if (EQ (registry, Qiso8859_1))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
347 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
348 if (! cs_iso8859_1
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
349 && ftfont_build_basic_charsets () < 0)
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
350 return Qnil;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
351 charset = cs_iso8859_1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
352 }
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
353 else if (! EQ (registry, Qiso10646_1) && ! EQ (registry, Qunicode_bmp))
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
354 return val;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
355 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
356
90510
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
357 otf_script[0] = '\0';
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
358 script = Qnil;
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
359 for (extra = AREF (spec, FONT_EXTRA_INDEX);
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
360 CONSP (extra); extra = XCDR (extra))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
361 {
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
362 Lisp_Object key, val;
90510
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
363
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
364 tmp = XCAR (extra);
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
365 key = XCAR (tmp), val = XCDR (tmp);
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
366 if (EQ (key, QCotf))
90510
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
367 {
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
368 script = assq_no_quit (val, Votf_script_alist);
90510
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
369 if (CONSP (script) && SYMBOLP (XCDR (script)))
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
370 script = XCDR (script);
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
371 tmp = SYMBOL_NAME (val);
90510
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
372 sprintf (otf_script, "otlayout:%s", (char *) SDATA (tmp));
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
373 }
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
374 else if (EQ (key, QClanguage))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
375 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
376 langset = FcLangSetCreate ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
377 if (! langset)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
378 goto err;
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
379 if (SYMBOLP (val))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
380 {
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
381 if (! FcLangSetAdd (langset, SYMBOL_FcChar8 (val)))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
382 goto err;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
383 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
384 else
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
385 for (; CONSP (val); val = XCDR (val))
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
386 if (SYMBOLP (XCAR (val))
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
387 && ! FcLangSetAdd (langset, SYMBOL_FcChar8 (XCAR (val))))
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
388 goto err;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
389 }
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
390 else if (EQ (key, QCscript))
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
391 script = val;
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
392 else if (EQ (key, QCdpi))
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
393 dpi = XINT (val);
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
394 else if (EQ (key, QCspacing))
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
395 spacing = XINT (val);
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
396 else if (EQ (key, QCscalable))
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
397 scalable = ! NILP (val);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
398 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
399
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
400 if (! NILP (script) && ! charset)
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
401 {
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
402 Lisp_Object chars = assq_no_quit (script, Vscript_representative_chars);
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
403
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
404 if (CONSP (chars))
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
405 {
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
406 charset = FcCharSetCreate ();
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
407 if (! charset)
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
408 goto err;
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
409 for (chars = XCDR (chars); CONSP (chars); chars = XCDR (chars))
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
410 if (CHARACTERP (XCAR (chars))
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
411 && ! FcCharSetAddChar (charset, XUINT (XCAR (chars))))
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
412 goto err;
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
413 }
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
414 }
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
415
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
416 pattern = FcPatternCreate ();
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
417 if (! pattern)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
418 goto err;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
419 tmp = AREF (spec, FONT_FOUNDRY_INDEX);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
420 if (SYMBOLP (tmp) && ! NILP (tmp)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
421 && ! FcPatternAddString (pattern, FC_FOUNDRY, SYMBOL_FcChar8 (tmp)))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
422 goto err;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
423 tmp = AREF (spec, FONT_FAMILY_INDEX);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
424 if (SYMBOLP (tmp) && ! NILP (tmp)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
425 && ! FcPatternAddString (pattern, FC_FAMILY, SYMBOL_FcChar8 (tmp)))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
426 goto err;
90480
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
427 /* Emacs conventionally doesn't distinguish normal, regular, and
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
428 medium weight, but fontconfig does. So, we can't restrict font
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
429 listing by weight. We check it after getting a list. */
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
430 tmp = AREF (spec, FONT_WEIGHT_INDEX);
90480
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
431 if (INTEGERP (tmp))
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
432 weight = XINT (tmp);
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
433 tmp = AREF (spec, FONT_SLANT_INDEX);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
434 if (INTEGERP (tmp)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
435 && ! FcPatternAddInteger (pattern, FC_SLANT, XINT (tmp) - 100))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
436 goto err;
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
437 tmp = AREF (spec, FONT_WIDTH_INDEX);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
438 if (INTEGERP (tmp)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
439 && ! FcPatternAddInteger (pattern, FC_WIDTH, XINT (tmp)))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
440 goto err;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
441
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
442 if (charset
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
443 && ! FcPatternAddCharSet (pattern, FC_CHARSET, charset))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
444 goto err;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
445 if (langset
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
446 && ! FcPatternAddLangSet (pattern, FC_LANG, langset))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
447 goto err;
90500
60e0667ab709 (ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents: 90480
diff changeset
448 if (dpi >= 0
60e0667ab709 (ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents: 90480
diff changeset
449 && ! FcPatternAddDouble (pattern, FC_DPI, dpi))
60e0667ab709 (ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents: 90480
diff changeset
450 goto err;
60e0667ab709 (ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents: 90480
diff changeset
451 if (spacing >= 0
60e0667ab709 (ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents: 90480
diff changeset
452 && ! FcPatternAddInteger (pattern, FC_SPACING, spacing))
60e0667ab709 (ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents: 90480
diff changeset
453 goto err;
60e0667ab709 (ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents: 90480
diff changeset
454 if (scalable >= 0
90522
90f8df2248ad (ftfont_list): Fix typo.
Kenichi Handa <handa@m17n.org>
parents: 90518
diff changeset
455 && ! FcPatternAddBool (pattern, FC_SCALABLE, scalable ? FcTrue : FcFalse))
90500
60e0667ab709 (ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents: 90480
diff changeset
456 goto err;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
457
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
458 objset = FcObjectSetBuild (FC_FOUNDRY, FC_FAMILY, FC_WEIGHT, FC_SLANT,
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
459 FC_WIDTH, FC_PIXEL_SIZE, FC_SPACING,
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
460 FC_CHARSET, FC_FILE, NULL);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
461 if (! objset)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
462 goto err;
90516
43ea66432bf9 (ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents: 90514
diff changeset
463 if (otf_script[0])
43ea66432bf9 (ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents: 90514
diff changeset
464 {
43ea66432bf9 (ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents: 90514
diff changeset
465 #ifndef FC_CAPABILITY
43ea66432bf9 (ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents: 90514
diff changeset
466 goto finish;
43ea66432bf9 (ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents: 90514
diff changeset
467 #else /* not FC_CAPABILITY */
43ea66432bf9 (ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents: 90514
diff changeset
468 if (! FcObjectSetAdd (objset, FC_CAPABILITY))
43ea66432bf9 (ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents: 90514
diff changeset
469 goto err;
90518
64c755511769 * ftfont.c (ftfont_list): Move misplaced #endif
Jan Djärv <jan.h.d@swipnet.se>
parents: 90516
diff changeset
470 #endif /* not FC_CAPABILITY */
90516
43ea66432bf9 (ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents: 90514
diff changeset
471 }
90474
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
472
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
473 fontset = FcFontList (NULL, pattern, objset);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
474 if (! fontset)
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
475 goto err;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
476
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
477 if (fontset->nfont > 0)
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
478 {
90474
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
479 double pixel_size;
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
480
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
481 if (NILP (AREF (spec, FONT_SIZE_INDEX)))
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
482 pixel_size = 0;
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
483 else
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
484 pixel_size = XINT (AREF (spec, FONT_SIZE_INDEX));
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
485
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
486 for (i = 0, val = Qnil; i < fontset->nfont; i++)
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
487 {
90474
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
488 Lisp_Object entity;
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
489
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
490 if (pixel_size > 0)
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
491 {
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
492 double this;
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
493
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
494 if (FcPatternGetDouble (fontset->fonts[i], FC_PIXEL_SIZE, 0,
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
495 &this) == FcResultMatch
90480
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
496 && ((this < pixel_size - FONT_PIXEL_SIZE_QUANTUM)
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
497 || (this > pixel_size + FONT_PIXEL_SIZE_QUANTUM)))
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
498 continue;
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
499 }
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
500 if (weight > 0)
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
501 {
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
502 int this;
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
503
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
504 if (FcPatternGetInteger (fontset->fonts[i], FC_WEIGHT, 0,
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
505 &this) != FcResultMatch
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
506 || (this != weight
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
507 && (weight != 100
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
508 || this < FC_WEIGHT_REGULAR
908d27653432 (ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents: 90474
diff changeset
509 || this > FC_WEIGHT_MEDIUM)))
90474
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
510 continue;
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
511 }
90516
43ea66432bf9 (ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents: 90514
diff changeset
512 #ifdef FC_CAPABILITY
90510
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
513 if (otf_script[0])
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
514 {
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
515 FcChar8 *this;
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
516
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
517 if (FcPatternGetString (fontset->fonts[i], FC_CAPABILITY, 0,
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
518 &this) != FcResultMatch
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
519 || ! strstr ((char *) this, otf_script))
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
520 continue;
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
521 }
90516
43ea66432bf9 (ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents: 90514
diff changeset
522 #endif /* FC_CAPABILITY */
90474
8627c9321afb (ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents: 90464
diff changeset
523 entity = ftfont_pattern_entity (fontset->fonts[i], frame, registry);
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
524 if (! NILP (entity))
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
525 val = Fcons (entity, val);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
526 }
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
527 val = Fvconcat (1, &val);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
528 }
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
529 else if (! NILP (AREF (spec, FONT_FAMILY_INDEX)))
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
530 val = ftfont_list_generic_family (spec, frame, registry);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
531 goto finish;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
532
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
533 err:
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
534 /* We come here because of unexpected error in fontconfig API call
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
535 (usually insufficient memory). */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
536 val = Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
537
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
538 finish:
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
539 if (charset && charset != cs_iso8859_1) FcCharSetDestroy (charset);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
540 if (objset) FcObjectSetDestroy (objset);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
541 if (fontset) FcFontSetDestroy (fontset);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
542 if (langset) FcLangSetDestroy (langset);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
543 if (pattern) FcPatternDestroy (pattern);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
544
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
545 return val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
546 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
547
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
548 static Lisp_Object
90565
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
549 ftfont_match (frame, spec)
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
550 Lisp_Object frame, spec;
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
551 {
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
552 Lisp_Object extra, val, entity;
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
553 FcPattern *pattern = NULL, *match = NULL;
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
554 FcResult result;
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
555
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
556 if (! fc_initialized)
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
557 {
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
558 FcInit ();
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
559 fc_initialized = 1;
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
560 }
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
561
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
562 extra = AREF (spec, FONT_EXTRA_INDEX);
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
563 val = assq_no_quit (QCname, extra);
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
564 if (! CONSP (val) || ! STRINGP (XCDR (val)))
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
565 return Qnil;
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
566
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
567 entity = Qnil;
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
568 pattern = FcNameParse (SDATA (XCDR (val)));
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
569 if (pattern)
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
570 {
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
571 if (FcConfigSubstitute (NULL, pattern, FcMatchPattern) == FcTrue)
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
572 {
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
573 FcDefaultSubstitute (pattern);
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
574 match = FcFontMatch (NULL, pattern, &result);
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
575 if (match)
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
576 {
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
577 entity = ftfont_pattern_entity (match, frame, Qunicode_bmp);
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
578 FcPatternDestroy (match);
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
579 }
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
580 }
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
581 FcPatternDestroy (pattern);
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
582 }
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
583
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
584 return entity;
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
585 }
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
586
258e759bcffa (ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents: 90555
diff changeset
587 static Lisp_Object
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
588 ftfont_list_family (frame)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
589 Lisp_Object frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
590 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
591 Lisp_Object list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
592 FcPattern *pattern = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
593 FcFontSet *fontset = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
594 FcObjectSet *objset = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
595 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
596
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
597 if (! fc_initialized)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
598 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
599 FcInit ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
600 fc_initialized = 1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
601 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
602
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
603 pattern = FcPatternCreate ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
604 if (! pattern)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
605 goto finish;
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
606 objset = FcObjectSetBuild (FC_FAMILY, NULL);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
607 if (! objset)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
608 goto finish;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
609 fontset = FcFontList (NULL, pattern, objset);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
610 if (! fontset)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
611 goto finish;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
612
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
613 list = Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
614 for (i = 0; i < fontset->nfont; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
615 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
616 FcPattern *pat = fontset->fonts[i];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
617 FcChar8 *str;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
618
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
619 if (FcPatternGetString (pat, FC_FAMILY, 0, &str) == FcResultMatch)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
620 list = Fcons (intern_downcase ((char *) str, strlen ((char *) str)),
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
621 list);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
622 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
623
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
624 finish:
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
625 if (objset) FcObjectSetDestroy (objset);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
626 if (fontset) FcFontSetDestroy (fontset);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
627 if (pattern) FcPatternDestroy (pattern);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
628
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
629 return list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
630 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
631
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
632
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
633 static void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
634 ftfont_free_entity (entity)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
635 Lisp_Object entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
636 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
637 Lisp_Object val = AREF (entity, FONT_EXTRA_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
638 FcPattern *pattern = XSAVE_VALUE (val)->pointer;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
639
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
640 FcPatternDestroy (pattern);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
641 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
642
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
643 static struct font *
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
644 ftfont_open (f, entity, pixel_size)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
645 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
646 Lisp_Object entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
647 int pixel_size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
648 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
649 struct ftfont_info *ftfont_info;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
650 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
651 FT_Face ft_face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
652 FT_Size ft_size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
653 FT_UInt size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
654 Lisp_Object val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
655 FcPattern *pattern;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
656 FcChar8 *file;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
657 int spacing;
90555
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
658 char *name;
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
659 int len;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
660
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
661 val = AREF (entity, FONT_EXTRA_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
662 if (XTYPE (val) != Lisp_Misc
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
663 || XMISCTYPE (val) != Lisp_Misc_Save_Value)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
664 return NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
665 pattern = XSAVE_VALUE (val)->pointer;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
666 if (XSAVE_VALUE (val)->integer == 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
667 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
668 /* We have not yet created FT_Face for this font. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
669 if (! ft_library
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
670 && FT_Init_FreeType (&ft_library) != 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
671 return NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
672 if (FcPatternGetString (pattern, FC_FILE, 0, &file) != FcResultMatch)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
673 return NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
674 if (FT_New_Face (ft_library, (char *) file, 0, &ft_face) != 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
675 return NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
676 FcPatternAddFTFace (pattern, FC_FT_FACE, ft_face);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
677 ft_size = ft_face->size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
678 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
679 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
680 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
681 if (FcPatternGetFTFace (pattern, FC_FT_FACE, 0, &ft_face)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
682 != FcResultMatch)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
683 return NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
684 if (FT_New_Size (ft_face, &ft_size) != 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
685 return NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
686 if (FT_Activate_Size (ft_size) != 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
687 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
688 FT_Done_Size (ft_size);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
689 return NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
690 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
691 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
692
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
693 size = XINT (AREF (entity, FONT_SIZE_INDEX));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
694 if (size == 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
695 size = pixel_size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
696 if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
697 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
698 if (XSAVE_VALUE (val)->integer == 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
699 FT_Done_Face (ft_face);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
700 return NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
701 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
702
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
703 ftfont_info = malloc (sizeof (struct ftfont_info));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
704 if (! ftfont_info)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
705 return NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
706 ftfont_info->ft_size = ft_size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
707
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
708 font = (struct font *) ftfont_info;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
709 font->entity = entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
710 font->pixel_size = size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
711 font->driver = &ftfont_driver;
90555
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
712 len = 96;
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
713 name = malloc (len);
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
714 while (name && font_unparse_fcname (entity, pixel_size, name, len) < 0)
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
715 {
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
716 char *new = realloc (name, len += 32);
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
717
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
718 if (! new)
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
719 free (name);
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
720 name = new;
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
721 }
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
722 font->font.full_name = font->font.name = name;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
723 font->file_name = (char *) file;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
724 font->font.size = ft_face->size->metrics.max_advance >> 6;
90555
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
725 if (font->font.size <= 0)
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
726 font->font.size = size;
90510
69dc5ab6d693 (ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents: 90500
diff changeset
727 font->font.charset = font->encoding_charset = font->repertory_charset = -1;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
728 font->ascent = ft_face->size->metrics.ascender >> 6;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
729 font->descent = - ft_face->size->metrics.descender >> 6;
90555
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
730 font->font.height = font->ascent + font->descent;
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
731 if (FcPatternGetInteger (pattern, FC_SPACING, 0, &spacing) != FcResultMatch)
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
732 spacing = FC_PROPORTIONAL;
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
733 if (spacing != FC_PROPORTIONAL)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
734 font->font.average_width = font->font.space_width = font->font.size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
735 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
736 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
737 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
738
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
739 for (i = 32; i < 127; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
740 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
741 if (FT_Load_Char (ft_face, i, FT_LOAD_DEFAULT) != 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
742 break;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
743 if (i == 32)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
744 font->font.space_width = ft_face->glyph->metrics.horiAdvance >> 6;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
745 font->font.average_width += ft_face->glyph->metrics.horiAdvance >> 6;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
746 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
747 if (i == 127)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
748 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
749 /* The font contains all ASCII printable characters. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
750 font->font.average_width /= 95;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
751 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
752 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
753 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
754 if (i == 32)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
755 font->font.space_width = font->font.size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
756 font->font.average_width = font->font.size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
757 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
758 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
759
90555
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
760 /* Unfortunately FreeType doesn't provide a way to get minimum char
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
761 width. So, we use space_width instead. */
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
762 font->min_width = font->font.space_width;
45553626fa76 (ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents: 90524
diff changeset
763
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
764 font->font.baseline_offset = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
765 font->font.relative_compose = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
766 font->font.default_ascent = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
767 font->font.vertical_centering = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
768
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
769 (XSAVE_VALUE (val)->integer)++;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
770
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
771 return font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
772 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
773
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
774 static void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
775 ftfont_close (f, font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
776 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
777 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
778 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
779 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
780 Lisp_Object entity = font->entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
781 Lisp_Object val = AREF (entity, FONT_EXTRA_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
782
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
783 (XSAVE_VALUE (val)->integer)--;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
784 if (XSAVE_VALUE (val)->integer == 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
785 FT_Done_Face (ftfont_info->ft_size->face);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
786 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
787 FT_Done_Size (ftfont_info->ft_size);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
788
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
789 free (font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
790 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
791
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
792 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
793 ftfont_has_char (entity, c)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
794 Lisp_Object entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
795 int c;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
796 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
797 Lisp_Object val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
798 FcPattern *pattern;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
799 FcCharSet *charset;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
800
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
801 val = AREF (entity, FONT_EXTRA_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
802 pattern = XSAVE_VALUE (val)->pointer;
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
803 if (FcPatternGetCharSet (pattern, FC_CHARSET, 0, &charset) != FcResultMatch)
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
804 return -1;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
805 return (FcCharSetHasChar (charset, (FcChar32) c) == FcTrue);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
806 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
807
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
808 static unsigned
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
809 ftfont_encode_char (font, c)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
810 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
811 int c;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
812 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
813 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
814 FT_Face ft_face = ftfont_info->ft_size->face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
815 FT_ULong charcode = c;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
816 FT_UInt code = FT_Get_Char_Index (ft_face, charcode);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
817
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
818 return (code > 0 ? code : 0xFFFFFFFF);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
819 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
820
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
821 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
822 ftfont_text_extents (font, code, nglyphs, metrics)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
823 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
824 unsigned *code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
825 int nglyphs;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
826 struct font_metrics *metrics;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
827 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
828 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
829 FT_Face ft_face = ftfont_info->ft_size->face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
830 int width = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
831 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
832
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
833 if (ftfont_info->ft_size != ft_face->size)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
834 FT_Activate_Size (ftfont_info->ft_size);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
835 if (metrics)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
836 bzero (metrics, sizeof (struct font_metrics));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
837 for (i = 0; i < nglyphs; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
838 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
839 if (FT_Load_Glyph (ft_face, code[i], FT_LOAD_DEFAULT) == 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
840 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
841 FT_Glyph_Metrics *m = &ft_face->glyph->metrics;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
842
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
843 if (metrics)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
844 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
845 if (metrics->lbearing > width + (m->horiBearingX >> 6))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
846 metrics->lbearing = width + (m->horiBearingX >> 6);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
847 if (metrics->rbearing
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
848 < width + ((m->horiBearingX + m->width) >> 6))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
849 metrics->rbearing
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
850 = width + ((m->horiBearingX + m->width) >> 6);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
851 if (metrics->ascent < (m->horiBearingY >> 6))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
852 metrics->ascent = m->horiBearingY >> 6;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
853 if (metrics->descent > ((m->horiBearingY + m->height) >> 6))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
854 metrics->descent = (m->horiBearingY + m->height) >> 6;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
855 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
856 width += m->horiAdvance >> 6;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
857 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
858 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
859 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
860 width += font->font.space_width;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
861 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
862 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
863 if (metrics)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
864 metrics->width = width;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
865
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
866 return width;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
867 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
868
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
869 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
870 ftfont_get_bitmap (font, code, bitmap, bits_per_pixel)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
871 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
872 unsigned code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
873 struct font_bitmap *bitmap;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
874 int bits_per_pixel;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
875 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
876 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
877 FT_Face ft_face = ftfont_info->ft_size->face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
878 FT_Int32 load_flags = FT_LOAD_RENDER;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
879
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
880 if (ftfont_info->ft_size != ft_face->size)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
881 FT_Activate_Size (ftfont_info->ft_size);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
882 if (bits_per_pixel == 1)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
883 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
884 #ifdef FT_LOAD_TARGET_MONO
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
885 load_flags |= FT_LOAD_TARGET_MONO;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
886 #else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
887 load_flags |= FT_LOAD_MONOCHROME;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
888 #endif
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
889 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
890 else if (bits_per_pixel != 8)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
891 /* We don't support such a rendering. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
892 return -1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
893
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
894 if (FT_Load_Glyph (ft_face, code, load_flags) != 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
895 return -1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
896 bitmap->rows = ft_face->glyph->bitmap.rows;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
897 bitmap->width = ft_face->glyph->bitmap.width;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
898 bitmap->pitch = ft_face->glyph->bitmap.pitch;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
899 bitmap->buffer = ft_face->glyph->bitmap.buffer;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
900 bitmap->left = ft_face->glyph->bitmap_left;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
901 bitmap->top = ft_face->glyph->bitmap_top;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
902 bitmap->advance = ft_face->glyph->metrics.horiAdvance >> 6;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
903 bitmap->extra = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
904
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
905 return 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
906 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
907
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
908 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
909 ftfont_anchor_point (font, code, index, x, y)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
910 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
911 unsigned code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
912 int index;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
913 int *x, *y;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
914 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
915 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
916 FT_Face ft_face = ftfont_info->ft_size->face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
917
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
918 if (ftfont_info->ft_size != ft_face->size)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
919 FT_Activate_Size (ftfont_info->ft_size);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
920 if (FT_Load_Glyph (ft_face, code, FT_LOAD_DEFAULT) != 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
921 return -1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
922 if (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
923 return -1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
924 if (index >= ft_face->glyph->outline.n_points)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
925 return -1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
926 *x = ft_face->glyph->outline.points[index].x;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
927 *y = ft_face->glyph->outline.points[index].y;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
928 return 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
929 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
930
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
931
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
932 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
933 syms_of_ftfont ()
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
934 {
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
935 DEFSYM (Qfreetype, "freetype");
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
936 DEFSYM (Qmonospace, "monospace");
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
937 DEFSYM (Qsans_serif, "sans-serif");
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
938 DEFSYM (Qserif, "serif");
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
939 DEFSYM (Qmono, "mono");
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
940 DEFSYM (Qsans, "sans");
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
941 DEFSYM (Qsans__serif, "sans serif");
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
942
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
943 staticpro (&freetype_font_cache);
90441
d63258b13d84 (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
944 freetype_font_cache = Fcons (Qt, Qnil);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
945
90464
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
946 staticpro (&ftfont_generic_family_list);
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
947 ftfont_generic_family_list
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
948 = Fcons (Fcons (Qmonospace, Qt),
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
949 Fcons (Fcons (Qsans_serif, Qt),
4702b592db4c (Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents: 90450
diff changeset
950 Fcons (Fcons (Qsans, Qt), Qnil)));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
951
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
952 ftfont_driver.type = Qfreetype;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
953 register_font_driver (&ftfont_driver, NULL);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
954 }
90427
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
955
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
956 /* arch-tag: 7cfa432c-33a6-4988-83d2-a82ed8604aca
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
957 (do not change this comment) */