emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

`set-fontset-font' and ascii characters


From: Oliver Scholz
Subject: `set-fontset-font' and ascii characters
Date: Sun, 27 Apr 2003 12:22:15 +0200
User-agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.3.50 (gnu/linux)

Is there any special reason why `set-fontset-font' should raise an
error, if CHARACTER specifies a single byte char? The patch below
seems to work, but I may be missing something.

    Oliver

*** fontset.c.~1.73.~   Fri Jan 17 09:10:00 2003
--- fontset.c   Sun Apr 27 12:05:48 2003
***************
*** 992,997 ****
--- 992,999 ----
    int from, to;
    int id;
    Lisp_Object family, registry;
+   int sbyte_change = 0; /* Flag indicating that CHARACTER specifies
+                          the `ascii' charset. */
  
    fontset = check_fontset_name (name);
  
***************
*** 1007,1013 ****
        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))
      {
--- 1009,1015 ----
        error ("Character range should be by non-generic characters.");
        if (!NILP (name)
          && (SINGLE_BYTE_CHAR_P (from) || SINGLE_BYTE_CHAR_P (to)))
!       sbyte_change = 1;
      }
    else if (SYMBOLP (character))
      {
***************
*** 1026,1038 ****
    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))
--- 1028,1040 ----
    if (!char_valid_p (from, 1))
      invalid_character (from);
    if (SINGLE_BYTE_CHAR_P (from))
!     sbyte_change = 1;
    if (from < to)
      {
        if (!char_valid_p (to, 1))
        invalid_character (to);
        if (SINGLE_BYTE_CHAR_P (to))
!       sbyte_change = 1;
      }
  
    if (STRINGP (fontname))
***************
*** 1067,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;
  }
--- 1069,1100 ----
      FONTSET_SET (fontset, from, elt);
    Foptimize_char_table (fontset);
  
!   if (sbyte_change)
!     {
!       /* The ascii charset needs a special treatment in order to make
!        sure that it is redisplayed in the correct font. The
!        following (stolen from `internal-set-lisp-face-attribute')
!        makes sure that the next call to init_iterator will free all
!        realized faces. */
!       ++face_change_count;
!       ++windows_or_buffers_changed;
!     } else {
!     /* 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;
  }


-- 
8 Floréal an 211 de la Révolution
Liberté, Egalité, Fraternité!





reply via email to

[Prev in Thread] Current Thread [Next in Thread]