|Subject:||Re: A patch for enforcing double-width CJK character display|
|Date:||Fri, 13 Apr 2012 19:42:05 +0800|
|User-agent:||Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120327 Thunderbird/10.0.2|
It seems my mail is rejected, send again.
This patch fix a issue about CJK font alignment with monospace fonts. The attachment shows before/after situations of same file opened in Emacs, NOTE the table in org-mode.
As we all know, programmer's editor should use monospace font as it's default font,
According to http://www.lowing.org/fonts/
Monospace fonts (Such as Courier or LetterGothic), or "fixed pitch" fonts, contain characters that all have the same character width, producing text that can be used to create forms, tabular material or documents that require exact text line lengths. An example of a fixed pitch font is Courier 12 pitch, which is a 10 point font that will print at exactly 12 characters per inch.
Primarily because the text will align more readily. Especially is areas like the comment block header.
For ascii users, the default English monospace fonts should be enough and OK, such as DejaVu Mono, Consolas, Liberation Mono, Monaco etc.
For CJK users, we will encouter a problem.
Normally, we set a default monospace font for Emacs, and let CJK or other languages font auto-match via fontconfig/Xft.
For example, I user Monaco as default font of Emacs, And when I need to input CJK characters, Emacs will automatch a proper font for me, For Chinese, it is "WenQuanYi Zen Hei"; for Japanese, it's "VL Gothic", for Korean, it's "Batang".
Here is a problem the patch fixed, generally The pixel width of auto-matched CJK font is not exactly equals to double monospace font width. mostly, For same font size, the pixel width of CJK font is smaller than double pixel width of monospace font.
By the way, all CJK glyphs in one CJK font is fixed pitch and double width.
We have some choices here:
1, Use a "so-called real monospace CJK font" as Emacs default font, "a real monospace CJK font" means the ascii glyphs in font is monospace and extactly equals to 1/2 of CJK glyph width. But English character's from most real monospace CJK font looks not so good, and it's also not so flexible with such settings.
Or 2, Set defferent font size for script HAN, for example , when I set Emacs default font to Monaco 10, the automatched CJK font is Hei 10, but the pixelsize of Monaco is 8, the CJK pixelsize is 14, that mean, I need increase the CJK font size for script HAN like this:
(custom-set-faces '(default ((t (:family "Monaco")))))
(set-fontset-font "fontset-default" 'han "WenQuanYi Zen Hei 12" )
But the CJK characters will looks very big and odd, especially, when we use them in comments of codes, the big font attracts all my attention:-D.
And such settings also can not support "text-scale" or something else.
This patch try's to fix this issue, calculate the width difference between default font and CJK fonts, add padding to CJK font width.
Actually, All double width font encounter this problem, but CJK(Script Han) is notable, since it had a large number of users.
于 2012年04月13日 04:33, Stefan Monnier 写道:
Now, it works very well with font remapping, rescaling.BTW, could someone explain to me what this patch intends to do? Stefan
|[Prev in Thread]||Current Thread||[Next in Thread]|