File emacs-23.1-jis2004.patch of Package emacs

--- emacs-23.1/src/ftfont.c.spacing	2009-06-26 16:24:06.000000000 +0200
+++ emacs-23.1/src/ftfont.c	2011-01-26 17:47:16.927918168 +0100
@@ -861,6 +862,21 @@ ftfont_spec_pattern (spec, otlayout, ots
   return pattern;
 }
 
+static int cmp_jis2004(const void *a, const void *b)
+{
+  FcPattern *a_pat = *(FcPattern**)a;
+  FcPattern *b_pat = *(FcPattern**)b;
+  FcChar8 *a_family = NULL, *b_family = NULL;
+  int result = 0;
+  if (FcPatternGetString (a_pat, FC_FAMILY, 0, &a_family) == FcResultMatch &&
+      strncmp(a_family, "IPA", 3))
+    result--;
+  if (FcPatternGetString (b_pat, FC_FAMILY, 0, &b_family) == FcResultMatch &&
+      strncmp(b_family, "IPA", 3))
+    result++;
+  return result;
+}
+
 static Lisp_Object
 ftfont_list (frame, spec)
      Lisp_Object frame, spec;
@@ -934,6 +950,15 @@ ftfont_list (frame, spec)
   fontset = FcFontList (NULL, pattern, objset);
   if (! fontset || fontset->nfont == 0)
     goto finish;
+
+  /* Move JIS2004 fonts to the end of the list. */
+  Lisp_Object registry = AREF (spec, FONT_REGISTRY_INDEX);
+  if (!NILP (registry))
+    {
+      if (0 == strcmp((char *) SDATA (SYMBOL_NAME (registry)), "jisx0208*-*"))
+	  qsort(fontset->fonts, fontset->nfont, sizeof(FcPattern*), cmp_jis2004);
+    }
+
 #if 0
   /* Need fix because this finds any fonts.  */
   if (fontset->nfont == 0 && ! NILP (family))
openSUSE Build Service is sponsored by