Ar an t-ochtú lá de mí na Samhain, scríobh Aidan Kehoe:
[...] The equivalent code on 21.4.19,
(set-charset-registry 'ascii "a very long pattern that won't match at
all")
doesn’t crash. That’s because of a special-case for ASCII, and the fact that
the XLFD is not edited to include the charset registry. I would like to
special-case ASCII too; is it reasonable to require that every X11 server we
run on have one font with its XLFD ending in iso8859-1 ?
The first X11 release with the current server-side font architecture, X11R5,
shipped with a long list of ISO-8859-1 fonts. So, I am inclined to add the
following. Any comments?
Index: src/charset.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/charset.h,v
retrieving revision 1.15
diff -u -r1.15 charset.h
--- src/charset.h 2006/11/05 22:31:43 1.15
+++ src/charset.h 2006/11/08 16:14:54
@@ -574,6 +574,8 @@
int USED_IF_MULE (l), unsigned_char_dynarr *dst,
enum unicode_type type, unsigned int little_endian);
+void set_charset_registries(Lisp_Object charset, Lisp_Object registries);
+
EXFUN (Funicode_to_char, 2);
EXFUN (Fchar_to_unicode, 1);
Index: src/mule-charset.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/mule-charset.c,v
retrieving revision 1.50
diff -u -r1.50 mule-charset.c
--- src/mule-charset.c 2006/11/07 14:04:56 1.50
+++ src/mule-charset.c 2006/11/08 16:14:54
@@ -883,6 +883,14 @@
return Qnil;
}
+void
+set_charset_registries(Lisp_Object charset, Lisp_Object registries)
+{
+ XCHARSET_REGISTRIES (charset) = registries;
+ invalidate_charset_font_caches (charset);
+ face_property_was_changed (Vdefault_face, Qfont, Qglobal);
+}
+
DEFUN ("set-charset-registries", Fset_charset_registries, 2, 2, 0, /*
Set the `registries' property of CHARSET to REGISTRIES.
@@ -913,11 +921,19 @@
invalid_argument("Not an X11 REGISTRY-ENCODING combination",
XVECTOR_DATA(registries)[i]);
}
+
+ if (qxestrchr(XSTRING_DATA(XVECTOR_DATA(registries)[i]), '*') ||
+ qxestrchr(XSTRING_DATA(XVECTOR_DATA(registries)[i]), '?'))
+ {
+ invalid_argument
+ ("XLFD wildcards not allowed in charset-registries",
+ XVECTOR_DATA(registries)[i]);
+
+ }
}
- XCHARSET_REGISTRIES (charset) = registries;
- invalidate_charset_font_caches (charset);
- face_property_was_changed (Vdefault_face, Qfont, Qglobal);
+ set_charset_registries(charset, registries);
+
return Qnil;
}
Index: src/objects-gtk.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/objects-gtk.c,v
retrieving revision 1.18
diff -u -r1.18 objects-gtk.c
--- src/objects-gtk.c 2006/11/05 22:31:44 1.18
+++ src/objects-gtk.c 2006/11/08 16:14:54
@@ -31,6 +31,7 @@
#include "lisp.h"
#include "buffer.h"
+#include "charset.h"
#include "device-impl.h"
#include "insdel.h"
Index: src/objects-xlike-inc.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/objects-xlike-inc.c,v
retrieving revision 1.3
diff -u -r1.3 objects-xlike-inc.c
--- src/objects-xlike-inc.c 2006/11/05 22:31:45 1.3
+++ src/objects-xlike-inc.c 2006/11/08 16:14:54
@@ -764,6 +764,78 @@
charset, stage);
}
+ /* In the event that the charset is ASCII and we haven't matched
+ anything up to now, even with a pattern of "*", add "iso8859-1"
+ to the charset's registry and try again. Not returning a result
+ for ASCII means our frame geometry calculations are
+ inconsistent, and means we crash. */
+
+ if (1 == xlfd_length && NILP(result) && EQ(charset, Vcharset_ascii)
+ && ('*' == eigetch(ei_xlfd_without_registry, 0)))
+
+ {
+ int have_latin1 = 0;
+
+ /* Set this to, for example, is08859-1 if you want to see the
+ error behaviour. */
+
+#define FALLBACK_ASCII_REGISTRY "iso8859-1"
+
+ for (j = 0; j < registries_len; ++j)
+ {
+ if (0 == qxestrcasecmp(XSTRING_DATA(XVECTOR_DATA(registries)[j]),
+ FALLBACK_ASCII_REGISTRY))
+ {
+ have_latin1 = 1;
+ break;
+ }
+ }
+
+ if (!have_latin1)
+ {
+ Lisp_Object new_registries = make_vector(registries_len + 1, Qnil);
+
+ warn_when_safe (Qxintl, Qwarning,
+ "Your ASCII charset registries contain nothing "
+ "sensible. Adding `" FALLBACK_ASCII_REGISTRY "'.");
+
+ XVECTOR_DATA(new_registries)[0]
+ = build_string(FALLBACK_ASCII_REGISTRY);
+
+ memcpy(XVECTOR_DATA(new_registries) + 1,
+ XVECTOR_DATA(registries),
+ sizeof XVECTOR_DATA(registries)[0] *
+ XVECTOR_LENGTH(registries));
+
+ /* Calling set_charset_registries instead of overwriting the
+ value directly, to allow the charset font caches to be
+ invalidated and a change to the default face to be
+ noted. */
+ set_charset_registries(charset, new_registries);
+
+ /* And recurse. */
+ result =
+ DEVMETH_OR_GIVEN (XDEVICE (device), find_charset_font,
+ (device, font, charset, stage),
+ result);
+ }
+ else
+ {
+ stderr_out("Cannot find a font for ASCII, deleting device on %s\n",
+ XSTRING_DATA(DEVICE_CONNECTION (XDEVICE(device))));
+
+ io_error_delete_device(device);
+
+ /* Do a normal warning in the event that we have other,
+ non-X frames available. */
+ warn_when_safe
+ (Qxintl, Qwarning,
+ "Cannot find a font for ASCII, deleting device on %s\n",
+ XSTRING_DATA(DEVICE_CONNECTION (XDEVICE(device))));
+ }
+
+ }
+
/* This function used to return the font spec, in the case where a font
didn't exist on the X server but it did match the charset. We're not
doing that any more, because none of the other platform code does, and
--
Santa Maradona, priez pour moi!
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches