From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-2022-JP?B?GyRCMis3ekNpGyhC?= Newsgroups: gmane.emacs.devel Subject: Re: A patch for enforcing double-width CJK character display Date: Wed, 18 Apr 2012 16:13:40 +0800 Message-ID: <4F8E77B4.8030808@i-soft.com.cn> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1334736856 23629 80.91.229.3 (18 Apr 2012 08:14:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 18 Apr 2012 08:14:16 +0000 (UTC) Cc: william.xwl@gmail.com, emacs-devel@gnu.org, Miles Bader To: Kenichi Handa Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 18 10:14:14 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SKQ1m-0002uR-5Y for ged-emacs-devel@m.gmane.org; Wed, 18 Apr 2012 10:14:14 +0200 Original-Received: from localhost ([::1]:52415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKQ1l-00053I-Em for ged-emacs-devel@m.gmane.org; Wed, 18 Apr 2012 04:14:13 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKQ1e-00052l-AW for emacs-devel@gnu.org; Wed, 18 Apr 2012 04:14:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SKQ1X-0007ua-F4 for emacs-devel@gnu.org; Wed, 18 Apr 2012 04:14:05 -0400 Original-Received: from mta319.sina.net ([202.108.3.196]:39885) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKQ1W-0007tR-ON; Wed, 18 Apr 2012 04:13:59 -0400 X-Originating-IP: [218.240.45.242] Original-Received: from unknown (HELO mta319.sina.net) ([10.54.5.51]) by irxd5-208.sina.net with ESMTP; 18 Apr 2012 16:13:47 +0800 Original-Received: by smtp-5-51.sina.net (SINAMAIL, from userid 1074) id B6C3CDCA902; Wed, 18 Apr 2012 16:13:41 +0800 (CST) Original-Received: from piggy.pure64.org (unknown [218.240.45.242]) by smtp-5-51.sina.net (SINAMAIL) with ESMTPA id 99D5DDCA8D0; Wed, 18 Apr 2012 16:13:41 +0800 (CST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120327 Thunderbird/10.0.2 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 202.108.3.196 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:149742 Archived-At: Not fixed in my OS: I have the ja "Kiloji" and "VL Gothic" Fonts and zh "YaHei" font installed in Linux. And "kiloji" and "VL Gothic" was not added to fontconfig conf files. 1,If the zh fonts exists. no matter whether the ja fonts controlled via fontconfig conf files or not. Emacs always try to match zh font first, even under ja_JP.utf8 locale. But GTK apps will match Japanese font "kiloji" first under ja_JP.utf8. 2,Remove all zh fonts. ja fonts is not controlled via fontconfig conf files. Emacs will match "kiloji" font first. All GTK apps also match the "kiloji" font first. 3,Add "VL Gothic" and "kiloji" to fontconfig conf files. The GTK apps will use "VL Gothic" to display Japanese characters under ja_JP.utf8. But Emacs still use "kiloji" By the way. CJK font sorting is difficult, since: 1, zh fonts provides almost all ja characters and some basic Korean letters, we all use "kanji/hanzi" of Chinese. And lot of "kanji/hanzi" had the same Unicode code. 2, ja fonts provides all ja characters, also some "kanji". some fonts may provides basic Korean letters. 3, ko fonts may/may not provide "kanji". That's to say: 1, zh fonts can display ALMOST all ja characters, but not all. 2, ja fonts can display some zh characters, but not all. Forgive my English writing, hope you can understand:-) 于 2012年04月18日 14:54, Kenichi Handa 写道: > In article , Miles Bader writes: > >> I set the font to "Droid Sans Mono", and the Japanese font Emacs >> automatically chose was "きろ字". I don't know _why_ Emacs chose that >> font, > That's because I couldn't use FcFontSetSort because it had a > serious bug when I wrote the relevant code long ago. Could > you please try this patch? > > --- > Kenichi Handa > handa@m17n.org > > === modified file 'src/ftfont.c' > --- src/ftfont.c 2012-03-19 04:08:07 +0000 > +++ src/ftfont.c 2012-04-18 06:44:59 +0000 > @@ -123,6 +123,7 @@ > { "big5-0", { 0xF6B1 }, "zh-tw" }, > { "jisx0208.1983-0", { 0x4E55 }, "ja"}, > { "ksc5601.1985-0", { 0xAC00 }, "ko"}, > + { "ksc5601.1987-0", { 0xAC00 }, "ko"}, > { "cns11643.1992-1", { 0xFE32 }, "zh-tw"}, > { "cns11643.1992-2", { 0x4E33, 0x7934 }}, > { "cns11643.1992-3", { 0x201A9 }}, > @@ -890,9 +891,10 @@ > Lisp_Object val = Qnil, family, adstyle; > int i; > FcPattern *pattern; > - FcFontSet *fontset = NULL; > + FcFontSet *fontset = NULL, *sorted = NULL; > FcObjectSet *objset = NULL; > FcCharSet *charset; > + FcResult result; > Lisp_Object chars = Qnil; > char otlayout[15]; /* For "otlayout:XXXX" */ > struct OpenTypeSpec *otspec = NULL; > @@ -983,7 +985,12 @@ > } > } > #endif > - for (i = 0; i < fontset->nfont; i++) > + if (FcConfigSubstitute (NULL, pattern, FcMatchPattern) != FcTrue) > + goto err; > + FcDefaultSubstitute (pattern); > + sorted = FcFontSetSort (NULL, &fontset, 1, pattern, FcFalse, NULL, &result); > + > + for (i = 0; i < sorted->nfont; i++) > { > Lisp_Object entity; > > @@ -991,7 +998,7 @@ > { > int this; > > - if ((FcPatternGetInteger (fontset->fonts[i], FC_SPACING, 0, &this) > + if ((FcPatternGetInteger (sorted->fonts[i], FC_SPACING, 0, &this) > == FcResultMatch) > && spacing != this) > continue; > @@ -1002,7 +1009,7 @@ > { > FcChar8 *this; > > - if (FcPatternGetString (fontset->fonts[i], FC_CAPABILITY, 0, &this) > + if (FcPatternGetString (sorted->fonts[i], FC_CAPABILITY, 0, &this) > != FcResultMatch > || ! strstr ((char *) this, otlayout)) > continue; > @@ -1014,7 +1021,7 @@ > FcChar8 *file; > OTF *otf; > > - if (FcPatternGetString (fontset->fonts[i], FC_FILE, 0, &file) > + if (FcPatternGetString (sorted->fonts[i], FC_FILE, 0, &file) > != FcResultMatch) > continue; > otf = OTF_open ((char *) file); > @@ -1035,7 +1042,7 @@ > { > int j; > > - if (FcPatternGetCharSet (fontset->fonts[i], FC_CHARSET, 0, &charset) > + if (FcPatternGetCharSet (sorted->fonts[i], FC_CHARSET, 0, &charset) > != FcResultMatch) > continue; > for (j = 0; j < ASIZE (chars); j++) > @@ -1047,7 +1054,7 @@ > } > if (! NILP (adstyle) || langname) > { > - Lisp_Object this_adstyle = get_adstyle_property (fontset->fonts[i]); > + Lisp_Object this_adstyle = get_adstyle_property (sorted->fonts[i]); > > if (! NILP (adstyle) > && (NILP (this_adstyle) > @@ -1059,7 +1066,7 @@ > && xstrcasecmp (langname, SSDATA (SYMBOL_NAME (this_adstyle)))) > continue; > } > - entity = ftfont_pattern_entity (fontset->fonts[i], > + entity = ftfont_pattern_entity (sorted->fonts[i], > AREF (spec, FONT_EXTRA_INDEX)); > if (! NILP (entity)) > val = Fcons (entity, val); > @@ -1076,6 +1083,7 @@ > FONT_ADD_LOG ("ftfont-list", spec, val); > if (objset) FcObjectSetDestroy (objset); > if (fontset) FcFontSetDestroy (fontset); > + if (sorted) FcFontSetDestroy (sorted); > if (pattern) FcPatternDestroy (pattern); > return val; > } > > > -- Huang JianZhong