summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>2009-07-28 02:02:40 +0000
committerKenichi Handa <handa@m17n.org>2009-07-28 02:02:40 +0000
commitb33f089c608a8b0c0b18ebc04b3d9354cb98d26a (patch)
treeec4c9327c3efe12ba4fc57c82ebc2f4bb7f3492f
parentca8a407194ad1cc45e49746d26a526fff729d79e (diff)
downloademacs-b33f089c608a8b0c0b18ebc04b3d9354cb98d26a.tar.gz
(xfont_list_pattern): Don't ignore the return value of
font_parse_xlfd. Check font properties more rigidly.
-rw-r--r--src/xfont.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/xfont.c b/src/xfont.c
index 35113fdf798..5337fb71961 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -411,16 +411,25 @@ xfont_list_pattern (Display *display, char *pattern,
continue;
entity = font_make_entity ();
xfont_decode_coding_xlfd (indices[i], -1, buf);
- font_parse_xlfd (buf, entity);
+ if (font_parse_xlfd (buf, entity) < 0)
+ continue;
ASET (entity, FONT_TYPE_INDEX, Qx);
/* Avoid auto-scaled fonts. */
- if (XINT (AREF (entity, FONT_DPI_INDEX)) != 0
+ if (INTEGERP (AREF (entity, FONT_DPI_INDEX))
+ && INTEGERP (AREF (entity, FONT_AVGWIDTH_INDEX))
+ && XINT (AREF (entity, FONT_DPI_INDEX)) != 0
&& XINT (AREF (entity, FONT_AVGWIDTH_INDEX)) == 0)
continue;
/* Avoid not-allowed scalable fonts. */
if (NILP (Vscalable_fonts_allowed))
{
- if (XINT (AREF (entity, FONT_SIZE_INDEX)) == 0)
+ int size = 0;
+
+ if (INTEGERP (AREF (entity, FONT_SIZE_INDEX)))
+ size = XINT (AREF (entity, FONT_SIZE_INDEX));
+ else if (FLOATP (AREF (entity, FONT_SIZE_INDEX)))
+ size = XFLOAT_DATA (AREF (entity, FONT_SIZE_INDEX));
+ if (size == 0)
continue;
}
else if (CONSP (Vscalable_fonts_allowed))
@@ -439,6 +448,10 @@ xfont_list_pattern (Display *display, char *pattern,
continue;
}
+ /* Avoid fonts of invalid registry. */
+ if (NILP (AREF (entity, FONT_REGISTRY_INDEX)))
+ continue;
+
/* Update encoding and repertory if necessary. */
if (! EQ (registry, AREF (entity, FONT_REGISTRY_INDEX)))
{