comparison src/font-mgr.c @ 3469:f986ebd9c080

[xemacs-hg @ 2006-06-23 15:44:59 by stephent] Quiet GCC 4 signedness warnings. <87zmg399dw.fsf@tleepslib.sk.tsukuba.ac.jp> <87veqr996l.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Fri, 23 Jun 2006 15:45:03 +0000
parents 182c0df289b7
children 605c915d2b9d
comparison
equal deleted inserted replaced
3468:4572e331d1cf 3469:f986ebd9c080
118 names. I suppose that Qnative is the right encoding, the manual 118 names. I suppose that Qnative is the right encoding, the manual
119 doesn't say much about this topic. This functions assumes that STR 119 doesn't say much about this topic. This functions assumes that STR
120 is a Lisp string. 120 is a Lisp string.
121 */ 121 */
122 #define extract_fcapi_string(str) \ 122 #define extract_fcapi_string(str) \
123 ((FcChar8 *) NEW_LISP_STRING_TO_EXTERNAL ((str), Qfc_font_name_encoding)) 123 (NEW_LISP_STRING_TO_EXTERNAL ((str), Qfc_font_name_encoding))
124 124
125 /* #### This homebrew lashup should be replaced with FcConstants. 125 /* #### This homebrew lashup should be replaced with FcConstants.
126 126
127 fontconfig assumes that objects (property names) are statically allocated, 127 fontconfig assumes that objects (property names) are statically allocated,
128 and you will get bizarre results if you pass Lisp string data or strings 128 and you will get bizarre results if you pass Lisp string data or strings
156 static struct hash_table *fc_property_name_hash_table; 156 static struct hash_table *fc_property_name_hash_table;
157 157
158 /* #### Maybe fc_intern should be exposed to LISP? The idea is that 158 /* #### Maybe fc_intern should be exposed to LISP? The idea is that
159 fc-pattern-add could warn or error if the property isn't interned. */ 159 fc-pattern-add could warn or error if the property isn't interned. */
160 160
161 static FcChar8 * 161 static const Extbyte *
162 fc_intern (Lisp_Object property) 162 fc_intern (Lisp_Object property)
163 { 163 {
164 const void *dummy; 164 const void *dummy;
165 FcChar8 *prop = extract_fcapi_string (property); 165 const Extbyte *prop = extract_fcapi_string (property);
166 const void *val = gethash (prop, fc_property_name_hash_table, &dummy); 166 const void *val = gethash (prop, fc_property_name_hash_table, &dummy);
167 167
168 /* extract_fcapi_string returns something alloca'd 168 /* extract_fcapi_string returns something alloca'd
169 so we can just drop the old value of prop on the floor */ 169 so we can just drop the old value of prop on the floor */
170 if (val) 170 if (val)
171 prop = (FcChar8 *) val; 171 prop = (const Extbyte *) val;
172 else 172 else
173 { 173 {
174 prop = FcStrCopy (prop); 174 prop = (const Extbyte *) FcStrCopy ((FcChar8 *) prop);
175 puthash (prop, NULL, fc_property_name_hash_table); 175 puthash (prop, NULL, fc_property_name_hash_table);
176 } 176 }
177 return prop; 177 return prop;
178 } 178 }
179 179
205 struct fc_pattern *fcpat = 205 struct fc_pattern *fcpat =
206 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); 206 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
207 207
208 CHECK_STRING(name); /* #### MEMORY LEAK!! maybe not ... */ 208 CHECK_STRING(name); /* #### MEMORY LEAK!! maybe not ... */
209 209
210 fcpat->fcpatPtr = FcNameParse (extract_fcapi_string (name)); 210 fcpat->fcpatPtr = FcNameParse ((FcChar8 *) extract_fcapi_string (name));
211 return wrap_fcpattern(fcpat); 211 return wrap_fcpattern(fcpat);
212 } 212 }
213 213
214 /* #### Ga-a-ack! Xft's similar function is actually a different API. 214 /* #### Ga-a-ack! Xft's similar function is actually a different API.
215 We provide both. */ 215 We provide both. */
218 */ 218 */
219 (pattern)) 219 (pattern))
220 { 220 {
221 CHECK_FCPATTERN(pattern); 221 CHECK_FCPATTERN(pattern);
222 { 222 {
223 FcChar8 *temp = FcNameUnparse(XFCPATTERN_PTR(pattern)); 223 Extbyte *temp = (Extbyte *) FcNameUnparse(XFCPATTERN_PTR(pattern));
224 Lisp_Object res = build_ext_string (temp, Qfc_font_name_encoding); 224 Lisp_Object res = build_ext_string (temp, Qfc_font_name_encoding);
225 free (temp); 225 free (temp);
226 return res; 226 return res;
227 } 227 }
228 } 228 }
229 229
230 DEFUN("fc-pattern-duplicate", Ffc_pattern_duplicate, 1, 1, 0, /* 230 DEFUN("fc-pattern-duplicate", Ffc_pattern_duplicate, 1, 1, 0, /*
231 Make a copy of the fc pattern object PATTERN and return it. 231 Make a copy of the fc pattern object PATTERN and return it.
248 will be added as an FcChar8[], int, double, or FcBool respectively. 248 will be added as an FcChar8[], int, double, or FcBool respectively.
249 */ 249 */
250 (pattern, property, value)) 250 (pattern, property, value))
251 { 251 {
252 Bool res = 0; 252 Bool res = 0;
253 Extbyte *obj; 253 const Extbyte *obj;
254 FcPattern *fcpat; 254 FcPattern *fcpat;
255 255
256 CHECK_FCPATTERN(pattern); 256 CHECK_FCPATTERN(pattern);
257 CHECK_STRING(property); 257 CHECK_STRING(property);
258 258
289 Bool res; 289 Bool res;
290 290
291 CHECK_FCPATTERN(pattern); 291 CHECK_FCPATTERN(pattern);
292 CHECK_STRING(property); 292 CHECK_STRING(property);
293 293
294 res = FcPatternDel(XFCPATTERN_PTR(pattern), 294 res = FcPatternDel(XFCPATTERN_PTR(pattern), extract_fcapi_string (property));
295 extract_fcapi_string (property));
296 return res ? Qt : Qnil; 295 return res ? Qt : Qnil;
297 } 296 }
298 297
299 /* Generic interface to FcPatternGet() 298 /* Generic interface to FcPatternGet()
300 * Don't support the losing symbol-for-property interface. 299 * Don't support the losing symbol-for-property interface.
373 372
374 The following properties which were standard in Xft v.1 are obsolete in 373 The following properties which were standard in Xft v.1 are obsolete in
375 Xft v.2: encoding, charwidth, charheight, core, and render. */ 374 Xft v.2: encoding, charwidth, charheight, core, and render. */
376 (pattern, property, id, type)) 375 (pattern, property, id, type))
377 { 376 {
378 FcChar8 *fc_property; /* UExtbyte * */ 377 Extbyte *fc_property;
379 FcResult fc_result; 378 FcResult fc_result;
380 FcValue fc_value; 379 FcValue fc_value;
381 380
382 /* 381 /*
383 process arguments 382 process arguments
388 /* Don't support the losing symbol-for-property interface. */ 387 /* Don't support the losing symbol-for-property interface. */
389 property = SYMBOLP (property) ? symbol_name (XSYMBOL (property)) : property; 388 property = SYMBOLP (property) ? symbol_name (XSYMBOL (property)) : property;
390 #endif 389 #endif
391 if (STRINGP (property)) 390 if (STRINGP (property))
392 { 391 {
393 fc_property = (FcChar8 *) extract_fcapi_string (property); 392 fc_property = extract_fcapi_string (property);
394 } 393 }
395 else 394 else
396 { 395 {
397 /* if we allow symbols, this would need to be 396 /* if we allow symbols, this would need to be
398 list3 (Qlambda, list1 (Qobject), 397 list3 (Qlambda, list1 (Qobject),
425 && !EQ (type, Qfloat)) 424 && !EQ (type, Qfloat))
426 ? Qfc_result_type_mismatch : make_float (fc_value.u.d)); 425 ? Qfc_result_type_mismatch : make_float (fc_value.u.d));
427 case FcTypeString: 426 case FcTypeString:
428 return ((!NILP (type) && !EQ (type, Qstring)) 427 return ((!NILP (type) && !EQ (type, Qstring))
429 ? Qfc_result_type_mismatch 428 ? Qfc_result_type_mismatch
430 : build_ext_string (fc_value.u.s, Qfc_font_name_encoding)); 429 : build_ext_string ((Extbyte *) fc_value.u.s,
430 Qfc_font_name_encoding));
431 case FcTypeBool: 431 case FcTypeBool:
432 return ((!NILP (type) && !EQ (type, Qboolean)) 432 return ((!NILP (type) && !EQ (type, Qboolean))
433 ? Qfc_result_type_mismatch : fc_value.u.b ? Qt : Qnil); 433 ? Qfc_result_type_mismatch : fc_value.u.b ? Qt : Qnil);
434 case FcTypeMatrix: 434 case FcTypeMatrix:
435 return Qfc_result_type_mismatch; 435 return Qfc_result_type_mismatch;
698 static void 698 static void
699 string_list_to_fcobjectset (Lisp_Object list, FcObjectSet *os) 699 string_list_to_fcobjectset (Lisp_Object list, FcObjectSet *os)
700 { 700 {
701 EXTERNAL_LIST_LOOP_2 (elt, list) 701 EXTERNAL_LIST_LOOP_2 (elt, list)
702 { 702 {
703 FcChar8 *s; 703 const Extbyte *s;
704 704
705 CHECK_STRING (elt); 705 CHECK_STRING (elt);
706 s = fc_intern (elt); 706 s = fc_intern (elt);
707 FcObjectSetAdd (os, s); 707 FcObjectSetAdd (os, s);
708 } 708 }