aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier <[email protected]>2008-02-22 19:04:03 +0000
committerStefan Monnier <[email protected]>2008-02-22 19:04:03 +0000
commit43a1d19b39aef461a49beb0bc684b99db61520ca (patch)
treec0aae5870afbe8c93858d4e7dbaf9b1c257d1dd6
parent9c7f8459fd159b5b8cd443c2cbf3d69f256d6b2e (diff)
(font_match_xlfd, font_check_xlfd_parse): New funs.
(font_parse_xlfd): Use them for sanity check. (Finternal_set_font_style_table): Make sure the table is bijiective.
-rw-r--r--src/ChangeLog4
-rw-r--r--src/font.c44
2 files changed, 44 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2f70d3be55..16ff26c18e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
2008-02-22 Stefan Monnier <[email protected]>
+ * font.c (font_match_xlfd, font_check_xlfd_parse): New funs.
+ (font_parse_xlfd): Use them for sanity check.
+ (Finternal_set_font_style_table): Make sure the table is bijiective.
+
Consolidate the image_cache to the terminal struct.
* termhooks.h (P_): Remove redundant def.
(struct terminal): New field `image_cache'.
diff --git a/src/font.c b/src/font.c
index b8da3de5ac..c63a15889f 100644
--- a/src/font.c
+++ b/src/font.c
@@ -870,6 +870,39 @@ font_expand_wildcards (field, n)
return 0;
}
+
+#ifdef ENABLE_CHECKING
+/* Match a 14-field XLFD pattern against a full XLFD font name. */
+static int
+font_match_xlfd (char *pattern, char *name)
+{
+ while (*pattern && *name)
+ {
+ if (*pattern == *name)
+ pattern++;
+ else if (*pattern == '*')
+ if (*name == pattern[1])
+ pattern += 2;
+ else
+ ;
+ else
+ return 0;
+ name++;
+ }
+ return 1;
+}
+
+/* Make sure the font object matches the XLFD font name. */
+static int
+font_check_xlfd_parse (Lisp_Object font, char *name)
+{
+ char name_check[256];
+ font_unparse_xlfd (font, 0, name_check, 255);
+ return font_match_xlfd (name_check, name);
+}
+
+#endif
+
/* Parse NAME (null terminated) as XLFD and store information in FONT
(font-spec or font-entity). Size property of FONT is set as
follows:
@@ -984,6 +1017,7 @@ font_parse_xlfd (name, font)
i = XLFD_RESX_INDEX;
ASET (font, FONT_EXTRA_INDEX,
intern_font_field (f[i], f[XLFD_REGISTRY_INDEX] - 1 - f[i]));
+ eassert (font_check_xlfd_parse (font, name));
return 0;
}
@@ -2911,7 +2945,7 @@ register_font_driver (driver, f)
struct font_driver_list *prev, *list;
if (f && ! driver->draw)
- error ("Unsable font driver for a frame: %s",
+ error ("Unusable font driver for a frame: %s",
SDATA (SYMBOL_NAME (driver->type)));
for (prev = NULL, list = root; list; prev = list, list = list->next)
@@ -3432,14 +3466,16 @@ sorted by numeric values. */)
error ("Invalid font style property: %s", SDATA (SYMBOL_NAME (prop)));
table = Fcopy_sequence (table);
numeric = -1;
- for (tail = table; ! NILP (tail); tail = Fcdr (tail))
+ for (tail = table; CONSP (tail); tail = XCDR (tail))
{
- prop = Fcar (Fcar (tail));
- val = Fcdr (Fcar (tail));
+ prop = Fcar (XCAR (tail));
+ val = Fcdr (XCAR (tail));
CHECK_SYMBOL (prop);
CHECK_NATNUM (val);
if (numeric > XINT (val))
error ("Numeric values not sorted for %s", SDATA (SYMBOL_NAME (prop)));
+ else if (numeric == XINT (val))
+ error ("Duplicate numeric values for %s", SDATA (SYMBOL_NAME (prop)));
numeric = XINT (val);
XSETCAR (tail, Fcons (prop, val));
}