Hi Shi Zhu, On 10/9/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
"Yongwei Wu" <[EMAIL PROTECTED]> 写于 2006-10-09 14:19:20: > On 10/9/06, Yongwei Wu <[EMAIL PROTECTED]> wrote: > > Hi Gurus, > > > > I have found another issue with Chinese and UTF-8 combined. When I > > select 新宋体 (probably called NSimSun on your non-Simplified Chinese > > Windows box) in gvim with encoding=utf-8, the result of typing `:set > > guifont?' is: > > > > guifont=<d0><c2><cb><ce><cc><e5>:h12:cGB2312 > > > > (The `<d0>...<e5' part is in blue colour. D0C2, CBCE, and CCE5 are > > exactly the GB2312/GBK code points for the three characters 新宋体.) > > > > I cannot choose the font by typing `:set guifont=新宋体:h12', so > > basically I cannot choose it in my _vimrc while using UTF-8. > > I was not accurate enough. I was able to choose this font by: > > exec 'set guifont=' . iconv('新宋体', 'utf-8', 'cp936') . ':h12' > > But I do not think it is a nice way. > > Best regards, > > Yongwei > -- > Wu Yongwei > URL: http://wyw.dcweb.cn/Hi, it seems that Windows require the fontname to be encoded as cp936, or if the '新宋体' is encoded in cp936? Well, whatever you do in Vim, Vim should ask windows for the fontname '新宋体' with cp936 encoding. But what should Vim do then? add a 'fontnameencoding' option?
dumpbin /imports gvim.exe | grep -i font 3A CreateFontIndirectA C9 EnumFontFamiliesA 39 CreateFontA 2 ChooseFontA If the ..A functions are used, font names should be converted from `encoding' (UTF-8 in my case) to system default encoding (CP936 in my case, which Vim *knows*). Alternatively, Vim could use the ..W functions, and convert the font names from `encoding' to UTF-16. I do not feel this necessary.
Every font has a pure-latin name, it may be safer to use the latin name of the font, (average users may not know how to get the latin name of the font though).
I did not know either. The font file is names simsun.ttc, and contains really two fonts: 宋体 (SimSun) and 新宋体 (NSimSun). Vim does not like SimSun (probably because it is not regarded a fixed-width font). I rebooted to another locale to find out the name NSimSun (but I did not try it since I was frustrated by the failure of set guifont=SimSun:h12). It works, so it is one solution. Thanks. Best regards, Yongwei -- Wu Yongwei URL: http://wyw.dcweb.cn/
