Mercurial > hg > xemacs-beta
comparison src/font-mgr.c @ 3931:fd1f0c73d4df
[xemacs-hg @ 2007-04-30 16:46:29 by stephent]
First draft of fc-config implementation. <87r6q1hkgo.fsf@uwakimon.sk.tsukuba.ac.jp>
author | stephent |
---|---|
date | Mon, 30 Apr 2007 16:46:36 +0000 |
parents | 605c915d2b9d |
children | f56fa2f5f055 |
comparison
equal
deleted
inserted
replaced
3930:1dac67fc67ae | 3931:fd1f0c73d4df |
---|---|
78 Lisp_Object Vxlfd_font_name_regexp; /* #### Really needed? */ | 78 Lisp_Object Vxlfd_font_name_regexp; /* #### Really needed? */ |
79 Lisp_Object Vxft_version; | 79 Lisp_Object Vxft_version; |
80 /* Lisp_Object Vfc_version; */ /* #### Should have this, too! */ | 80 /* Lisp_Object Vfc_version; */ /* #### Should have this, too! */ |
81 Fixnum debug_xft; /* Set to 1 enables lots of obnoxious messages. | 81 Fixnum debug_xft; /* Set to 1 enables lots of obnoxious messages. |
82 Setting it to 2 or 3 enables even more. */ | 82 Setting it to 2 or 3 enables even more. */ |
83 #ifdef FONTCONFIG_EXPOSE_CONFIG | |
84 Lisp_Object Qfc_configp; | |
85 static Lisp_Object Vfc_config_weak_list; | |
86 #endif | |
83 | 87 |
84 /**************************************************************** | 88 /**************************************************************** |
85 * FcPattern objects * | 89 * FcPattern objects * |
86 ****************************************************************/ | 90 ****************************************************************/ |
87 | 91 |
527 } | 531 } |
528 else | 532 else |
529 return wrap_fcpattern(res_fcpat); | 533 return wrap_fcpattern(res_fcpat); |
530 } | 534 } |
531 | 535 |
532 /* NOTE NOTE NOTE This function destroys the FcFontSet passed to it. */ | 536 enum DestroyFontsetP { DestroyNo = 0, DestroyYes = 1 }; |
537 | |
533 static Lisp_Object | 538 static Lisp_Object |
534 fontset_to_list (FcFontSet *fontset) | 539 fontset_to_list (FcFontSet *fontset, enum DestroyFontsetP destroyp) |
535 { | 540 { |
536 int idx; | 541 int idx; |
537 Lisp_Object fontlist = Qnil; | 542 Lisp_Object fontlist = Qnil; |
538 fc_pattern *fcpat; | 543 fc_pattern *fcpat; |
539 | 544 |
546 fcpat = | 551 fcpat = |
547 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); | 552 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); |
548 fcpat->fcpatPtr = FcPatternDuplicate (fontset->fonts[idx]); | 553 fcpat->fcpatPtr = FcPatternDuplicate (fontset->fonts[idx]); |
549 fontlist = Fcons (wrap_fcpattern(fcpat), fontlist); | 554 fontlist = Fcons (wrap_fcpattern(fcpat), fontlist); |
550 } | 555 } |
551 FcFontSetDestroy (fontset); | 556 if (destroyp) |
557 FcFontSetDestroy (fontset); | |
552 return fontlist; | 558 return fontlist; |
553 } | 559 } |
554 | 560 |
555 /* #### fix this name to correspond to Ben's new nomenclature */ | 561 /* #### fix this name to correspond to Ben's new nomenclature */ |
556 DEFUN("fc-list-fonts-pattern-objects", Ffc_list_fonts_pattern_objects, | 562 DEFUN("fc-list-fonts-pattern-objects", Ffc_list_fonts_pattern_objects, |
576 string_list_to_fcobjectset (properties, os); | 582 string_list_to_fcobjectset (properties, os); |
577 /* #### why don't we need to do the "usual substitutions"? */ | 583 /* #### why don't we need to do the "usual substitutions"? */ |
578 fontset = FcFontList (NULL, XFCPATTERN_PTR (pattern), os); | 584 fontset = FcFontList (NULL, XFCPATTERN_PTR (pattern), os); |
579 FcObjectSetDestroy (os); | 585 FcObjectSetDestroy (os); |
580 | 586 |
581 return fontset_to_list (fontset); | 587 return fontset_to_list (fontset, DestroyYes); |
582 | 588 |
583 } | 589 } |
584 | 590 |
585 /* #### maybe this can/should be folded into fc-list-fonts-pattern-objects? */ | 591 /* #### maybe this can/should be folded into fc-list-fonts-pattern-objects? */ |
586 DEFUN("fc-font-sort", Ffc_font_sort, 2, 4, 0, /* | 592 DEFUN("fc-font-sort", Ffc_font_sort, 2, 4, 0, /* |
612 if (NILP(nosub)) /* #### temporary debug hack */ | 618 if (NILP(nosub)) /* #### temporary debug hack */ |
613 FcDefaultSubstitute (p); | 619 FcDefaultSubstitute (p); |
614 FcConfigSubstitute (fcc, p, FcMatchPattern); | 620 FcConfigSubstitute (fcc, p, FcMatchPattern); |
615 fontset = FcFontSort (fcc, p, !NILP(trim), NULL, &fcresult); | 621 fontset = FcFontSort (fcc, p, !NILP(trim), NULL, &fcresult); |
616 | 622 |
617 return fontset_to_list (fontset); | 623 return fontset_to_list (fontset, DestroyYes); |
618 } | 624 } |
619 } | 625 } |
626 | |
627 #ifdef FONTCONFIG_EXPOSE_CONFIG | |
628 | |
629 /* Configuration routines --- for debugging | |
630 Don't depend on these routines being available in the future! | |
631 | |
632 3.2.10 Initialization | |
633 --------------------- | |
634 | |
635 An FcConfig object holds the internal representation of a configuration. | |
636 There is a default configuration which applications may use by passing | |
637 0 to any function using the data within an FcConfig. | |
638 */ | |
639 | |
640 static void | |
641 finalize_fc_config (void *header, int UNUSED (for_disksave)) | |
642 { | |
643 struct fc_config *p = (struct fc_config *) header; | |
644 if (p->fccfgPtr && p->fccfgPtr != FcConfigGetCurrent()) | |
645 { | |
646 /* If we get here, all of *our* references are garbage (see comment on | |
647 fc_config_create_using() for why), and the only reference that | |
648 fontconfig keeps is the current FcConfig. */ | |
649 FcConfigDestroy (p->fccfgPtr); | |
650 } | |
651 p->fccfgPtr = 0; | |
652 } | |
653 | |
654 static void | |
655 print_fc_config (Lisp_Object obj, Lisp_Object printcharfun, | |
656 int UNUSED(escapeflag)) | |
657 { | |
658 struct fc_config *c = XFCCONFIG (obj); | |
659 if (print_readably) | |
660 printing_unreadable_object ("#<fc-config 0x%x>", c->header.uid); | |
661 write_fmt_string (printcharfun, "#<fc-config 0x%x>", c->header.uid); | |
662 } | |
663 | |
664 static const struct memory_description fcconfig_description [] = { | |
665 /* #### nothing here, is this right?? */ | |
666 { XD_END } | |
667 }; | |
668 | |
669 DEFINE_LRECORD_IMPLEMENTATION("fc-config", fc_config, 0, | |
670 0, print_fc_config, finalize_fc_config, 0, 0, | |
671 fcconfig_description, | |
672 struct fc_config); | |
673 | |
674 /* We obviously need to be careful about garbage collecting the current | |
675 FcConfig. I infer from the documentation of FcConfigDestroy that that | |
676 is the only reference maintained by fontconfig. | |
677 So we keep track of our own references on a weak list, and only cons a | |
678 new object if we don't already have a reference to it there. */ | |
679 | |
680 static Lisp_Object | |
681 fc_config_create_using (FcConfig * (*create_function) ()) | |
682 { | |
683 FcConfig *fc = (*create_function) (); | |
684 Lisp_Object configs = XWEAK_LIST_LIST (Vfc_config_weak_list); | |
685 | |
686 /* Linear search: fc_configs are not going to multiply like conses. */ | |
687 { | |
688 LIST_LOOP_2 (cfg, configs) | |
689 if (fc == XFCCONFIG_PTR (cfg)) | |
690 return cfg; | |
691 } | |
692 | |
693 { | |
694 fc_config *fccfg = | |
695 ALLOC_LCRECORD_TYPE (struct fc_config, &lrecord_fc_config); | |
696 fccfg->fccfgPtr = fc; | |
697 configs = Fcons (wrap_fcconfig (fccfg), configs); | |
698 XWEAK_LIST_LIST (Vfc_config_weak_list) = configs; | |
699 return wrap_fcconfig (fccfg); | |
700 } | |
701 } | |
702 | |
703 DEFUN("fc-config-p", Ffc_config_p, 1, 1, 0, /* | |
704 Returns t if OBJECT is of type fc-config, nil otherwise. | |
705 */ | |
706 (object)) | |
707 { | |
708 return FCCONFIGP (object) ? Qt : Qnil; | |
709 } | |
710 | |
711 DEFUN("fc-config-create", Ffc_config_create, 0, 0, 0, /* | |
712 -- Function: FcConfig *FcConfigCreate (void) | |
713 Creates an empty configuration. */ | |
714 ()) | |
715 { | |
716 return fc_config_create_using (&FcConfigCreate); | |
717 } | |
718 | |
719 #if 0 | |
720 /* I'm sorry, but we just don't do this in Lisp, OK? | |
721 Don't even think about implementing this. */ | |
722 DEFUN("fc-config-destroy", Ffc_config_destroy, 1, 1, 0, /* | |
723 -- Function: void FcConfigDestroy (FcConfig *config) | |
724 Destroys a configuration and any data associated with it. Note | |
725 that calling this function with the return value from | |
726 FcConfigGetCurrent will place the library in an indeterminate | |
727 state. */ | |
728 (config)) | |
729 { | |
730 signal_error (Qunimplemented, "No user-servicable parts!", | |
731 intern ("fc-config-destroy"); | |
732 } | |
733 #endif | |
734 | |
735 DEFUN("fc-config-get-current", Ffc_config_get_current, 0, 0, 0, /* | |
736 -- Function: FcConfig *FcConfigGetCurrent (void) | |
737 Returns the current default configuration. */ | |
738 ()) | |
739 { | |
740 return fc_config_create_using (&FcConfigGetCurrent); | |
741 } | |
742 | |
743 DEFUN("fc-config-up-to-date", Ffc_config_up_to_date, 1, 1, 0, /* | |
744 -- Function: FcBool FcConfigUptoDate (FcConfig *config) | |
745 Checks all of the files related to 'config' and returns whether the | |
746 in-memory version is in sync with the disk version. */ | |
747 (config)) | |
748 { | |
749 CHECK_FCCONFIG (config); | |
750 return FcConfigUptoDate (XFCCONFIG_PTR (config)) == FcFalse ? Qnil : Qt; | |
751 } | |
752 | |
753 DEFUN("fc-config-build-fonts", Ffc_config_build_fonts, 1, 1, 0, /* | |
754 -- Function: FcBool FcConfigBuildFonts (FcConfig *config) | |
755 Builds the set of available fonts for the given configuration. | |
756 Note that any changes to the configuration after this call have | |
757 indeterminate effects. Returns FcFalse if this operation runs out | |
758 of memory. | |
759 XEmacs: signal out-of-memory, or return nil on success. */ | |
760 (config)) | |
761 { | |
762 CHECK_FCCONFIG (config); | |
763 if (FcConfigBuildFonts (XFCCONFIG_PTR (config)) == FcFalse) | |
764 out_of_memory ("FcConfigBuildFonts failed", config); | |
765 return Qnil; | |
766 } | |
767 | |
768 /* Calls its argument on `config', which must be defined by the caller. */ | |
769 | |
770 #define FCSTRLIST_TO_LISP_USING(source) do { \ | |
771 FcChar8 *thing; \ | |
772 FcStrList *thing_list; \ | |
773 Lisp_Object value = Qnil; \ | |
774 CHECK_FCCONFIG (config); \ | |
775 thing_list = source (XFCCONFIG_PTR(config)); \ | |
776 /* Yes, we need to do this check -- sheesh, Keith! */ \ | |
777 if (!thing_list) \ | |
778 return Qnil; \ | |
779 while ((thing = FcStrListNext (thing_list))) \ | |
780 value = Fcons (build_fcapi_string (thing), value); \ | |
781 FcStrListDone (thing_list); \ | |
782 return value; \ | |
783 } while (0) | |
784 | |
785 DEFUN("fc-config-get-config-dirs", Ffc_config_get_config_dirs, 1, 1, 0, /* | |
786 -- Function: FcStrList *FcConfigGetConfigDirs (FcConfig *config) | |
787 Returns the list of font directories specified in the | |
788 configuration files for 'config'. Does not include any | |
789 subdirectories. */ | |
790 (config)) | |
791 { | |
792 FCSTRLIST_TO_LISP_USING (FcConfigGetConfigDirs); | |
793 } | |
794 | |
795 DEFUN("fc-config-get-font-dirs", Ffc_config_get_font_dirs, 1, 1, 0, /* | |
796 -- Function: FcStrList *FcConfigGetFontDirs (FcConfig *config) | |
797 Returns the list of font directories in 'config'. This includes the | |
798 configured font directories along with any directories below those | |
799 in the filesystem. */ | |
800 (config)) | |
801 { | |
802 FCSTRLIST_TO_LISP_USING (FcConfigGetFontDirs); | |
803 } | |
804 | |
805 DEFUN("fc-config-get-config-files", Ffc_config_get_config_files, 1, 1, 0, /* | |
806 -- Function: FcStrList *FcConfigGetConfigFiles (FcConfig *config) | |
807 Returns the list of known configuration files used to generate | |
808 'config'. Note that this will not include any configuration done | |
809 with FcConfigParse. */ | |
810 (config)) | |
811 { | |
812 FCSTRLIST_TO_LISP_USING (FcConfigGetConfigFiles); | |
813 } | |
814 | |
815 #undef FCSTRLIST_TO_LISP_USING | |
816 | |
817 DEFUN("fc-config-get-cache", Ffc_config_get_cache, 1, 1, 0, /* | |
818 -- Function: char *FcConfigGetCache (FcConfig *config) | |
819 Returns the name of the file used to store per-user font | |
820 information. */ | |
821 (config)) | |
822 { | |
823 CHECK_FCCONFIG (config); | |
824 /* Surely FcConfigGetCache just casts an FcChar8* to char*. */ | |
825 return build_fcapi_string ((FcChar8 *) FcConfigGetCache (XFCCONFIG_PTR (config))); | |
826 } | |
827 | |
828 DEFUN("fc-config-get-fonts", Ffc_config_get_fonts, 2, 2, 0, /* | |
829 -- Function: FcFontSet *FcConfigGetFonts (FcConfig *config, FcSetName set) | |
830 Returns one of the two sets of fonts from the configuration as | |
831 specified by 'set'. | |
832 `FcSetName' | |
833 Specifies one of the two sets of fonts available in a | |
834 configuration; FcSetSystem for those fonts specified in the | |
835 configuration and FcSetApplication which holds fonts provided by | |
836 the application. */ | |
837 (config, set)) | |
838 { | |
839 FcSetName name = FcSetSystem; | |
840 FcFontSet *fs = NULL; | |
841 | |
842 CHECK_FCCONFIG (config); | |
843 CHECK_SYMBOL (set); | |
844 | |
845 if (EQ (set, intern ("fc-set-system"))) | |
846 name = FcSetSystem; | |
847 else if (EQ (set, intern ("fc-set-application"))) | |
848 name = FcSetApplication; | |
849 else | |
850 wtaerror ("must be in (fc-set-system fc-set-application)", set); | |
851 | |
852 fs = FcConfigGetFonts (XFCCONFIG_PTR (config), name); | |
853 return fs ? fontset_to_list (fs, DestroyNo) : Qnil; | |
854 } | |
855 | |
856 DEFUN("fc-config-set-current", Ffc_config_set_current, 1, 1, 0, /* | |
857 -- Function: FcBool FcConfigSetCurrent (FcConfig *config) | |
858 Sets the current default configuration to 'config'. Implicitly | |
859 calls FcConfigBuildFonts if necessary, returning FcFalse if that | |
860 call fails. | |
861 XEmacs: signals out-of-memory if FcConfigBuildFonts fails, or args-out-of-range | |
862 if the resulting FcConfig has no fonts (which would crash XEmacs if installed). | |
863 */ | |
864 (config)) | |
865 { | |
866 CHECK_FCCONFIG (config); | |
867 /* *sigh* "Success" DOES NOT mean you have any fonts available. It is | |
868 easy to crash fontconfig, and XEmacs with it. Without the following | |
869 check, this will do it: | |
870 (progn | |
871 (fc-config-set-current (fc-config-create)) | |
872 (set-face-font 'default "serif-12")) | |
873 */ | |
874 | |
875 if (FcConfigBuildFonts (XFCCONFIG_PTR (config)) == FcFalse) | |
876 out_of_memory ("FcConfigBuildFonts failed", config); | |
877 /* #### We'd like to avoid this consing, and FcConfigGetFonts sometimes | |
878 returns NULL, but it doesn't always. This will do for now .... */ | |
879 if (NILP (Ffc_config_get_fonts (config, intern ("fc-set-system"))) | |
880 && NILP (Ffc_config_get_fonts (config, intern ("fc-set-application")))) | |
881 signal_error (intern ("args-out-of-range"), "no fonts found", config); | |
882 /* Should never happen, but I don't trust Keith anymore .... */ | |
883 if (FcConfigSetCurrent (XFCCONFIG_PTR (config)) == FcFalse) | |
884 out_of_memory ("FcConfigBuildFonts failed in set", config); | |
885 return Qnil; | |
886 } | |
887 | |
888 DEFUN("fc-config-get-blanks", Ffc_config_get_blanks, 1, 1, 0, /* | |
889 -- Function: FcBlanks *FcConfigGetBlanks (FcConfig *config) | |
890 Returns the FcBlanks object associated with the given | |
891 configuration, if no blanks were present in the configuration, | |
892 this function will return 0. | |
893 XEmacs: should convert to a chartable. | |
894 #### Unimplemented. */ | |
895 (config)) | |
896 { | |
897 CHECK_FCCONFIG (config); | |
898 signal_error (Qunimplemented, "no method to convert FcBlanks object", | |
899 intern ("fc-config-get-blanks")); | |
900 } | |
901 | |
902 /* The misspelling in the fontconfig function name accurately corresponds to | |
903 the version of fontconfig.h I had on 2007-04-13. -- sjt */ | |
904 DEFUN("fc-config-get-rescan-interval", Ffc_config_get_rescan_interval, 1, 1, 0, /* | |
905 -- Function: int FcConfigGetRescanInverval (FcConfig *config) | |
906 Returns the interval between automatic checks of the configuration | |
907 (in seconds) specified in 'config'. The configuration is checked | |
908 during a call to FcFontList when this interval has passed since | |
909 the last check. */ | |
910 (config)) | |
911 { | |
912 CHECK_FCCONFIG (config); | |
913 return make_int (FcConfigGetRescanInverval (XFCCONFIG_PTR (config))); | |
914 } | |
915 | |
916 /* The misspelling in the fontconfig function name accurately corresponds to | |
917 the version of fontconfig.h I had on 2007-04-13. -- sjt */ | |
918 DEFUN("fc-config-set-rescan-interval", Ffc_config_set_rescan_interval, 2, 2, 0, /* | |
919 -- Function: FcBool FcConfigSetRescanInverval (FcConfig *config, int | |
920 rescanInterval) | |
921 Sets the rescan interval; returns FcFalse if an error occurred. | |
922 XEmacs: signal such error, or return nil on success. */ | |
923 (config, rescan_interval)) | |
924 { | |
925 CHECK_FCCONFIG (config); | |
926 CHECK_INT (rescan_interval); | |
927 if (FcConfigSetRescanInverval (XFCCONFIG_PTR (config), | |
928 XINT (rescan_interval)) == FcFalse) | |
929 signal_error (Qio_error, "FcConfigSetRescanInverval barfed", | |
930 intern ("fc-config-set-rescan-interval")); | |
931 return Qnil; | |
932 } | |
933 | |
934 /* #### This might usefully be made interactive. */ | |
935 DEFUN("fc-config-app-font-add-file", Ffc_config_app_font_add_file, 2, 2, 0, /* | |
936 -- Function: FcBool FcConfigAppFontAddFile (FcConfig *config, const | |
937 char *file) | |
938 Adds an application-specific font to the configuration. */ | |
939 (config, file)) | |
940 { | |
941 CHECK_FCCONFIG (config); | |
942 CHECK_STRING (file); | |
943 if (FcConfigAppFontAddFile | |
944 (XFCCONFIG_PTR (config), | |
945 /* #### FIXME! is this really Qnative? */ | |
946 (FcChar8 *) NEW_LISP_STRING_TO_EXTERNAL ((file), Qnative)) == FcFalse) | |
947 return Qnil; | |
948 else | |
949 return Qt; | |
950 } | |
951 | |
952 /* #### This might usefully be made interactive. */ | |
953 DEFUN("fc-config-app-font-add-dir", Ffc_config_app_font_add_dir, 2, 2, 0, /* | |
954 -- Function: FcBool FcConfigAppFontAddDir (FcConfig *config, const | |
955 char *dir) | |
956 Scans the specified directory for fonts, adding each one found to | |
957 the application-specific set of fonts. */ | |
958 (config, dir)) | |
959 { | |
960 CHECK_FCCONFIG (config); | |
961 CHECK_STRING (dir); | |
962 if (FcConfigAppFontAddDir | |
963 (XFCCONFIG_PTR (config), | |
964 /* #### FIXME! is this really Qnative? */ | |
965 (FcChar8 *) NEW_LISP_STRING_TO_EXTERNAL ((dir), Qnative)) == FcFalse) | |
966 return Qnil; | |
967 else | |
968 return Qt; | |
969 } | |
970 | |
971 /* #### This might usefully be made interactive. */ | |
972 DEFUN("fc-config-app-font-clear", Ffc_config_app_font_clear, 1, 1, 0, /* | |
973 -- Function: void FcConfigAppFontClear (FcConfig *config) | |
974 Clears the set of application-specific fonts. */ | |
975 (config)) | |
976 { | |
977 CHECK_FCCONFIG (config); | |
978 FcConfigAppFontClear (XFCCONFIG_PTR (config)); | |
979 return Qnil; | |
980 } | |
981 | |
982 /* These functions provide some control over how the default | |
983 configuration of the library is initialized. (This configuration is | |
984 normally implicitly initialized.) */ | |
985 | |
986 DEFUN("fc-config-filename", Ffc_config_filename, 1, 1, 0, /* | |
987 -- Function: char *FcConfigFilename (const char *name) | |
988 Given the specified external entity name, return the associated | |
989 filename. This provides applications a way to convert various | |
990 configuration file references into filename form. | |
991 | |
992 A null or empty 'name' indicates that the default configuration | |
993 file should be used; which file this references can be overridden | |
994 with the FC_CONFIG_FILE environment variable. Next, if the name | |
995 starts with '~', it refers to a file in the current users home | |
996 directory. Otherwise if the name doesn't start with '/', it | |
997 refers to a file in the default configuration directory; the | |
998 built-in default directory can be overridden with the | |
999 FC_CONFIG_DIR environment variable. */ | |
1000 (name)) | |
1001 { | |
1002 char *fcname = ""; | |
1003 | |
1004 if (!NILP (name)) | |
1005 { | |
1006 CHECK_STRING (name); | |
1007 /* #### FIXME! is this really Qnative? */ | |
1008 fcname = NEW_LISP_STRING_TO_EXTERNAL (name, Qnative); | |
1009 } | |
1010 return (build_fcapi_string (FcConfigFilename ((FcChar8 *) fcname))); | |
1011 } | |
1012 | |
1013 DEFUN("fc-init-load-config", Ffc_init_load_config, 0, 0, 0, /* | |
1014 -- Function: FcConfig *FcInitLoadConfig (void) | |
1015 Loads the default configuration file and returns the resulting | |
1016 configuration. Does not load any font information. */ | |
1017 ()) | |
1018 { | |
1019 return fc_config_create_using (&FcInitLoadConfig); | |
1020 } | |
1021 | |
1022 DEFUN("fc-init-load-config-and-fonts", Ffc_init_load_config_and_fonts, 0, 0, 0, /* | |
1023 -- Function: FcConfig *FcInitLoadConfigAndFonts (void) | |
1024 Loads the default configuration file and builds information about | |
1025 the available fonts. Returns the resulting configuration. */ | |
1026 ()) | |
1027 { | |
1028 return fc_config_create_using (&FcInitLoadConfigAndFonts); | |
1029 } | |
1030 | |
1031 DEFUN("fc-init", Ffc_init, 0, 0, 0, /* | |
1032 -- Function: FcBool FcInit (void) | |
1033 Loads the default configuration file and the fonts referenced | |
1034 therein and sets the default configuration to that result. | |
1035 Returns whether this process succeeded or not. If the default | |
1036 configuration has already been loaded, this routine does nothing | |
1037 and returns FcTrue. */ | |
1038 ()) | |
1039 { | |
1040 return (FcInit () == FcTrue) ? Qt : Qnil; | |
1041 } | |
1042 | |
1043 DEFUN("fc-get-version", Ffc_get_version, 0, 0, 0, /* | |
1044 -- Function: int FcGetVersion (void) | |
1045 Returns the version number of the library. | |
1046 XEmacs: No, this should NOT return a pretty string. | |
1047 (let ((i (fc-get-version))) | |
1048 (format "%d.%d.%d" (/ i 10000) (mod (/ i 100) 100) (mod i 100))) | |
1049 gives the usual x.y.z format. */ | |
1050 ()) | |
1051 { | |
1052 return make_int (FcGetVersion ()); | |
1053 } | |
1054 | |
1055 DEFUN("fc-init-reinitialize", Ffc_init_reinitialize, 0, 0, 0, /* | |
1056 -- Function: FcBool FcInitReinitialize (void) | |
1057 Forces the default configuration file to be reloaded and resets | |
1058 the default configuration. */ | |
1059 ()) | |
1060 { | |
1061 return (FcInitReinitialize () == FcTrue) ? Qt : Qnil; | |
1062 } | |
1063 | |
1064 DEFUN("fc-init-bring-up-to-date", Ffc_init_bring_up_to_date, 0, 0, 0, /* | |
1065 -- Function: FcBool FcInitBringUptoDate (void) | |
1066 Checks the rescan interval in the default configuration, checking | |
1067 the configuration if the interval has passed and reloading the | |
1068 configuration when any changes are detected. */ | |
1069 ()) | |
1070 { | |
1071 return (FcInitBringUptoDate () == FcTrue) ? Qt : Qnil; | |
1072 } | |
1073 | |
1074 #endif /* FONTCONFIG_EXPOSE_CONFIG */ | |
620 | 1075 |
621 DEFUN("xlfd-font-name-p", Fxlfd_font_name_p, 1, 1, 0, /* | 1076 DEFUN("xlfd-font-name-p", Fxlfd_font_name_p, 1, 1, 0, /* |
622 Check whether the string FONTNAME is a XLFD font name. */ | 1077 Check whether the string FONTNAME is a XLFD font name. */ |
623 (fontname)) | 1078 (fontname)) |
624 { | 1079 { |
762 DEFSUBR(Ffc_pattern_get); | 1217 DEFSUBR(Ffc_pattern_get); |
763 DEFSUBR(Ffc_list_fonts_pattern_objects); | 1218 DEFSUBR(Ffc_list_fonts_pattern_objects); |
764 DEFSUBR(Ffc_font_sort); | 1219 DEFSUBR(Ffc_font_sort); |
765 DEFSUBR(Ffc_font_match); | 1220 DEFSUBR(Ffc_font_match); |
766 DEFSUBR(Fxlfd_font_name_p); | 1221 DEFSUBR(Fxlfd_font_name_p); |
1222 | |
1223 #ifdef FONTCONFIG_EXPOSE_CONFIG | |
1224 INIT_LRECORD_IMPLEMENTATION(fc_config); | |
1225 | |
1226 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_configp); | |
1227 | |
1228 DEFSUBR(Ffc_config_p); | |
1229 DEFSUBR(Ffc_config_create); | |
1230 #if 0 | |
1231 DEFSUBR(Ffc_config_destroy); | |
1232 #endif | |
1233 DEFSUBR(Ffc_config_set_current); | |
1234 DEFSUBR(Ffc_config_get_current); | |
1235 DEFSUBR(Ffc_config_up_to_date); | |
1236 DEFSUBR(Ffc_config_build_fonts); | |
1237 DEFSUBR(Ffc_config_get_config_dirs); | |
1238 DEFSUBR(Ffc_config_get_font_dirs); | |
1239 DEFSUBR(Ffc_config_get_config_files); | |
1240 DEFSUBR(Ffc_config_get_cache); | |
1241 DEFSUBR(Ffc_config_get_fonts); | |
1242 DEFSUBR(Ffc_config_get_blanks); | |
1243 DEFSUBR(Ffc_config_get_rescan_interval); | |
1244 DEFSUBR(Ffc_config_set_rescan_interval); | |
1245 DEFSUBR(Ffc_config_app_font_add_file); | |
1246 DEFSUBR(Ffc_config_app_font_add_dir); | |
1247 DEFSUBR(Ffc_config_app_font_clear); | |
1248 DEFSUBR(Ffc_config_filename); | |
1249 DEFSUBR(Ffc_init_load_config); | |
1250 DEFSUBR(Ffc_init_load_config_and_fonts); | |
1251 DEFSUBR(Ffc_init); | |
1252 DEFSUBR(Ffc_get_version); | |
1253 DEFSUBR(Ffc_init_reinitialize); | |
1254 DEFSUBR(Ffc_init_bring_up_to_date); | |
1255 #endif /* FONTCONFIG_EXPOSE_CONFIG */ | |
767 } | 1256 } |
768 | 1257 |
769 void | 1258 void |
770 vars_of_font_mgr (void) | 1259 vars_of_font_mgr (void) |
771 { | 1260 { |
789 } | 1278 } |
790 | 1279 |
791 void | 1280 void |
792 complex_vars_of_font_mgr (void) | 1281 complex_vars_of_font_mgr (void) |
793 { | 1282 { |
1283 #ifdef FONTCONFIG_EXPOSE_CONFIG | |
1284 Vfc_config_weak_list = make_weak_list (WEAK_LIST_SIMPLE); | |
1285 staticpro (&Vfc_config_weak_list); | |
1286 #endif | |
1287 | |
794 DEFVAR_LISP("xft-xlfd-font-regexp", &Vxlfd_font_name_regexp /* | 1288 DEFVAR_LISP("xft-xlfd-font-regexp", &Vxlfd_font_name_regexp /* |
795 The regular expression used to match XLFD font names. */ | 1289 The regular expression used to match XLFD font names. */ |
796 ); | 1290 ); |
797 Vxlfd_font_name_regexp = make_xlfd_font_regexp(); | 1291 Vxlfd_font_name_regexp = make_xlfd_font_regexp(); |
798 } | 1292 } |