Mercurial > hg > xemacs-beta
comparison src/font-mgr.c @ 5178:97eb4942aec8
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Mon, 29 Mar 2010 21:28:13 -0500 |
parents | 8b2f75cecb89 f965e31a35f0 |
children | b65692aa90d8 |
comparison
equal
deleted
inserted
replaced
5177:b785049378e3 | 5178:97eb4942aec8 |
---|---|
1 /* Lisp font handling implementation for X with Xft. | 1 /* Lisp font handling implementation for X with Xft. |
2 | 2 |
3 Copyright (C) 2003 Eric Knauel and Matthias Neubauer | 3 Copyright (C) 2003 Eric Knauel and Matthias Neubauer |
4 Copyright (C) 2005 Eric Knauel | 4 Copyright (C) 2005 Eric Knauel |
5 Copyright (C) 2004-2009 Free Software Foundation, Inc. | 5 Copyright (C) 2004-2009 Free Software Foundation, Inc. |
6 Copyright (C) 2010 Ben Wing. | |
6 | 7 |
7 Authors: Eric Knauel <knauel@informatik.uni-tuebingen.de> | 8 Authors: Eric Knauel <knauel@informatik.uni-tuebingen.de> |
8 Matthias Neubauer <neubauer@informatik.uni-freiburg.de> | 9 Matthias Neubauer <neubauer@informatik.uni-freiburg.de> |
9 Stephen J. Turnbull <stephen@xemacs.org> | 10 Stephen J. Turnbull <stephen@xemacs.org> |
10 Created: 27 Oct 2003 | 11 Created: 27 Oct 2003 |
91 /**************************************************************** | 92 /**************************************************************** |
92 * FcPattern objects * | 93 * FcPattern objects * |
93 ****************************************************************/ | 94 ****************************************************************/ |
94 | 95 |
95 static void | 96 static void |
96 finalize_fc_pattern (void *header, int UNUSED (for_disksave)) | 97 finalize_fc_pattern (Lisp_Object obj) |
97 { | 98 { |
98 struct fc_pattern *p = (struct fc_pattern *) header; | 99 struct fc_pattern *p = XFC_PATTERN (obj); |
99 if (p->fcpatPtr) | 100 if (p->fcpatPtr) |
100 { | 101 { |
101 FcPatternDestroy (p->fcpatPtr); | 102 FcPatternDestroy (p->fcpatPtr); |
102 p->fcpatPtr = 0; | 103 p->fcpatPtr = 0; |
103 } | 104 } |
104 } | |
105 | |
106 static void | |
107 print_fc_pattern (Lisp_Object obj, Lisp_Object printcharfun, | |
108 int UNUSED(escapeflag)) | |
109 { | |
110 struct fc_pattern *c = XFCPATTERN (obj); | |
111 if (print_readably) | |
112 printing_unreadable_object ("#<fc-pattern 0x%x>", c->header.uid); | |
113 write_fmt_string (printcharfun, "#<fc-pattern 0x%x>", c->header.uid); | |
114 } | 105 } |
115 | 106 |
116 /* #### We really need an equal method and a hash method (required if you | 107 /* #### We really need an equal method and a hash method (required if you |
117 have an equal method). For the equal method, we can probably use one | 108 have an equal method). For the equal method, we can probably use one |
118 or both of | 109 or both of |
140 static const struct memory_description fcpattern_description [] = { | 131 static const struct memory_description fcpattern_description [] = { |
141 /* #### nothing here, is this right?? */ | 132 /* #### nothing here, is this right?? */ |
142 { XD_END } | 133 { XD_END } |
143 }; | 134 }; |
144 | 135 |
145 DEFINE_LRECORD_IMPLEMENTATION("fc-pattern", fc_pattern, 0, | 136 DEFINE_NODUMP_LISP_OBJECT ("fc-pattern", fc_pattern, |
146 0, print_fc_pattern, finalize_fc_pattern, | 137 0, external_object_printer, finalize_fc_pattern, |
147 0, 0, fcpattern_description, | 138 0, 0, fcpattern_description, |
148 struct fc_pattern); | 139 struct fc_pattern); |
149 | 140 |
150 /* | 141 /* |
151 * Helper Functions | 142 * Helper Functions |
152 */ | 143 */ |
153 static Lisp_Object make_xlfd_font_regexp (void); | 144 static Lisp_Object make_xlfd_font_regexp (void); |
224 DEFUN("fc-pattern-p", Ffc_pattern_p, 1, 1, 0, /* | 215 DEFUN("fc-pattern-p", Ffc_pattern_p, 1, 1, 0, /* |
225 Returns t if OBJECT is of type fc-pattern, nil otherwise. | 216 Returns t if OBJECT is of type fc-pattern, nil otherwise. |
226 */ | 217 */ |
227 (object)) | 218 (object)) |
228 { | 219 { |
229 return FCPATTERNP(object) ? Qt : Qnil; | 220 return FC_PATTERNP(object) ? Qt : Qnil; |
230 } | 221 } |
231 | 222 |
232 DEFUN("fc-pattern-create", Ffc_pattern_create, 0, 0, 0, /* | 223 DEFUN("fc-pattern-create", Ffc_pattern_create, 0, 0, 0, /* |
233 Return a new, empty fc-pattern object. | 224 Return a new, empty fc-pattern object. |
234 */ | 225 */ |
235 ()) | 226 ()) |
236 { | 227 { |
237 fc_pattern *fcpat = | 228 fc_pattern *fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
238 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); | 229 |
239 | 230 fcpat->fcpatPtr = FcPatternCreate (); |
240 fcpat->fcpatPtr = FcPatternCreate(); | 231 return wrap_fc_pattern (fcpat); |
241 return wrap_fcpattern(fcpat); | |
242 } | 232 } |
243 | 233 |
244 DEFUN("fc-name-parse", Ffc_name_parse, 1, 1, 0, /* | 234 DEFUN("fc-name-parse", Ffc_name_parse, 1, 1, 0, /* |
245 Parse an Fc font name and return its representation as a fc pattern object. | 235 Parse an Fc font name and return its representation as a fc pattern object. |
246 */ | 236 */ |
247 (name)) | 237 (name)) |
248 { | 238 { |
249 struct fc_pattern *fcpat = | 239 fc_pattern *fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
250 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); | 240 |
251 | 241 CHECK_STRING (name); |
252 CHECK_STRING(name); | |
253 | 242 |
254 fcpat->fcpatPtr = FcNameParse ((FcChar8 *) extract_fcapi_string (name)); | 243 fcpat->fcpatPtr = FcNameParse ((FcChar8 *) extract_fcapi_string (name)); |
255 return wrap_fcpattern(fcpat); | 244 return wrap_fc_pattern (fcpat); |
256 } | 245 } |
257 | 246 |
258 /* #### Ga-a-ack! Xft's similar function is actually a different API. | 247 /* #### Ga-a-ack! Xft's similar function is actually a different API. |
259 We provide both. */ | 248 We provide both. */ |
260 DEFUN("fc-name-unparse", Ffc_name_unparse, 1, 1, 0, /* | 249 DEFUN("fc-name-unparse", Ffc_name_unparse, 1, 1, 0, /* |
262 */ | 251 */ |
263 (pattern)) | 252 (pattern)) |
264 { | 253 { |
265 FcChar8 *name; | 254 FcChar8 *name; |
266 Lisp_Object result; | 255 Lisp_Object result; |
267 CHECK_FCPATTERN(pattern); | 256 CHECK_FC_PATTERN(pattern); |
268 name = FcNameUnparse (XFCPATTERN_PTR (pattern)); | 257 name = FcNameUnparse (XFC_PATTERN_PTR (pattern)); |
269 result = build_fcapi_string (name); | 258 result = build_fcapi_string (name); |
270 xfree (name); | 259 xfree (name); |
271 return result; | 260 return result; |
272 } | 261 } |
273 | 262 |
275 Make a copy of the fc pattern object PATTERN and return it. | 264 Make a copy of the fc pattern object PATTERN and return it. |
276 */ | 265 */ |
277 (pattern)) | 266 (pattern)) |
278 { | 267 { |
279 struct fc_pattern *copy = NULL; | 268 struct fc_pattern *copy = NULL; |
280 CHECK_FCPATTERN(pattern); | 269 CHECK_FC_PATTERN (pattern); |
281 | 270 |
282 copy = ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); | 271 copy = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
283 copy->fcpatPtr = FcPatternDuplicate(XFCPATTERN_PTR(pattern)); | 272 copy->fcpatPtr = FcPatternDuplicate (XFC_PATTERN_PTR (pattern)); |
284 return wrap_fcpattern(copy); | 273 return wrap_fc_pattern (copy); |
285 } | 274 } |
286 | 275 |
287 DEFUN("fc-pattern-add", Ffc_pattern_add, 3, 3, 0, /* | 276 DEFUN("fc-pattern-add", Ffc_pattern_add, 3, 3, 0, /* |
288 Add attributes to the pattern object PATTERN. PROPERTY is a string naming | 277 Add attributes to the pattern object PATTERN. PROPERTY is a string naming |
289 the attribute to add, VALUE the value for this attribute. | 278 the attribute to add, VALUE the value for this attribute. |
295 { | 284 { |
296 Bool res = 0; | 285 Bool res = 0; |
297 const Extbyte *obj; | 286 const Extbyte *obj; |
298 FcPattern *fcpat; | 287 FcPattern *fcpat; |
299 | 288 |
300 CHECK_FCPATTERN(pattern); | 289 CHECK_FC_PATTERN (pattern); |
301 CHECK_STRING(property); | 290 CHECK_STRING (property); |
302 | 291 |
303 obj = fc_intern (property); | 292 obj = fc_intern (property); |
304 fcpat = XFCPATTERN_PTR (pattern); | 293 fcpat = XFC_PATTERN_PTR (pattern); |
305 | 294 |
306 if (STRINGP(value)) | 295 if (STRINGP(value)) |
307 { | 296 { |
308 FcChar8 *str = (FcChar8 *) extract_fcapi_string (value); | 297 FcChar8 *str = (FcChar8 *) extract_fcapi_string (value); |
309 res = FcPatternAddString (fcpat, obj, str); | 298 res = FcPatternAddString (fcpat, obj, str); |
330 */ | 319 */ |
331 (pattern, property)) | 320 (pattern, property)) |
332 { | 321 { |
333 Bool res; | 322 Bool res; |
334 | 323 |
335 CHECK_FCPATTERN(pattern); | 324 CHECK_FC_PATTERN(pattern); |
336 CHECK_STRING(property); | 325 CHECK_STRING(property); |
337 | 326 |
338 res = FcPatternDel(XFCPATTERN_PTR(pattern), extract_fcapi_string (property)); | 327 res = FcPatternDel(XFC_PATTERN_PTR(pattern), extract_fcapi_string (property)); |
339 return res ? Qt : Qnil; | 328 return res ? Qt : Qnil; |
340 } | 329 } |
341 | 330 |
342 /* Generic interface to FcPatternGet() | 331 /* Generic interface to FcPatternGet() |
343 * Don't support the losing symbol-for-property interface. | 332 * Don't support the losing symbol-for-property interface. |
423 FcValue fc_value; | 412 FcValue fc_value; |
424 | 413 |
425 /* | 414 /* |
426 process arguments | 415 process arguments |
427 */ | 416 */ |
428 CHECK_FCPATTERN (pattern); | 417 CHECK_FC_PATTERN (pattern); |
429 | 418 |
430 #if 0 | 419 #if 0 |
431 /* Don't support the losing symbol-for-property interface. */ | 420 /* Don't support the losing symbol-for-property interface. */ |
432 property = SYMBOLP (property) ? symbol_name (XSYMBOL (property)) : property; | 421 property = SYMBOLP (property) ? symbol_name (XSYMBOL (property)) : property; |
433 #endif | 422 #endif |
447 | 436 |
448 if (!NILP (id)) CHECK_NATNUM (id); | 437 if (!NILP (id)) CHECK_NATNUM (id); |
449 if (!NILP (type)) CHECK_SYMBOL (type); | 438 if (!NILP (type)) CHECK_SYMBOL (type); |
450 | 439 |
451 /* get property */ | 440 /* get property */ |
452 fc_result = FcPatternGet (XFCPATTERN_PTR (pattern), | 441 fc_result = FcPatternGet (XFC_PATTERN_PTR (pattern), |
453 fc_property, | 442 fc_property, |
454 NILP (id) ? 0 : XINT(id), | 443 NILP (id) ? 0 : XINT(id), |
455 &fc_value); | 444 &fc_value); |
456 | 445 |
457 switch (fc_result) | 446 switch (fc_result) |
515 Lisp_Object configs = XWEAK_LIST_LIST (Vfc_config_weak_list); | 504 Lisp_Object configs = XWEAK_LIST_LIST (Vfc_config_weak_list); |
516 | 505 |
517 /* Linear search: fc_configs are not going to multiply like conses. */ | 506 /* Linear search: fc_configs are not going to multiply like conses. */ |
518 { | 507 { |
519 LIST_LOOP_2 (cfg, configs) | 508 LIST_LOOP_2 (cfg, configs) |
520 if (fc == XFCCONFIG_PTR (cfg)) | 509 if (fc == XFC_CONFIG_PTR (cfg)) |
521 return cfg; | 510 return cfg; |
522 } | 511 } |
523 | 512 |
524 { | 513 { |
525 fc_config *fccfg = | 514 fc_config *fccfg = XFC_CONFIG (ALLOC_NORMAL_LISP_OBJECT (fc_config)); |
526 ALLOC_LCRECORD_TYPE (struct fc_config, &lrecord_fc_config); | |
527 fccfg->fccfgPtr = fc; | 515 fccfg->fccfgPtr = fc; |
528 configs = Fcons (wrap_fcconfig (fccfg), configs); | 516 configs = Fcons (wrap_fc_config (fccfg), configs); |
529 XWEAK_LIST_LIST (Vfc_config_weak_list) = configs; | 517 XWEAK_LIST_LIST (Vfc_config_weak_list) = configs; |
530 return wrap_fcconfig (fccfg); | 518 return wrap_fc_config (fccfg); |
531 } | 519 } |
532 } | 520 } |
533 | 521 |
534 static Lisp_Object | 522 static Lisp_Object |
535 fc_strlist_to_lisp_using (FcStrList * (*getter) (FcConfig *), | 523 fc_strlist_to_lisp_using (FcStrList * (*getter) (FcConfig *), |
537 { | 525 { |
538 FcChar8 *thing; | 526 FcChar8 *thing; |
539 Lisp_Object value = Qnil; | 527 Lisp_Object value = Qnil; |
540 FcStrList *thing_list; | 528 FcStrList *thing_list; |
541 | 529 |
542 CHECK_FCCONFIG (config); | 530 CHECK_FC_CONFIG (config); |
543 thing_list = (*getter) (XFCCONFIG_PTR(config)); | 531 thing_list = (*getter) (XFC_CONFIG_PTR(config)); |
544 /* Yes, we need to do this check -- sheesh, Keith! */ | 532 /* Yes, we need to do this check -- sheesh, Keith! */ |
545 if (!thing_list) | 533 if (!thing_list) |
546 return Qnil; | 534 return Qnil; |
547 while ((thing = FcStrListNext (thing_list))) | 535 while ((thing = FcStrListNext (thing_list))) |
548 value = Fcons (build_fcapi_string (thing), value); | 536 value = Fcons (build_fcapi_string (thing), value); |
560 /* #### improve this error message */ | 548 /* #### improve this error message */ |
561 if (!fontset) | 549 if (!fontset) |
562 invalid_state ("failed to create FcFontSet", Qunbound); | 550 invalid_state ("failed to create FcFontSet", Qunbound); |
563 for (idx = 0; idx < fontset->nfont; ++idx) | 551 for (idx = 0; idx < fontset->nfont; ++idx) |
564 { | 552 { |
565 fcpat = | 553 fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
566 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); | |
567 fcpat->fcpatPtr = FcPatternDuplicate (fontset->fonts[idx]); | 554 fcpat->fcpatPtr = FcPatternDuplicate (fontset->fonts[idx]); |
568 fontlist = Fcons (wrap_fcpattern(fcpat), fontlist); | 555 fontlist = Fcons (wrap_fc_pattern(fcpat), fontlist); |
569 } | 556 } |
570 if (destroyp) | 557 if (destroyp) |
571 FcFontSetDestroy (fontset); | 558 FcFontSetDestroy (fontset); |
572 return fontlist; | 559 return fontlist; |
573 } | 560 } |
575 DEFUN("fc-config-p", Ffc_config_p, 1, 1, 0, /* | 562 DEFUN("fc-config-p", Ffc_config_p, 1, 1, 0, /* |
576 Returns t if OBJECT is of type fc-config, nil otherwise. | 563 Returns t if OBJECT is of type fc-config, nil otherwise. |
577 */ | 564 */ |
578 (object)) | 565 (object)) |
579 { | 566 { |
580 return FCCONFIGP (object) ? Qt : Qnil; | 567 return FC_CONFIGP (object) ? Qt : Qnil; |
581 } | 568 } |
582 | 569 |
583 DEFUN("fc-config-create", Ffc_config_create, 0, 0, 0, /* | 570 DEFUN("fc-config-create", Ffc_config_create, 0, 0, 0, /* |
584 -- Function: FcConfig *FcConfigCreate (void) | 571 -- Function: FcConfig *FcConfigCreate (void) |
585 Creates an empty configuration. */ | 572 Creates an empty configuration. */ |
608 -- Function: FcBool FcConfigUptoDate (FcConfig *config) | 595 -- Function: FcBool FcConfigUptoDate (FcConfig *config) |
609 Checks all of the files related to 'config' and returns whether the | 596 Checks all of the files related to 'config' and returns whether the |
610 in-memory version is in sync with the disk version. */ | 597 in-memory version is in sync with the disk version. */ |
611 (config)) | 598 (config)) |
612 { | 599 { |
613 CHECK_FCCONFIG (config); | 600 CHECK_FC_CONFIG (config); |
614 return FcConfigUptoDate (XFCCONFIG_PTR (config)) == FcFalse ? Qnil : Qt; | 601 return FcConfigUptoDate (XFC_CONFIG_PTR (config)) == FcFalse ? Qnil : Qt; |
615 } | 602 } |
616 | 603 |
617 DEFUN("fc-config-build-fonts", Ffc_config_build_fonts, 1, 1, 0, /* | 604 DEFUN("fc-config-build-fonts", Ffc_config_build_fonts, 1, 1, 0, /* |
618 -- Function: FcBool FcConfigBuildFonts (FcConfig *config) | 605 -- Function: FcBool FcConfigBuildFonts (FcConfig *config) |
619 Builds the set of available fonts for the given configuration. | 606 Builds the set of available fonts for the given configuration. |
621 indeterminate effects. Returns FcFalse if this operation runs out | 608 indeterminate effects. Returns FcFalse if this operation runs out |
622 of memory. | 609 of memory. |
623 XEmacs: signal out-of-memory, or return nil on success. */ | 610 XEmacs: signal out-of-memory, or return nil on success. */ |
624 (config)) | 611 (config)) |
625 { | 612 { |
626 CHECK_FCCONFIG (config); | 613 CHECK_FC_CONFIG (config); |
627 if (FcConfigBuildFonts (XFCCONFIG_PTR (config)) == FcFalse) | 614 if (FcConfigBuildFonts (XFC_CONFIG_PTR (config)) == FcFalse) |
628 out_of_memory ("FcConfigBuildFonts failed", config); | 615 out_of_memory ("FcConfigBuildFonts failed", config); |
629 return Qnil; | 616 return Qnil; |
630 } | 617 } |
631 | 618 |
632 DEFUN("fc-config-get-config-dirs", Ffc_config_get_config_dirs, 1, 1, 0, /* | 619 DEFUN("fc-config-get-config-dirs", Ffc_config_get_config_dirs, 1, 1, 0, /* |
663 -- Function: char *FcConfigGetCache (FcConfig *config) | 650 -- Function: char *FcConfigGetCache (FcConfig *config) |
664 Returns the name of the file used to store per-user font | 651 Returns the name of the file used to store per-user font |
665 information. */ | 652 information. */ |
666 (config)) | 653 (config)) |
667 { | 654 { |
668 CHECK_FCCONFIG (config); | 655 CHECK_FC_CONFIG (config); |
669 /* Surely FcConfigGetCache just casts an FcChar8* to char*. */ | 656 /* Surely FcConfigGetCache just casts an FcChar8* to char*. */ |
670 return build_fcapi_string ((FcChar8 *) FcConfigGetCache (XFCCONFIG_PTR (config))); | 657 return build_fcapi_string ((FcChar8 *) FcConfigGetCache (XFC_CONFIG_PTR (config))); |
671 } | 658 } |
672 | 659 |
673 DEFUN("fc-config-get-fonts", Ffc_config_get_fonts, 2, 2, 0, /* | 660 DEFUN("fc-config-get-fonts", Ffc_config_get_fonts, 2, 2, 0, /* |
674 -- Function: FcFontSet *FcConfigGetFonts (FcConfig *config, FcSetName set) | 661 -- Function: FcFontSet *FcConfigGetFonts (FcConfig *config, FcSetName set) |
675 Returns one of the two sets of fonts from the configuration as | 662 Returns one of the two sets of fonts from the configuration as |
682 (config, set)) | 669 (config, set)) |
683 { | 670 { |
684 FcSetName name = FcSetSystem; | 671 FcSetName name = FcSetSystem; |
685 FcFontSet *fs = NULL; | 672 FcFontSet *fs = NULL; |
686 | 673 |
687 CHECK_FCCONFIG (config); | 674 CHECK_FC_CONFIG (config); |
688 CHECK_SYMBOL (set); | 675 CHECK_SYMBOL (set); |
689 | 676 |
690 if (EQ (set, intern ("fc-set-system"))) | 677 if (EQ (set, intern ("fc-set-system"))) |
691 name = FcSetSystem; | 678 name = FcSetSystem; |
692 else if (EQ (set, intern ("fc-set-application"))) | 679 else if (EQ (set, intern ("fc-set-application"))) |
693 name = FcSetApplication; | 680 name = FcSetApplication; |
694 else | 681 else |
695 wtaerror ("must be in (fc-set-system fc-set-application)", set); | 682 wtaerror ("must be in (fc-set-system fc-set-application)", set); |
696 | 683 |
697 fs = FcConfigGetFonts (XFCCONFIG_PTR (config), name); | 684 fs = FcConfigGetFonts (XFC_CONFIG_PTR (config), name); |
698 return fs ? fontset_to_list (fs, DestroyNo) : Qnil; | 685 return fs ? fontset_to_list (fs, DestroyNo) : Qnil; |
699 } | 686 } |
700 | 687 |
701 DEFUN("fc-config-set-current", Ffc_config_set_current, 1, 1, 0, /* | 688 DEFUN("fc-config-set-current", Ffc_config_set_current, 1, 1, 0, /* |
702 -- Function: FcBool FcConfigSetCurrent (FcConfig *config) | 689 -- Function: FcBool FcConfigSetCurrent (FcConfig *config) |
706 XEmacs: signals out-of-memory if FcConfigBuildFonts fails, or args-out-of-range | 693 XEmacs: signals out-of-memory if FcConfigBuildFonts fails, or args-out-of-range |
707 if the resulting FcConfig has no fonts (which would crash XEmacs if installed). | 694 if the resulting FcConfig has no fonts (which would crash XEmacs if installed). |
708 */ | 695 */ |
709 (config)) | 696 (config)) |
710 { | 697 { |
711 CHECK_FCCONFIG (config); | 698 CHECK_FC_CONFIG (config); |
712 /* *sigh* "Success" DOES NOT mean you have any fonts available. It is | 699 /* *sigh* "Success" DOES NOT mean you have any fonts available. It is |
713 easy to crash fontconfig, and XEmacs with it. Without the following | 700 easy to crash fontconfig, and XEmacs with it. Without the following |
714 check, this will do it: | 701 check, this will do it: |
715 (progn | 702 (progn |
716 (fc-config-set-current (fc-config-create)) | 703 (fc-config-set-current (fc-config-create)) |
717 (set-face-font 'default "serif-12")) | 704 (set-face-font 'default "serif-12")) |
718 */ | 705 */ |
719 | 706 |
720 if (FcConfigBuildFonts (XFCCONFIG_PTR (config)) == FcFalse) | 707 if (FcConfigBuildFonts (XFC_CONFIG_PTR (config)) == FcFalse) |
721 out_of_memory ("FcConfigBuildFonts failed", config); | 708 out_of_memory ("FcConfigBuildFonts failed", config); |
722 /* #### We'd like to avoid this consing, and FcConfigGetFonts sometimes | 709 /* #### We'd like to avoid this consing, and FcConfigGetFonts sometimes |
723 returns NULL, but it doesn't always. This will do for now .... */ | 710 returns NULL, but it doesn't always. This will do for now .... */ |
724 if (NILP (Ffc_config_get_fonts (config, intern ("fc-set-system"))) | 711 if (NILP (Ffc_config_get_fonts (config, intern ("fc-set-system"))) |
725 && NILP (Ffc_config_get_fonts (config, intern ("fc-set-application")))) | 712 && NILP (Ffc_config_get_fonts (config, intern ("fc-set-application")))) |
726 signal_error (intern ("args-out-of-range"), "no fonts found", config); | 713 signal_error (intern ("args-out-of-range"), "no fonts found", config); |
727 /* Should never happen, but I don't trust Keith anymore .... */ | 714 /* Should never happen, but I don't trust Keith anymore .... */ |
728 if (FcConfigSetCurrent (XFCCONFIG_PTR (config)) == FcFalse) | 715 if (FcConfigSetCurrent (XFC_CONFIG_PTR (config)) == FcFalse) |
729 out_of_memory ("FcConfigBuildFonts failed in set", config); | 716 out_of_memory ("FcConfigBuildFonts failed in set", config); |
730 return Qnil; | 717 return Qnil; |
731 } | 718 } |
732 | 719 |
733 DEFUN("fc-config-get-blanks", Ffc_config_get_blanks, 1, 1, 0, /* | 720 DEFUN("fc-config-get-blanks", Ffc_config_get_blanks, 1, 1, 0, /* |
737 this function will return 0. | 724 this function will return 0. |
738 XEmacs: should convert to a chartable. | 725 XEmacs: should convert to a chartable. |
739 #### Unimplemented. */ | 726 #### Unimplemented. */ |
740 (config)) | 727 (config)) |
741 { | 728 { |
742 CHECK_FCCONFIG (config); | 729 CHECK_FC_CONFIG (config); |
743 signal_error (Qunimplemented, "no method to convert FcBlanks object", | 730 signal_error (Qunimplemented, "no method to convert FcBlanks object", |
744 intern ("fc-config-get-blanks")); | 731 intern ("fc-config-get-blanks")); |
745 } | 732 } |
746 | 733 |
747 DEFUN("fc-config-get-rescan-interval", Ffc_config_get_rescan_interval, 1, 1, 0, /* | 734 DEFUN("fc-config-get-rescan-interval", Ffc_config_get_rescan_interval, 1, 1, 0, /* |
750 (in seconds) specified in 'config'. The configuration is checked | 737 (in seconds) specified in 'config'. The configuration is checked |
751 during a call to FcFontList when this interval has passed since | 738 during a call to FcFontList when this interval has passed since |
752 the last check. */ | 739 the last check. */ |
753 (config)) | 740 (config)) |
754 { | 741 { |
755 CHECK_FCCONFIG (config); | 742 CHECK_FC_CONFIG (config); |
756 return make_int (FcConfigGetRescanInterval (XFCCONFIG_PTR (config))); | 743 return make_int (FcConfigGetRescanInterval (XFC_CONFIG_PTR (config))); |
757 } | 744 } |
758 | 745 |
759 DEFUN("fc-config-set-rescan-interval", Ffc_config_set_rescan_interval, 2, 2, 0, /* | 746 DEFUN("fc-config-set-rescan-interval", Ffc_config_set_rescan_interval, 2, 2, 0, /* |
760 -- Function: FcBool FcConfigSetRescanInterval (FcConfig *config, int | 747 -- Function: FcBool FcConfigSetRescanInterval (FcConfig *config, int |
761 rescanInterval) | 748 rescanInterval) |
762 Sets the rescan interval; returns FcFalse if an error occurred. | 749 Sets the rescan interval; returns FcFalse if an error occurred. |
763 XEmacs: signal such error, or return nil on success. */ | 750 XEmacs: signal such error, or return nil on success. */ |
764 (config, rescan_interval)) | 751 (config, rescan_interval)) |
765 { | 752 { |
766 CHECK_FCCONFIG (config); | 753 CHECK_FC_CONFIG (config); |
767 CHECK_INT (rescan_interval); | 754 CHECK_INT (rescan_interval); |
768 if (FcConfigSetRescanInterval (XFCCONFIG_PTR (config), | 755 if (FcConfigSetRescanInterval (XFC_CONFIG_PTR (config), |
769 XINT (rescan_interval)) == FcFalse) | 756 XINT (rescan_interval)) == FcFalse) |
770 signal_error (Qio_error, "FcConfigSetRescanInverval barfed", | 757 signal_error (Qio_error, "FcConfigSetRescanInverval barfed", |
771 intern ("fc-config-set-rescan-interval")); | 758 intern ("fc-config-set-rescan-interval")); |
772 return Qnil; | 759 return Qnil; |
773 } | 760 } |
777 -- Function: FcBool FcConfigAppFontAddFile (FcConfig *config, const | 764 -- Function: FcBool FcConfigAppFontAddFile (FcConfig *config, const |
778 char *file) | 765 char *file) |
779 Adds an application-specific font to the configuration. */ | 766 Adds an application-specific font to the configuration. */ |
780 (config, file)) | 767 (config, file)) |
781 { | 768 { |
782 CHECK_FCCONFIG (config); | 769 CHECK_FC_CONFIG (config); |
783 CHECK_STRING (file); | 770 CHECK_STRING (file); |
784 if (FcConfigAppFontAddFile | 771 if (FcConfigAppFontAddFile |
785 (XFCCONFIG_PTR (config), | 772 (XFC_CONFIG_PTR (config), |
786 /* #### FIXME! is Qfile_name right? */ | 773 /* #### FIXME! is Qfile_name right? */ |
787 (FcChar8 *) LISP_STRING_TO_EXTERNAL (file, Qfile_name)) == FcFalse) | 774 (FcChar8 *) LISP_STRING_TO_EXTERNAL (file, Qfile_name)) == FcFalse) |
788 return Qnil; | 775 return Qnil; |
789 else | 776 else |
790 return Qt; | 777 return Qt; |
796 char *dir) | 783 char *dir) |
797 Scans the specified directory for fonts, adding each one found to | 784 Scans the specified directory for fonts, adding each one found to |
798 the application-specific set of fonts. */ | 785 the application-specific set of fonts. */ |
799 (config, dir)) | 786 (config, dir)) |
800 { | 787 { |
801 CHECK_FCCONFIG (config); | 788 CHECK_FC_CONFIG (config); |
802 CHECK_STRING (dir); | 789 CHECK_STRING (dir); |
803 if (FcConfigAppFontAddDir | 790 if (FcConfigAppFontAddDir |
804 (XFCCONFIG_PTR (config), | 791 (XFC_CONFIG_PTR (config), |
805 /* #### FIXME! is Qfile_name right? */ | 792 /* #### FIXME! is Qfile_name right? */ |
806 (FcChar8 *) LISP_STRING_TO_EXTERNAL (dir, Qfile_name)) == FcFalse) | 793 (FcChar8 *) LISP_STRING_TO_EXTERNAL (dir, Qfile_name)) == FcFalse) |
807 return Qnil; | 794 return Qnil; |
808 else | 795 else |
809 return Qt; | 796 return Qt; |
813 DEFUN("fc-config-app-font-clear", Ffc_config_app_font_clear, 1, 1, 0, /* | 800 DEFUN("fc-config-app-font-clear", Ffc_config_app_font_clear, 1, 1, 0, /* |
814 -- Function: void FcConfigAppFontClear (FcConfig *config) | 801 -- Function: void FcConfigAppFontClear (FcConfig *config) |
815 Clears the set of application-specific fonts. */ | 802 Clears the set of application-specific fonts. */ |
816 (config)) | 803 (config)) |
817 { | 804 { |
818 CHECK_FCCONFIG (config); | 805 CHECK_FC_CONFIG (config); |
819 FcConfigAppFontClear (XFCCONFIG_PTR (config)); | 806 FcConfigAppFontClear (XFC_CONFIG_PTR (config)); |
820 return Qnil; | 807 return Qnil; |
821 } | 808 } |
822 | 809 |
823 /* These functions provide some control over how the default | 810 /* These functions provide some control over how the default |
824 configuration of the library is initialized. (This configuration is | 811 configuration of the library is initialized. (This configuration is |
886 * Patterns without a specified style or slant are set to Roman | 873 * Patterns without a specified style or slant are set to Roman |
887 * Patterns without a specified pixel size are given one computed from any | 874 * Patterns without a specified pixel size are given one computed from any |
888 specified point size (default 12), dpi (default 75) and scale (default 1). */ | 875 specified point size (default 12), dpi (default 75) and scale (default 1). */ |
889 (pattern)) | 876 (pattern)) |
890 { | 877 { |
891 CHECK_FCPATTERN (pattern); | 878 CHECK_FC_PATTERN (pattern); |
892 FcDefaultSubstitute (XFCPATTERN_PTR (pattern)); | 879 FcDefaultSubstitute (XFC_PATTERN_PTR (pattern)); |
893 return Qnil; | 880 return Qnil; |
894 } | 881 } |
895 | 882 |
896 /* -- Function: FcBool FcConfigSubstituteWithPat (FcConfig *config, | 883 /* -- Function: FcBool FcConfigSubstituteWithPat (FcConfig *config, |
897 FcPattern *p, FcPattern *p_pat FcMatchKind kind) | 884 FcPattern *p, FcPattern *p_pat FcMatchKind kind) |
921 knd = FcMatchPattern; | 908 knd = FcMatchPattern; |
922 else | 909 else |
923 wtaerror ("need `fc-match-pattern' or `fc-match-font'", kind); | 910 wtaerror ("need `fc-match-pattern' or `fc-match-font'", kind); |
924 | 911 |
925 /* Typecheck arguments */ | 912 /* Typecheck arguments */ |
926 CHECK_FCPATTERN (pattern); | 913 CHECK_FC_PATTERN (pattern); |
927 if (!NILP (testpat)) CHECK_FCPATTERN (testpat); | 914 if (!NILP (testpat)) CHECK_FC_PATTERN (testpat); |
928 if (!NILP (config)) CHECK_FCCONFIG (config); | 915 if (!NILP (config)) CHECK_FC_CONFIG (config); |
929 | 916 |
930 return (FcConfigSubstituteWithPat | 917 return (FcConfigSubstituteWithPat |
931 (NILP (config) ? FcConfigGetCurrent () : XFCCONFIG_PTR (config), | 918 (NILP (config) ? FcConfigGetCurrent () : XFC_CONFIG_PTR (config), |
932 XFCPATTERN_PTR (pattern), | 919 XFC_PATTERN_PTR (pattern), |
933 NILP (testpat) ? NULL : XFCPATTERN_PTR (testpat), | 920 NILP (testpat) ? NULL : XFC_PATTERN_PTR (testpat), |
934 knd) == FcTrue) | 921 knd) == FcTrue) |
935 ? Qt : Qnil; | 922 ? Qt : Qnil; |
936 } | 923 } |
937 | 924 |
938 /* Pattern matching functions. */ | 925 /* Pattern matching functions. */ |
955 (pattern, font, config)) | 942 (pattern, font, config)) |
956 { | 943 { |
957 if (NILP (config)) { | 944 if (NILP (config)) { |
958 config = Ffc_config_get_current (); | 945 config = Ffc_config_get_current (); |
959 } | 946 } |
960 CHECK_FCPATTERN (pattern); | 947 CHECK_FC_PATTERN (pattern); |
961 CHECK_FCPATTERN (font); | 948 CHECK_FC_PATTERN (font); |
962 CHECK_FCCONFIG (config); | 949 CHECK_FC_CONFIG (config); |
963 | 950 |
964 /* I don't think this can fail? */ | 951 /* I don't think this can fail? */ |
965 return wrap_fcpattern (FcFontRenderPrepare (XFCCONFIG_PTR(config), | 952 return wrap_fc_pattern (FcFontRenderPrepare (XFC_CONFIG_PTR(config), |
966 XFCPATTERN_PTR(font), | 953 XFC_PATTERN_PTR(font), |
967 XFCPATTERN_PTR(pattern))); | 954 XFC_PATTERN_PTR(pattern))); |
968 } | 955 } |
969 | 956 |
970 DEFUN("fc-font-match", Ffc_font_match, 2, 3, 0, /* | 957 DEFUN("fc-font-match", Ffc_font_match, 2, 3, 0, /* |
971 Return the font on DEVICE that most closely matches PATTERN. | 958 Return the font on DEVICE that most closely matches PATTERN. |
972 | 959 |
983 FcResult res; | 970 FcResult res; |
984 struct fc_pattern *res_fcpat; | 971 struct fc_pattern *res_fcpat; |
985 FcPattern *p; | 972 FcPattern *p; |
986 FcConfig *fcc; | 973 FcConfig *fcc; |
987 | 974 |
988 CHECK_FCPATTERN(pattern); | 975 CHECK_FC_PATTERN(pattern); |
989 if (NILP(device)) | 976 if (NILP(device)) |
990 return Qnil; | 977 return Qnil; |
991 CHECK_X_DEVICE(device); | 978 CHECK_X_DEVICE(device); |
992 if (!DEVICE_LIVE_P(XDEVICE(device))) | 979 if (!DEVICE_LIVE_P(XDEVICE(device))) |
993 return Qnil; | 980 return Qnil; |
994 if (!NILP (config)) | 981 if (!NILP (config)) |
995 CHECK_FCCONFIG (config); | 982 CHECK_FC_CONFIG (config); |
996 | 983 |
997 res_fcpat = ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); | 984 res_fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
998 p = XFCPATTERN_PTR(pattern); | 985 p = XFC_PATTERN_PTR(pattern); |
999 fcc = NILP (config) ? FcConfigGetCurrent () : XFCCONFIG_PTR (config); | 986 fcc = NILP (config) ? FcConfigGetCurrent () : XFC_CONFIG_PTR (config); |
1000 | 987 |
1001 FcConfigSubstitute (fcc, p, FcMatchPattern); | 988 FcConfigSubstitute (fcc, p, FcMatchPattern); |
1002 FcDefaultSubstitute (p); | 989 FcDefaultSubstitute (p); |
1003 res = FcResultMatch; | 990 res = FcResultMatch; |
1004 res_fcpat->fcpatPtr = FcFontMatch (fcc, p, &res); | 991 res_fcpat->fcpatPtr = FcFontMatch (fcc, p, &res); |
1011 return Qfc_result_no_id; | 998 return Qfc_result_no_id; |
1012 default: | 999 default: |
1013 return Qfc_internal_error; | 1000 return Qfc_internal_error; |
1014 } | 1001 } |
1015 else | 1002 else |
1016 return wrap_fcpattern(res_fcpat); | 1003 return wrap_fc_pattern(res_fcpat); |
1017 } | 1004 } |
1018 | 1005 |
1019 /* #### fix this name to correspond to Ben's new nomenclature */ | 1006 /* #### fix this name to correspond to Ben's new nomenclature */ |
1020 DEFUN("fc-list-fonts-pattern-objects", Ffc_list_fonts_pattern_objects, | 1007 DEFUN("fc-list-fonts-pattern-objects", Ffc_list_fonts_pattern_objects, |
1021 3, 3, 0, /* | 1008 3, 3, 0, /* |
1031 (UNUSED (device), pattern, properties)) | 1018 (UNUSED (device), pattern, properties)) |
1032 { | 1019 { |
1033 FcObjectSet *os; | 1020 FcObjectSet *os; |
1034 FcFontSet *fontset; | 1021 FcFontSet *fontset; |
1035 | 1022 |
1036 CHECK_FCPATTERN (pattern); | 1023 CHECK_FC_PATTERN (pattern); |
1037 CHECK_LIST (properties); | 1024 CHECK_LIST (properties); |
1038 | 1025 |
1039 os = FcObjectSetCreate (); | 1026 os = FcObjectSetCreate (); |
1040 string_list_to_fcobjectset (properties, os); | 1027 string_list_to_fcobjectset (properties, os); |
1041 /* #### why don't we need to do the "usual substitutions"? */ | 1028 /* #### why don't we need to do the "usual substitutions"? */ |
1042 fontset = FcFontList (NULL, XFCPATTERN_PTR (pattern), os); | 1029 fontset = FcFontList (NULL, XFC_PATTERN_PTR (pattern), os); |
1043 FcObjectSetDestroy (os); | 1030 FcObjectSetDestroy (os); |
1044 | 1031 |
1045 return fontset_to_list (fontset, DestroyYes); | 1032 return fontset_to_list (fontset, DestroyYes); |
1046 | 1033 |
1047 } | 1034 } |
1063 | 1050 |
1064 #### DEVICE is unused, ignored, and may be removed if it's not needed to | 1051 #### DEVICE is unused, ignored, and may be removed if it's not needed to |
1065 match other font-listing APIs. */ | 1052 match other font-listing APIs. */ |
1066 (UNUSED (device), pattern, trim, nosub)) | 1053 (UNUSED (device), pattern, trim, nosub)) |
1067 { | 1054 { |
1068 CHECK_FCPATTERN (pattern); | 1055 CHECK_FC_PATTERN (pattern); |
1069 | 1056 |
1070 { | 1057 { |
1071 FcConfig *fcc = FcConfigGetCurrent(); | 1058 FcConfig *fcc = FcConfigGetCurrent(); |
1072 FcFontSet *fontset; | 1059 FcFontSet *fontset; |
1073 FcPattern *p = XFCPATTERN_PTR (pattern); | 1060 FcPattern *p = XFC_PATTERN_PTR (pattern); |
1074 FcResult fcresult; | 1061 FcResult fcresult; |
1075 | 1062 |
1076 if (NILP(nosub)) /* #### temporary debug hack */ | 1063 if (NILP(nosub)) /* #### temporary debug hack */ |
1077 FcDefaultSubstitute (p); | 1064 FcDefaultSubstitute (p); |
1078 FcConfigSubstitute (fcc, p, FcMatchPattern); | 1065 FcConfigSubstitute (fcc, p, FcMatchPattern); |
1094 There is a default configuration which applications may use by passing | 1081 There is a default configuration which applications may use by passing |
1095 0 to any function using the data within an FcConfig. | 1082 0 to any function using the data within an FcConfig. |
1096 */ | 1083 */ |
1097 | 1084 |
1098 static void | 1085 static void |
1099 finalize_fc_config (void *header, int UNUSED (for_disksave)) | 1086 finalize_fc_config (Lisp_Object obj) |
1100 { | 1087 { |
1101 struct fc_config *p = (struct fc_config *) header; | 1088 struct fc_config *p = XFC_CONFIG (obj); |
1102 if (p->fccfgPtr && p->fccfgPtr != FcConfigGetCurrent()) | 1089 if (p->fccfgPtr && p->fccfgPtr != FcConfigGetCurrent()) |
1103 { | 1090 { |
1104 /* If we get here, all of *our* references are garbage (see comment on | 1091 /* If we get here, all of *our* references are garbage (see comment on |
1105 fc_config_create_using() for why), and the only reference that | 1092 fc_config_create_using() for why), and the only reference that |
1106 fontconfig keeps is the current FcConfig. */ | 1093 fontconfig keeps is the current FcConfig. */ |
1107 FcConfigDestroy (p->fccfgPtr); | 1094 FcConfigDestroy (p->fccfgPtr); |
1108 } | 1095 } |
1109 p->fccfgPtr = 0; | 1096 p->fccfgPtr = 0; |
1110 } | 1097 } |
1111 | 1098 |
1112 static void | |
1113 print_fc_config (Lisp_Object obj, Lisp_Object printcharfun, | |
1114 int UNUSED(escapeflag)) | |
1115 { | |
1116 struct fc_config *c = XFCCONFIG (obj); | |
1117 if (print_readably) | |
1118 printing_unreadable_object ("#<fc-config 0x%x>", c->header.uid); | |
1119 write_fmt_string (printcharfun, "#<fc-config 0x%x>", c->header.uid); | |
1120 } | |
1121 | |
1122 static const struct memory_description fcconfig_description [] = { | 1099 static const struct memory_description fcconfig_description [] = { |
1123 /* #### nothing here, is this right?? */ | 1100 /* #### nothing here, is this right?? */ |
1124 { XD_END } | 1101 { XD_END } |
1125 }; | 1102 }; |
1126 | 1103 |
1127 DEFINE_LRECORD_IMPLEMENTATION("fc-config", fc_config, 0, | 1104 DEFINE_NODUMP_LISP_OBJECT ("fc-config", fc_config, |
1128 0, print_fc_config, finalize_fc_config, 0, 0, | 1105 0, external_object_printer, finalize_fc_config, |
1129 fcconfig_description, | 1106 0, 0, fcconfig_description, |
1130 struct fc_config); | 1107 struct fc_config); |
1131 | 1108 |
1132 DEFUN("fc-init", Ffc_init, 0, 0, 0, /* | 1109 DEFUN("fc-init", Ffc_init, 0, 0, 0, /* |
1133 -- Function: FcBool FcInit (void) | 1110 -- Function: FcBool FcInit (void) |
1134 Loads the default configuration file and the fonts referenced | 1111 Loads the default configuration file and the fonts referenced |
1135 therein and sets the default configuration to that result. | 1112 therein and sets the default configuration to that result. |
1297 } | 1274 } |
1298 } | 1275 } |
1299 | 1276 |
1300 void | 1277 void |
1301 syms_of_font_mgr (void) { | 1278 syms_of_font_mgr (void) { |
1302 INIT_LRECORD_IMPLEMENTATION(fc_pattern); | 1279 INIT_LISP_OBJECT(fc_pattern); |
1303 | 1280 |
1304 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_patternp); | 1281 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_patternp); |
1305 | 1282 |
1306 DEFSYMBOL(Qfc_result_type_mismatch); | 1283 DEFSYMBOL(Qfc_result_type_mismatch); |
1307 DEFSYMBOL(Qfc_result_no_match); | 1284 DEFSYMBOL(Qfc_result_no_match); |
1326 DEFSUBR(Ffc_config_substitute); | 1303 DEFSUBR(Ffc_config_substitute); |
1327 DEFSUBR(Ffc_font_render_prepare); | 1304 DEFSUBR(Ffc_font_render_prepare); |
1328 DEFSUBR(Fxlfd_font_name_p); | 1305 DEFSUBR(Fxlfd_font_name_p); |
1329 | 1306 |
1330 #ifdef FONTCONFIG_EXPOSE_CONFIG | 1307 #ifdef FONTCONFIG_EXPOSE_CONFIG |
1331 INIT_LRECORD_IMPLEMENTATION(fc_config); | 1308 INIT_LISP_OBJECT(fc_config); |
1332 | 1309 |
1333 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_configp); | 1310 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_configp); |
1334 | 1311 |
1335 DEFSUBR(Ffc_config_p); | 1312 DEFSUBR(Ffc_config_p); |
1336 DEFSUBR(Ffc_config_create); | 1313 DEFSUBR(Ffc_config_create); |