Mercurial > hg > xemacs-beta
annotate src/font-mgr.c @ 5197:ce8ffb95bbe3
finish up CHANGES-beta -- all changes thru Apr 9, 2010
-------------------- ChangeLog entries follow: --------------------
ChangeLog addition:
2010-04-09 Ben Wing <ben@xemacs.org>
* CHANGES-beta:
Update with my changes to the trunk since the release of 21.5.29
in 2009 up through April 9, 2010.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 09 Apr 2010 02:33:11 -0500 |
parents | b65692aa90d8 |
children | c096d8051f89 308d34e9f07d |
rev | line source |
---|---|
3354 | 1 /* Lisp font handling implementation for X with Xft. |
2 | |
3 Copyright (C) 2003 Eric Knauel and Matthias Neubauer | |
4 Copyright (C) 2005 Eric Knauel | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
5 Copyright (C) 2004-2009 Free Software Foundation, Inc. |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
6 Copyright (C) 2010 Ben Wing. |
3354 | 7 |
8 Authors: Eric Knauel <knauel@informatik.uni-tuebingen.de> | |
9 Matthias Neubauer <neubauer@informatik.uni-freiburg.de> | |
10 Stephen J. Turnbull <stephen@xemacs.org> | |
11 Created: 27 Oct 2003 | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
12 Updated: 18 November 2009 by Stephen J. Turnbull |
3354 | 13 |
14 This file is part of XEmacs. | |
15 | |
16 XEmacs is free software; you can redistribute it and/or modify it | |
17 under the terms of the GNU General Public License as published by the | |
18 Free Software Foundation; either version 2, or (at your option) any | |
19 later version. | |
20 | |
21 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
22 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
23 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
24 for more details. | |
25 | |
26 You should have received a copy of the GNU General Public License | |
27 along with XEmacs; see the file COPYING. If not, write to | |
28 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
29 Boston, MA 02111-1307, USA. */ | |
30 | |
31 /* Synched up with: Not in GNU Emacs. */ | |
32 | |
33 /* This module provides the Lisp interface to fonts in X11, including Xft, | |
34 but (at least at first) not GTK+ or Qt. | |
35 | |
36 Sealevel code should be in ../lwlib/lwlib-fonts.c or | |
37 ../lwlib/lwlib-colors.c. | |
38 */ | |
39 | |
40 #include <config.h> | |
41 #include "lisp.h" | |
42 #include "device.h" | |
43 #include "device-impl.h" | |
44 #include "console-x-impl.h" | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
45 #include "fontcolor-x.h" |
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
46 #include "fontcolor-x-impl.h" |
3354 | 47 #include "hash.h" |
48 #include "font-mgr.h" | |
49 | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
50 #include "sysfile.h" |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
51 |
3354 | 52 /* #### TO DO #### |
53 . The "x-xft-*" and "x_xft_*" nomenclature is mostly redundant, especially | |
54 if we separate X fonts from Xft fonts, and use fontconfig more generally. | |
55 . We should support the most recent Xft first, old Xft libraries later. | |
56 . We may (think about it) wish to use fontconfig generally, even if we're | |
57 not using Xft. Either way, names that are really from fontconfig should | |
58 use the Fc* namespace. | |
59 . Mule-ize this file. | |
60 . Separate X Font Struct ops from Xft Font ops; give precedence to Xft but | |
61 allow fallback to X. | |
62 . Push decisions about font choice, defaults, fallbacks to Lisp; if we | |
63 really need efficiency, can reimplement in C later. | |
64 . Implement symbols interned in this file in the Q* namespace. | |
65 . Implement FcMatrix (Lisp vector). | |
66 . Implement FcCharSets (Lisp chartable? For implementation hints, see | |
67 FcCharSetFirstPage and FcCharSetNextPage). | |
68 . Implement FcConfigs. | |
69 DONE | |
70 . Fontconfig fontnames are encoded in UTF-8. | |
71 */ | |
72 | |
3360 | 73 Lisp_Object Qfont_mgr; |
3354 | 74 Lisp_Object Qfc_patternp; |
75 /* Lisp_Object Qfc_result_match; */ /* FcResultMatch */ | |
76 Lisp_Object Qfc_result_type_mismatch; /* FcResultTypeMismatch */ | |
77 Lisp_Object Qfc_result_no_match; /* FcResultNoMatch */ | |
78 Lisp_Object Qfc_result_no_id; /* FcResultNoId */ | |
79 Lisp_Object Qfc_internal_error; | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
80 Lisp_Object Qfc_match_pattern; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
81 Lisp_Object Qfc_match_font; |
3354 | 82 Lisp_Object Vxlfd_font_name_regexp; /* #### Really needed? */ |
3935 | 83 Fixnum xft_version; |
84 Fixnum fc_version; | |
3354 | 85 Fixnum debug_xft; /* Set to 1 enables lots of obnoxious messages. |
86 Setting it to 2 or 3 enables even more. */ | |
3931 | 87 #ifdef FONTCONFIG_EXPOSE_CONFIG |
88 Lisp_Object Qfc_configp; | |
89 static Lisp_Object Vfc_config_weak_list; | |
90 #endif | |
3354 | 91 |
92 /**************************************************************** | |
93 * FcPattern objects * | |
94 ****************************************************************/ | |
95 | |
96 static void | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
97 finalize_fc_pattern (Lisp_Object obj) |
3354 | 98 { |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
99 struct fc_pattern *p = XFC_PATTERN (obj); |
3354 | 100 if (p->fcpatPtr) |
101 { | |
102 FcPatternDestroy (p->fcpatPtr); | |
103 p->fcpatPtr = 0; | |
104 } | |
105 } | |
106 | |
3906 | 107 /* #### We really need an equal method and a hash method (required if you |
108 have an equal method). For the equal method, we can probably use one | |
109 or both of | |
110 | |
111 -- Function: FcBool FcPatternEqual (const FcPattern *pa, const | |
112 FcPattern *pb); | |
113 Returns whether PA and PB are exactly alike. | |
114 | |
115 -- Function: FcBool FcPatternEqualSubset (const FcPattern *pa, const | |
116 FcPattern *pb, const FcObjectSet *os) | |
117 Returns whether PA and PB have exactly the same values for all of | |
118 the objects in OS. | |
119 | |
120 For the hash, we'll have to extract some subset of attributes. | |
121 | |
122 #### Crap. It's altogether unobvious what we need. x_color_instance | |
123 does have a hash method, but fonts are apparently special. I get the | |
124 feeling that for this to work properly we're going to need to switch | |
125 to fontconfig-based font specifications (although we can allow the | |
126 platform syntaxes, the underlying specification object will need to | |
127 conform to the fontconfig API, or more precisely the font-mgr API). | |
128 | |
129 I think the whole `font-truename' interface needs to be dropped. */ | |
130 | |
3354 | 131 static const struct memory_description fcpattern_description [] = { |
132 /* #### nothing here, is this right?? */ | |
133 { XD_END } | |
134 }; | |
135 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
136 DEFINE_NODUMP_LISP_OBJECT ("fc-pattern", fc_pattern, |
5142
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5127
diff
changeset
|
137 0, external_object_printer, finalize_fc_pattern, |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
138 0, 0, fcpattern_description, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
139 struct fc_pattern); |
3354 | 140 |
141 /* | |
142 * Helper Functions | |
143 */ | |
144 static Lisp_Object make_xlfd_font_regexp (void); | |
145 static void string_list_to_fcobjectset (Lisp_Object list, FcObjectSet *os); | |
146 | |
147 /* | |
148 extract the C representation of the Lisp string STR and convert it | |
149 to the encoding used by the Fontconfig API for property and font | |
150 names. I suppose that Qnative is the right encoding, the manual | |
151 doesn't say much about this topic. This functions assumes that STR | |
152 is a Lisp string. | |
153 */ | |
154 #define extract_fcapi_string(str) \ | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
155 (LISP_STRING_TO_EXTERNAL ((str), Qfc_font_name_encoding)) |
3354 | 156 |
3906 | 157 #define build_fcapi_string(str) \ |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
158 (build_extstring ((Extbyte *) (str), Qfc_font_name_encoding)) |
3906 | 159 |
3360 | 160 /* #### This homebrew lashup should be replaced with FcConstants. |
161 | |
162 fontconfig assumes that objects (property names) are statically allocated, | |
3354 | 163 and you will get bizarre results if you pass Lisp string data or strings |
164 allocated on the stack as objects. fontconfig _does_ copy values, so we | |
165 (I hope) don't have to worry about that member. | |
166 | |
167 Probably these functions don't get called so often that the memory leak | |
168 due to strdup'ing every time we add a property would matter, but XEmacs | |
169 _is_ a long-running process. So we hash them. | |
170 | |
171 I suspect that using symbol names or even keywords does not provide | |
172 assurance that the string won't move in memory. So we hash them | |
3360 | 173 ourselves; hash.c hashtables do not interpret the value pointers. |
174 | |
175 This array should be FcChar8**, but GCC 4.x bitches about signedness. */ | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
176 static const Extbyte *fc_standard_properties[] = |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
177 { |
3360 | 178 /* treated specially, ordered first */ |
179 "family", "size", | |
180 /* remaining are alphabetized by group */ | |
181 /* standard properties in fontconfig and Xft v.2 */ | |
182 "antialias", "aspect", "autohint", "charset", "dpi", "file", | |
3354 | 183 "foundry", "ftface", "globaladvance", "hinting", "index", "lang", |
184 "minspace", "outline", "pixelsize", "rasterizer", "rgba", "scalable", | |
3360 | 185 "scale", "slant", "spacing", "style", "verticallayout", "weight", |
186 /* common in modern fonts */ | |
187 "fontformat", "fontversion", | |
3354 | 188 /* obsolete after Xft v. 1 */ |
189 "charwidth", "charheight", "core", "encoding", "render" | |
190 }; | |
191 | |
192 static struct hash_table *fc_property_name_hash_table; | |
193 | |
194 /* #### Maybe fc_intern should be exposed to LISP? The idea is that | |
195 fc-pattern-add could warn or error if the property isn't interned. */ | |
196 | |
3469 | 197 static const Extbyte * |
3354 | 198 fc_intern (Lisp_Object property) |
199 { | |
200 const void *dummy; | |
3469 | 201 const Extbyte *prop = extract_fcapi_string (property); |
3354 | 202 const void *val = gethash (prop, fc_property_name_hash_table, &dummy); |
203 | |
204 /* extract_fcapi_string returns something alloca'd | |
205 so we can just drop the old value of prop on the floor */ | |
206 if (val) | |
3469 | 207 prop = (const Extbyte *) val; |
3354 | 208 else |
209 { | |
3469 | 210 prop = (const Extbyte *) FcStrCopy ((FcChar8 *) prop); |
3354 | 211 puthash (prop, NULL, fc_property_name_hash_table); |
212 } | |
213 return prop; | |
214 } | |
215 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
216 DEFUN ("fc-pattern-p", Ffc_pattern_p, 1, 1, 0, /* |
3354 | 217 Returns t if OBJECT is of type fc-pattern, nil otherwise. |
218 */ | |
219 (object)) | |
220 { | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
221 return FC_PATTERNP (object) ? Qt : Qnil; |
3354 | 222 } |
223 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
224 DEFUN ("fc-pattern-create", Ffc_pattern_create, 0, 0, 0, /* |
3354 | 225 Return a new, empty fc-pattern object. |
226 */ | |
227 ()) | |
228 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
229 fc_pattern *fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
3354 | 230 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
231 fcpat->fcpatPtr = FcPatternCreate (); |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
232 return wrap_fc_pattern (fcpat); |
3354 | 233 } |
234 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
235 DEFUN ("fc-name-parse", Ffc_name_parse, 1, 1, 0, /* |
3354 | 236 Parse an Fc font name and return its representation as a fc pattern object. |
237 */ | |
238 (name)) | |
239 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
240 fc_pattern *fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
3354 | 241 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
242 CHECK_STRING (name); |
3354 | 243 |
3469 | 244 fcpat->fcpatPtr = FcNameParse ((FcChar8 *) extract_fcapi_string (name)); |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
245 return wrap_fc_pattern (fcpat); |
3354 | 246 } |
247 | |
248 /* #### Ga-a-ack! Xft's similar function is actually a different API. | |
249 We provide both. */ | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
250 DEFUN ("fc-name-unparse", Ffc_name_unparse, 1, 1, 0, /* |
3354 | 251 Unparse an fc pattern object to a string. |
252 */ | |
253 (pattern)) | |
254 { | |
4799
ca99a807b025
Free, rather than discard, the return value of FcNameUnparse. See message
Jerry James <james@xemacs.org>
parents:
4758
diff
changeset
|
255 FcChar8 *name; |
ca99a807b025
Free, rather than discard, the return value of FcNameUnparse. See message
Jerry James <james@xemacs.org>
parents:
4758
diff
changeset
|
256 Lisp_Object result; |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
257 CHECK_FC_PATTERN (pattern); |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
258 name = FcNameUnparse (XFC_PATTERN_PTR (pattern)); |
4799
ca99a807b025
Free, rather than discard, the return value of FcNameUnparse. See message
Jerry James <james@xemacs.org>
parents:
4758
diff
changeset
|
259 result = build_fcapi_string (name); |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
260 xfree (name); |
4799
ca99a807b025
Free, rather than discard, the return value of FcNameUnparse. See message
Jerry James <james@xemacs.org>
parents:
4758
diff
changeset
|
261 return result; |
3354 | 262 } |
263 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
264 DEFUN ("fc-pattern-duplicate", Ffc_pattern_duplicate, 1, 1, 0, /* |
3354 | 265 Make a copy of the fc pattern object PATTERN and return it. |
266 */ | |
267 (pattern)) | |
268 { | |
269 struct fc_pattern *copy = NULL; | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
270 CHECK_FC_PATTERN (pattern); |
3354 | 271 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
272 copy = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
273 copy->fcpatPtr = FcPatternDuplicate (XFC_PATTERN_PTR (pattern)); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
274 return wrap_fc_pattern (copy); |
3354 | 275 } |
276 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
277 DEFUN ("fc-pattern-add", Ffc_pattern_add, 3, 3, 0, /* |
3354 | 278 Add attributes to the pattern object PATTERN. PROPERTY is a string naming |
279 the attribute to add, VALUE the value for this attribute. | |
280 | |
281 VALUE may be a string, integer, float, or symbol, in which case the value | |
282 will be added as an FcChar8[], int, double, or FcBool respectively. | |
283 */ | |
284 (pattern, property, value)) | |
285 { | |
286 Bool res = 0; | |
3469 | 287 const Extbyte *obj; |
3354 | 288 FcPattern *fcpat; |
289 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
290 CHECK_FC_PATTERN (pattern); |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
291 CHECK_STRING (property); |
3354 | 292 |
293 obj = fc_intern (property); | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
294 fcpat = XFC_PATTERN_PTR (pattern); |
3354 | 295 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
296 if (STRINGP (value)) |
3354 | 297 { |
298 FcChar8 *str = (FcChar8 *) extract_fcapi_string (value); | |
299 res = FcPatternAddString (fcpat, obj, str); | |
300 } | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
301 else if (INTP (value)) |
3354 | 302 { |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
303 res = FcPatternAddInteger (fcpat, obj, XINT (value)); |
3354 | 304 } |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
305 else if (FLOATP (value)) |
3354 | 306 { |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
307 res = FcPatternAddDouble (fcpat, obj, (double) XFLOAT_DATA (value)); |
3354 | 308 } |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
309 else if (SYMBOLP (value)) |
3354 | 310 { |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
311 res = FcPatternAddBool (fcpat, obj, !NILP (value)); |
3354 | 312 } |
313 /* else ... maybe we should wta here? */ | |
314 | |
315 return res ? Qt : Qnil; | |
316 } | |
317 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
318 DEFUN ("fc-pattern-del", Ffc_pattern_del, 2, 2, 0, /* |
3354 | 319 Remove attribute PROPERTY from fc pattern object OBJECT. |
320 */ | |
321 (pattern, property)) | |
322 { | |
323 Bool res; | |
324 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
325 CHECK_FC_PATTERN (pattern); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
326 CHECK_STRING (property); |
3354 | 327 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
328 res = FcPatternDel (XFC_PATTERN_PTR (pattern), extract_fcapi_string (property)); |
3354 | 329 return res ? Qt : Qnil; |
330 } | |
331 | |
332 /* Generic interface to FcPatternGet() | |
333 * Don't support the losing symbol-for-property interface. | |
334 */ | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
335 DEFUN ("fc-pattern-get", Ffc_pattern_get, 2, 4, 0, /* |
3354 | 336 From PATTERN, extract PROPERTY for the ID'th member, of type TYPE. |
337 | |
338 PATTERN is an Xft (fontconfig) pattern object. | |
339 PROPERTY is a string naming an fontconfig font property. | |
340 Optional ID is a nonnegative integer indexing the list of values for PROPERTY | |
341 stored in PATTERN, defaulting to 0 (the first value). | |
342 Optional TYPE is a symbol, one of 'string, 'boolean, 'integer, 'float, | |
343 'double, 'matrix, 'charset, or 'void, corresponding to the FcValue types. | |
344 ('float is an alias for 'double). | |
345 | |
346 The Lisp types returned will conform to TYPE: | |
347 string string | |
348 boolean `t' or `nil' | |
349 integer integer | |
350 double (float) float | |
351 matrix not implemented | |
352 charset not implemented | |
353 void not implemented | |
354 | |
355 Symbols with names of the form "fc-result-DESCRIPTION" are returned when | |
356 the desired value is not available. These are | |
357 | |
358 fc-result-type-mismatch the value found has an unexpected type | |
359 fc-result-no-match there is no such attribute | |
360 fc-result-no-id there is no value for the requested ID | |
361 | |
362 The types of the following standard properties are predefined by fontconfig. | |
363 The symbol 'fc-result-type-mismatch will be returned if the object exists but | |
364 TYPE does not match the predefined type. It is best not to specify a type | |
365 for predefined properties, as a mistake here ensures error returns on the | |
366 correct type. | |
367 | |
368 Each standard property has a convenience accessor defined in fontconfig.el, | |
369 named in the form "fc-pattern-get-PROPERTY". The convenience functions are | |
370 preferred to `fc-pattern-get' since a typo in the string naming a property | |
371 will result in a silent null return, while a typo in a function name will | |
372 usually result in a compiler or runtime \"not fboundp\" error. You may use | |
373 `defsubst' to define convenience functions for non-standard properties. | |
374 | |
375 family String Font family name | |
376 style String Font style. Overrides weight and slant | |
377 slant Int Italic, oblique or roman | |
378 weight Int Light, medium, demibold, bold or black | |
379 size Double Point size | |
380 aspect Double Stretches glyphs horizontally before hinting | |
381 pixelsize Double Pixel size | |
382 spacing Int Proportional, monospace or charcell | |
383 foundry String Font foundry name | |
384 antialias Bool Whether glyphs can be antialiased | |
385 hinting Bool Whether the rasterizer should use hinting | |
386 verticallayout Bool Use vertical layout | |
387 autohint Bool Use autohinter instead of normal hinter | |
388 globaladvance Bool Use font global advance data | |
389 file String The filename holding the font | |
390 index Int The index of the font within the file | |
391 ftface FT_Face Use the specified FreeType face object | |
392 rasterizer String Which rasterizer is in use | |
393 outline Bool Whether the glyphs are outlines | |
394 scalable Bool Whether glyphs can be scaled | |
395 scale Double Scale factor for point->pixel conversions | |
396 dpi Double Target dots per inch | |
397 rgba Int unknown, rgb, bgr, vrgb, vbgr, none - subpixel geometry | |
398 minspace Bool Eliminate leading from line spacing | |
399 charset CharSet Unicode chars encoded by the font | |
400 lang String List of RFC-3066-style languages this font supports | |
401 | |
402 The FT_Face, Matrix, CharSet types are unimplemented, so the corresponding | |
403 properties are not accessible from Lisp at this time. If the value of a | |
404 property returned has type FT_Face, FcCharSet, or FcMatrix, | |
405 `fc-result-type-mismatch' is returned. | |
406 | |
407 The following properties which were standard in Xft v.1 are obsolete in | |
408 Xft v.2: encoding, charwidth, charheight, core, and render. */ | |
409 (pattern, property, id, type)) | |
410 { | |
3469 | 411 Extbyte *fc_property; |
3354 | 412 FcResult fc_result; |
413 FcValue fc_value; | |
414 | |
415 /* | |
416 process arguments | |
417 */ | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
418 CHECK_FC_PATTERN (pattern); |
3354 | 419 |
420 #if 0 | |
421 /* Don't support the losing symbol-for-property interface. */ | |
422 property = SYMBOLP (property) ? symbol_name (XSYMBOL (property)) : property; | |
423 #endif | |
424 if (STRINGP (property)) | |
425 { | |
3469 | 426 fc_property = extract_fcapi_string (property); |
3354 | 427 } |
428 else | |
429 { | |
430 /* if we allow symbols, this would need to be | |
431 list3 (Qlambda, list1 (Qobject), | |
432 list3 (Qor, list2 (Qstringp, Qobject), | |
433 list2 (Qsymbolp, Qobject))) | |
434 or something like that? */ | |
435 dead_wrong_type_argument (Qstringp, property); | |
436 } | |
437 | |
438 if (!NILP (id)) CHECK_NATNUM (id); | |
439 if (!NILP (type)) CHECK_SYMBOL (type); | |
440 | |
441 /* get property */ | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
442 fc_result = FcPatternGet (XFC_PATTERN_PTR (pattern), |
3354 | 443 fc_property, |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
444 NILP (id) ? 0 : XINT (id), |
3354 | 445 &fc_value); |
446 | |
447 switch (fc_result) | |
448 { | |
449 case FcResultMatch: | |
450 /* wrap it and return */ | |
451 switch (fc_value.type) | |
452 { | |
453 case FcTypeInteger: | |
454 return ((!NILP (type) && !EQ (type, Qinteger)) | |
455 ? Qfc_result_type_mismatch : make_int (fc_value.u.i)); | |
456 case FcTypeDouble: | |
457 return ((!NILP (type) && !EQ (type, intern ("double")) | |
458 && !EQ (type, Qfloat)) | |
459 ? Qfc_result_type_mismatch : make_float (fc_value.u.d)); | |
460 case FcTypeString: | |
461 return ((!NILP (type) && !EQ (type, Qstring)) | |
462 ? Qfc_result_type_mismatch | |
3906 | 463 : build_fcapi_string (fc_value.u.s)); |
3354 | 464 case FcTypeBool: |
465 return ((!NILP (type) && !EQ (type, Qboolean)) | |
466 ? Qfc_result_type_mismatch : fc_value.u.b ? Qt : Qnil); | |
467 case FcTypeMatrix: | |
468 return Qfc_result_type_mismatch; | |
469 /* #### unimplemented | |
470 return ((!NILP (type) && !EQ (type, intern ("matrix"))) | |
471 ? Qfc_result_type_mismatch : make_int (fc_value.u.m)); | |
472 */ | |
473 case FcTypeCharSet: | |
474 return Qfc_result_type_mismatch; | |
475 /* #### unimplemented | |
476 return ((!NILP (type) && !EQ (type, intern ("charset"))) | |
477 ? Qfc_result_type_mismatch : make_int (fc_value.u.c)); | |
478 */ | |
479 } | |
480 case FcResultTypeMismatch: | |
481 return Qfc_result_type_mismatch; | |
482 case FcResultNoMatch: | |
483 return Qfc_result_no_match; | |
484 case FcResultNoId: | |
485 return Qfc_result_no_id; | |
486 default: | |
487 return Qfc_internal_error; | |
488 } | |
489 } | |
490 | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
491 /* FcConfig handling functions. */ |
3354 | 492 |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
493 /* We obviously need to be careful about garbage collecting the current |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
494 FcConfig. I infer from the documentation of FcConfigDestroy that that |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
495 is the only reference maintained by fontconfig. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
496 So we keep track of our own references on a weak list, and only cons a |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
497 new object if we don't already have a reference to it there. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
498 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
499 enum DestroyFontsetP { DestroyNo = 0, DestroyYes = 1 }; |
3354 | 500 |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
501 static Lisp_Object |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
502 fc_config_create_using (FcConfig * (*create_function) (void)) |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
503 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
504 FcConfig *fc = (*create_function) (); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
505 Lisp_Object configs = XWEAK_LIST_LIST (Vfc_config_weak_list); |
3354 | 506 |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
507 /* Linear search: fc_configs are not going to multiply like conses. */ |
3360 | 508 { |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
509 LIST_LOOP_2 (cfg, configs) |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
510 if (fc == XFC_CONFIG_PTR (cfg)) |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
511 return cfg; |
3360 | 512 } |
513 | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
514 { |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
515 fc_config *fccfg = XFC_CONFIG (ALLOC_NORMAL_LISP_OBJECT (fc_config)); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
516 fccfg->fccfgPtr = fc; |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
517 configs = Fcons (wrap_fc_config (fccfg), configs); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
518 XWEAK_LIST_LIST (Vfc_config_weak_list) = configs; |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
519 return wrap_fc_config (fccfg); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
520 } |
3354 | 521 } |
522 | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
523 static Lisp_Object |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
524 fc_strlist_to_lisp_using (FcStrList * (*getter) (FcConfig *), |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
525 Lisp_Object config) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
526 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
527 FcChar8 *thing; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
528 Lisp_Object value = Qnil; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
529 FcStrList *thing_list; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
530 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
531 CHECK_FC_CONFIG (config); |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
532 thing_list = (*getter) (XFC_CONFIG_PTR (config)); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
533 /* Yes, we need to do this check -- sheesh, Keith! */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
534 if (!thing_list) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
535 return Qnil; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
536 while ((thing = FcStrListNext (thing_list))) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
537 value = Fcons (build_fcapi_string (thing), value); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
538 FcStrListDone (thing_list); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
539 return value; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
540 } |
3931 | 541 |
3354 | 542 static Lisp_Object |
3931 | 543 fontset_to_list (FcFontSet *fontset, enum DestroyFontsetP destroyp) |
3354 | 544 { |
545 int idx; | |
546 Lisp_Object fontlist = Qnil; | |
547 fc_pattern *fcpat; | |
548 | |
549 /* #### improve this error message */ | |
550 if (!fontset) | |
4860 | 551 invalid_state ("failed to create FcFontSet", Qunbound); |
3354 | 552 for (idx = 0; idx < fontset->nfont; ++idx) |
553 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
554 fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
3354 | 555 fcpat->fcpatPtr = FcPatternDuplicate (fontset->fonts[idx]); |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
556 fontlist = Fcons (wrap_fc_pattern (fcpat), fontlist); |
3354 | 557 } |
3931 | 558 if (destroyp) |
559 FcFontSetDestroy (fontset); | |
3354 | 560 return fontlist; |
561 } | |
562 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
563 DEFUN ("fc-config-p", Ffc_config_p, 1, 1, 0, /* |
3931 | 564 Returns t if OBJECT is of type fc-config, nil otherwise. |
565 */ | |
566 (object)) | |
567 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
568 return FC_CONFIGP (object) ? Qt : Qnil; |
3931 | 569 } |
570 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
571 DEFUN ("fc-config-create", Ffc_config_create, 0, 0, 0, /* |
3931 | 572 -- Function: FcConfig *FcConfigCreate (void) |
573 Creates an empty configuration. */ | |
574 ()) | |
575 { | |
576 return fc_config_create_using (&FcConfigCreate); | |
577 } | |
578 | |
579 #if 0 | |
580 /* I'm sorry, but we just don't do this in Lisp, OK? | |
581 Don't even think about implementing this. */ | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
582 DEFUN ("fc-config-destroy", Ffc_config_destroy, 1, 1, 0, /* |
3931 | 583 -- Function: void FcConfigDestroy (FcConfig *config) |
584 Destroys a configuration and any data associated with it. Note | |
585 that calling this function with the return value from | |
586 FcConfigGetCurrent will place the library in an indeterminate | |
587 state. */ | |
588 (config)) | |
589 { | |
590 signal_error (Qunimplemented, "No user-servicable parts!", | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
591 intern ("fc-config-destroy")); |
3931 | 592 } |
593 #endif | |
594 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
595 DEFUN ("fc-config-up-to-date", Ffc_config_up_to_date, 1, 1, 0, /* |
3931 | 596 -- Function: FcBool FcConfigUptoDate (FcConfig *config) |
597 Checks all of the files related to 'config' and returns whether the | |
598 in-memory version is in sync with the disk version. */ | |
599 (config)) | |
600 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
601 CHECK_FC_CONFIG (config); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
602 return FcConfigUptoDate (XFC_CONFIG_PTR (config)) == FcFalse ? Qnil : Qt; |
3931 | 603 } |
604 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
605 DEFUN ("fc-config-build-fonts", Ffc_config_build_fonts, 1, 1, 0, /* |
3931 | 606 -- Function: FcBool FcConfigBuildFonts (FcConfig *config) |
607 Builds the set of available fonts for the given configuration. | |
608 Note that any changes to the configuration after this call have | |
609 indeterminate effects. Returns FcFalse if this operation runs out | |
610 of memory. | |
611 XEmacs: signal out-of-memory, or return nil on success. */ | |
612 (config)) | |
613 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
614 CHECK_FC_CONFIG (config); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
615 if (FcConfigBuildFonts (XFC_CONFIG_PTR (config)) == FcFalse) |
3931 | 616 out_of_memory ("FcConfigBuildFonts failed", config); |
617 return Qnil; | |
618 } | |
619 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
620 DEFUN ("fc-config-get-config-dirs", Ffc_config_get_config_dirs, 1, 1, 0, /* |
3931 | 621 -- Function: FcStrList *FcConfigGetConfigDirs (FcConfig *config) |
622 Returns the list of font directories specified in the | |
623 configuration files for 'config'. Does not include any | |
624 subdirectories. */ | |
625 (config)) | |
626 { | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
627 return fc_strlist_to_lisp_using (&FcConfigGetConfigDirs, config); |
3931 | 628 } |
629 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
630 DEFUN ("fc-config-get-font-dirs", Ffc_config_get_font_dirs, 1, 1, 0, /* |
3931 | 631 -- Function: FcStrList *FcConfigGetFontDirs (FcConfig *config) |
632 Returns the list of font directories in 'config'. This includes the | |
633 configured font directories along with any directories below those | |
634 in the filesystem. */ | |
635 (config)) | |
636 { | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
637 return fc_strlist_to_lisp_using (&FcConfigGetFontDirs, config); |
3931 | 638 } |
639 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
640 DEFUN ("fc-config-get-config-files", Ffc_config_get_config_files, 1, 1, 0, /* |
3931 | 641 -- Function: FcStrList *FcConfigGetConfigFiles (FcConfig *config) |
642 Returns the list of known configuration files used to generate | |
643 'config'. Note that this will not include any configuration done | |
644 with FcConfigParse. */ | |
645 (config)) | |
646 { | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
647 return fc_strlist_to_lisp_using (&FcConfigGetConfigFiles, config); |
3931 | 648 } |
649 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
650 DEFUN ("fc-config-get-cache", Ffc_config_get_cache, 1, 1, 0, /* |
3931 | 651 -- Function: char *FcConfigGetCache (FcConfig *config) |
652 Returns the name of the file used to store per-user font | |
653 information. */ | |
654 (config)) | |
655 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
656 CHECK_FC_CONFIG (config); |
3931 | 657 /* Surely FcConfigGetCache just casts an FcChar8* to char*. */ |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
658 return build_fcapi_string ((FcChar8 *) FcConfigGetCache (XFC_CONFIG_PTR (config))); |
3931 | 659 } |
660 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
661 DEFUN ("fc-config-get-fonts", Ffc_config_get_fonts, 2, 2, 0, /* |
3931 | 662 -- Function: FcFontSet *FcConfigGetFonts (FcConfig *config, FcSetName set) |
663 Returns one of the two sets of fonts from the configuration as | |
664 specified by 'set'. | |
665 `FcSetName' | |
666 Specifies one of the two sets of fonts available in a | |
667 configuration; FcSetSystem for those fonts specified in the | |
668 configuration and FcSetApplication which holds fonts provided by | |
669 the application. */ | |
670 (config, set)) | |
671 { | |
672 FcSetName name = FcSetSystem; | |
673 FcFontSet *fs = NULL; | |
674 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
675 CHECK_FC_CONFIG (config); |
3931 | 676 CHECK_SYMBOL (set); |
677 | |
678 if (EQ (set, intern ("fc-set-system"))) | |
679 name = FcSetSystem; | |
680 else if (EQ (set, intern ("fc-set-application"))) | |
681 name = FcSetApplication; | |
682 else | |
683 wtaerror ("must be in (fc-set-system fc-set-application)", set); | |
684 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
685 fs = FcConfigGetFonts (XFC_CONFIG_PTR (config), name); |
3931 | 686 return fs ? fontset_to_list (fs, DestroyNo) : Qnil; |
687 } | |
688 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
689 DEFUN ("fc-config-set-current", Ffc_config_set_current, 1, 1, 0, /* |
3931 | 690 -- Function: FcBool FcConfigSetCurrent (FcConfig *config) |
691 Sets the current default configuration to 'config'. Implicitly | |
692 calls FcConfigBuildFonts if necessary, returning FcFalse if that | |
693 call fails. | |
694 XEmacs: signals out-of-memory if FcConfigBuildFonts fails, or args-out-of-range | |
695 if the resulting FcConfig has no fonts (which would crash XEmacs if installed). | |
696 */ | |
697 (config)) | |
698 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
699 CHECK_FC_CONFIG (config); |
3931 | 700 /* *sigh* "Success" DOES NOT mean you have any fonts available. It is |
701 easy to crash fontconfig, and XEmacs with it. Without the following | |
702 check, this will do it: | |
703 (progn | |
704 (fc-config-set-current (fc-config-create)) | |
705 (set-face-font 'default "serif-12")) | |
706 */ | |
707 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
708 if (FcConfigBuildFonts (XFC_CONFIG_PTR (config)) == FcFalse) |
3931 | 709 out_of_memory ("FcConfigBuildFonts failed", config); |
710 /* #### We'd like to avoid this consing, and FcConfigGetFonts sometimes | |
711 returns NULL, but it doesn't always. This will do for now .... */ | |
712 if (NILP (Ffc_config_get_fonts (config, intern ("fc-set-system"))) | |
713 && NILP (Ffc_config_get_fonts (config, intern ("fc-set-application")))) | |
714 signal_error (intern ("args-out-of-range"), "no fonts found", config); | |
715 /* Should never happen, but I don't trust Keith anymore .... */ | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
716 if (FcConfigSetCurrent (XFC_CONFIG_PTR (config)) == FcFalse) |
3931 | 717 out_of_memory ("FcConfigBuildFonts failed in set", config); |
718 return Qnil; | |
719 } | |
720 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
721 DEFUN ("fc-config-get-blanks", Ffc_config_get_blanks, 1, 1, 0, /* |
3931 | 722 -- Function: FcBlanks *FcConfigGetBlanks (FcConfig *config) |
723 Returns the FcBlanks object associated with the given | |
724 configuration, if no blanks were present in the configuration, | |
725 this function will return 0. | |
726 XEmacs: should convert to a chartable. | |
727 #### Unimplemented. */ | |
728 (config)) | |
729 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
730 CHECK_FC_CONFIG (config); |
3931 | 731 signal_error (Qunimplemented, "no method to convert FcBlanks object", |
732 intern ("fc-config-get-blanks")); | |
733 } | |
734 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
735 DEFUN ("fc-config-get-rescan-interval", Ffc_config_get_rescan_interval, 1, 1, 0, /* |
4328
dfd878799ef0
Autoconfiscate the recent fontconfig spelling change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3935
diff
changeset
|
736 -- Function: int FcConfigGetRescanInterval (FcConfig *config) |
3931 | 737 Returns the interval between automatic checks of the configuration |
738 (in seconds) specified in 'config'. The configuration is checked | |
739 during a call to FcFontList when this interval has passed since | |
740 the last check. */ | |
741 (config)) | |
742 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
743 CHECK_FC_CONFIG (config); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
744 return make_int (FcConfigGetRescanInterval (XFC_CONFIG_PTR (config))); |
3931 | 745 } |
746 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
747 DEFUN ("fc-config-set-rescan-interval", Ffc_config_set_rescan_interval, 2, 2, 0, /* |
4328
dfd878799ef0
Autoconfiscate the recent fontconfig spelling change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3935
diff
changeset
|
748 -- Function: FcBool FcConfigSetRescanInterval (FcConfig *config, int |
3931 | 749 rescanInterval) |
750 Sets the rescan interval; returns FcFalse if an error occurred. | |
751 XEmacs: signal such error, or return nil on success. */ | |
752 (config, rescan_interval)) | |
753 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
754 CHECK_FC_CONFIG (config); |
3931 | 755 CHECK_INT (rescan_interval); |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
756 if (FcConfigSetRescanInterval (XFC_CONFIG_PTR (config), |
3931 | 757 XINT (rescan_interval)) == FcFalse) |
758 signal_error (Qio_error, "FcConfigSetRescanInverval barfed", | |
759 intern ("fc-config-set-rescan-interval")); | |
760 return Qnil; | |
761 } | |
762 | |
763 /* #### This might usefully be made interactive. */ | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
764 DEFUN ("fc-config-app-font-add-file", Ffc_config_app_font_add_file, 2, 2, 0, /* |
3931 | 765 -- Function: FcBool FcConfigAppFontAddFile (FcConfig *config, const |
766 char *file) | |
767 Adds an application-specific font to the configuration. */ | |
768 (config, file)) | |
769 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
770 CHECK_FC_CONFIG (config); |
3931 | 771 CHECK_STRING (file); |
772 if (FcConfigAppFontAddFile | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
773 (XFC_CONFIG_PTR (config), |
4834
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
774 /* #### FIXME! is Qfile_name right? */ |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
775 (FcChar8 *) LISP_STRING_TO_EXTERNAL (file, Qfile_name)) == FcFalse) |
3931 | 776 return Qnil; |
777 else | |
778 return Qt; | |
779 } | |
780 | |
781 /* #### This might usefully be made interactive. */ | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
782 DEFUN ("fc-config-app-font-add-dir", Ffc_config_app_font_add_dir, 2, 2, 0, /* |
3931 | 783 -- Function: FcBool FcConfigAppFontAddDir (FcConfig *config, const |
784 char *dir) | |
785 Scans the specified directory for fonts, adding each one found to | |
786 the application-specific set of fonts. */ | |
787 (config, dir)) | |
788 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
789 CHECK_FC_CONFIG (config); |
3931 | 790 CHECK_STRING (dir); |
791 if (FcConfigAppFontAddDir | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
792 (XFC_CONFIG_PTR (config), |
4834
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
793 /* #### FIXME! is Qfile_name right? */ |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
794 (FcChar8 *) LISP_STRING_TO_EXTERNAL (dir, Qfile_name)) == FcFalse) |
3931 | 795 return Qnil; |
796 else | |
797 return Qt; | |
798 } | |
799 | |
800 /* #### This might usefully be made interactive. */ | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
801 DEFUN ("fc-config-app-font-clear", Ffc_config_app_font_clear, 1, 1, 0, /* |
3931 | 802 -- Function: void FcConfigAppFontClear (FcConfig *config) |
803 Clears the set of application-specific fonts. */ | |
804 (config)) | |
805 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
806 CHECK_FC_CONFIG (config); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
807 FcConfigAppFontClear (XFC_CONFIG_PTR (config)); |
3931 | 808 return Qnil; |
809 } | |
810 | |
811 /* These functions provide some control over how the default | |
812 configuration of the library is initialized. (This configuration is | |
813 normally implicitly initialized.) */ | |
814 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
815 DEFUN ("fc-config-filename", Ffc_config_filename, 1, 1, 0, /* |
3931 | 816 -- Function: char *FcConfigFilename (const char *name) |
817 Given the specified external entity name, return the associated | |
818 filename. This provides applications a way to convert various | |
819 configuration file references into filename form. | |
820 | |
821 A null or empty 'name' indicates that the default configuration | |
822 file should be used; which file this references can be overridden | |
823 with the FC_CONFIG_FILE environment variable. Next, if the name | |
824 starts with '~', it refers to a file in the current users home | |
825 directory. Otherwise if the name doesn't start with '/', it | |
826 refers to a file in the default configuration directory; the | |
827 built-in default directory can be overridden with the | |
828 FC_CONFIG_DIR environment variable. */ | |
829 (name)) | |
830 { | |
4932 | 831 const Ascbyte *fcname = ""; |
3931 | 832 |
833 if (!NILP (name)) | |
834 { | |
835 CHECK_STRING (name); | |
4834
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
836 /* #### FIXME! is Qfile_name right? */ |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
837 LISP_PATHNAME_CONVERT_OUT (name, fcname); |
3931 | 838 } |
839 return (build_fcapi_string (FcConfigFilename ((FcChar8 *) fcname))); | |
840 } | |
841 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
842 DEFUN ("fc-init-load-config", Ffc_init_load_config, 0, 0, 0, /* |
3931 | 843 -- Function: FcConfig *FcInitLoadConfig (void) |
844 Loads the default configuration file and returns the resulting | |
845 configuration. Does not load any font information. */ | |
846 ()) | |
847 { | |
848 return fc_config_create_using (&FcInitLoadConfig); | |
849 } | |
850 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
851 DEFUN ("fc-init-load-config-and-fonts", Ffc_init_load_config_and_fonts, 0, 0, 0, /* |
3931 | 852 -- Function: FcConfig *FcInitLoadConfigAndFonts (void) |
853 Loads the default configuration file and builds information about | |
854 the available fonts. Returns the resulting configuration. */ | |
855 ()) | |
856 { | |
857 return fc_config_create_using (&FcInitLoadConfigAndFonts); | |
858 } | |
859 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
860 DEFUN ("fc-config-get-current", Ffc_config_get_current, 0, 0, 0, /* |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
861 -- Function: FcConfig *FcConfigGetCurrent (void) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
862 Returns the current default configuration. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
863 ()) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
864 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
865 return fc_config_create_using (&FcConfigGetCurrent); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
866 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
867 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
868 /* Pattern manipulation functions. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
869 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
870 DEFUN ("fc-default-substitute", Ffc_default_substitute, 1, 1, 0, /* |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
871 Adds defaults for certain attributes if not specified in PATTERN. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
872 FcPattern PATTERN is modified in-place, and nil is returned. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
873 * Patterns without a specified style or weight are set to Medium |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
874 * Patterns without a specified style or slant are set to Roman |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
875 * Patterns without a specified pixel size are given one computed from any |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
876 specified point size (default 12), dpi (default 75) and scale (default 1). */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
877 (pattern)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
878 { |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
879 CHECK_FC_PATTERN (pattern); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
880 FcDefaultSubstitute (XFC_PATTERN_PTR (pattern)); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
881 return Qnil; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
882 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
883 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
884 /* -- Function: FcBool FcConfigSubstituteWithPat (FcConfig *config, |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
885 FcPattern *p, FcPattern *p_pat FcMatchKind kind) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
886 OMITTED: use optional arguments in `fc-config-substitute'. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
887 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
888 DEFUN ("fc-config-substitute", Ffc_config_substitute, 1, 4, 0, /* |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
889 Modifies PATTERN according to KIND and TESTPAT using operations from CONFIG. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
890 PATTERN is modified in-place. Returns an undocumented Boolean value. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
891 If optional KIND is `fc-match-pattern', then those tagged as pattern operations |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
892 are applied, else if KIND is `fc-match-font', those tagged as font operations |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
893 are applied and TESTPAT is used for <test> elements with target=pattern. KIND |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
894 defaults to `fc-match-font'. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
895 If optional TESTPAT is nil, it is ignored. Otherwise it must be an FcPattern. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
896 Optional CONFIG must be an FcConfig, defaulting to the current one. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
897 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
898 Note that this function actually corresponds to FcConfigSubstituteWithPat, and |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
899 the argument order is changed to take advantage of Lisp optional arguments. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
900 (pattern, kind, testpat, config)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
901 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
902 FcMatchKind knd; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
903 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
904 /* There ought to be a standard idiom for this.... */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
905 if (NILP (kind) |
4860 | 906 || EQ (kind, Qfc_match_font)) |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
907 knd = FcMatchFont; |
4860 | 908 else if (EQ (kind, Qfc_match_pattern)) |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
909 knd = FcMatchPattern; |
4860 | 910 else |
911 wtaerror ("need `fc-match-pattern' or `fc-match-font'", kind); | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
912 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
913 /* Typecheck arguments */ |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
914 CHECK_FC_PATTERN (pattern); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
915 if (!NILP (testpat)) CHECK_FC_PATTERN (testpat); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
916 if (!NILP (config)) CHECK_FC_CONFIG (config); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
917 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
918 return (FcConfigSubstituteWithPat |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
919 (NILP (config) ? FcConfigGetCurrent () : XFC_CONFIG_PTR (config), |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
920 XFC_PATTERN_PTR (pattern), |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
921 NILP (testpat) ? NULL : XFC_PATTERN_PTR (testpat), |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
922 knd) == FcTrue) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
923 ? Qt : Qnil; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
924 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
925 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
926 /* Pattern matching functions. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
927 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
928 /* The following functions return fonts that match a certain pattern. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
929 `FcFontRenderPrepare' and `FcFontMatch' always return a single best |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
930 match. `FcFontList' returns the list of fonts that match a given |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
931 pattern on a certain set of properties. `FcFontSort' returns the |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
932 entire list of fonts, sorted in order of match quality, possibly |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
933 filtering out fonts that do not provide additional characters beyond |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
934 those provided by preferred fonts. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
935 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
936 DEFUN ("fc-font-render-prepare", Ffc_font_render_prepare, 2, 3, 0, /* |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
937 Return a new pattern blending PATTERN and FONT. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
938 Optional CONFIG is an FcConfig, defaulting to the current one. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
939 The returned pattern consists of elements of FONT not appearing in PATTERN, |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
940 elements of PATTERN not appearing in FONT, and the best matching value from |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
941 PATTERN for elements appearing in both. The result is passed to |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
942 FcConfigSubstitute with 'kind' FcMatchFont and then returned. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
943 (pattern, font, config)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
944 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
945 if (NILP (config)) { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
946 config = Ffc_config_get_current (); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
947 } |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
948 CHECK_FC_PATTERN (pattern); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
949 CHECK_FC_PATTERN (font); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
950 CHECK_FC_CONFIG (config); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
951 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
952 /* I don't think this can fail? */ |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
953 return wrap_fc_pattern (FcFontRenderPrepare (XFC_CONFIG_PTR (config), |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
954 XFC_PATTERN_PTR (font), |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
955 XFC_PATTERN_PTR (pattern))); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
956 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
957 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
958 DEFUN ("fc-font-match", Ffc_font_match, 2, 3, 0, /* |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
959 Return the font on DEVICE that most closely matches PATTERN. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
960 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
961 DEVICE is an X11 device. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
962 PATTERN is a fontconfig pattern object. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
963 Optional CONFIG is an FcConfig, defaulting to the current one. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
964 Returns a fontconfig pattern object representing the closest match to the |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
965 given pattern, or an error code. Possible error codes are |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
966 `fc-result-no-match' and `fc-result-no-id'. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
967 PATTERN is massaged with FcConfigSubstitute and FcDefaultSubstitute before |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
968 being processed by FcFontMatch. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
969 (device, pattern, config)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
970 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
971 FcResult res; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
972 struct fc_pattern *res_fcpat; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
973 FcPattern *p; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
974 FcConfig *fcc; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
975 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
976 CHECK_FC_PATTERN (pattern); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
977 if (NILP (device)) |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
978 return Qnil; |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
979 CHECK_X_DEVICE (device); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
980 if (!DEVICE_LIVE_P (XDEVICE (device))) |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
981 return Qnil; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
982 if (!NILP (config)) |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
983 CHECK_FC_CONFIG (config); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
984 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
985 res_fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
986 p = XFC_PATTERN_PTR (pattern); |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
987 fcc = NILP (config) ? FcConfigGetCurrent () : XFC_CONFIG_PTR (config); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
988 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
989 FcConfigSubstitute (fcc, p, FcMatchPattern); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
990 FcDefaultSubstitute (p); |
4809
0d3ccd5a2509
Initialize the result variable passed to FcFontMatch. See xemacs-patches
Jerry James <james@xemacs.org>
parents:
4799
diff
changeset
|
991 res = FcResultMatch; |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
992 res_fcpat->fcpatPtr = FcFontMatch (fcc, p, &res); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
993 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
994 if (res_fcpat->fcpatPtr == NULL) |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
995 switch (res) |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
996 { |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
997 case FcResultNoMatch: |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
998 return Qfc_result_no_match; |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
999 case FcResultNoId: |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1000 return Qfc_result_no_id; |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1001 default: |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1002 return Qfc_internal_error; |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1003 } |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1004 else |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1005 return wrap_fc_pattern (res_fcpat); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1006 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1007 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1008 /* #### fix this name to correspond to Ben's new nomenclature */ |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1009 DEFUN ("fc-list-fonts-pattern-objects", Ffc_list_fonts_pattern_objects, |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1010 3, 3, 0, /* |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1011 Return a list of fonts on DEVICE that match PATTERN for PROPERTIES. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1012 Each font is represented by a fontconfig pattern object. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1013 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1014 DEVICE is an X11 device. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1015 PATTERN is a fontconfig pattern to be matched. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1016 PROPERTIES is a list of property names (strings) that should match. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1017 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1018 #### DEVICE is unused, ignored, and may be removed if it's not needed to |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1019 match other font-listing APIs. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1020 (UNUSED (device), pattern, properties)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1021 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1022 FcObjectSet *os; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1023 FcFontSet *fontset; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1024 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1025 CHECK_FC_PATTERN (pattern); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1026 CHECK_LIST (properties); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1027 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1028 os = FcObjectSetCreate (); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1029 string_list_to_fcobjectset (properties, os); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1030 /* #### why don't we need to do the "usual substitutions"? */ |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1031 fontset = FcFontList (NULL, XFC_PATTERN_PTR (pattern), os); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1032 FcObjectSetDestroy (os); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1033 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1034 return fontset_to_list (fontset, DestroyYes); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1035 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1036 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1037 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1038 /* #### maybe this can/should be folded into fc-list-fonts-pattern-objects? */ |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1039 DEFUN ("fc-font-sort", Ffc_font_sort, 2, 4, 0, /* |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1040 Return a list of all fonts sorted by proximity to PATTERN. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1041 Each font is represented by a fontconfig pattern object. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1042 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1043 DEVICE is an X11 device. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1044 PATTERN is a fontconfig pattern to be matched. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1045 Optional argument TRIM, if non-nil, means to trim trailing fonts that do not |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1046 contribute new characters to the union repertoire. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1047 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1048 #### Optional argument NOSUB, if non-nil, suppresses some of the usual |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1049 property substitutions. DON'T USE THIS in production code, it is intended |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1050 for exploring behavior of fontconfig and will be removed when this code is |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1051 stable. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1052 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1053 #### DEVICE is unused, ignored, and may be removed if it's not needed to |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1054 match other font-listing APIs. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1055 (UNUSED (device), pattern, trim, nosub)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1056 { |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1057 CHECK_FC_PATTERN (pattern); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1058 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1059 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1060 FcConfig *fcc = FcConfigGetCurrent(); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1061 FcFontSet *fontset; |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1062 FcPattern *p = XFC_PATTERN_PTR (pattern); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1063 FcResult fcresult; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1064 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1065 if (NILP (nosub)) /* #### temporary debug hack */ |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1066 FcDefaultSubstitute (p); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1067 FcConfigSubstitute (fcc, p, FcMatchPattern); |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1068 fontset = FcFontSort (fcc, p, !NILP (trim), NULL, &fcresult); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1069 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1070 return fontset_to_list (fontset, DestroyYes); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1071 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1072 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1073 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1074 #ifdef FONTCONFIG_EXPOSE_CONFIG |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1075 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1076 /* Configuration routines --- for debugging |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1077 Don't depend on these routines being available in the future! |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1078 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1079 3.2.10 Initialization |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1080 --------------------- |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1081 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1082 An FcConfig object holds the internal representation of a configuration. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1083 There is a default configuration which applications may use by passing |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1084 0 to any function using the data within an FcConfig. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1085 */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1086 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1087 static void |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1088 finalize_fc_config (Lisp_Object obj) |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1089 { |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1090 struct fc_config *p = XFC_CONFIG (obj); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1091 if (p->fccfgPtr && p->fccfgPtr != FcConfigGetCurrent()) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1092 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1093 /* If we get here, all of *our* references are garbage (see comment on |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1094 fc_config_create_using() for why), and the only reference that |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1095 fontconfig keeps is the current FcConfig. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1096 FcConfigDestroy (p->fccfgPtr); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1097 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1098 p->fccfgPtr = 0; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1099 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1100 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1101 static const struct memory_description fcconfig_description [] = { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1102 /* #### nothing here, is this right?? */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1103 { XD_END } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1104 }; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1105 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
1106 DEFINE_NODUMP_LISP_OBJECT ("fc-config", fc_config, |
5142
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5127
diff
changeset
|
1107 0, external_object_printer, finalize_fc_config, |
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5127
diff
changeset
|
1108 0, 0, fcconfig_description, |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
1109 struct fc_config); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1110 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1111 DEFUN ("fc-init", Ffc_init, 0, 0, 0, /* |
3931 | 1112 -- Function: FcBool FcInit (void) |
1113 Loads the default configuration file and the fonts referenced | |
1114 therein and sets the default configuration to that result. | |
1115 Returns whether this process succeeded or not. If the default | |
1116 configuration has already been loaded, this routine does nothing | |
1117 and returns FcTrue. */ | |
1118 ()) | |
1119 { | |
1120 return (FcInit () == FcTrue) ? Qt : Qnil; | |
1121 } | |
1122 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1123 DEFUN ("fc-get-version", Ffc_get_version, 0, 0, 0, /* |
3931 | 1124 -- Function: int FcGetVersion (void) |
1125 Returns the version number of the library. | |
3935 | 1126 XEmacs: No, this should NOT return a pretty string. |
3931 | 1127 (let ((i (fc-get-version))) |
1128 (format "%d.%d.%d" (/ i 10000) (mod (/ i 100) 100) (mod i 100))) | |
3935 | 1129 gives the usual x.y.z format. This is the version of the .so. It can be |
1130 checked against `fc-version', which is the version of fontconfig.h. | |
1131 It's probably not a disaster if `(> (fc-get-version) fc-version)'. */ | |
3931 | 1132 ()) |
1133 { | |
1134 return make_int (FcGetVersion ()); | |
1135 } | |
1136 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1137 DEFUN ("fc-init-reinitialize", Ffc_init_reinitialize, 0, 0, 0, /* |
3931 | 1138 -- Function: FcBool FcInitReinitialize (void) |
1139 Forces the default configuration file to be reloaded and resets | |
1140 the default configuration. */ | |
1141 ()) | |
1142 { | |
1143 return (FcInitReinitialize () == FcTrue) ? Qt : Qnil; | |
1144 } | |
1145 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1146 DEFUN ("fc-init-bring-up-to-date", Ffc_init_bring_up_to_date, 0, 0, 0, /* |
3931 | 1147 -- Function: FcBool FcInitBringUptoDate (void) |
1148 Checks the rescan interval in the default configuration, checking | |
1149 the configuration if the interval has passed and reloading the | |
1150 configuration when any changes are detected. */ | |
1151 ()) | |
1152 { | |
1153 return (FcInitBringUptoDate () == FcTrue) ? Qt : Qnil; | |
1154 } | |
1155 | |
1156 #endif /* FONTCONFIG_EXPOSE_CONFIG */ | |
1157 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1158 DEFUN ("xlfd-font-name-p", Fxlfd_font_name_p, 1, 1, 0, /* |
3354 | 1159 Check whether the string FONTNAME is a XLFD font name. */ |
1160 (fontname)) | |
1161 { | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1162 CHECK_STRING (fontname); |
3354 | 1163 /* #### should bind `case-fold-search' here? */ |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1164 return Fstring_match (Vxlfd_font_name_regexp, fontname, Qnil, Qnil); |
3354 | 1165 } |
1166 | |
1167 /* FcPatternPrint: there is no point in having wrappers fc-pattern-print, | |
1168 Ffc_pattern_print since this function prints to stdout. */ | |
1169 | |
1170 /* Initialization of font-mgr */ | |
1171 | |
1172 #define XE_XLFD_SEPARATOR "-" | |
1173 /* XLFD specifies ISO 8859-1 encoding, but we can't handle non-ASCII | |
1174 in Mule when this function is called. So use HPC. */ | |
1175 #if 0 | |
1176 #define XE_XLFD_PREFIX "\\(\\+[\040-\176\240-\377]*\\)?-" | |
1177 #define XE_XLFD_OPT_TEXT "\\([\040-\044\046-\176\240-\377]*\\)" | |
1178 #define XE_XLFD_TEXT "\\([\040-\044\046-\176\240-\377]+\\)" | |
1179 #else | |
1180 #define XE_XLFD_PREFIX "\\(\\+[\040-\176]*\\)?-" | |
1181 #define XE_XLFD_OPT_TEXT "\\([^-]*\\)" | |
1182 #define XE_XLFD_TEXT "\\([^-]+\\)" | |
1183 #endif | |
1184 | |
1185 #define XE_XLFD_SLANT "\\([0-9ior?*][iot]?\\)" | |
1186 #define XE_XLFD_SPACING "\\([cmp?*]\\)" | |
1187 /* Hyphen as minus conflicts with use as separator. */ | |
1188 #define XE_XLFD_OPT_NEGATE "~?" | |
1189 #define XE_XLFD_NUMBER "\\([0-9?*]+\\)" | |
1190 #define XE_XLFD_PSIZE "\\([0-9?*]+\\|\\[[ 0-9+~.e?*]+\\]\\)" | |
1191 | |
1192 /* Call this only from the init code | |
1193 #### This is really horrible, let's get rid of it, please. */ | |
1194 static Lisp_Object | |
1195 make_xlfd_font_regexp (void) | |
1196 { | |
1197 struct gcpro gcpro1; | |
1198 unsigned i; | |
1199 Lisp_Object reg = Qnil; | |
1200 const Extbyte *re[] = /* #### This could just be catenated by | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1201 cpp and passed to build_extstring. */ |
3354 | 1202 { |
1203 /* Regular expression matching XLFDs as defined by XLFD v. 1.5. | |
1204 Matches must be case-insensitive. | |
1205 PSIZE is a pixel or point size, which may be a "matrix". The | |
1206 syntax of a matrix is not checked, just some lexical properties. | |
1207 AFAICT none of the TEXT fields except adstyle is optional. | |
1208 | |
1209 NB. It should not be a problem if this matches "too much", since | |
1210 an "old" server will simply not be able to find a matching font. */ | |
1211 "\\`", | |
1212 XE_XLFD_PREFIX, /* prefix */ | |
1213 XE_XLFD_TEXT, /* foundry */ | |
1214 XE_XLFD_SEPARATOR, | |
1215 XE_XLFD_TEXT, /* family */ | |
1216 XE_XLFD_SEPARATOR, | |
1217 XE_XLFD_TEXT, /* weight */ | |
1218 XE_XLFD_SEPARATOR, | |
1219 XE_XLFD_SLANT, /* slant */ | |
1220 XE_XLFD_SEPARATOR, | |
1221 XE_XLFD_TEXT, /* swidth */ | |
1222 XE_XLFD_SEPARATOR, | |
1223 XE_XLFD_OPT_TEXT, /* adstyle */ | |
1224 XE_XLFD_SEPARATOR, | |
1225 XE_XLFD_PSIZE, /* pixelsize */ | |
1226 XE_XLFD_SEPARATOR, | |
1227 XE_XLFD_PSIZE, /* pointsize */ | |
1228 XE_XLFD_SEPARATOR, | |
1229 XE_XLFD_NUMBER, /* resx */ | |
1230 XE_XLFD_SEPARATOR, | |
1231 XE_XLFD_NUMBER, /* resy */ | |
1232 XE_XLFD_SEPARATOR, | |
1233 XE_XLFD_SPACING, /* spacing */ | |
1234 XE_XLFD_SEPARATOR, | |
1235 XE_XLFD_OPT_NEGATE, /* avgwidth */ | |
1236 XE_XLFD_NUMBER, | |
1237 XE_XLFD_SEPARATOR, | |
1238 XE_XLFD_TEXT, /* registry */ | |
1239 XE_XLFD_SEPARATOR, | |
1240 XE_XLFD_TEXT, /* encoding */ | |
1241 "\\'" | |
1242 }; | |
1243 | |
1244 GCPRO1 (reg); | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1245 for (i = 0; i < sizeof (re)/sizeof (Extbyte *); i++) |
3354 | 1246 { |
1247 /* #### Currently this is Host Portable Coding, not ISO 8859-1. */ | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1248 reg = concat2 (reg, build_extstring (re[i], Qx_font_name_encoding)); |
3354 | 1249 } |
1250 | |
1251 RETURN_UNGCPRO (reg); | |
1252 } | |
1253 #undef XE_XLFD_SEPARATOR | |
1254 #undef XE_XLFD_PREFIX | |
1255 #undef XE_XLFD_OPT_TEXT | |
1256 #undef XE_XLFD_TEXT | |
1257 #undef XE_XLFD_OPT_SLANT | |
1258 #undef XE_XLFD_OPT_SPACING | |
1259 #undef XE_XLFD_OPT_NEGATE | |
1260 #undef XE_XLFD_NUMBER | |
1261 #undef XE_XLFD_PSIZE | |
1262 | |
1263 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \ | |
1264 ? ((unsigned long) (x)) : ((unsigned long) (y))) | |
1265 | |
1266 static void | |
1267 string_list_to_fcobjectset (Lisp_Object list, FcObjectSet *os) | |
1268 { | |
1269 EXTERNAL_LIST_LOOP_2 (elt, list) | |
1270 { | |
3469 | 1271 const Extbyte *s; |
3354 | 1272 |
1273 CHECK_STRING (elt); | |
1274 s = fc_intern (elt); | |
1275 FcObjectSetAdd (os, s); | |
1276 } | |
1277 } | |
1278 | |
1279 void | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1280 syms_of_font_mgr (void) |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1281 { |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1282 INIT_LISP_OBJECT (fc_pattern); |
3354 | 1283 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1284 DEFSYMBOL_MULTIWORD_PREDICATE (Qfc_patternp); |
3354 | 1285 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1286 DEFSYMBOL (Qfc_result_type_mismatch); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1287 DEFSYMBOL (Qfc_result_no_match); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1288 DEFSYMBOL (Qfc_result_no_id); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1289 DEFSYMBOL (Qfc_internal_error); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1290 DEFSYMBOL (Qfc_match_pattern); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1291 DEFSYMBOL (Qfc_match_font); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1292 DEFSYMBOL (Qfont_mgr); |
3354 | 1293 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1294 DEFSUBR (Ffc_pattern_p); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1295 DEFSUBR (Ffc_pattern_create); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1296 DEFSUBR (Ffc_name_parse); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1297 DEFSUBR (Ffc_name_unparse); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1298 DEFSUBR (Ffc_pattern_duplicate); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1299 DEFSUBR (Ffc_pattern_add); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1300 DEFSUBR (Ffc_pattern_del); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1301 DEFSUBR (Ffc_pattern_get); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1302 DEFSUBR (Ffc_list_fonts_pattern_objects); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1303 DEFSUBR (Ffc_font_sort); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1304 DEFSUBR (Ffc_font_match); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1305 DEFSUBR (Ffc_default_substitute); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1306 DEFSUBR (Ffc_config_substitute); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1307 DEFSUBR (Ffc_font_render_prepare); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1308 DEFSUBR (Fxlfd_font_name_p); |
3931 | 1309 |
1310 #ifdef FONTCONFIG_EXPOSE_CONFIG | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1311 INIT_LISP_OBJECT (fc_config); |
3931 | 1312 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1313 DEFSYMBOL_MULTIWORD_PREDICATE (Qfc_configp); |
3931 | 1314 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1315 DEFSUBR (Ffc_config_p); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1316 DEFSUBR (Ffc_config_create); |
3931 | 1317 #if 0 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1318 DEFSUBR (Ffc_config_destroy); |
3931 | 1319 #endif |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1320 DEFSUBR (Ffc_config_set_current); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1321 DEFSUBR (Ffc_config_get_current); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1322 DEFSUBR (Ffc_config_up_to_date); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1323 DEFSUBR (Ffc_config_build_fonts); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1324 DEFSUBR (Ffc_config_get_config_dirs); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1325 DEFSUBR (Ffc_config_get_font_dirs); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1326 DEFSUBR (Ffc_config_get_config_files); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1327 DEFSUBR (Ffc_config_get_cache); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1328 DEFSUBR (Ffc_config_get_fonts); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1329 DEFSUBR (Ffc_config_get_blanks); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1330 DEFSUBR (Ffc_config_get_rescan_interval); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1331 DEFSUBR (Ffc_config_set_rescan_interval); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1332 DEFSUBR (Ffc_config_app_font_add_file); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1333 DEFSUBR (Ffc_config_app_font_add_dir); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1334 DEFSUBR (Ffc_config_app_font_clear); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1335 DEFSUBR (Ffc_config_filename); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1336 DEFSUBR (Ffc_init_load_config); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1337 DEFSUBR (Ffc_init_load_config_and_fonts); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1338 DEFSUBR (Ffc_init); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1339 DEFSUBR (Ffc_get_version); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1340 DEFSUBR (Ffc_init_reinitialize); |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1341 DEFSUBR (Ffc_init_bring_up_to_date); |
3931 | 1342 #endif /* FONTCONFIG_EXPOSE_CONFIG */ |
3354 | 1343 } |
1344 | |
1345 void | |
1346 vars_of_font_mgr (void) | |
1347 { | |
3935 | 1348 /* #### The next two DEFVARs belong somewhere else. */ |
3354 | 1349 |
1350 /* #### I know, but the right fix is use the generic debug facility. */ | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1351 DEFVAR_INT ("debug-xft", &debug_xft /* |
3354 | 1352 Level of debugging messages to issue to stderr for Xft. |
1353 A nonnegative integer. Set to 0 to suppress all warnings. | |
1354 Default is 1 to ensure a minimum of debugging output at initialization. | |
1355 Higher levels give even more information. | |
1356 */ ); | |
4757
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4328
diff
changeset
|
1357 debug_xft = 0; |
3354 | 1358 |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1359 DEFVAR_CONST_INT ("xft-version", &xft_version /* |
3354 | 1360 The major version number of the Xft library being used. |
1361 */ ); | |
3935 | 1362 xft_version = XFT_VERSION; |
1363 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1364 DEFVAR_CONST_INT ("fc-version", &fc_version /* |
3935 | 1365 The version number of fontconfig.h. It can be checked against |
1366 `(fc-get-version)', which is the version of the .so. | |
1367 It's probably not a disaster if `(> (fc-get-version) fc-version)'. | |
1368 */ ); | |
1369 fc_version = FC_VERSION; | |
3354 | 1370 |
3360 | 1371 Fprovide (intern ("font-mgr")); |
3354 | 1372 } |
1373 | |
1374 void | |
1375 complex_vars_of_font_mgr (void) | |
1376 { | |
3931 | 1377 #ifdef FONTCONFIG_EXPOSE_CONFIG |
1378 Vfc_config_weak_list = make_weak_list (WEAK_LIST_SIMPLE); | |
1379 staticpro (&Vfc_config_weak_list); | |
1380 #endif | |
1381 | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5178
diff
changeset
|
1382 DEFVAR_LISP ("xft-xlfd-font-regexp", &Vxlfd_font_name_regexp /* |
3354 | 1383 The regular expression used to match XLFD font names. */ |
1384 ); | |
1385 Vxlfd_font_name_regexp = make_xlfd_font_regexp(); | |
1386 } | |
1387 | |
1388 void | |
1389 reinit_vars_of_font_mgr (void) | |
1390 { | |
1391 int i, size = (int) countof (fc_standard_properties); | |
1392 | |
1393 FcInit (); | |
1394 | |
1395 fc_property_name_hash_table = make_string_hash_table (size); | |
1396 for (i = 0; i < size; ++i) | |
1397 puthash (fc_standard_properties[i], NULL, fc_property_name_hash_table); | |
1398 } | |
1399 |