diff options
| author | Kenichi Handa | 2006-07-26 01:19:04 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2006-07-26 01:19:04 +0000 |
| commit | 417a1b10f711c7cbd845d5df5c7e3e9c0f7ca772 (patch) | |
| tree | 954661f13bcf14c6846b88fe100735b9eae06982 /src | |
| parent | 1a8a83b29d33ab1a5b93308d64fc57c428f05830 (diff) | |
| download | emacs-417a1b10f711c7cbd845d5df5c7e3e9c0f7ca772.tar.gz emacs-417a1b10f711c7cbd845d5df5c7e3e9c0f7ca772.zip | |
(font_unparse_fcname): Fix typo (swidth->width).
(font_list_entities): Check driver_list->on.
(register_font_driver): Initalize `on' member to 0.
(font_update_drivers): New function.
(Fclear_font_cache): Check driver_list->on.
Diffstat (limited to 'src')
| -rw-r--r-- | src/font.c | 138 |
1 files changed, 97 insertions, 41 deletions
diff --git a/src/font.c b/src/font.c index eddea78f8d6..021c8f335b8 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -1242,7 +1242,7 @@ font_unparse_fcname (font, pixel_size, name, nbytes) | |||
| 1242 | int i, len = 1; | 1242 | int i, len = 1; |
| 1243 | char *p; | 1243 | char *p; |
| 1244 | Lisp_Object styles[3]; | 1244 | Lisp_Object styles[3]; |
| 1245 | char *style_names[3] = { "weight", "slant", "swidth" }; | 1245 | char *style_names[3] = { "weight", "slant", "width" }; |
| 1246 | 1246 | ||
| 1247 | val = AREF (font, FONT_FAMILY_INDEX); | 1247 | val = AREF (font, FONT_FAMILY_INDEX); |
| 1248 | if (SYMBOLP (val) && ! NILP (val)) | 1248 | if (SYMBOLP (val) && ! NILP (val)) |
| @@ -2247,7 +2247,8 @@ font_list_entities (frame, spec) | |||
| 2247 | ftype = AREF (spec, FONT_TYPE_INDEX); | 2247 | ftype = AREF (spec, FONT_TYPE_INDEX); |
| 2248 | 2248 | ||
| 2249 | for (i = 0; driver_list; driver_list = driver_list->next) | 2249 | for (i = 0; driver_list; driver_list = driver_list->next) |
| 2250 | if (NILP (ftype) || EQ (driver_list->driver->type, ftype)) | 2250 | if (driver_list->on |
| 2251 | && (NILP (ftype) || EQ (driver_list->driver->type, ftype))) | ||
| 2251 | { | 2252 | { |
| 2252 | Lisp_Object cache = driver_list->driver->get_cache (frame); | 2253 | Lisp_Object cache = driver_list->driver->get_cache (frame); |
| 2253 | Lisp_Object tail = alternate_familes; | 2254 | Lisp_Object tail = alternate_familes; |
| @@ -2645,10 +2646,10 @@ font_open_by_name (f, name) | |||
| 2645 | 2646 | ||
| 2646 | /* Register font-driver DRIVER. This function is used in two ways. | 2647 | /* Register font-driver DRIVER. This function is used in two ways. |
| 2647 | 2648 | ||
| 2648 | The first is with frame F non-NULL. In this case, DRIVER is | 2649 | The first is with frame F non-NULL. In this case, make DRIVER |
| 2649 | registered to be used for drawing characters on F. All frame | 2650 | available (but not yet activated) on F. All frame creaters |
| 2650 | creaters (e.g. Fx_create_frame) must call this function at least | 2651 | (e.g. Fx_create_frame) must call this function at least once with |
| 2651 | once with an available font-driver. | 2652 | an available font-driver. |
| 2652 | 2653 | ||
| 2653 | The second is with frame F NULL. In this case, DRIVER is globally | 2654 | The second is with frame F NULL. In this case, DRIVER is globally |
| 2654 | registered in the variable `font_driver_list'. All font-driver | 2655 | registered in the variable `font_driver_list'. All font-driver |
| @@ -2672,6 +2673,7 @@ register_font_driver (driver, f) | |||
| 2672 | error ("Duplicated font driver: %s", SDATA (SYMBOL_NAME (driver->type))); | 2673 | error ("Duplicated font driver: %s", SDATA (SYMBOL_NAME (driver->type))); |
| 2673 | 2674 | ||
| 2674 | list = malloc (sizeof (struct font_driver_list)); | 2675 | list = malloc (sizeof (struct font_driver_list)); |
| 2676 | list->on = 0; | ||
| 2675 | list->driver = driver; | 2677 | list->driver = driver; |
| 2676 | list->next = NULL; | 2678 | list->next = NULL; |
| 2677 | if (prev) | 2679 | if (prev) |
| @@ -2699,6 +2701,53 @@ free_font_driver_list (f) | |||
| 2699 | } | 2701 | } |
| 2700 | } | 2702 | } |
| 2701 | 2703 | ||
| 2704 | /* Make all font drivers listed in NEW_DRIVERS be used on F. If | ||
| 2705 | NEW_DRIVERS is nil, make all available font drivers be used. | ||
| 2706 | FONT is the current default font of F, it may be NULL. */ | ||
| 2707 | |||
| 2708 | void | ||
| 2709 | font_update_drivers (f, new_drivers, font) | ||
| 2710 | FRAME_PTR f; | ||
| 2711 | Lisp_Object new_drivers; | ||
| 2712 | struct font *font; | ||
| 2713 | { | ||
| 2714 | Lisp_Object active_drivers = Qnil; | ||
| 2715 | Lisp_Object old_spec; | ||
| 2716 | struct font_driver_list *list; | ||
| 2717 | |||
| 2718 | if (font) | ||
| 2719 | { | ||
| 2720 | old_spec = font_get_spec (font_find_object (font)); | ||
| 2721 | free_all_realized_faces (Qnil); | ||
| 2722 | Fclear_font_cache (); | ||
| 2723 | } | ||
| 2724 | |||
| 2725 | for (list = f->font_driver_list; list; list = list->next) | ||
| 2726 | { | ||
| 2727 | if (NILP (new_drivers) | ||
| 2728 | || ! NILP (Fmemq (list->driver->type, new_drivers))) | ||
| 2729 | { | ||
| 2730 | list->on = 1; | ||
| 2731 | active_drivers = Fcons (list->driver->type, active_drivers); | ||
| 2732 | } | ||
| 2733 | else | ||
| 2734 | list->on = 0; | ||
| 2735 | } | ||
| 2736 | |||
| 2737 | store_frame_param (f, Qfont_backend, active_drivers); | ||
| 2738 | |||
| 2739 | if (font) | ||
| 2740 | { | ||
| 2741 | Lisp_Object frame; | ||
| 2742 | |||
| 2743 | XSETFRAME (frame, f); | ||
| 2744 | x_set_font (f, Fframe_parameter (frame, Qfont), Qnil); | ||
| 2745 | ++face_change_count; | ||
| 2746 | ++windows_or_buffers_changed; | ||
| 2747 | } | ||
| 2748 | } | ||
| 2749 | |||
| 2750 | |||
| 2702 | Lisp_Object | 2751 | Lisp_Object |
| 2703 | font_at (c, pos, face, w, object) | 2752 | font_at (c, pos, face, w, object) |
| 2704 | int c; | 2753 | int c; |
| @@ -2954,42 +3003,49 @@ DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0, | |||
| 2954 | struct font_driver_list *driver_list = f->font_driver_list; | 3003 | struct font_driver_list *driver_list = f->font_driver_list; |
| 2955 | 3004 | ||
| 2956 | for (; driver_list; driver_list = driver_list->next) | 3005 | for (; driver_list; driver_list = driver_list->next) |
| 2957 | { | 3006 | if (driver_list->on) |
| 2958 | Lisp_Object cache = driver_list->driver->get_cache (frame); | 3007 | { |
| 2959 | Lisp_Object tail, elt; | 3008 | Lisp_Object cache = driver_list->driver->get_cache (frame); |
| 3009 | Lisp_Object tail, elt; | ||
| 2960 | 3010 | ||
| 2961 | for (tail = XCDR (cache); CONSP (tail); tail = XCDR (tail)) | 3011 | for (tail = XCDR (cache); CONSP (tail); tail = XCDR (tail)) |
| 2962 | { | 3012 | { |
| 2963 | elt = XCAR (tail); | 3013 | elt = XCAR (tail); |
| 2964 | if (CONSP (elt) && FONT_SPEC_P (XCAR (elt))) | 3014 | if (CONSP (elt) && FONT_SPEC_P (XCAR (elt))) |
| 2965 | { | 3015 | { |
| 2966 | Lisp_Object vec = XCDR (elt); | 3016 | Lisp_Object vec = XCDR (elt); |
| 2967 | int i; | 3017 | int i; |
| 2968 | 3018 | ||
| 2969 | for (i = 0; i < ASIZE (vec); i++) | 3019 | for (i = 0; i < ASIZE (vec); i++) |
| 2970 | { | 3020 | { |
| 2971 | Lisp_Object entity = AREF (vec, i); | 3021 | Lisp_Object entity = AREF (vec, i); |
| 2972 | Lisp_Object objlist = AREF (entity, FONT_OBJLIST_INDEX); | 3022 | |
| 2973 | 3023 | if (EQ (driver_list->driver->type, | |
| 2974 | for (; CONSP (objlist); objlist = XCDR (objlist)) | 3024 | AREF (entity, FONT_TYPE_INDEX))) |
| 2975 | { | 3025 | { |
| 2976 | Lisp_Object val = XCAR (objlist); | 3026 | Lisp_Object objlist |
| 2977 | struct Lisp_Save_Value *p = XSAVE_VALUE (val); | 3027 | = AREF (entity, FONT_OBJLIST_INDEX); |
| 2978 | struct font *font = p->pointer; | 3028 | |
| 2979 | 3029 | for (; CONSP (objlist); objlist = XCDR (objlist)) | |
| 2980 | xassert (font | 3030 | { |
| 2981 | && driver_list->driver == font->driver); | 3031 | Lisp_Object val = XCAR (objlist); |
| 2982 | driver_list->driver->close (f, font); | 3032 | struct Lisp_Save_Value *p = XSAVE_VALUE (val); |
| 2983 | p->pointer = NULL; | 3033 | struct font *font = p->pointer; |
| 2984 | p->integer = 0; | 3034 | |
| 2985 | } | 3035 | xassert (font && (driver_list->driver |
| 2986 | if (driver_list->driver->free_entity) | 3036 | == font->driver)); |
| 2987 | driver_list->driver->free_entity (entity); | 3037 | driver_list->driver->close (f, font); |
| 2988 | } | 3038 | p->pointer = NULL; |
| 2989 | } | 3039 | p->integer = 0; |
| 2990 | } | 3040 | } |
| 2991 | XSETCDR (cache, Qnil); | 3041 | if (driver_list->driver->free_entity) |
| 2992 | } | 3042 | driver_list->driver->free_entity (entity); |
| 3043 | } | ||
| 3044 | } | ||
| 3045 | } | ||
| 3046 | } | ||
| 3047 | XSETCDR (cache, Qnil); | ||
| 3048 | } | ||
| 2993 | } | 3049 | } |
| 2994 | 3050 | ||
| 2995 | return Qnil; | 3051 | return Qnil; |