emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A patch for enforcing double-width CJK character display


From: 黄建忠
Subject: Re: A patch for enforcing double-width CJK character display
Date: Wed, 18 Apr 2012 16:13:40 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120327 Thunderbird/10.0.2

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 <address@hidden>, Miles Bader <address@hidden> 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
> address@hidden
>
> === 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]