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