unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Oliver Scholz <alkibiades@gmx.de>
Cc: emacs-devel@gnu.org
Subject: Re: `set-fontset-font' and ascii characters
Date: Thu, 01 May 2003 19:48:37 +0200	[thread overview]
Message-ID: <87u1cezhlu.fsf@ID-87814.user.dfncis.de> (raw)
In-Reply-To: <200305010810.RAA15007@etlken.m17n.org> (Kenichi Handa's message of "Thu, 1 May 2003 17:10:49 +0900 (JST)")

[-- Attachment #1: Type: text/plain, Size: 1493 bytes --]

Kenichi Handa <handa@m17n.org> writes:

> In article <87he8kutns.fsf@ID-87814.user.dfncis.de>, Oliver Scholz <alkibiades@gmx.de> writes:
>> 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.
>
> Thank you for working on it.
>
> If we change the ASCII font in the fontset of the default
> face, I think it should have the same effect as changing the
> font of the default face (e.g. changing the font size
> results in chaning the frame size).  The reason I inhibitted
> changing ASCII font in a fontset is that it seems difficult
> to achieve that effect (or at least I didn't know how to do
> that when I wrote the code).  Does you change pay attetion
> to that?
[...]

It doesn't, sorry. I didn't realize that this could be an issue,
because I use an window manager which keeps frames full-size anyways.

But I spent the afternoon browsing the sources for a solution that
does. The two patches below seem to make it work (only slightly
tested).

Now, if an ASCII font was changed, Fset_fontset_font checks all frames
whether FONTSET is their frame fontset and forces a resizing of all
frames that have. This is done by the new function
x_new_fontset_force, which is like x_new_fontset, except that it does
its works even if new fontset = old fontset. (This is done by
factoring out a new function x_set_fontset_internal out of x_set_fontset.)

    Oliver


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fontset.diff --]
[-- Type: text/x-patch, Size: 4332 bytes --]

*** fontset.c.~1.76.~	Thu Feb 20 15:13:04 2003
--- fontset.c	Thu May  1 19:31:18 2003
***************
*** 36,41 ****
--- 36,42 ----
  #include "dispextern.h"
  #include "fontset.h"
  #include "window.h"
+ #include "xterm.h"
  
  #ifdef FONTSET_DEBUG
  #undef xassert
***************
*** 993,998 ****
--- 994,1001 ----
    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);
  
***************
*** 1008,1014 ****
  	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))
      {
--- 1011,1017 ----
  	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))
      {
***************
*** 1027,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))
--- 1030,1042 ----
    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))
***************
*** 1068,1089 ****
      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;
  }
--- 1071,1119 ----
      FONTSET_SET (fontset, from, elt);
    Foptimize_char_table (fontset);
  
!   /* Make sure that Emacs displays all faces with the correct
!      font. The ascii charset needs a special treatment.*/
!   if (sbyte_change)
!     {
!       Lisp_Object fr_list;
!       FRAME_PTR frpt;
!       
!       /* Check all frames whether they have FONTSET as the fontset for
! 	 the default face. If so, make sure that Emacs changes the
! 	 size of the frame accordingly. */
!       for (fr_list = Vframe_list;
! 	   CONSP (fr_list);
! 	   fr_list = XCDR (fr_list))
  	{
! 	  frpt = XFRAME (XCAR (fr_list));
! 	  if (FONTSET_ID (fontset) == FRAME_FONTSET (frpt))
! 	    {
! 	      Lisp_Object fpvalue = get_frame_param (frpt, Qfont);
! 	      x_new_fontset_force (frpt, SDATA (fpvalue));
! 	    }
  	}
!       /* Make sure that the next call to init_iterator will free all
! 	 realized faces (stolen from
! 	 `internal-set-lisp-face-attribute'). */
!       ++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;
  }

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: xterm.diff --]
[-- Type: text/x-patch, Size: 2109 bytes --]

*** xterm.c.~1.790.~	Wed Apr  9 18:44:46 2003
--- xterm.c	Thu May  1 19:30:51 2003
***************
*** 7937,7943 ****
       char *fontsetname;
  {
    int fontset = fs_query_fontset (build_string (fontsetname), 0);
-   Lisp_Object result;
  
    if (fontset < 0)
      return Qnil;
--- 7937,7942 ----
***************
*** 7947,7957 ****
         to do.  */
      return fontset_name (fontset);
  
!   result = x_new_font (f, (SDATA (fontset_ascii (fontset))));
  
    if (!STRINGP (result))
      /* Can't load ASCII font.  */
!     return Qnil;
  
    /* Since x_new_font doesn't update any fontset information, do it now.  */
    f->output_data.x->fontset = fontset;
--- 7946,7986 ----
         to do.  */
      return fontset_name (fontset);
  
!   if (x_new_fontset_internal (f, fontset) == 0)
!     return build_string (fontsetname);
!   else return Qnil;
! }
! 
! 
! /* Like x_new_fontset, but don't check wheter the fontset is already
!    set in the frame. */
! 
! Lisp_Object
! x_new_fontset_force (f, fontsetname)
!      struct frame *f;
!      char *fontsetname;
! {
!   int fontset = fs_query_fontset (build_string (fontsetname), 0);
! 
!   if (fontset < 0)
!     return Qnil;
! 
!   if (x_new_fontset_internal (f, fontset) == 0)
!     return build_string (fontsetname);
!   else return Qnil;
! }
! 
! int
! x_new_fontset_internal (f, fontset)
!      struct frame *f;
!      int fontset;
! {
!   Lisp_Object result
!     = x_new_font (f, (SDATA (fontset_ascii (fontset))));
  
    if (!STRINGP (result))
      /* Can't load ASCII font.  */
!     return 1;
  
    /* Since x_new_font doesn't update any fontset information, do it now.  */
    f->output_data.x->fontset = fontset;
***************
*** 7961,7968 ****
        && (FRAME_XIC_STYLE (f) & (XIMPreeditPosition | XIMStatusArea)))
      xic_set_xfontset (f, SDATA (fontset_ascii (fontset)));
  #endif
! 
!   return build_string (fontsetname);
  }
  
  \f
--- 7990,7996 ----
        && (FRAME_XIC_STYLE (f) & (XIMPreeditPosition | XIMStatusArea)))
      xic_set_xfontset (f, SDATA (fontset_ascii (fontset)));
  #endif
!   return 0;
  }
  
  \f

[-- Attachment #4: Type: text/plain, Size: 243 bytes --]



-- 
Oliver Scholz               12 Floréal an 211 de la Révolution
Taunusstr. 25               Liberté, Egalité, Fraternité!
60329 Frankfurt a. M.       http://www.jungdemokratenhessen.de
Tel. (069) 97 40 99 42      http://www.jdjl.org

[-- Attachment #5: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel

  reply	other threads:[~2003-05-01 17:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-27 10:22 `set-fontset-font' and ascii characters Oliver Scholz
2003-05-01  8:10 ` Kenichi Handa
2003-05-01 17:48   ` Oliver Scholz [this message]
2003-05-01 20:01     ` Oliver Scholz
2003-05-01 23:53       ` Kenichi Handa
2003-05-02  0:06         ` Kenichi Handa
2003-05-02  0:39         ` Oliver Scholz
2003-05-02  1:05           ` Kenichi Handa
2003-05-02 23:16             ` Oliver Scholz
2003-05-03  2:48               ` Kenichi Handa
2003-05-03 22:24                 ` Oliver Scholz
2003-05-05  8:33                   ` Kenichi Handa
2003-05-06 13:48                     ` Oliver Scholz
2003-05-07  1:12                       ` Kenichi Handa
2003-05-25 12:17                         ` Oliver Scholz
2003-06-10  2:16                           ` Kenichi Handa
2003-06-10  2:47                             ` Stefan Monnier
2003-05-02  7:06   ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87u1cezhlu.fsf@ID-87814.user.dfncis.de \
    --to=alkibiades@gmx.de \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).