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: Kenichi Handa
Subject: Re: A patch for enforcing double-width CJK character display
Date: Wed, 18 Apr 2012 15:54:22 +0900

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;
 }




reply via email to

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