diff options
Diffstat (limited to 'src/fontset.c')
-rw-r--r-- | src/fontset.c | 120 |
1 files changed, 48 insertions, 72 deletions
diff --git a/src/fontset.c b/src/fontset.c index d9aa99d05f5..c0303fa5a34 100644 --- a/src/fontset.c +++ b/src/fontset.c @@ -92,26 +92,27 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ range of characters in this fontset, but may be available in the default fontset. + A fontset has 8 extra slots. - A fontset has 9 extra slots. - - The 1st slot: the ID number of the fontset + The 1st slot: + base: the ID number of the fontset + realized: Likewise The 2nd slot: base: the name of the fontset realized: nil The 3rd slot: - base: nil - realized: the base fontset + base: the font name for ASCII characters + realized: nil The 4th slot: base: nil - realized: the frame that the fontset belongs to + realized: the base fontset The 5th slot: - base: the font name for ASCII characters - realized: nil + base: nil + realized: the frame that the fontset belongs to The 6th slot: base: nil @@ -120,15 +121,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ The 7th slot: base: nil - realized: Alist of font index vs the corresponding repertory - char-table. - - The 8th slot: - base: nil realized: If the base is not the default fontset, a fontset - realized from the default fontset, else nil. + realized from the default fontset, else nil. - The 9th slot: + The 8th slot: base: Same as element value (but for fallback fonts). realized: Likewise. @@ -156,11 +152,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /********** VARIABLES and FUNCTION PROTOTYPES **********/ -static Lisp_Object Qfontset; -static Lisp_Object Qfontset_info; -static Lisp_Object Qprepend, Qappend; -Lisp_Object Qlatin; - /* Vector containing all fontsets. */ static Lisp_Object Vfontset_table; @@ -209,27 +200,27 @@ set_fontset_name (Lisp_Object fontset, Lisp_Object name) set_char_table_extras (fontset, 1, name); } -#define FONTSET_ASCII(fontset) XCHAR_TABLE (fontset)->extras[4] +#define FONTSET_ASCII(fontset) XCHAR_TABLE (fontset)->extras[2] static void set_fontset_ascii (Lisp_Object fontset, Lisp_Object ascii) { - set_char_table_extras (fontset, 4, ascii); + set_char_table_extras (fontset, 2, ascii); } /* Access special values of (realized) FONTSET. */ -#define FONTSET_BASE(fontset) XCHAR_TABLE (fontset)->extras[2] +#define FONTSET_BASE(fontset) XCHAR_TABLE (fontset)->extras[3] static void set_fontset_base (Lisp_Object fontset, Lisp_Object base) { - set_char_table_extras (fontset, 2, base); + set_char_table_extras (fontset, 3, base); } -#define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[3] +#define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[4] static void set_fontset_frame (Lisp_Object fontset, Lisp_Object frame) { - set_char_table_extras (fontset, 3, frame); + set_char_table_extras (fontset, 4, frame); } #define FONTSET_NOFONT_FACE(fontset) XCHAR_TABLE (fontset)->extras[5] @@ -239,20 +230,20 @@ set_fontset_nofont_face (Lisp_Object fontset, Lisp_Object face) set_char_table_extras (fontset, 5, face); } -#define FONTSET_DEFAULT(fontset) XCHAR_TABLE (fontset)->extras[7] +#define FONTSET_DEFAULT(fontset) XCHAR_TABLE (fontset)->extras[6] static void set_fontset_default (Lisp_Object fontset, Lisp_Object def) { - set_char_table_extras (fontset, 7, def); + set_char_table_extras (fontset, 6, def); } /* For both base and realized fontset. */ -#define FONTSET_FALLBACK(fontset) XCHAR_TABLE (fontset)->extras[8] +#define FONTSET_FALLBACK(fontset) XCHAR_TABLE (fontset)->extras[7] static void set_fontset_fallback (Lisp_Object fontset, Lisp_Object fallback) { - set_char_table_extras (fontset, 8, fallback); + set_char_table_extras (fontset, 7, fallback); } #define BASE_FONTSET_P(fontset) (NILP (FONTSET_BASE (fontset))) @@ -358,16 +349,17 @@ fontset_add (Lisp_Object fontset, Lisp_Object range, Lisp_Object elt, Lisp_Objec from1 = from, to1 = to; args[idx] = char_table_ref_and_range (fontset, from, &from1, &to1); char_table_set_range (fontset, from, to1, - NILP (args[idx]) ? args[1 - idx] - : Fvconcat (2, args)); + (NILP (args[idx]) ? args[1 - idx] + : CALLMANY (Fvconcat, args))); from = to1 + 1; } while (from < to); } else { args[idx] = FONTSET_FALLBACK (fontset); - set_fontset_fallback - (fontset, NILP (args[idx]) ? args[1 - idx] : Fvconcat (2, args)); + set_fontset_fallback (fontset, + (NILP (args[idx]) ? args[1 - idx] + : CALLMANY (Fvconcat, args))); } } @@ -393,7 +385,7 @@ reorder_font_vector (Lisp_Object font_group, struct font *font) Lisp_Object vec, font_object; int size; int i; - bool score_changed = 0; + bool score_changed = false; if (font) XSETFONT (font_object, font); @@ -448,14 +440,15 @@ reorder_font_vector (Lisp_Object font_group, struct font *font) if (RFONT_DEF_SCORE (rfont_def) != score) { RFONT_DEF_SET_SCORE (rfont_def, score); - score_changed = 1; + score_changed = true; } } if (score_changed) qsort (XVECTOR (vec)->contents, size, word_size, fontset_compare_rfontdef); - XSETCAR (font_group, make_number (charset_ordered_list_tick)); + EMACS_INT low_tick_bits = charset_ordered_list_tick & MOST_POSITIVE_FIXNUM; + XSETCAR (font_group, make_number (low_tick_bits)); } /* Return a font-group (actually a cons (-1 . FONT-GROUP-VECTOR)) for @@ -852,21 +845,6 @@ fontset_ascii (int id) return elt; } -static void -free_realized_fontset (struct frame *f, Lisp_Object fontset) -{ -#if 0 - Lisp_Object tail; - - if (0) - for (tail = FONTSET_OBJLIST (fontset); CONSP (tail); tail = XCDR (tail)) - { - eassert (FONT_OBJECT_P (XCAR (tail))); - font_close_object (f, XCAR (tail)); - } -#endif -} - /* Free fontset of FACE defined on frame F. Called from free_realized_face. */ @@ -880,7 +858,6 @@ free_face_fontset (struct frame *f, struct face *face) return; eassert (! BASE_FONTSET_P (fontset)); eassert (f == XFRAME (FONTSET_FRAME (fontset))); - free_realized_fontset (f, fontset); ASET (Vfontset_table, face->fontset, Qnil); if (face->fontset < next_fontset_id) next_fontset_id = face->fontset; @@ -891,7 +868,6 @@ free_face_fontset (struct frame *f, struct face *face) fontset = AREF (Vfontset_table, id); eassert (!NILP (fontset) && ! BASE_FONTSET_P (fontset)); eassert (f == XFRAME (FONTSET_FRAME (fontset))); - free_realized_fontset (f, fontset); ASET (Vfontset_table, id, Qnil); if (id < next_fontset_id) next_fontset_id = face->fontset; @@ -1096,10 +1072,11 @@ fontset_pattern_regexp (Lisp_Object pattern) /* If PATTERN is not full XLFD we convert "*" to ".*". Otherwise we convert "*" to "[^-]*" which is much faster in regular expression matching. */ - if (ndashes < 14) - p1 = regex = alloca (SBYTES (pattern) + 2 * nstars + 2 * nescs + 1); - else - p1 = regex = alloca (SBYTES (pattern) + 5 * nstars + 2 * nescs + 1); + ptrdiff_t regexsize = (SBYTES (pattern) + + (ndashes < 14 ? 2 : 5) * nstars + + 2 * nescs + 1); + USE_SAFE_ALLOCA; + p1 = regex = SAFE_ALLOCA (regexsize); *p1++ = '^'; for (p0 = SDATA (pattern); *p0; p0++) @@ -1127,6 +1104,7 @@ fontset_pattern_regexp (Lisp_Object pattern) Vcached_fontset_data = Fcons (build_string (SSDATA (pattern)), build_string ((char *) regex)); + SAFE_FREE (); } return CACHED_FONTSET_REGEX; @@ -1455,12 +1433,8 @@ appended. By default, FONT-SPEC overrides the previous settings. */) } else if (STRINGP (font_spec)) { - Lisp_Object args[2]; - fontname = font_spec; - args[0] = QCname; - args[1] = font_spec; - font_spec = Ffont_spec (2, args); + font_spec = CALLN (Ffont_spec, QCname, fontname); } else if (FONT_SPEC_P (font_spec)) fontname = Ffont_xlfd_name (font_spec, Qnil); @@ -1477,8 +1451,8 @@ appended. By default, FONT-SPEC overrides the previous settings. */) registry = AREF (font_spec, FONT_REGISTRY_INDEX); if (! NILP (registry)) registry = Fdowncase (SYMBOL_NAME (registry)); - encoding = find_font_encoding (concat3 (family, build_string ("-"), - registry)); + AUTO_STRING (dash, "-"); + encoding = find_font_encoding (concat3 (family, dash, registry)); if (NILP (encoding)) encoding = Qascii; @@ -1590,7 +1564,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */) if (ascii_changed) { - Lisp_Object tail, fr, alist; + Lisp_Object tail, fr; int fontset_id = XINT (FONTSET_ID (fontset)); set_fontset_ascii (fontset, fontname); @@ -1613,8 +1587,8 @@ appended. By default, FONT-SPEC overrides the previous settings. */) if (! NILP (font_object)) { update_auto_fontset_alist (font_object, fontset); - alist = list1 (Fcons (Qfont, Fcons (name, font_object))); - Fmodify_frame_parameters (fr, alist); + AUTO_FRAME_ARG (arg, Qfont, Fcons (name, font_object)); + Fmodify_frame_parameters (fr, arg); } } } @@ -1854,7 +1828,7 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0, w = XWINDOW (window); f = XFRAME (w->frame); face_id = face_at_buffer_position (w, pos, &dummy, - pos + 100, 0, -1); + pos + 100, false, -1); } if (! CHAR_VALID_P (c)) return Qnil; @@ -1909,7 +1883,9 @@ format is the same as above. */) /* Recode fontsets realized on FRAME from the base fontset FONTSET in the table `realized'. */ - realized[0] = alloca (word_size * ASIZE (Vfontset_table)); + USE_SAFE_ALLOCA; + SAFE_ALLOCA_LISP (realized[0], 2 * ASIZE (Vfontset_table)); + realized[1] = realized[0] + ASIZE (Vfontset_table); for (i = j = 0; i < ASIZE (Vfontset_table); i++) { elt = FONTSET_FROM_ID (i); @@ -1920,7 +1896,6 @@ format is the same as above. */) } realized[0][j] = Qnil; - realized[1] = alloca (word_size * ASIZE (Vfontset_table)); for (i = j = 0; ! NILP (realized[0][i]); i++) { elt = FONTSET_DEFAULT (realized[0][i]); @@ -2012,6 +1987,7 @@ format is the same as above. */) break; } + SAFE_FREE (); return tables[0]; } @@ -2163,7 +2139,7 @@ void syms_of_fontset (void) { DEFSYM (Qfontset, "fontset"); - Fput (Qfontset, Qchar_table_extra_slots, make_number (9)); + Fput (Qfontset, Qchar_table_extra_slots, make_number (8)); DEFSYM (Qfontset_info, "fontset-info"); Fput (Qfontset_info, Qchar_table_extra_slots, make_number (1)); |