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