Mercurial > hg > xemacs-beta
comparison src/font-mgr.c @ 5133:444a448b2f53
Merge branch ben-lisp-object into default branch
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sun, 07 Mar 2010 06:47:37 -0600 |
parents | a9c41067dd88 |
children | f965e31a35f0 |
comparison
equal
deleted
inserted
replaced
5113:b2dcf6a6d8ab | 5133:444a448b2f53 |
---|---|
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 } |
105 | 106 |
106 static void | 107 static void |
107 print_fc_pattern (Lisp_Object obj, Lisp_Object printcharfun, | 108 print_fc_pattern (Lisp_Object obj, Lisp_Object printcharfun, |
108 int UNUSED(escapeflag)) | 109 int UNUSED(escapeflag)) |
109 { | 110 { |
110 struct fc_pattern *c = XFCPATTERN (obj); | 111 struct fc_pattern *c = XFC_PATTERN (obj); |
111 if (print_readably) | 112 if (print_readably) |
112 printing_unreadable_object ("#<fc-pattern 0x%x>", c->header.uid); | 113 printing_unreadable_object ("#<fc-pattern 0x%x>", c->header.uid); |
113 write_fmt_string (printcharfun, "#<fc-pattern 0x%x>", c->header.uid); | 114 write_fmt_string (printcharfun, "#<fc-pattern 0x%x>", c->header.uid); |
114 } | 115 } |
115 | 116 |
140 static const struct memory_description fcpattern_description [] = { | 141 static const struct memory_description fcpattern_description [] = { |
141 /* #### nothing here, is this right?? */ | 142 /* #### nothing here, is this right?? */ |
142 { XD_END } | 143 { XD_END } |
143 }; | 144 }; |
144 | 145 |
145 DEFINE_LRECORD_IMPLEMENTATION("fc-pattern", fc_pattern, 0, | 146 DEFINE_NODUMP_LISP_OBJECT ("fc-pattern", fc_pattern, |
146 0, print_fc_pattern, finalize_fc_pattern, | 147 0, print_fc_pattern, finalize_fc_pattern, |
147 0, 0, fcpattern_description, | 148 0, 0, fcpattern_description, |
148 struct fc_pattern); | 149 struct fc_pattern); |
149 | 150 |
150 /* | 151 /* |
151 * Helper Functions | 152 * Helper Functions |
152 */ | 153 */ |
153 static Lisp_Object make_xlfd_font_regexp (void); | 154 static Lisp_Object make_xlfd_font_regexp (void); |
224 DEFUN("fc-pattern-p", Ffc_pattern_p, 1, 1, 0, /* | 225 DEFUN("fc-pattern-p", Ffc_pattern_p, 1, 1, 0, /* |
225 Returns t if OBJECT is of type fc-pattern, nil otherwise. | 226 Returns t if OBJECT is of type fc-pattern, nil otherwise. |
226 */ | 227 */ |
227 (object)) | 228 (object)) |
228 { | 229 { |
229 return FCPATTERNP(object) ? Qt : Qnil; | 230 return FC_PATTERNP(object) ? Qt : Qnil; |
230 } | 231 } |
231 | 232 |
232 DEFUN("fc-pattern-create", Ffc_pattern_create, 0, 0, 0, /* | 233 DEFUN("fc-pattern-create", Ffc_pattern_create, 0, 0, 0, /* |
233 Return a new, empty fc-pattern object. | 234 Return a new, empty fc-pattern object. |
234 */ | 235 */ |
235 ()) | 236 ()) |
236 { | 237 { |
237 fc_pattern *fcpat = | 238 fc_pattern *fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
238 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); | 239 |
239 | 240 fcpat->fcpatPtr = FcPatternCreate (); |
240 fcpat->fcpatPtr = FcPatternCreate(); | 241 return wrap_fc_pattern (fcpat); |
241 return wrap_fcpattern(fcpat); | |
242 } | 242 } |
243 | 243 |
244 DEFUN("fc-name-parse", Ffc_name_parse, 1, 1, 0, /* | 244 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. | 245 Parse an Fc font name and return its representation as a fc pattern object. |
246 */ | 246 */ |
247 (name)) | 247 (name)) |
248 { | 248 { |
249 struct fc_pattern *fcpat = | 249 fc_pattern *fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
250 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); | 250 |
251 | 251 CHECK_STRING (name); |
252 CHECK_STRING(name); | |
253 | 252 |
254 fcpat->fcpatPtr = FcNameParse ((FcChar8 *) extract_fcapi_string (name)); | 253 fcpat->fcpatPtr = FcNameParse ((FcChar8 *) extract_fcapi_string (name)); |
255 return wrap_fcpattern(fcpat); | 254 return wrap_fc_pattern (fcpat); |
256 } | 255 } |
257 | 256 |
258 /* #### Ga-a-ack! Xft's similar function is actually a different API. | 257 /* #### Ga-a-ack! Xft's similar function is actually a different API. |
259 We provide both. */ | 258 We provide both. */ |
260 DEFUN("fc-name-unparse", Ffc_name_unparse, 1, 1, 0, /* | 259 DEFUN("fc-name-unparse", Ffc_name_unparse, 1, 1, 0, /* |
262 */ | 261 */ |
263 (pattern)) | 262 (pattern)) |
264 { | 263 { |
265 FcChar8 *name; | 264 FcChar8 *name; |
266 Lisp_Object result; | 265 Lisp_Object result; |
267 CHECK_FCPATTERN(pattern); | 266 CHECK_FC_PATTERN(pattern); |
268 name = FcNameUnparse (XFCPATTERN_PTR (pattern)); | 267 name = FcNameUnparse (XFC_PATTERN_PTR (pattern)); |
269 result = build_fcapi_string (name); | 268 result = build_fcapi_string (name); |
270 xfree (name); | 269 xfree (name); |
271 return result; | 270 return result; |
272 } | 271 } |
273 | 272 |
275 Make a copy of the fc pattern object PATTERN and return it. | 274 Make a copy of the fc pattern object PATTERN and return it. |
276 */ | 275 */ |
277 (pattern)) | 276 (pattern)) |
278 { | 277 { |
279 struct fc_pattern *copy = NULL; | 278 struct fc_pattern *copy = NULL; |
280 CHECK_FCPATTERN(pattern); | 279 CHECK_FC_PATTERN (pattern); |
281 | 280 |
282 copy = ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); | 281 copy = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
283 copy->fcpatPtr = FcPatternDuplicate(XFCPATTERN_PTR(pattern)); | 282 copy->fcpatPtr = FcPatternDuplicate (XFC_PATTERN_PTR (pattern)); |
284 return wrap_fcpattern(copy); | 283 return wrap_fc_pattern (copy); |
285 } | 284 } |
286 | 285 |
287 DEFUN("fc-pattern-add", Ffc_pattern_add, 3, 3, 0, /* | 286 DEFUN("fc-pattern-add", Ffc_pattern_add, 3, 3, 0, /* |
288 Add attributes to the pattern object PATTERN. PROPERTY is a string naming | 287 Add attributes to the pattern object PATTERN. PROPERTY is a string naming |
289 the attribute to add, VALUE the value for this attribute. | 288 the attribute to add, VALUE the value for this attribute. |
295 { | 294 { |
296 Bool res = 0; | 295 Bool res = 0; |
297 const Extbyte *obj; | 296 const Extbyte *obj; |
298 FcPattern *fcpat; | 297 FcPattern *fcpat; |
299 | 298 |
300 CHECK_FCPATTERN(pattern); | 299 CHECK_FC_PATTERN (pattern); |
301 CHECK_STRING(property); | 300 CHECK_STRING (property); |
302 | 301 |
303 obj = fc_intern (property); | 302 obj = fc_intern (property); |
304 fcpat = XFCPATTERN_PTR (pattern); | 303 fcpat = XFC_PATTERN_PTR (pattern); |
305 | 304 |
306 if (STRINGP(value)) | 305 if (STRINGP(value)) |
307 { | 306 { |
308 FcChar8 *str = (FcChar8 *) extract_fcapi_string (value); | 307 FcChar8 *str = (FcChar8 *) extract_fcapi_string (value); |
309 res = FcPatternAddString (fcpat, obj, str); | 308 res = FcPatternAddString (fcpat, obj, str); |
330 */ | 329 */ |
331 (pattern, property)) | 330 (pattern, property)) |
332 { | 331 { |
333 Bool res; | 332 Bool res; |
334 | 333 |
335 CHECK_FCPATTERN(pattern); | 334 CHECK_FC_PATTERN(pattern); |
336 CHECK_STRING(property); | 335 CHECK_STRING(property); |
337 | 336 |
338 res = FcPatternDel(XFCPATTERN_PTR(pattern), extract_fcapi_string (property)); | 337 res = FcPatternDel(XFC_PATTERN_PTR(pattern), extract_fcapi_string (property)); |
339 return res ? Qt : Qnil; | 338 return res ? Qt : Qnil; |
340 } | 339 } |
341 | 340 |
342 /* Generic interface to FcPatternGet() | 341 /* Generic interface to FcPatternGet() |
343 * Don't support the losing symbol-for-property interface. | 342 * Don't support the losing symbol-for-property interface. |
423 FcValue fc_value; | 422 FcValue fc_value; |
424 | 423 |
425 /* | 424 /* |
426 process arguments | 425 process arguments |
427 */ | 426 */ |
428 CHECK_FCPATTERN (pattern); | 427 CHECK_FC_PATTERN (pattern); |
429 | 428 |
430 #if 0 | 429 #if 0 |
431 /* Don't support the losing symbol-for-property interface. */ | 430 /* Don't support the losing symbol-for-property interface. */ |
432 property = SYMBOLP (property) ? symbol_name (XSYMBOL (property)) : property; | 431 property = SYMBOLP (property) ? symbol_name (XSYMBOL (property)) : property; |
433 #endif | 432 #endif |
447 | 446 |
448 if (!NILP (id)) CHECK_NATNUM (id); | 447 if (!NILP (id)) CHECK_NATNUM (id); |
449 if (!NILP (type)) CHECK_SYMBOL (type); | 448 if (!NILP (type)) CHECK_SYMBOL (type); |
450 | 449 |
451 /* get property */ | 450 /* get property */ |
452 fc_result = FcPatternGet (XFCPATTERN_PTR (pattern), | 451 fc_result = FcPatternGet (XFC_PATTERN_PTR (pattern), |
453 fc_property, | 452 fc_property, |
454 NILP (id) ? 0 : XINT(id), | 453 NILP (id) ? 0 : XINT(id), |
455 &fc_value); | 454 &fc_value); |
456 | 455 |
457 switch (fc_result) | 456 switch (fc_result) |
515 Lisp_Object configs = XWEAK_LIST_LIST (Vfc_config_weak_list); | 514 Lisp_Object configs = XWEAK_LIST_LIST (Vfc_config_weak_list); |
516 | 515 |
517 /* Linear search: fc_configs are not going to multiply like conses. */ | 516 /* Linear search: fc_configs are not going to multiply like conses. */ |
518 { | 517 { |
519 LIST_LOOP_2 (cfg, configs) | 518 LIST_LOOP_2 (cfg, configs) |
520 if (fc == XFCCONFIG_PTR (cfg)) | 519 if (fc == XFC_CONFIG_PTR (cfg)) |
521 return cfg; | 520 return cfg; |
522 } | 521 } |
523 | 522 |
524 { | 523 { |
525 fc_config *fccfg = | 524 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; | 525 fccfg->fccfgPtr = fc; |
528 configs = Fcons (wrap_fcconfig (fccfg), configs); | 526 configs = Fcons (wrap_fc_config (fccfg), configs); |
529 XWEAK_LIST_LIST (Vfc_config_weak_list) = configs; | 527 XWEAK_LIST_LIST (Vfc_config_weak_list) = configs; |
530 return wrap_fcconfig (fccfg); | 528 return wrap_fc_config (fccfg); |
531 } | 529 } |
532 } | 530 } |
533 | 531 |
534 static Lisp_Object | 532 static Lisp_Object |
535 fc_strlist_to_lisp_using (FcStrList * (*getter) (FcConfig *), | 533 fc_strlist_to_lisp_using (FcStrList * (*getter) (FcConfig *), |
537 { | 535 { |
538 FcChar8 *thing; | 536 FcChar8 *thing; |
539 Lisp_Object value = Qnil; | 537 Lisp_Object value = Qnil; |
540 FcStrList *thing_list; | 538 FcStrList *thing_list; |
541 | 539 |
542 CHECK_FCCONFIG (config); | 540 CHECK_FC_CONFIG (config); |
543 thing_list = (*getter) (XFCCONFIG_PTR(config)); | 541 thing_list = (*getter) (XFC_CONFIG_PTR(config)); |
544 /* Yes, we need to do this check -- sheesh, Keith! */ | 542 /* Yes, we need to do this check -- sheesh, Keith! */ |
545 if (!thing_list) | 543 if (!thing_list) |
546 return Qnil; | 544 return Qnil; |
547 while ((thing = FcStrListNext (thing_list))) | 545 while ((thing = FcStrListNext (thing_list))) |
548 value = Fcons (build_fcapi_string (thing), value); | 546 value = Fcons (build_fcapi_string (thing), value); |
560 /* #### improve this error message */ | 558 /* #### improve this error message */ |
561 if (!fontset) | 559 if (!fontset) |
562 invalid_state ("failed to create FcFontSet", Qunbound); | 560 invalid_state ("failed to create FcFontSet", Qunbound); |
563 for (idx = 0; idx < fontset->nfont; ++idx) | 561 for (idx = 0; idx < fontset->nfont; ++idx) |
564 { | 562 { |
565 fcpat = | 563 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]); | 564 fcpat->fcpatPtr = FcPatternDuplicate (fontset->fonts[idx]); |
568 fontlist = Fcons (wrap_fcpattern(fcpat), fontlist); | 565 fontlist = Fcons (wrap_fc_pattern(fcpat), fontlist); |
569 } | 566 } |
570 if (destroyp) | 567 if (destroyp) |
571 FcFontSetDestroy (fontset); | 568 FcFontSetDestroy (fontset); |
572 return fontlist; | 569 return fontlist; |
573 } | 570 } |
575 DEFUN("fc-config-p", Ffc_config_p, 1, 1, 0, /* | 572 DEFUN("fc-config-p", Ffc_config_p, 1, 1, 0, /* |
576 Returns t if OBJECT is of type fc-config, nil otherwise. | 573 Returns t if OBJECT is of type fc-config, nil otherwise. |
577 */ | 574 */ |
578 (object)) | 575 (object)) |
579 { | 576 { |
580 return FCCONFIGP (object) ? Qt : Qnil; | 577 return FC_CONFIGP (object) ? Qt : Qnil; |
581 } | 578 } |
582 | 579 |
583 DEFUN("fc-config-create", Ffc_config_create, 0, 0, 0, /* | 580 DEFUN("fc-config-create", Ffc_config_create, 0, 0, 0, /* |
584 -- Function: FcConfig *FcConfigCreate (void) | 581 -- Function: FcConfig *FcConfigCreate (void) |
585 Creates an empty configuration. */ | 582 Creates an empty configuration. */ |
608 -- Function: FcBool FcConfigUptoDate (FcConfig *config) | 605 -- Function: FcBool FcConfigUptoDate (FcConfig *config) |
609 Checks all of the files related to 'config' and returns whether the | 606 Checks all of the files related to 'config' and returns whether the |
610 in-memory version is in sync with the disk version. */ | 607 in-memory version is in sync with the disk version. */ |
611 (config)) | 608 (config)) |
612 { | 609 { |
613 CHECK_FCCONFIG (config); | 610 CHECK_FC_CONFIG (config); |
614 return FcConfigUptoDate (XFCCONFIG_PTR (config)) == FcFalse ? Qnil : Qt; | 611 return FcConfigUptoDate (XFC_CONFIG_PTR (config)) == FcFalse ? Qnil : Qt; |
615 } | 612 } |
616 | 613 |
617 DEFUN("fc-config-build-fonts", Ffc_config_build_fonts, 1, 1, 0, /* | 614 DEFUN("fc-config-build-fonts", Ffc_config_build_fonts, 1, 1, 0, /* |
618 -- Function: FcBool FcConfigBuildFonts (FcConfig *config) | 615 -- Function: FcBool FcConfigBuildFonts (FcConfig *config) |
619 Builds the set of available fonts for the given configuration. | 616 Builds the set of available fonts for the given configuration. |
621 indeterminate effects. Returns FcFalse if this operation runs out | 618 indeterminate effects. Returns FcFalse if this operation runs out |
622 of memory. | 619 of memory. |
623 XEmacs: signal out-of-memory, or return nil on success. */ | 620 XEmacs: signal out-of-memory, or return nil on success. */ |
624 (config)) | 621 (config)) |
625 { | 622 { |
626 CHECK_FCCONFIG (config); | 623 CHECK_FC_CONFIG (config); |
627 if (FcConfigBuildFonts (XFCCONFIG_PTR (config)) == FcFalse) | 624 if (FcConfigBuildFonts (XFC_CONFIG_PTR (config)) == FcFalse) |
628 out_of_memory ("FcConfigBuildFonts failed", config); | 625 out_of_memory ("FcConfigBuildFonts failed", config); |
629 return Qnil; | 626 return Qnil; |
630 } | 627 } |
631 | 628 |
632 DEFUN("fc-config-get-config-dirs", Ffc_config_get_config_dirs, 1, 1, 0, /* | 629 DEFUN("fc-config-get-config-dirs", Ffc_config_get_config_dirs, 1, 1, 0, /* |
663 -- Function: char *FcConfigGetCache (FcConfig *config) | 660 -- Function: char *FcConfigGetCache (FcConfig *config) |
664 Returns the name of the file used to store per-user font | 661 Returns the name of the file used to store per-user font |
665 information. */ | 662 information. */ |
666 (config)) | 663 (config)) |
667 { | 664 { |
668 CHECK_FCCONFIG (config); | 665 CHECK_FC_CONFIG (config); |
669 /* Surely FcConfigGetCache just casts an FcChar8* to char*. */ | 666 /* Surely FcConfigGetCache just casts an FcChar8* to char*. */ |
670 return build_fcapi_string ((FcChar8 *) FcConfigGetCache (XFCCONFIG_PTR (config))); | 667 return build_fcapi_string ((FcChar8 *) FcConfigGetCache (XFC_CONFIG_PTR (config))); |
671 } | 668 } |
672 | 669 |
673 DEFUN("fc-config-get-fonts", Ffc_config_get_fonts, 2, 2, 0, /* | 670 DEFUN("fc-config-get-fonts", Ffc_config_get_fonts, 2, 2, 0, /* |
674 -- Function: FcFontSet *FcConfigGetFonts (FcConfig *config, FcSetName set) | 671 -- Function: FcFontSet *FcConfigGetFonts (FcConfig *config, FcSetName set) |
675 Returns one of the two sets of fonts from the configuration as | 672 Returns one of the two sets of fonts from the configuration as |
682 (config, set)) | 679 (config, set)) |
683 { | 680 { |
684 FcSetName name = FcSetSystem; | 681 FcSetName name = FcSetSystem; |
685 FcFontSet *fs = NULL; | 682 FcFontSet *fs = NULL; |
686 | 683 |
687 CHECK_FCCONFIG (config); | 684 CHECK_FC_CONFIG (config); |
688 CHECK_SYMBOL (set); | 685 CHECK_SYMBOL (set); |
689 | 686 |
690 if (EQ (set, intern ("fc-set-system"))) | 687 if (EQ (set, intern ("fc-set-system"))) |
691 name = FcSetSystem; | 688 name = FcSetSystem; |
692 else if (EQ (set, intern ("fc-set-application"))) | 689 else if (EQ (set, intern ("fc-set-application"))) |
693 name = FcSetApplication; | 690 name = FcSetApplication; |
694 else | 691 else |
695 wtaerror ("must be in (fc-set-system fc-set-application)", set); | 692 wtaerror ("must be in (fc-set-system fc-set-application)", set); |
696 | 693 |
697 fs = FcConfigGetFonts (XFCCONFIG_PTR (config), name); | 694 fs = FcConfigGetFonts (XFC_CONFIG_PTR (config), name); |
698 return fs ? fontset_to_list (fs, DestroyNo) : Qnil; | 695 return fs ? fontset_to_list (fs, DestroyNo) : Qnil; |
699 } | 696 } |
700 | 697 |
701 DEFUN("fc-config-set-current", Ffc_config_set_current, 1, 1, 0, /* | 698 DEFUN("fc-config-set-current", Ffc_config_set_current, 1, 1, 0, /* |
702 -- Function: FcBool FcConfigSetCurrent (FcConfig *config) | 699 -- Function: FcBool FcConfigSetCurrent (FcConfig *config) |
706 XEmacs: signals out-of-memory if FcConfigBuildFonts fails, or args-out-of-range | 703 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). | 704 if the resulting FcConfig has no fonts (which would crash XEmacs if installed). |
708 */ | 705 */ |
709 (config)) | 706 (config)) |
710 { | 707 { |
711 CHECK_FCCONFIG (config); | 708 CHECK_FC_CONFIG (config); |
712 /* *sigh* "Success" DOES NOT mean you have any fonts available. It is | 709 /* *sigh* "Success" DOES NOT mean you have any fonts available. It is |
713 easy to crash fontconfig, and XEmacs with it. Without the following | 710 easy to crash fontconfig, and XEmacs with it. Without the following |
714 check, this will do it: | 711 check, this will do it: |
715 (progn | 712 (progn |
716 (fc-config-set-current (fc-config-create)) | 713 (fc-config-set-current (fc-config-create)) |
717 (set-face-font 'default "serif-12")) | 714 (set-face-font 'default "serif-12")) |
718 */ | 715 */ |
719 | 716 |
720 if (FcConfigBuildFonts (XFCCONFIG_PTR (config)) == FcFalse) | 717 if (FcConfigBuildFonts (XFC_CONFIG_PTR (config)) == FcFalse) |
721 out_of_memory ("FcConfigBuildFonts failed", config); | 718 out_of_memory ("FcConfigBuildFonts failed", config); |
722 /* #### We'd like to avoid this consing, and FcConfigGetFonts sometimes | 719 /* #### We'd like to avoid this consing, and FcConfigGetFonts sometimes |
723 returns NULL, but it doesn't always. This will do for now .... */ | 720 returns NULL, but it doesn't always. This will do for now .... */ |
724 if (NILP (Ffc_config_get_fonts (config, intern ("fc-set-system"))) | 721 if (NILP (Ffc_config_get_fonts (config, intern ("fc-set-system"))) |
725 && NILP (Ffc_config_get_fonts (config, intern ("fc-set-application")))) | 722 && NILP (Ffc_config_get_fonts (config, intern ("fc-set-application")))) |
726 signal_error (intern ("args-out-of-range"), "no fonts found", config); | 723 signal_error (intern ("args-out-of-range"), "no fonts found", config); |
727 /* Should never happen, but I don't trust Keith anymore .... */ | 724 /* Should never happen, but I don't trust Keith anymore .... */ |
728 if (FcConfigSetCurrent (XFCCONFIG_PTR (config)) == FcFalse) | 725 if (FcConfigSetCurrent (XFC_CONFIG_PTR (config)) == FcFalse) |
729 out_of_memory ("FcConfigBuildFonts failed in set", config); | 726 out_of_memory ("FcConfigBuildFonts failed in set", config); |
730 return Qnil; | 727 return Qnil; |
731 } | 728 } |
732 | 729 |
733 DEFUN("fc-config-get-blanks", Ffc_config_get_blanks, 1, 1, 0, /* | 730 DEFUN("fc-config-get-blanks", Ffc_config_get_blanks, 1, 1, 0, /* |
737 this function will return 0. | 734 this function will return 0. |
738 XEmacs: should convert to a chartable. | 735 XEmacs: should convert to a chartable. |
739 #### Unimplemented. */ | 736 #### Unimplemented. */ |
740 (config)) | 737 (config)) |
741 { | 738 { |
742 CHECK_FCCONFIG (config); | 739 CHECK_FC_CONFIG (config); |
743 signal_error (Qunimplemented, "no method to convert FcBlanks object", | 740 signal_error (Qunimplemented, "no method to convert FcBlanks object", |
744 intern ("fc-config-get-blanks")); | 741 intern ("fc-config-get-blanks")); |
745 } | 742 } |
746 | 743 |
747 DEFUN("fc-config-get-rescan-interval", Ffc_config_get_rescan_interval, 1, 1, 0, /* | 744 DEFUN("fc-config-get-rescan-interval", Ffc_config_get_rescan_interval, 1, 1, 0, /* |
750 (in seconds) specified in 'config'. The configuration is checked | 747 (in seconds) specified in 'config'. The configuration is checked |
751 during a call to FcFontList when this interval has passed since | 748 during a call to FcFontList when this interval has passed since |
752 the last check. */ | 749 the last check. */ |
753 (config)) | 750 (config)) |
754 { | 751 { |
755 CHECK_FCCONFIG (config); | 752 CHECK_FC_CONFIG (config); |
756 return make_int (FcConfigGetRescanInterval (XFCCONFIG_PTR (config))); | 753 return make_int (FcConfigGetRescanInterval (XFC_CONFIG_PTR (config))); |
757 } | 754 } |
758 | 755 |
759 DEFUN("fc-config-set-rescan-interval", Ffc_config_set_rescan_interval, 2, 2, 0, /* | 756 DEFUN("fc-config-set-rescan-interval", Ffc_config_set_rescan_interval, 2, 2, 0, /* |
760 -- Function: FcBool FcConfigSetRescanInterval (FcConfig *config, int | 757 -- Function: FcBool FcConfigSetRescanInterval (FcConfig *config, int |
761 rescanInterval) | 758 rescanInterval) |
762 Sets the rescan interval; returns FcFalse if an error occurred. | 759 Sets the rescan interval; returns FcFalse if an error occurred. |
763 XEmacs: signal such error, or return nil on success. */ | 760 XEmacs: signal such error, or return nil on success. */ |
764 (config, rescan_interval)) | 761 (config, rescan_interval)) |
765 { | 762 { |
766 CHECK_FCCONFIG (config); | 763 CHECK_FC_CONFIG (config); |
767 CHECK_INT (rescan_interval); | 764 CHECK_INT (rescan_interval); |
768 if (FcConfigSetRescanInterval (XFCCONFIG_PTR (config), | 765 if (FcConfigSetRescanInterval (XFC_CONFIG_PTR (config), |
769 XINT (rescan_interval)) == FcFalse) | 766 XINT (rescan_interval)) == FcFalse) |
770 signal_error (Qio_error, "FcConfigSetRescanInverval barfed", | 767 signal_error (Qio_error, "FcConfigSetRescanInverval barfed", |
771 intern ("fc-config-set-rescan-interval")); | 768 intern ("fc-config-set-rescan-interval")); |
772 return Qnil; | 769 return Qnil; |
773 } | 770 } |
777 -- Function: FcBool FcConfigAppFontAddFile (FcConfig *config, const | 774 -- Function: FcBool FcConfigAppFontAddFile (FcConfig *config, const |
778 char *file) | 775 char *file) |
779 Adds an application-specific font to the configuration. */ | 776 Adds an application-specific font to the configuration. */ |
780 (config, file)) | 777 (config, file)) |
781 { | 778 { |
782 CHECK_FCCONFIG (config); | 779 CHECK_FC_CONFIG (config); |
783 CHECK_STRING (file); | 780 CHECK_STRING (file); |
784 if (FcConfigAppFontAddFile | 781 if (FcConfigAppFontAddFile |
785 (XFCCONFIG_PTR (config), | 782 (XFC_CONFIG_PTR (config), |
786 /* #### FIXME! is Qfile_name right? */ | 783 /* #### FIXME! is Qfile_name right? */ |
787 (FcChar8 *) LISP_STRING_TO_EXTERNAL (file, Qfile_name)) == FcFalse) | 784 (FcChar8 *) LISP_STRING_TO_EXTERNAL (file, Qfile_name)) == FcFalse) |
788 return Qnil; | 785 return Qnil; |
789 else | 786 else |
790 return Qt; | 787 return Qt; |
796 char *dir) | 793 char *dir) |
797 Scans the specified directory for fonts, adding each one found to | 794 Scans the specified directory for fonts, adding each one found to |
798 the application-specific set of fonts. */ | 795 the application-specific set of fonts. */ |
799 (config, dir)) | 796 (config, dir)) |
800 { | 797 { |
801 CHECK_FCCONFIG (config); | 798 CHECK_FC_CONFIG (config); |
802 CHECK_STRING (dir); | 799 CHECK_STRING (dir); |
803 if (FcConfigAppFontAddDir | 800 if (FcConfigAppFontAddDir |
804 (XFCCONFIG_PTR (config), | 801 (XFC_CONFIG_PTR (config), |
805 /* #### FIXME! is Qfile_name right? */ | 802 /* #### FIXME! is Qfile_name right? */ |
806 (FcChar8 *) LISP_STRING_TO_EXTERNAL (dir, Qfile_name)) == FcFalse) | 803 (FcChar8 *) LISP_STRING_TO_EXTERNAL (dir, Qfile_name)) == FcFalse) |
807 return Qnil; | 804 return Qnil; |
808 else | 805 else |
809 return Qt; | 806 return Qt; |
813 DEFUN("fc-config-app-font-clear", Ffc_config_app_font_clear, 1, 1, 0, /* | 810 DEFUN("fc-config-app-font-clear", Ffc_config_app_font_clear, 1, 1, 0, /* |
814 -- Function: void FcConfigAppFontClear (FcConfig *config) | 811 -- Function: void FcConfigAppFontClear (FcConfig *config) |
815 Clears the set of application-specific fonts. */ | 812 Clears the set of application-specific fonts. */ |
816 (config)) | 813 (config)) |
817 { | 814 { |
818 CHECK_FCCONFIG (config); | 815 CHECK_FC_CONFIG (config); |
819 FcConfigAppFontClear (XFCCONFIG_PTR (config)); | 816 FcConfigAppFontClear (XFC_CONFIG_PTR (config)); |
820 return Qnil; | 817 return Qnil; |
821 } | 818 } |
822 | 819 |
823 /* These functions provide some control over how the default | 820 /* These functions provide some control over how the default |
824 configuration of the library is initialized. (This configuration is | 821 configuration of the library is initialized. (This configuration is |
886 * Patterns without a specified style or slant are set to Roman | 883 * Patterns without a specified style or slant are set to Roman |
887 * Patterns without a specified pixel size are given one computed from any | 884 * 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). */ | 885 specified point size (default 12), dpi (default 75) and scale (default 1). */ |
889 (pattern)) | 886 (pattern)) |
890 { | 887 { |
891 CHECK_FCPATTERN (pattern); | 888 CHECK_FC_PATTERN (pattern); |
892 FcDefaultSubstitute (XFCPATTERN_PTR (pattern)); | 889 FcDefaultSubstitute (XFC_PATTERN_PTR (pattern)); |
893 return Qnil; | 890 return Qnil; |
894 } | 891 } |
895 | 892 |
896 /* -- Function: FcBool FcConfigSubstituteWithPat (FcConfig *config, | 893 /* -- Function: FcBool FcConfigSubstituteWithPat (FcConfig *config, |
897 FcPattern *p, FcPattern *p_pat FcMatchKind kind) | 894 FcPattern *p, FcPattern *p_pat FcMatchKind kind) |
921 knd = FcMatchPattern; | 918 knd = FcMatchPattern; |
922 else | 919 else |
923 wtaerror ("need `fc-match-pattern' or `fc-match-font'", kind); | 920 wtaerror ("need `fc-match-pattern' or `fc-match-font'", kind); |
924 | 921 |
925 /* Typecheck arguments */ | 922 /* Typecheck arguments */ |
926 CHECK_FCPATTERN (pattern); | 923 CHECK_FC_PATTERN (pattern); |
927 if (!NILP (testpat)) CHECK_FCPATTERN (testpat); | 924 if (!NILP (testpat)) CHECK_FC_PATTERN (testpat); |
928 if (!NILP (config)) CHECK_FCCONFIG (config); | 925 if (!NILP (config)) CHECK_FC_CONFIG (config); |
929 | 926 |
930 return (FcConfigSubstituteWithPat | 927 return (FcConfigSubstituteWithPat |
931 (NILP (config) ? FcConfigGetCurrent () : XFCCONFIG_PTR (config), | 928 (NILP (config) ? FcConfigGetCurrent () : XFC_CONFIG_PTR (config), |
932 XFCPATTERN_PTR (pattern), | 929 XFC_PATTERN_PTR (pattern), |
933 NILP (testpat) ? NULL : XFCPATTERN_PTR (testpat), | 930 NILP (testpat) ? NULL : XFC_PATTERN_PTR (testpat), |
934 knd) == FcTrue) | 931 knd) == FcTrue) |
935 ? Qt : Qnil; | 932 ? Qt : Qnil; |
936 } | 933 } |
937 | 934 |
938 /* Pattern matching functions. */ | 935 /* Pattern matching functions. */ |
955 (pattern, font, config)) | 952 (pattern, font, config)) |
956 { | 953 { |
957 if (NILP (config)) { | 954 if (NILP (config)) { |
958 config = Ffc_config_get_current (); | 955 config = Ffc_config_get_current (); |
959 } | 956 } |
960 CHECK_FCPATTERN (pattern); | 957 CHECK_FC_PATTERN (pattern); |
961 CHECK_FCPATTERN (font); | 958 CHECK_FC_PATTERN (font); |
962 CHECK_FCCONFIG (config); | 959 CHECK_FC_CONFIG (config); |
963 | 960 |
964 /* I don't think this can fail? */ | 961 /* I don't think this can fail? */ |
965 return wrap_fcpattern (FcFontRenderPrepare (XFCCONFIG_PTR(config), | 962 return wrap_fc_pattern (FcFontRenderPrepare (XFC_CONFIG_PTR(config), |
966 XFCPATTERN_PTR(font), | 963 XFC_PATTERN_PTR(font), |
967 XFCPATTERN_PTR(pattern))); | 964 XFC_PATTERN_PTR(pattern))); |
968 } | 965 } |
969 | 966 |
970 DEFUN("fc-font-match", Ffc_font_match, 2, 3, 0, /* | 967 DEFUN("fc-font-match", Ffc_font_match, 2, 3, 0, /* |
971 Return the font on DEVICE that most closely matches PATTERN. | 968 Return the font on DEVICE that most closely matches PATTERN. |
972 | 969 |
983 FcResult res; | 980 FcResult res; |
984 struct fc_pattern *res_fcpat; | 981 struct fc_pattern *res_fcpat; |
985 FcPattern *p; | 982 FcPattern *p; |
986 FcConfig *fcc; | 983 FcConfig *fcc; |
987 | 984 |
988 CHECK_FCPATTERN(pattern); | 985 CHECK_FC_PATTERN(pattern); |
989 if (NILP(device)) | 986 if (NILP(device)) |
990 return Qnil; | 987 return Qnil; |
991 CHECK_X_DEVICE(device); | 988 CHECK_X_DEVICE(device); |
992 if (!DEVICE_LIVE_P(XDEVICE(device))) | 989 if (!DEVICE_LIVE_P(XDEVICE(device))) |
993 return Qnil; | 990 return Qnil; |
994 if (!NILP (config)) | 991 if (!NILP (config)) |
995 CHECK_FCCONFIG (config); | 992 CHECK_FC_CONFIG (config); |
996 | 993 |
997 res_fcpat = ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); | 994 res_fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
998 p = XFCPATTERN_PTR(pattern); | 995 p = XFC_PATTERN_PTR(pattern); |
999 fcc = NILP (config) ? FcConfigGetCurrent () : XFCCONFIG_PTR (config); | 996 fcc = NILP (config) ? FcConfigGetCurrent () : XFC_CONFIG_PTR (config); |
1000 | 997 |
1001 FcConfigSubstitute (fcc, p, FcMatchPattern); | 998 FcConfigSubstitute (fcc, p, FcMatchPattern); |
1002 FcDefaultSubstitute (p); | 999 FcDefaultSubstitute (p); |
1003 res = FcResultMatch; | 1000 res = FcResultMatch; |
1004 res_fcpat->fcpatPtr = FcFontMatch (fcc, p, &res); | 1001 res_fcpat->fcpatPtr = FcFontMatch (fcc, p, &res); |
1011 return Qfc_result_no_id; | 1008 return Qfc_result_no_id; |
1012 default: | 1009 default: |
1013 return Qfc_internal_error; | 1010 return Qfc_internal_error; |
1014 } | 1011 } |
1015 else | 1012 else |
1016 return wrap_fcpattern(res_fcpat); | 1013 return wrap_fc_pattern(res_fcpat); |
1017 } | 1014 } |
1018 | 1015 |
1019 /* #### fix this name to correspond to Ben's new nomenclature */ | 1016 /* #### fix this name to correspond to Ben's new nomenclature */ |
1020 DEFUN("fc-list-fonts-pattern-objects", Ffc_list_fonts_pattern_objects, | 1017 DEFUN("fc-list-fonts-pattern-objects", Ffc_list_fonts_pattern_objects, |
1021 3, 3, 0, /* | 1018 3, 3, 0, /* |
1031 (UNUSED (device), pattern, properties)) | 1028 (UNUSED (device), pattern, properties)) |
1032 { | 1029 { |
1033 FcObjectSet *os; | 1030 FcObjectSet *os; |
1034 FcFontSet *fontset; | 1031 FcFontSet *fontset; |
1035 | 1032 |
1036 CHECK_FCPATTERN (pattern); | 1033 CHECK_FC_PATTERN (pattern); |
1037 CHECK_LIST (properties); | 1034 CHECK_LIST (properties); |
1038 | 1035 |
1039 os = FcObjectSetCreate (); | 1036 os = FcObjectSetCreate (); |
1040 string_list_to_fcobjectset (properties, os); | 1037 string_list_to_fcobjectset (properties, os); |
1041 /* #### why don't we need to do the "usual substitutions"? */ | 1038 /* #### why don't we need to do the "usual substitutions"? */ |
1042 fontset = FcFontList (NULL, XFCPATTERN_PTR (pattern), os); | 1039 fontset = FcFontList (NULL, XFC_PATTERN_PTR (pattern), os); |
1043 FcObjectSetDestroy (os); | 1040 FcObjectSetDestroy (os); |
1044 | 1041 |
1045 return fontset_to_list (fontset, DestroyYes); | 1042 return fontset_to_list (fontset, DestroyYes); |
1046 | 1043 |
1047 } | 1044 } |
1063 | 1060 |
1064 #### DEVICE is unused, ignored, and may be removed if it's not needed to | 1061 #### DEVICE is unused, ignored, and may be removed if it's not needed to |
1065 match other font-listing APIs. */ | 1062 match other font-listing APIs. */ |
1066 (UNUSED (device), pattern, trim, nosub)) | 1063 (UNUSED (device), pattern, trim, nosub)) |
1067 { | 1064 { |
1068 CHECK_FCPATTERN (pattern); | 1065 CHECK_FC_PATTERN (pattern); |
1069 | 1066 |
1070 { | 1067 { |
1071 FcConfig *fcc = FcConfigGetCurrent(); | 1068 FcConfig *fcc = FcConfigGetCurrent(); |
1072 FcFontSet *fontset; | 1069 FcFontSet *fontset; |
1073 FcPattern *p = XFCPATTERN_PTR (pattern); | 1070 FcPattern *p = XFC_PATTERN_PTR (pattern); |
1074 FcResult fcresult; | 1071 FcResult fcresult; |
1075 | 1072 |
1076 if (NILP(nosub)) /* #### temporary debug hack */ | 1073 if (NILP(nosub)) /* #### temporary debug hack */ |
1077 FcDefaultSubstitute (p); | 1074 FcDefaultSubstitute (p); |
1078 FcConfigSubstitute (fcc, p, FcMatchPattern); | 1075 FcConfigSubstitute (fcc, p, FcMatchPattern); |
1094 There is a default configuration which applications may use by passing | 1091 There is a default configuration which applications may use by passing |
1095 0 to any function using the data within an FcConfig. | 1092 0 to any function using the data within an FcConfig. |
1096 */ | 1093 */ |
1097 | 1094 |
1098 static void | 1095 static void |
1099 finalize_fc_config (void *header, int UNUSED (for_disksave)) | 1096 finalize_fc_config (Lisp_Object obj) |
1100 { | 1097 { |
1101 struct fc_config *p = (struct fc_config *) header; | 1098 struct fc_config *p = XFC_CONFIG (obj); |
1102 if (p->fccfgPtr && p->fccfgPtr != FcConfigGetCurrent()) | 1099 if (p->fccfgPtr && p->fccfgPtr != FcConfigGetCurrent()) |
1103 { | 1100 { |
1104 /* If we get here, all of *our* references are garbage (see comment on | 1101 /* 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 | 1102 fc_config_create_using() for why), and the only reference that |
1106 fontconfig keeps is the current FcConfig. */ | 1103 fontconfig keeps is the current FcConfig. */ |
1111 | 1108 |
1112 static void | 1109 static void |
1113 print_fc_config (Lisp_Object obj, Lisp_Object printcharfun, | 1110 print_fc_config (Lisp_Object obj, Lisp_Object printcharfun, |
1114 int UNUSED(escapeflag)) | 1111 int UNUSED(escapeflag)) |
1115 { | 1112 { |
1116 struct fc_config *c = XFCCONFIG (obj); | 1113 struct fc_config *c = XFC_CONFIG (obj); |
1117 if (print_readably) | 1114 if (print_readably) |
1118 printing_unreadable_object ("#<fc-config 0x%x>", c->header.uid); | 1115 printing_unreadable_object ("#<fc-config 0x%x>", c->header.uid); |
1119 write_fmt_string (printcharfun, "#<fc-config 0x%x>", c->header.uid); | 1116 write_fmt_string (printcharfun, "#<fc-config 0x%x>", c->header.uid); |
1120 } | 1117 } |
1121 | 1118 |
1122 static const struct memory_description fcconfig_description [] = { | 1119 static const struct memory_description fcconfig_description [] = { |
1123 /* #### nothing here, is this right?? */ | 1120 /* #### nothing here, is this right?? */ |
1124 { XD_END } | 1121 { XD_END } |
1125 }; | 1122 }; |
1126 | 1123 |
1127 DEFINE_LRECORD_IMPLEMENTATION("fc-config", fc_config, 0, | 1124 DEFINE_NODUMP_LISP_OBJECT ("fc-config", fc_config, |
1128 0, print_fc_config, finalize_fc_config, 0, 0, | 1125 0, print_fc_config, finalize_fc_config, 0, 0, |
1129 fcconfig_description, | 1126 fcconfig_description, |
1130 struct fc_config); | 1127 struct fc_config); |
1131 | 1128 |
1132 DEFUN("fc-init", Ffc_init, 0, 0, 0, /* | 1129 DEFUN("fc-init", Ffc_init, 0, 0, 0, /* |
1133 -- Function: FcBool FcInit (void) | 1130 -- Function: FcBool FcInit (void) |
1134 Loads the default configuration file and the fonts referenced | 1131 Loads the default configuration file and the fonts referenced |
1135 therein and sets the default configuration to that result. | 1132 therein and sets the default configuration to that result. |
1297 } | 1294 } |
1298 } | 1295 } |
1299 | 1296 |
1300 void | 1297 void |
1301 syms_of_font_mgr (void) { | 1298 syms_of_font_mgr (void) { |
1302 INIT_LRECORD_IMPLEMENTATION(fc_pattern); | 1299 INIT_LISP_OBJECT(fc_pattern); |
1303 | 1300 |
1304 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_patternp); | 1301 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_patternp); |
1305 | 1302 |
1306 DEFSYMBOL(Qfc_result_type_mismatch); | 1303 DEFSYMBOL(Qfc_result_type_mismatch); |
1307 DEFSYMBOL(Qfc_result_no_match); | 1304 DEFSYMBOL(Qfc_result_no_match); |
1326 DEFSUBR(Ffc_config_substitute); | 1323 DEFSUBR(Ffc_config_substitute); |
1327 DEFSUBR(Ffc_font_render_prepare); | 1324 DEFSUBR(Ffc_font_render_prepare); |
1328 DEFSUBR(Fxlfd_font_name_p); | 1325 DEFSUBR(Fxlfd_font_name_p); |
1329 | 1326 |
1330 #ifdef FONTCONFIG_EXPOSE_CONFIG | 1327 #ifdef FONTCONFIG_EXPOSE_CONFIG |
1331 INIT_LRECORD_IMPLEMENTATION(fc_config); | 1328 INIT_LISP_OBJECT(fc_config); |
1332 | 1329 |
1333 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_configp); | 1330 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_configp); |
1334 | 1331 |
1335 DEFSUBR(Ffc_config_p); | 1332 DEFSUBR(Ffc_config_p); |
1336 DEFSUBR(Ffc_config_create); | 1333 DEFSUBR(Ffc_config_create); |