Commit 7c4bd58d authored by Kenichi Handa's avatar Kenichi Handa
Browse files

(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.
parent c3bb7671
......@@ -673,7 +673,7 @@ ftfont_spec_pattern (spec, otlayout, otspec)
{
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 @@ ftfont_list (frame, spec)
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 @@ ftfont_list (frame, spec)
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 @@ ftfont_list (frame, spec)
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 @@ ftfont_list (frame, spec)
{
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 @@ ftfont_list (frame, spec)
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 @@ ftfont_list (frame, spec)
val = Qnil;
finish:
font_add_log ("ftfont-list", spec, val);
if (objset) FcObjectSetDestroy (objset);
if (fontset) FcFontSetDestroy (fontset);
if (pattern) FcPatternDestroy (pattern);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment