From: Dmitry Antipov Date: Tue, 13 Aug 2013 08:18:11 +0000 (+0400) Subject: * font.c (clear_font_cache): New function, stripped from... X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1686^2~287 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a45543bc75e845c9217130c65ddd00a81c18ffd1;p=emacs.git * font.c (clear_font_cache): New function, stripped from... (Fclear_font_cache): ...here, which now uses the function above. Adjust comment. * font.h (clear_font_cache): Add prototype. * xfaces.c (clear_face_cache): Use clear_font_cache. --- diff --git a/src/ChangeLog b/src/ChangeLog index 32b0eb209c9..74af248575a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2013-08-13 Dmitry Antipov + + * font.c (clear_font_cache): New function, stripped from... + (Fclear_font_cache): ...here, which now uses the function + above. Adjust comment. + * font.h (clear_font_cache): Add prototype. + * xfaces.c (clear_face_cache): Use clear_font_cache. + 2013-08-13 Dmitry Antipov * window.c (Fset_window_start): Compare `w', not `window' because diff --git a/src/font.c b/src/font.c index 073487b540d..6a8262623dc 100644 --- a/src/font.c +++ b/src/font.c @@ -4226,36 +4226,38 @@ the consecutive wildcards are folded into one. */) return make_string (name, namelen); } +void +clear_font_cache (struct frame *f) +{ + struct font_driver_list *driver_list = f->font_driver_list; + + for (; driver_list; driver_list = driver_list->next) + if (driver_list->on) + { + Lisp_Object val, tmp, cache = driver_list->driver->get_cache (f); + + val = XCDR (cache); + while (! NILP (val) + && ! EQ (XCAR (XCAR (val)), driver_list->driver->type)) + val = XCDR (val); + eassert (! NILP (val)); + tmp = XCDR (XCAR (val)); + if (XINT (XCAR (tmp)) == 0) + { + font_clear_cache (f, XCAR (val), driver_list->driver); + XSETCDR (cache, XCDR (val)); + } + } +} + DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0, - doc: /* Clear font cache. */) + doc: /* Clear font cache of each frame. */) (void) { Lisp_Object list, frame; FOR_EACH_FRAME (list, frame) - { - struct frame *f = XFRAME (frame); - struct font_driver_list *driver_list = f->font_driver_list; - - for (; driver_list; driver_list = driver_list->next) - if (driver_list->on) - { - Lisp_Object cache = driver_list->driver->get_cache (f); - Lisp_Object val, tmp; - - val = XCDR (cache); - while (! NILP (val) - && ! EQ (XCAR (XCAR (val)), driver_list->driver->type)) - val = XCDR (val); - eassert (! NILP (val)); - tmp = XCDR (XCAR (val)); - if (XINT (XCAR (tmp)) == 0) - { - font_clear_cache (f, XCAR (val), driver_list->driver); - XSETCDR (cache, XCDR (val)); - } - } - } + clear_font_cache (XFRAME (frame)); return Qnil; } diff --git a/src/font.h b/src/font.h index daeb320c1ab..adb4a582fd8 100644 --- a/src/font.h +++ b/src/font.h @@ -760,6 +760,7 @@ extern Lisp_Object font_load_for_lface (struct frame *f, Lisp_Object *lface, Lisp_Object spec); extern void font_prepare_for_face (struct frame *f, struct face *face); extern void font_done_for_face (struct frame *f, struct face *face); +extern void clear_font_cache (struct frame *); extern Lisp_Object font_open_by_spec (struct frame *f, Lisp_Object spec); extern Lisp_Object font_open_by_name (struct frame *f, Lisp_Object name); diff --git a/src/xfaces.c b/src/xfaces.c index acd2d2b1116..b76f9d24180 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -759,11 +759,6 @@ clear_face_cache (int clear_fonts_p) if (clear_fonts_p || ++clear_font_table_count == CLEAR_FONT_TABLE_COUNT) { -#if 0 - /* Not yet implemented. */ - clear_font_cache (frame); -#endif - /* From time to time see if we can unload some fonts. This also frees all realized faces on all frames. Fonts needed by faces will be loaded again when faces are realized again. */ @@ -774,7 +769,10 @@ clear_face_cache (int clear_fonts_p) struct frame *f = XFRAME (frame); if (FRAME_WINDOW_P (f) && FRAME_X_DISPLAY_INFO (f)->n_fonts > CLEAR_FONT_TABLE_NFONTS) - free_all_realized_faces (frame); + { + clear_font_cache (f); + free_all_realized_faces (frame); + } } } else