diff options
Diffstat (limited to 'src/font.c')
-rw-r--r-- | src/font.c | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/src/font.c b/src/font.c index b85956f225c..36e71669453 100644 --- a/src/font.c +++ b/src/font.c @@ -23,6 +23,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <float.h> #include <stdio.h> +#include <stdlib.h> #include <c-ctype.h> @@ -131,7 +132,7 @@ static struct font_driver_list *font_driver_list; /* Used to catch bogus pointers in font objects. */ bool -valid_font_driver (struct font_driver *drv) +valid_font_driver (struct font_driver const *drv) { Lisp_Object tail, frame; struct font_driver_list *fdl; @@ -264,14 +265,13 @@ font_intern_prop (const char *str, ptrdiff_t len, bool force_symbol) break; if (i == len) { - EMACS_INT n; - i = 0; - for (n = 0; (n += str[i++] - '0') <= MOST_POSITIVE_FIXNUM; n *= 10) + for (EMACS_INT n = 0; + (n += str[i++] - '0') <= MOST_POSITIVE_FIXNUM; ) { if (i == len) return make_number (n); - if (MOST_POSITIVE_FIXNUM / 10 < n) + if (INT_MULTIPLY_WRAPV (n, 10, &n)) break; } @@ -1771,7 +1771,8 @@ font_parse_family_registry (Lisp_Object family, Lisp_Object registry, Lisp_Objec p1 = strchr (p0, '-'); if (! p1) { - AUTO_STRING (extra, (&"*-*"[len && p0[len - 1] == '*'])); + bool asterisk = len && p0[len - 1] == '*'; + AUTO_STRING_WITH_LEN (extra, &"*-*"[asterisk], 3 - asterisk); registry = concat2 (registry, extra); } registry = Fdowncase (registry); @@ -2233,7 +2234,8 @@ font_sort_entities (Lisp_Object list, Lisp_Object prefer, struct font_sort_data *data; unsigned best_score; Lisp_Object best_entity; - Lisp_Object tail, vec IF_LINT (= Qnil); + Lisp_Object tail; + Lisp_Object vec UNINIT; USE_SAFE_ALLOCA; for (i = FONT_WEIGHT_INDEX; i <= FONT_AVGWIDTH_INDEX; i++) @@ -2541,14 +2543,11 @@ font_match_p (Lisp_Object spec, Lisp_Object font) is a number frames sharing this cache, and FONT-CACHE-DATA is a cons (FONT-SPEC . [FONT-ENTITY ...]). */ -static void font_prepare_cache (struct frame *, struct font_driver *); -static void font_finish_cache (struct frame *, struct font_driver *); -static Lisp_Object font_get_cache (struct frame *, struct font_driver *); static void font_clear_cache (struct frame *, Lisp_Object, - struct font_driver *); + struct font_driver const *); static void -font_prepare_cache (struct frame *f, struct font_driver *driver) +font_prepare_cache (struct frame *f, struct font_driver const *driver) { Lisp_Object cache, val; @@ -2570,7 +2569,7 @@ font_prepare_cache (struct frame *f, struct font_driver *driver) static void -font_finish_cache (struct frame *f, struct font_driver *driver) +font_finish_cache (struct frame *f, struct font_driver const *driver) { Lisp_Object cache, val, tmp; @@ -2591,7 +2590,7 @@ font_finish_cache (struct frame *f, struct font_driver *driver) static Lisp_Object -font_get_cache (struct frame *f, struct font_driver *driver) +font_get_cache (struct frame *f, struct font_driver const *driver) { Lisp_Object val = driver->get_cache (f); Lisp_Object type = driver->type; @@ -2606,7 +2605,8 @@ font_get_cache (struct frame *f, struct font_driver *driver) static void -font_clear_cache (struct frame *f, Lisp_Object cache, struct font_driver *driver) +font_clear_cache (struct frame *f, Lisp_Object cache, + struct font_driver const *driver) { Lisp_Object tail, elt; Lisp_Object entity; @@ -2861,7 +2861,7 @@ font_open_entity (struct frame *f, Lisp_Object entity, int pixel_size) struct font_driver_list *driver_list; Lisp_Object objlist, size, val, font_object; struct font *font; - int min_width, height, psize; + int height, psize; eassert (FONT_ENTITY_P (entity)); size = AREF (entity, FONT_SIZE_INDEX); @@ -2905,10 +2905,12 @@ font_open_entity (struct frame *f, Lisp_Object entity, int pixel_size) Fcons (font_object, AREF (entity, FONT_OBJLIST_INDEX))); font = XFONT_OBJECT (font_object); - min_width = (font->min_width ? font->min_width - : font->average_width ? font->average_width - : font->space_width ? font->space_width - : 1); +#ifdef HAVE_WINDOW_SYSTEM + int min_width = (font->min_width ? font->min_width + : font->average_width ? font->average_width + : font->space_width ? font->space_width + : 1); +#endif int font_ascent, font_descent; get_font_ascent_descent (font, &font_ascent, &font_descent); @@ -3459,7 +3461,7 @@ font_open_by_name (struct frame *f, Lisp_Object name) (e.g. syms_of_xfont). */ void -register_font_driver (struct font_driver *driver, struct frame *f) +register_font_driver (struct font_driver const *driver, struct frame *f) { struct font_driver_list *root = f ? f->font_driver_list : font_driver_list; struct font_driver_list *prev, *list; @@ -3520,7 +3522,7 @@ font_update_drivers (struct frame *f, Lisp_Object new_drivers) drivers. */ for (list = f->font_driver_list; list; list = list->next) { - struct font_driver *driver = list->driver; + struct font_driver const *driver = list->driver; if ((EQ (new_drivers, Qt) || ! NILP (Fmemq (driver->type, new_drivers))) != list->on) { @@ -3583,7 +3585,7 @@ font_update_drivers (struct frame *f, Lisp_Object new_drivers) and then use it under w32 or ns. */ for (list = f->font_driver_list; list; list = list->next) { - struct font_driver *driver = list->driver; + struct font_driver const *driver = list->driver; eassert (! list->on); if (! driver->start_for_frame || driver->start_for_frame (f) == 0) @@ -5271,6 +5273,16 @@ font_deferred_log (const char *action, Lisp_Object arg, Lisp_Object result) } void +font_drop_xrender_surfaces (struct frame *f) +{ + struct font_driver_list *list; + + for (list = f->font_driver_list; list; list = list->next) + if (list->on && list->driver->drop_xrender_surfaces) + list->driver->drop_xrender_surfaces (f); +} + +void syms_of_font (void) { sort_shift_bits[FONT_TYPE_INDEX] = 0; @@ -5403,19 +5415,19 @@ Each element has the form: [NUMERIC-VALUE SYMBOLIC-NAME ALIAS-NAME ...] NUMERIC-VALUE is an integer, and SYMBOLIC-NAME and ALIAS-NAME are symbols. */); Vfont_weight_table = BUILD_STYLE_TABLE (weight_table); - XSYMBOL (intern_c_string ("font-weight-table"))->constant = 1; + make_symbol_constant (intern_c_string ("font-weight-table")); DEFVAR_LISP_NOPRO ("font-slant-table", Vfont_slant_table, doc: /* Vector of font slant symbols vs the corresponding numeric values. See `font-weight-table' for the format of the vector. */); Vfont_slant_table = BUILD_STYLE_TABLE (slant_table); - XSYMBOL (intern_c_string ("font-slant-table"))->constant = 1; + make_symbol_constant (intern_c_string ("font-slant-table")); DEFVAR_LISP_NOPRO ("font-width-table", Vfont_width_table, doc: /* Alist of font width symbols vs the corresponding numeric values. See `font-weight-table' for the format of the vector. */); Vfont_width_table = BUILD_STYLE_TABLE (width_table); - XSYMBOL (intern_c_string ("font-width-table"))->constant = 1; + make_symbol_constant (intern_c_string ("font-width-table")); staticpro (&font_style_table); font_style_table = make_uninit_vector (3); |