diff options
| author | Kenichi Handa | 2007-11-19 05:14:46 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2007-11-19 05:14:46 +0000 |
| commit | f697fff0b77c27bf9668909b14e52b3ae9809da0 (patch) | |
| tree | d4e3d6f25e01d1099e447c77a01fd5231dfa583f | |
| parent | 50e3873c243ddd5295f989baf811d8f3d992cefa (diff) | |
| download | emacs-f697fff0b77c27bf9668909b14e52b3ae9809da0.tar.gz emacs-f697fff0b77c27bf9668909b14e52b3ae9809da0.zip | |
(font_update_drivers): Call driver->start_for_frame and
driver->end_for_frame at proper timings.
(font_put_frame_data, font_get_frame_data): New functions.
(Ffont_spec): Add usage in the docstring.
| -rw-r--r-- | src/font.c | 96 |
1 files changed, 80 insertions, 16 deletions
diff --git a/src/font.c b/src/font.c index d192a29ded0..7a1aca6f26e 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -110,8 +110,8 @@ Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClanguage, QCscript; | |||
| 110 | /* Symbols representing values of font spacing property. */ | 110 | /* Symbols representing values of font spacing property. */ |
| 111 | Lisp_Object Qc, Qm, Qp, Qd; | 111 | Lisp_Object Qc, Qm, Qp, Qd; |
| 112 | 112 | ||
| 113 | /* List of all font drivers. All font-backends (XXXfont.c) call | 113 | /* List of all font drivers. Each font-backend (XXXfont.c) calls |
| 114 | add_font_driver in syms_of_XXXfont to register the font-driver | 114 | register_font_driver in syms_of_XXXfont to register its font-driver |
| 115 | here. */ | 115 | here. */ |
| 116 | static struct font_driver_list *font_driver_list; | 116 | static struct font_driver_list *font_driver_list; |
| 117 | 117 | ||
| @@ -2940,14 +2940,14 @@ free_font_driver_list (f) | |||
| 2940 | } | 2940 | } |
| 2941 | 2941 | ||
| 2942 | 2942 | ||
| 2943 | /* Make the frame F use font backends listed in NEW_BACKENDS (list of | 2943 | /* Make the frame F use font backends listed in NEW_DRIVERS (list of |
| 2944 | symbols). If NEW_BACKENDS is nil, make F use all available font | 2944 | symbols, e.g. xft, x). If NEW_DRIVERS is nil, make F use all |
| 2945 | drivers. If no backend is available, dont't alter | 2945 | available font drivers. If no backend is available, dont't alter |
| 2946 | f->font_driver_list. | 2946 | F->font_driver_list. |
| 2947 | 2947 | ||
| 2948 | A caller must free all realized faces and clear all font caches if | 2948 | A caller must free all realized faces and clear all font caches if |
| 2949 | any in advance. The return value is a list of font backends | 2949 | any in advance. The return value is a list of font backends |
| 2950 | actually made used for on F. */ | 2950 | actually made used on F. */ |
| 2951 | 2951 | ||
| 2952 | Lisp_Object | 2952 | Lisp_Object |
| 2953 | font_update_drivers (f, new_drivers) | 2953 | font_update_drivers (f, new_drivers) |
| @@ -2957,23 +2957,86 @@ font_update_drivers (f, new_drivers) | |||
| 2957 | Lisp_Object active_drivers = Qnil; | 2957 | Lisp_Object active_drivers = Qnil; |
| 2958 | struct font_driver_list *list; | 2958 | struct font_driver_list *list; |
| 2959 | 2959 | ||
| 2960 | /* At first check which font backends are available. */ | 2960 | /* At first, finialize all font drivers for F. */ |
| 2961 | for (list = f->font_driver_list; list; list = list->next) | ||
| 2962 | if (list->on) | ||
| 2963 | { | ||
| 2964 | if (list->driver->end_for_frame) | ||
| 2965 | list->driver->end_for_frame (f); | ||
| 2966 | list->on = 0; | ||
| 2967 | } | ||
| 2968 | |||
| 2969 | /* Then start the requested drivers. */ | ||
| 2961 | for (list = f->font_driver_list; list; list = list->next) | 2970 | for (list = f->font_driver_list; list; list = list->next) |
| 2962 | if (NILP (new_drivers) | 2971 | if (NILP (new_drivers) |
| 2963 | || ! NILP (Fmemq (list->driver->type, new_drivers))) | 2972 | || ! NILP (Fmemq (list->driver->type, new_drivers))) |
| 2964 | { | 2973 | { |
| 2965 | list->on = 2; | 2974 | if (! list->driver->start_for_frame |
| 2966 | active_drivers = nconc2 (active_drivers, | 2975 | || list->driver->start_for_frame (f) == 0); |
| 2967 | Fcons (list->driver->type, Qnil)); | 2976 | { |
| 2977 | list->on = 1; | ||
| 2978 | active_drivers = nconc2 (active_drivers, | ||
| 2979 | Fcons (list->driver->type, Qnil)); | ||
| 2980 | } | ||
| 2968 | } | 2981 | } |
| 2969 | /* If at least one backend is available, update all list->on. */ | ||
| 2970 | if (! NILP (active_drivers)) | ||
| 2971 | for (list = f->font_driver_list; list; list = list->next) | ||
| 2972 | list->on = (list->on == 2); | ||
| 2973 | 2982 | ||
| 2974 | return active_drivers; | 2983 | return active_drivers; |
| 2975 | } | 2984 | } |
| 2976 | 2985 | ||
| 2986 | int | ||
| 2987 | font_put_frame_data (f, driver, data) | ||
| 2988 | FRAME_PTR f; | ||
| 2989 | struct font_driver *driver; | ||
| 2990 | void *data; | ||
| 2991 | { | ||
| 2992 | struct font_data_list *list, *prev; | ||
| 2993 | |||
| 2994 | for (prev = NULL, list = f->font_data_list; list; | ||
| 2995 | prev = list, list = list->next) | ||
| 2996 | if (list->driver == driver) | ||
| 2997 | break; | ||
| 2998 | if (! data) | ||
| 2999 | { | ||
| 3000 | if (list) | ||
| 3001 | { | ||
| 3002 | if (prev) | ||
| 3003 | prev->next = list->next; | ||
| 3004 | else | ||
| 3005 | f->font_data_list = list->next; | ||
| 3006 | free (list); | ||
| 3007 | } | ||
| 3008 | return 0; | ||
| 3009 | } | ||
| 3010 | |||
| 3011 | if (! list) | ||
| 3012 | { | ||
| 3013 | list = malloc (sizeof (struct font_data_list)); | ||
| 3014 | if (! list) | ||
| 3015 | return -1; | ||
| 3016 | list->driver = driver; | ||
| 3017 | list->next = f->font_data_list; | ||
| 3018 | f->font_data_list = list; | ||
| 3019 | } | ||
| 3020 | list->data = data; | ||
| 3021 | return 0; | ||
| 3022 | } | ||
| 3023 | |||
| 3024 | |||
| 3025 | void * | ||
| 3026 | font_get_frame_data (f, driver) | ||
| 3027 | FRAME_PTR f; | ||
| 3028 | struct font_driver *driver; | ||
| 3029 | { | ||
| 3030 | struct font_data_list *list; | ||
| 3031 | |||
| 3032 | for (list = f->font_data_list; list; list = list->next) | ||
| 3033 | if (list->driver == driver) | ||
| 3034 | break; | ||
| 3035 | if (! list) | ||
| 3036 | return NULL; | ||
| 3037 | return list->data; | ||
| 3038 | } | ||
| 3039 | |||
| 2977 | 3040 | ||
| 2978 | /* Return the font used to draw character C by FACE at buffer position | 3041 | /* Return the font used to draw character C by FACE at buffer position |
| 2979 | POS in window W. If OBJECT is non-nil, it is a string containing C | 3042 | POS in window W. If OBJECT is non-nil, it is a string containing C |
| @@ -3052,7 +3115,8 @@ encoding of a font, e.g. ``iso8859-1''. | |||
| 3052 | 3115 | ||
| 3053 | VALUE must be a non-negative integer or a floating point number | 3116 | VALUE must be a non-negative integer or a floating point number |
| 3054 | specifying the font size. It specifies the font size in 1/10 pixels | 3117 | specifying the font size. It specifies the font size in 1/10 pixels |
| 3055 | (if VALUE is an integer), or in points (if VALUE is a float). */) | 3118 | (if VALUE is an integer), or in points (if VALUE is a float). |
| 3119 | usage: (font-spec ARGS ...) */) | ||
| 3056 | (nargs, args) | 3120 | (nargs, args) |
| 3057 | int nargs; | 3121 | int nargs; |
| 3058 | Lisp_Object *args; | 3122 | Lisp_Object *args; |