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