Created
September 22, 2013 04:52
-
-
Save snogglethorpe/6656816 to your computer and use it in GitHub Desktop.
handa-emacs-fontconfig-search-order.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 5cce45ee20e4dc7d6025e75ae3f3f56d3e541992 | |
Author: Miles Bader <miles@gnu.org> | |
Date: Wed Oct 10 14:09:12 2012 +0900 | |
Handa fontconfig sorting patch | |
diff --git a/src/ftfont.c b/src/ftfont.c | |
index 10090cb..545c999 100644 | |
--- a/src/ftfont.c | |
+++ b/src/ftfont.c | |
@@ -121,6 +121,7 @@ static struct | |
{ "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 }}, | |
@@ -889,9 +890,10 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec) | |
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; | |
@@ -982,7 +984,12 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec) | |
} | |
} | |
#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; | |
@@ -990,7 +997,7 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec) | |
{ | |
int this; | |
- if ((FcPatternGetInteger (fontset->fonts[i], FC_SPACING, 0, &this) | |
+ if ((FcPatternGetInteger (sorted->fonts[i], FC_SPACING, 0, &this) | |
== FcResultMatch) | |
&& spacing != this) | |
continue; | |
@@ -1001,7 +1008,7 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec) | |
{ | |
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; | |
@@ -1013,7 +1020,7 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec) | |
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); | |
@@ -1034,7 +1041,7 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec) | |
{ | |
ptrdiff_t 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++) | |
@@ -1046,7 +1053,7 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec) | |
} | |
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) | |
@@ -1058,7 +1065,7 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec) | |
&& 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); | |
@@ -1075,6 +1082,7 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec) | |
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment