summaryrefslogtreecommitdiff
path: root/src/fontset.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-09-08 10:37:18 +0800
committerPo Lu <luangruo@yahoo.com>2023-09-08 10:37:18 +0800
commitc933f5081fdaadbe7192d2cc1f7e705f0b0fb842 (patch)
tree4e1f8d214a762819a6203b2ada2be649fc86fd9d /src/fontset.c
parentb1bcd396ede2323e5501d6ec78a5246a6e1dae72 (diff)
downloademacs-c933f5081fdaadbe7192d2cc1f7e705f0b0fb842.tar.gz
Permit XLFD names to exceed 255 characters
* doc/lispref/display.texi (Low-Level Font) <font-xlfd-name>: Document new argument `long-xlfds'. * etc/NEWS: Mention removal of XLFD length restrictions. * src/font.c (font_build_object): Dynamically allocate XLFD, permitting them to surpass 255 characters in length. (font_parse_xlfd_1): Cease rejecting XLFDs more than 255 characters in length. (font_dynamic_unparse_xlfd): New function. Like font_unparse_xlfd, but allocate the XLFD dynamically. (font_delete_unmatched): Dynamically allocate XLFD if necessary. (Ffont_xlfd_name): New arg LONG_XLFDs. If t, return a dynamically allocated XLFD. All callers changed. * src/font.h: Update prototypes. * src/fontset.c (Fnew_fontset): Dynamically allocate XLFD when establishing fontset name.
Diffstat (limited to 'src/fontset.c')
-rw-r--r--src/fontset.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/fontset.c b/src/fontset.c
index 139dcb6eb89..347763cd77e 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1546,7 +1546,7 @@ overwrites the previous settings. */)
font_parse_family_registry (XCAR (font_spec), XCDR (font_spec), spec);
font_spec = spec;
- fontname = Ffont_xlfd_name (font_spec, Qnil);
+ fontname = Ffont_xlfd_name (font_spec, Qnil, Qt);
}
else if (STRINGP (font_spec))
{
@@ -1554,7 +1554,7 @@ overwrites the previous settings. */)
font_spec = CALLN (Ffont_spec, QCname, fontname);
}
else if (FONT_SPEC_P (font_spec))
- fontname = Ffont_xlfd_name (font_spec, Qnil);
+ fontname = Ffont_xlfd_name (font_spec, Qnil, Qt);
else if (! NILP (font_spec))
Fsignal (Qfont, list2 (build_string ("Invalid font-spec"), font_spec));
@@ -1740,6 +1740,7 @@ FONT-SPEC is a vector, a cons, or a string. See the documentation of
{
Lisp_Object fontset, tail;
int id;
+ char *string;
CHECK_STRING (name);
@@ -1749,8 +1750,6 @@ FONT-SPEC is a vector, a cons, or a string. See the documentation of
{
Lisp_Object font_spec = Ffont_spec (0, NULL);
Lisp_Object short_name;
- char xlfd[256];
- int len;
if (font_parse_xlfd (SSDATA (name), SBYTES (name), font_spec) < 0)
error ("Fontset name must be in XLFD format");
@@ -1762,10 +1761,11 @@ FONT-SPEC is a vector, a cons, or a string. See the documentation of
Vfontset_alias_alist);
ASET (font_spec, FONT_REGISTRY_INDEX, Qiso8859_1);
fontset = make_fontset (Qnil, name, Qnil);
- len = font_unparse_xlfd (font_spec, 0, xlfd, 256);
- if (len < 0)
+ string = font_dynamic_unparse_xlfd (font_spec, 0);
+ if (!string)
error ("Invalid fontset name (perhaps too long): %s", SDATA (name));
- set_fontset_ascii (fontset, make_unibyte_string (xlfd, len));
+ set_fontset_ascii (fontset, build_unibyte_string (string));
+ xfree (string);
}
else
{
@@ -1816,7 +1816,7 @@ fontset_from_font (Lisp_Object font_object)
Lisp_Object font_spec = copy_font_spec (font_object);
Lisp_Object registry = AREF (font_spec, FONT_REGISTRY_INDEX);
Lisp_Object fontset_spec, alias, name, fontset;
- Lisp_Object val;
+ Lisp_Object val, xlfd;
val = assoc_no_quit (font_spec, auto_fontset_alist);
if (CONSP (val))
@@ -1832,14 +1832,27 @@ fontset_from_font (Lisp_Object font_object)
}
fontset_spec = copy_font_spec (font_spec);
ASET (fontset_spec, FONT_REGISTRY_INDEX, alias);
- name = Ffont_xlfd_name (fontset_spec, Qnil);
+ name = Ffont_xlfd_name (fontset_spec, Qnil, Qt);
eassert (!NILP (name));
fontset = make_fontset (Qnil, name, Qnil);
Vfontset_alias_alist = Fcons (Fcons (name, SYMBOL_NAME (alias)),
Vfontset_alias_alist);
- alias = Fdowncase (AREF (font_object, FONT_NAME_INDEX));
- Vfontset_alias_alist = Fcons (Fcons (name, alias), Vfontset_alias_alist);
- auto_fontset_alist = Fcons (Fcons (font_spec, fontset), auto_fontset_alist);
+
+ xlfd = AREF (font_object, FONT_NAME_INDEX);
+
+ /* XLFD can be nil if the font's registry or family name gives rise
+ to an XLFD name that cannot be represented within 255
+ characters. (bug#65800) */
+
+ if (!NILP (xlfd))
+ {
+ alias = Fdowncase (xlfd);
+ Vfontset_alias_alist
+ = Fcons (Fcons (name, alias), Vfontset_alias_alist);
+ auto_fontset_alist
+ = Fcons (Fcons (font_spec, fontset), auto_fontset_alist);
+ }
+
font_spec = Ffont_spec (0, NULL);
ASET (font_spec, FONT_REGISTRY_INDEX, registry);
{
@@ -2006,7 +2019,7 @@ format is the same as above. */)
for (; CONSP (alist); alist = XCDR (alist))
{
elt = XCAR (alist);
- XSETCAR (elt, Ffont_xlfd_name (XCAR (elt), Qnil));
+ XSETCAR (elt, Ffont_xlfd_name (XCAR (elt), Qnil, Qt));
}
}
c = to + 1;