emacs-devel
[Top][All Lists]
Advanced

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

Re: A patch for enforcing double-width CJK character display


From: Eli Zaretskii
Subject: Re: A patch for enforcing double-width CJK character display
Date: Thu, 12 Apr 2012 17:27:18 +0300

> Date: Thu, 12 Apr 2012 19:18:39 +0800
> From: 黄建忠 <address@hidden>
> CC: address@hidden, address@hidden
> 
> >> Can anybody provide a clue how to catch the new width of default font
> >> via FRAME_PTR when scale happened?
> > I don't think there is a way to do that, if all you have is the frame
> > pointer.  text-scale-mode does not modify the frame's default font, it
> > remaps the 'default' face to another face which specifies a larger or
> > a smaller font.  So the way to find the width of the font after
> > scaling is to get hold of the font itself, or of the face to which
> > 'default' was remapped.  Then you can use FONT_WIDTH, I think (but I
> > didn't test this).
> I can get the default font(the first font loaded when frame be 
> initialized) via FRAME_FONT, it's great that it can not be changed after 
> first font loaded.
> But I still can not get the current width after scale, since the props 
> of FRAME_FONT also not be changed.
> [...]
> I noticed there were some global Lisp_Object such as 
> "f_Vface_font_rescale_alist"/"f_Vface_remapping_alist"/"f_Vface_new_frame_defaults",
>  
> maybe I can use them, Hope so.

This will retrieve the numerical ID of the default face on frame F:

  int id = lookup_basic_face (F, DEFAULT_FACE_ID);

lookup_basic_face consults f_Vface_remapping_alist.  If the value of
id above is different from DEFAULT_FACE_ID, that means the default
face was remapped.  Then you can get the remapped face like this:

  struct face *face = FACE_FROM_ID (F, id);

Now the font of the face is available as

  struct font *font = face->font;

And I think FONT_WIDTH (font) will give you the width you want to use
instead of FRAME_COLUMN_WIDTH.

Again, this is 100% untested.  Good luck!




reply via email to

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