{
Lisp_Object chars = assq_no_quit (script, Vscript_representative_chars);
- if (CONSP (chars))
+ if (CONSP (chars) && CONSP (CDR (chars)))
{
charset = FcCharSetCreate ();
if (! charset)
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;
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);
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))
{
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;
}
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:
val = Qnil;
finish:
+ font_add_log ("ftfont-list", spec, val);
if (objset) FcObjectSetDestroy (objset);
if (fontset) FcFontSetDestroy (fontset);
if (pattern) FcPatternDestroy (pattern);