comparison src/font.c @ 90549:5dab62a4573c

(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.
author Kenichi Handa <handa@m17n.org>
date Wed, 26 Jul 2006 01:19:04 +0000
parents b7130e76c2f9
children e56a86aa94cc
comparison
equal deleted inserted replaced
90548:7cc05972a79e 90549:5dab62a4573c
1240 int point_size; 1240 int point_size;
1241 int dpi, spacing, scalable; 1241 int dpi, spacing, scalable;
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))
1249 len += SBYTES (SYMBOL_NAME (val)); 1249 len += SBYTES (SYMBOL_NAME (val));
1250 1250
2245 2245
2246 xassert (ASIZE (spec) == FONT_SPEC_MAX); 2246 xassert (ASIZE (spec) == FONT_SPEC_MAX);
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;
2254 Lisp_Object val; 2255 Lisp_Object val;
2255 2256
2643 } 2644 }
2644 2645
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
2655 implementations must call this function in its syms_of_XXXX 2656 implementations must call this function in its syms_of_XXXX
2656 (e.g. syms_of_xfont). */ 2657 (e.g. syms_of_xfont). */
2670 for (prev = NULL, list = root; list; prev = list, list = list->next) 2671 for (prev = NULL, list = root; list; prev = list, list = list->next)
2671 if (list->driver->type == driver->type) 2672 if (list->driver->type == driver->type)
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)
2678 prev->next = list; 2680 prev->next = list;
2679 else if (f) 2681 else if (f)
2696 2698
2697 free (f->font_driver_list); 2699 free (f->font_driver_list);
2698 f->font_driver_list = next; 2700 f->font_driver_list = next;
2699 } 2701 }
2700 } 2702 }
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
2701 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;
2705 EMACS_INT pos; 2754 EMACS_INT pos;
2952 { 3001 {
2953 FRAME_PTR f = XFRAME (frame); 3002 FRAME_PTR f = XFRAME (frame);
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;
2996 } 3052 }
2997 3053