*** fontset.c.~1.76.~ Thu Feb 20 15:13:04 2003 --- fontset.c Sat May 3 01:09:28 2003 *************** *** 939,958 **** return Qnil; } - - /* Clear all elements of FONTSET for multibyte characters. */ - - static void - clear_fontset_elements (fontset) - Lisp_Object fontset; - { - int i; - - for (i = CHAR_TABLE_SINGLE_BYTE_SLOTS; i < CHAR_TABLE_ORDINARY_SLOTS; i++) - XCHAR_TABLE (fontset)->contents[i] = Qnil; - } - - /* Check validity of NAME as a fontset name and return the corresponding fontset. If not valid, signal an error. If NAME is nil, return Vdefault_fontset. */ --- 939,944 ---- *************** *** 973,978 **** --- 959,967 ---- return FONTSET_FROM_ID (id); } + extern Lisp_Object QCfont; + extern Lisp_Object Vface_new_frame_defaults; + DEFUN ("set-fontset-font", Fset_fontset_font, Sset_fontset_font, 3, 4, 0, doc: /* Modify fontset NAME to use FONTNAME for CHARACTER. *************** *** 993,999 **** --- 982,991 ---- int from, to; int id; Lisp_Object family, registry; + Lisp_Object lf_fnt, lfaces, fontset_name; + + fontset_name = Fquery_fontset (name, Qnil); fontset = check_fontset_name (name); if (CONSP (character)) *************** *** 1006,1014 **** to = XINT (XCDR (character)); if (!char_valid_p (from, 0) || !char_valid_p (to, 0)) error ("Character range should be by non-generic characters."); - if (!NILP (name) - && (SINGLE_BYTE_CHAR_P (from) || SINGLE_BYTE_CHAR_P (to))) - error ("Can't change font for a single byte character"); } else if (SYMBOLP (character)) { --- 998,1003 ---- *************** *** 1026,1039 **** } if (!char_valid_p (from, 1)) invalid_character (from); - if (SINGLE_BYTE_CHAR_P (from)) - error ("Can't change font for a single byte character"); if (from < to) { if (!char_valid_p (to, 1)) invalid_character (to); - if (SINGLE_BYTE_CHAR_P (to)) - error ("Can't change font for a single byte character"); } if (STRINGP (fontname)) --- 1015,1024 ---- *************** *** 1068,1088 **** FONTSET_SET (fontset, from, elt); Foptimize_char_table (fontset); ! /* If there's a realized fontset REALIZED whose parent is FONTSET, ! clear all the elements of REALIZED and free all multibyte faces ! whose fontset is REALIZED. This way, the specified character(s) ! are surely redisplayed by a correct font. */ ! for (id = 0; id < ASIZE (Vfontset_table); id++) ! { ! realized = AREF (Vfontset_table, id); ! if (!NILP (realized) ! && !BASE_FONTSET_P (realized) ! && EQ (FONTSET_BASE (realized), fontset)) ! { ! FRAME_PTR f = XFRAME (FONTSET_FRAME (realized)); ! clear_fontset_elements (realized); ! free_realized_multibyte_face (f, id); ! } } return Qnil; --- 1053,1082 ---- FONTSET_SET (fontset, from, elt); Foptimize_char_table (fontset); ! /* If the fontset is already used in a face, then we need to update ! the display accordingly. ! ! This is done by calling Finternal_set_lisp_face. To find the ! faces which we need to update this way, we loop through all the ! faces declared in Vface_new_frame_alist and check each face ! whether FONTSET_NAME is specified as its fontset. Each element in ! Vface_new_frame_alist a cons cell with the symbol for the face as ! its car and an LFACE (a Lisp vector containing the face ! specification) as its cdr. */ ! ! for (lfaces = Vface_new_frame_defaults; ! CONSP (lfaces); ! lfaces = XCDR (lfaces)) ! { ! /* Set lf_fnt to the font or fontset specified for the current ! LFACE. */ ! lf_fnt = AREF (XCDR (XCAR (lfaces)), LFACE_FONT_INDEX); ! /* We call Fquery_fontset, so we are not puzzled by alias names, ! which may be used in LFACE. */ ! if (STRINGP (lf_fnt) && ! !NILP (Fequal (fontset_name, Fquery_fontset (lf_fnt, Qnil)))) ! Finternal_set_lisp_face_attribute ! ((XCAR (XCAR (lfaces))), QCfont, fontset_name, 0); } return Qnil;