Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 592408 - [RHEL6 snapshot 2] emacs has incorrect window size when using IPA Gothic font
Summary: [RHEL6 snapshot 2] emacs has incorrect window size when using IPA Gothic font
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: emacs
Version: 6.0
Hardware: All
OS: Linux
medium
high
Target Milestone: rc
: ---
Assignee: Radek Lat
QA Contact: desktop-bugs@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-05-14 19:38 UTC by Alan Matsuoka
Modified: 2018-10-27 12:05 UTC (History)
8 users (show)

Fixed In Version: emacs-23.1-19.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-11-10 20:21:22 UTC
Target Upstream Version:


Attachments (Terms of Use)
emacs2.png (deleted)
2010-05-14 19:40 UTC, Alan Matsuoka
no flags Details
sosreport-t120ae1.885233-20100514114519-122f.tar.bz2 (deleted)
2010-05-14 19:41 UTC, Alan Matsuoka
no flags Details
Emacs and Japanese characters (deleted)
2010-05-18 09:37 UTC, Karel Klíč
no flags Details
Correct size (deleted)
2010-08-05 11:12 UTC, Radek Lat
no flags Details

Description Alan Matsuoka 2010-05-14 19:38:57 UTC
1. Summary:
 emacs has incorrect window size when using IPA Gothic font

2. Description of problem:
 When using emacs with IPA Gothic font, emacs will have incorrect
 window size.  An 80x31 emacs window can actually display 145
 characters per line.
Note:
 I am using 003.02-1 package from Snapshot 2 for the IPA fonts, which
 fixes a problem with the spacing between characters in the 003.01-4.1
 package from RHEL6 beta 1.

3. Version-Release number of selected component (if applicable):
 ipa-pgothic-fonts-003.02-1.el6.noarch
 ipa-pmincho-fonts-003.02-1.el6.noarch
 ipa-gothic-fonts-003.02-1.el6.noarch
 ipa-mincho-fonts-003.02-1.el6.noarch

4. How reproducible:
 Always

5. Steps to Reproduce:
 Start emacs
 Select Options -> Set Default Font
 Choose Family: IPAGothic, Size: 8

6. Actual results:
 A wide window capable of displaying 145 characters per line appears.
 The size of the window is shown when resizing the emacs window.

7. Expected results:
 The window should be wide enough to display 80 characters.

8. Hardware info:
 This issue is hardware independent.

9. Business impact:
 Users will not be able to view full JIS2004 characters.

10. Additional info:
 Attached is a screenshot of emacs

Comment 1 Alan Matsuoka 2010-05-14 19:40:24 UTC
Created attachment 414144 [details]
emacs2.png

Comment 2 Alan Matsuoka 2010-05-14 19:41:33 UTC
Created attachment 414145 [details]
sosreport-t120ae1.885233-20100514114519-122f.tar.bz2

Comment 5 Karel Klíč 2010-05-18 09:37:37 UTC
Created attachment 414785 [details]
Emacs and Japanese characters

Hi Furuta-san,

It seems that setting the IPA Gothic font stretches the Emacs window to display 80 Japanese characters. The width of 80 Japanese characters corresponds to approx. 145 Latin characters in this case.

It makes sense to me that setting a Japanese font adjusts the window width for Japanese characters.

What do you think about it?

Comment 6 Issue Tracker 2010-05-18 13:35:23 UTC
Event posted on 05-18-2010 08:16pm JST by tatsu@ab.jp.nec.com

> It seems that setting the IPA Gothic font stretches the Emacs window to
display 80 Japanese characters. > The width of 80 Japanese characters
corresponds to approx. 145 Latin characters in this case.
>
> It makes sense to me that setting a Japanese font adjusts the window
width for Japanese characters.

Other CJK fonts behave differently, so I don't think this is the intended
behavior.

VL Gothic: Japanese
AR PL UMing CN: Chinese
Undotum: Korean



This event sent from IssueTracker by mfuruta@redhat.com 
 issue 885233

Comment 7 Masaki Furuta 2010-05-18 13:40:00 UTC
Hi  Karel Klíč-san,

(In reply to comment #5)
> Created an attachment (id=414785) [details]
> Emacs and Japanese characters
> 
> Hi Furuta-san,
> 
> It seems that setting the IPA Gothic font stretches the Emacs window to display
> 80 Japanese characters. The width of 80 Japanese characters corresponds to
> approx. 145 Latin characters in this case.
> 
> It makes sense to me that setting a Japanese font adjusts the window width for
> Japanese characters.
> 
> What do you think about it?    

I've forwarded feedback by Tatsukawa-san from NEC.
According to report, that seems not be intended behaviour and I also agree with that.

Could you please check it?

Thank you in advance.
Best Regards,

Masaki Furuta

Comment 8 Karel Klíč 2010-05-19 11:02:40 UTC
Relevant source code is in file src/xterm.c, function x_new_font():
FRAME_COLUMN_WIDTH (f) = font->average_width;

IPA Gothic reports average_width 16
VL Gothic 8
DejaVu Sans Mono 10
UnDotum 8
AR PL UMing CN-light 8

Comment 9 Karel Klíč 2010-05-19 12:11:35 UTC
The average_width field of font structure is filled in function xftfont_open() in file src/xftfont.c.

There are two possibilities how it is set:
1) if spacing != FC_PROPORTIONAL, avgwidth = xftfont->max_advance_width
   XftFont structure is defined in /usr/include/X11/Xft/Xft.h
2) avgwidth = (font->space_width + extents.xOff) / 95;

Here is the result for various fonts:
DejaVu Sans Mono:pixelsize=13: avgwidth = xftfont->max_advance_width = 8
DejaVu Sans:pixelsize=16: avgwidth = space_width 5 + extents.xOff 892 / 95 = 9
IPAGothic:pixelsize=16: avgwidth = xftfont->max_advance_width = 16
UnDotum:pixelsize=16:weight=bold: avgwidth = space_width 5 + extents.xOff 826 / 95 = 8
UnDotum:pixelsize=16:weight=normal: avgwidth = space_width 5 + extents.xOff 789 / 95 = 8
VL Gothic:pixelsize=16: avgwidth = space_width 8 + extents.xOff 752 / 95 = 8


So the width 16 for IPAGothic font comes from xftfont->max_advance_width.
The field max_advance_width should *not* be used with IPAGothic font, because it only makes sense to use it with Monospace fonts.

IPAGothic sets FC_DUAL (int 90) spacing. All remaining Japanese/Chinese/Korean fonts set FC_PROPORTIONAL (int 0) spacing, so they do not read avgwidth from xftfont->max_advance_width. Their xftfont->max_advance_width is similar (17, 20 etc) to the max_adv_width of IPAGothic.

Comment 10 Karel Klíč 2010-05-19 12:50:38 UTC
Reassigning this bug to ipa-gothic-fonts.

$ fc-query /usr/share/fonts/ipa-gothic/ipag.ttf 
Pattern has 21 elts (size 32)
	family: "IPAGothic"(s) "IPAゴシック"(s)
	familylang: "en"(s) "ja"(s)
	style: "Regular"(s)
	stylelang: "en"(s)
	fullname: "IPAGothic"(s) "IPAゴシック"(s)
	fullnamelang: "en"(s) "ja"(s)
	slant: 0(i)(s)
	weight: 80(i)(s)
	width: 100(i)(s)
	spacing: 90(i)(s)
!!      ^^^^^^^^^^^^^^^^^
	foundry: "unknown"(s)
	file: "/usr/share/fonts/ipa-gothic/ipag.ttf"(s)
	index: 0(i)(s)
	outline: FcTrue(s)
	scalable: FcTrue(s)

Please remove IPA Gothic font spacing field, which is currently set to DUAL (=90). Other CJK fonts UnDotum, VL Gothic, AR PL UMing CN do not set spacing, so PROPORTIONAL (=0) spacing is used. This seems to be the right way as the font also contains half-width Latin characters.

Comment 11 Akira TAGOH 2010-05-24 10:42:09 UTC
Hmm, this isn't that easy thing. actually IPAGothic is supposed to be the monospaced font and no wonder fontconfig adds FC_DUAL to the spacing as well as other monospaced fonts, except it contains the narrow width characters and the wide width characters.

However there are no way to notify both different advances to the applications through TrueType specification. so that could says at least freetype's document is wrong;

    max_advance_width  The maximal advance width, in font units, for _all_ glyphs
                       in this face. This can be used to make word wrapping
                       computations faster. Only relevant for scalable formats.

and the emacs's implementation relying on it is also wrong then.
correctly it should be for latin characters only.

Comment 12 Karel Klíč 2010-06-03 09:27:45 UTC
Agreed. It seems that this should be fixed in Emacs, given that other applications handle IPA Gothic well.

https://bugzilla.redhat.com/show_bug.cgi?id=599437
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=4129

Assigning this back to Emacs.
Thank you for the explanation.

Comment 13 Jens Petersen 2010-06-10 04:47:12 UTC
I see this was already fixed in fedora. :)

Comment 17 Radek Lat 2010-08-05 11:12:07 UTC
Created attachment 436820 [details]
Correct size

Verified on 
emacs-23.1-20.el6.x86_64
ipa-gothic-fonts-003.02-4.2.el6.noarch
ipa-pgothic-fonts-003.02-4.1.el6.noarch
ipa-pmincho-fonts-003.02-3.1.el6.noarch
ipa-mincho-fonts-003.02-3.1.el6.noarch

Comment 18 releng-rhel@redhat.com 2010-11-10 20:21:22 UTC
Red Hat Enterprise Linux 6.0 is now available and should resolve
the problem described in this bug report. This report is therefore being closed
with a resolution of CURRENTRELEASE. You may reopen this bug report if the
solution does not work for you.


Note You need to log in before you can comment on or make changes to this bug.