# HG changeset patch # User Kenichi Handa # Date 1220237183 0 # Node ID 464a00cca3cf7d30f670065f2367d0ea28ad1b76 # Parent 3a2d65dc9abc18d04443b2cc6f5ee56ddf80b3f6 (ftfont_spec_pattern): Don't create a charset of the representative chars of the script is a vector. (ftfont_list): Handle the case the representative chars of the script is a vector. diff -r 3a2d65dc9abc -r 464a00cca3cf src/ftfont.c --- a/src/ftfont.c Mon Sep 01 02:44:56 2008 +0000 +++ b/src/ftfont.c Mon Sep 01 02:46:23 2008 +0000 @@ -673,7 +673,7 @@ { Lisp_Object chars = assq_no_quit (script, Vscript_representative_chars); - if (CONSP (chars)) + if (CONSP (chars) && CONSP (CDR (chars))) { charset = FcCharSetCreate (); if (! charset) @@ -744,6 +744,9 @@ FcPattern *pattern; FcFontSet *fontset = NULL; FcObjectSet *objset = NULL; + FcCharSet *charset; + Lisp_Object chars = Qnil; + FcResult result; char otlayout[15]; /* For "otlayout:XXXX" */ struct OpenTypeSpec *otspec = NULL; int spacing = -1; @@ -757,6 +760,17 @@ pattern = ftfont_spec_pattern (spec, otlayout, &otspec); if (! pattern) return Qnil; + if (FcPatternGetCharSet (pattern, FC_CHARSET, 0, &charset) != FcResultMatch) + { + val = assq_no_quit (QCscript, AREF (spec, FONT_EXTRA_INDEX)); + if (! NILP (val)) + { + val = assq_no_quit (XCDR (val), Vscript_representative_chars); + if (CONSP (val) && VECTORP (XCDR (val))) + chars = XCDR (val); + } + val = Qnil; + } if (INTEGERP (AREF (spec, FONT_SPACING_INDEX))) spacing = XINT (AREF (spec, FONT_SPACING_INDEX)); family = AREF (spec, FONT_FAMILY_INDEX); @@ -786,10 +800,12 @@ NULL); if (! objset) goto err; + if (! NILP (chars)) + FcObjectSetAdd (objset, FC_CHARSET); fontset = FcFontList (NULL, pattern, objset); - if (! fontset) - goto err; + if (! fontset || fontset->nfont == 0) + goto finish; #if 0 /* Need fix because this finds any fonts. */ if (fontset->nfont == 0 && ! NILP (family)) @@ -836,8 +852,8 @@ { FcChar8 *this; - if (FcPatternGetString (fontset->fonts[i], FC_CAPABILITY, 0, - &this) != FcResultMatch + if (FcPatternGetString (fontset->fonts[i], FC_CAPABILITY, 0, &this) + != FcResultMatch || ! strstr ((char *) this, otlayout)) continue; } @@ -865,12 +881,26 @@ continue; } #endif /* HAVE_LIBOTF */ + if (VECTORP (chars)) + { + int j; + + if (FcPatternGetCharSet (fontset->fonts[i], FC_CHARSET, 0, &charset) + != FcResultMatch) + continue; + for (j = 0; j < ASIZE (chars); j++) + if (NATNUMP (AREF (chars, j)) + && FcCharSetHasChar (charset, XFASTINT (AREF (chars, j)))) + break; + if (j == ASIZE (chars)) + continue; + } entity = ftfont_pattern_entity (fontset->fonts[i], AREF (spec, FONT_EXTRA_INDEX)); if (! NILP (entity)) val = Fcons (entity, val); } - font_add_log ("ftfont-list", spec, val); + val = Fnreverse (val); goto finish; err: @@ -879,6 +909,7 @@ val = Qnil; finish: + font_add_log ("ftfont-list", spec, val); if (objset) FcObjectSetDestroy (objset); if (fontset) FcFontSetDestroy (fontset); if (pattern) FcPatternDestroy (pattern);