Hi, Eli, Many many thinks, your suggestion is really very very great. Now we can get the frame font width no matter it is default, remapped or rescaled. I updated the patch as you suggested, other changes also include in attachment: 1, remove "default_font_width" global variable, get font width from FRAME_PTR as you sugguested. 2, pass FRAME_PTR to every xftfont_info structure, we can use it anywhere. 3, add a feild "is_cjk" to "xftfont_info" structure, initialize it when xftfont_open, avoid call "is_cjk_font" many times when draw and extents calculation. Now, it works very well with font remapping, rescaling. 于 2012年04月12日 22:27, Eli Zaretskii 写道: >> Date: Thu, 12 Apr 2012 19:18:39 +0800 >> From: 黄建忠 >> CC: kanru@kanru.info, emacs-devel@gnu.org >> >>>> 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! > >