aboutsummaryrefslogtreecommitdiffstats
path: root/src/font.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/font.c')
-rw-r--r--src/font.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/font.c b/src/font.c
index ea6fc47884c..27abbe25786 100644
--- a/src/font.c
+++ b/src/font.c
@@ -739,7 +739,7 @@ font_put_extra (Lisp_Object font, Lisp_Object prop, Lisp_Object val)
739 739
740static int parse_matrix (const char *); 740static int parse_matrix (const char *);
741static int font_expand_wildcards (Lisp_Object *, int); 741static int font_expand_wildcards (Lisp_Object *, int);
742static int font_parse_name (char *, Lisp_Object); 742static int font_parse_name (char *, ptrdiff_t, Lisp_Object);
743 743
744/* An enumerator for each field of an XLFD font name. */ 744/* An enumerator for each field of an XLFD font name. */
745enum xlfd_field_index 745enum xlfd_field_index
@@ -1019,9 +1019,8 @@ font_expand_wildcards (Lisp_Object *field, int n)
1019 a fully specified XLFD. */ 1019 a fully specified XLFD. */
1020 1020
1021int 1021int
1022font_parse_xlfd (char *name, Lisp_Object font) 1022font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font)
1023{ 1023{
1024 ptrdiff_t len = strlen (name);
1025 int i, j, n; 1024 int i, j, n;
1026 char *f[XLFD_LAST_INDEX + 1]; 1025 char *f[XLFD_LAST_INDEX + 1];
1027 Lisp_Object val; 1026 Lisp_Object val;
@@ -1336,12 +1335,11 @@ font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes)
1336 This function tries to guess which format it is. */ 1335 This function tries to guess which format it is. */
1337 1336
1338static int 1337static int
1339font_parse_fcname (char *name, Lisp_Object font) 1338font_parse_fcname (char *name, ptrdiff_t len, Lisp_Object font)
1340{ 1339{
1341 char *p, *q; 1340 char *p, *q;
1342 char *size_beg = NULL, *size_end = NULL; 1341 char *size_beg = NULL, *size_end = NULL;
1343 char *props_beg = NULL, *family_end = NULL; 1342 char *props_beg = NULL, *family_end = NULL;
1344 ptrdiff_t len = strlen (name);
1345 1343
1346 if (len == 0) 1344 if (len == 0)
1347 return -1; 1345 return -1;
@@ -1694,11 +1692,11 @@ font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes)
1694 0. Otherwise return -1. */ 1692 0. Otherwise return -1. */
1695 1693
1696static int 1694static int
1697font_parse_name (char *name, Lisp_Object font) 1695font_parse_name (char *name, ptrdiff_t namelen, Lisp_Object font)
1698{ 1696{
1699 if (name[0] == '-' || strchr (name, '*') || strchr (name, '?')) 1697 if (name[0] == '-' || strchr (name, '*') || strchr (name, '?'))
1700 return font_parse_xlfd (name, font); 1698 return font_parse_xlfd (name, namelen, font);
1701 return font_parse_fcname (name, font); 1699 return font_parse_fcname (name, namelen, font);
1702} 1700}
1703 1701
1704 1702
@@ -2987,7 +2985,7 @@ font_spec_from_name (Lisp_Object font_name)
2987 Lisp_Object spec = Ffont_spec (0, NULL); 2985 Lisp_Object spec = Ffont_spec (0, NULL);
2988 2986
2989 CHECK_STRING (font_name); 2987 CHECK_STRING (font_name);
2990 if (font_parse_name (SSDATA (font_name), spec) == -1) 2988 if (font_parse_name (SSDATA (font_name), SBYTES (font_name), spec) == -1)
2991 return Qnil; 2989 return Qnil;
2992 font_put_extra (spec, QCname, font_name); 2990 font_put_extra (spec, QCname, font_name);
2993 font_put_extra (spec, QCuser_spec, font_name); 2991 font_put_extra (spec, QCuser_spec, font_name);
@@ -3359,13 +3357,13 @@ font_open_by_spec (FRAME_PTR f, Lisp_Object spec)
3359 found, return Qnil. */ 3357 found, return Qnil. */
3360 3358
3361Lisp_Object 3359Lisp_Object
3362font_open_by_name (FRAME_PTR f, const char *name) 3360font_open_by_name (FRAME_PTR f, const char *name, ptrdiff_t len)
3363{ 3361{
3364 Lisp_Object args[2]; 3362 Lisp_Object args[2];
3365 Lisp_Object spec, ret; 3363 Lisp_Object spec, ret;
3366 3364
3367 args[0] = QCname; 3365 args[0] = QCname;
3368 args[1] = make_unibyte_string (name, strlen (name)); 3366 args[1] = make_unibyte_string (name, len);
3369 spec = Ffont_spec (2, args); 3367 spec = Ffont_spec (2, args);
3370 ret = font_open_by_spec (f, spec); 3368 ret = font_open_by_spec (f, spec);
3371 /* Do not lose name originally put in. */ 3369 /* Do not lose name originally put in. */
@@ -3872,7 +3870,7 @@ usage: (font-spec ARGS...) */)
3872 if (EQ (key, QCname)) 3870 if (EQ (key, QCname))
3873 { 3871 {
3874 CHECK_STRING (val); 3872 CHECK_STRING (val);
3875 font_parse_name (SSDATA (val), spec); 3873 font_parse_name (SSDATA (val), SBYTES (val), spec);
3876 font_put_extra (spec, key, val); 3874 font_put_extra (spec, key, val);
3877 } 3875 }
3878 else 3876 else
@@ -4887,7 +4885,7 @@ If the named font is not yet loaded, return nil. */)
4887 4885
4888 if (fontset >= 0) 4886 if (fontset >= 0)
4889 name = fontset_ascii (fontset); 4887 name = fontset_ascii (fontset);
4890 font_object = font_open_by_name (f, SSDATA (name)); 4888 font_object = font_open_by_name (f, SSDATA (name), SBYTES (name));
4891 } 4889 }
4892 else if (FONT_OBJECT_P (name)) 4890 else if (FONT_OBJECT_P (name))
4893 font_object = name; 4891 font_object = name;