aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-02-22 19:04:03 +0000
committerStefan Monnier2008-02-22 19:04:03 +0000
commit43a1d19b39aef461a49beb0bc684b99db61520ca (patch)
treec0aae5870afbe8c93858d4e7dbaf9b1c257d1dd6
parent9c7f8459fd159b5b8cd443c2cbf3d69f256d6b2e (diff)
downloademacs-43a1d19b39aef461a49beb0bc684b99db61520ca.tar.gz
emacs-43a1d19b39aef461a49beb0bc684b99db61520ca.zip
(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 2f70d3be552..16ff26c18ef 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
12008-02-22 Stefan Monnier <monnier@iro.umontreal.ca> 12008-02-22 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * font.c (font_match_xlfd, font_check_xlfd_parse): New funs.
4 (font_parse_xlfd): Use them for sanity check.
5 (Finternal_set_font_style_table): Make sure the table is bijiective.
6
3 Consolidate the image_cache to the terminal struct. 7 Consolidate the image_cache to the terminal struct.
4 * termhooks.h (P_): Remove redundant def. 8 * termhooks.h (P_): Remove redundant def.
5 (struct terminal): New field `image_cache'. 9 (struct terminal): New field `image_cache'.
diff --git a/src/font.c b/src/font.c
index b8da3de5ac7..c63a15889fc 100644
--- a/src/font.c
+++ b/src/font.c
@@ -870,6 +870,39 @@ font_expand_wildcards (field, n)
870 return 0; 870 return 0;
871} 871}
872 872
873
874#ifdef ENABLE_CHECKING
875/* Match a 14-field XLFD pattern against a full XLFD font name. */
876static int
877font_match_xlfd (char *pattern, char *name)
878{
879 while (*pattern && *name)
880 {
881 if (*pattern == *name)
882 pattern++;
883 else if (*pattern == '*')
884 if (*name == pattern[1])
885 pattern += 2;
886 else
887 ;
888 else
889 return 0;
890 name++;
891 }
892 return 1;
893}
894
895/* Make sure the font object matches the XLFD font name. */
896static int
897font_check_xlfd_parse (Lisp_Object font, char *name)
898{
899 char name_check[256];
900 font_unparse_xlfd (font, 0, name_check, 255);
901 return font_match_xlfd (name_check, name);
902}
903
904#endif
905
873/* Parse NAME (null terminated) as XLFD and store information in FONT 906/* Parse NAME (null terminated) as XLFD and store information in FONT
874 (font-spec or font-entity). Size property of FONT is set as 907 (font-spec or font-entity). Size property of FONT is set as
875 follows: 908 follows:
@@ -984,6 +1017,7 @@ font_parse_xlfd (name, font)
984 i = XLFD_RESX_INDEX; 1017 i = XLFD_RESX_INDEX;
985 ASET (font, FONT_EXTRA_INDEX, 1018 ASET (font, FONT_EXTRA_INDEX,
986 intern_font_field (f[i], f[XLFD_REGISTRY_INDEX] - 1 - f[i])); 1019 intern_font_field (f[i], f[XLFD_REGISTRY_INDEX] - 1 - f[i]));
1020 eassert (font_check_xlfd_parse (font, name));
987 return 0; 1021 return 0;
988 } 1022 }
989 1023
@@ -2911,7 +2945,7 @@ register_font_driver (driver, f)
2911 struct font_driver_list *prev, *list; 2945 struct font_driver_list *prev, *list;
2912 2946
2913 if (f && ! driver->draw) 2947 if (f && ! driver->draw)
2914 error ("Unsable font driver for a frame: %s", 2948 error ("Unusable font driver for a frame: %s",
2915 SDATA (SYMBOL_NAME (driver->type))); 2949 SDATA (SYMBOL_NAME (driver->type)));
2916 2950
2917 for (prev = NULL, list = root; list; prev = list, list = list->next) 2951 for (prev = NULL, list = root; list; prev = list, list = list->next)
@@ -3432,14 +3466,16 @@ sorted by numeric values. */)
3432 error ("Invalid font style property: %s", SDATA (SYMBOL_NAME (prop))); 3466 error ("Invalid font style property: %s", SDATA (SYMBOL_NAME (prop)));
3433 table = Fcopy_sequence (table); 3467 table = Fcopy_sequence (table);
3434 numeric = -1; 3468 numeric = -1;
3435 for (tail = table; ! NILP (tail); tail = Fcdr (tail)) 3469 for (tail = table; CONSP (tail); tail = XCDR (tail))
3436 { 3470 {
3437 prop = Fcar (Fcar (tail)); 3471 prop = Fcar (XCAR (tail));
3438 val = Fcdr (Fcar (tail)); 3472 val = Fcdr (XCAR (tail));
3439 CHECK_SYMBOL (prop); 3473 CHECK_SYMBOL (prop);
3440 CHECK_NATNUM (val); 3474 CHECK_NATNUM (val);
3441 if (numeric > XINT (val)) 3475 if (numeric > XINT (val))
3442 error ("Numeric values not sorted for %s", SDATA (SYMBOL_NAME (prop))); 3476 error ("Numeric values not sorted for %s", SDATA (SYMBOL_NAME (prop)));
3477 else if (numeric == XINT (val))
3478 error ("Duplicate numeric values for %s", SDATA (SYMBOL_NAME (prop)));
3443 numeric = XINT (val); 3479 numeric = XINT (val);
3444 XSETCAR (tail, Fcons (prop, val)); 3480 XSETCAR (tail, Fcons (prop, val));
3445 } 3481 }