summaryrefslogtreecommitdiff
path: root/src/fontset.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fontset.c')
-rw-r--r--src/fontset.c70
1 files changed, 51 insertions, 19 deletions
diff --git a/src/fontset.c b/src/fontset.c
index 7af6782a37c..d27fa22015e 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -266,19 +266,19 @@ font_def_new (Lisp_Object font_spec, Lisp_Object encoding,
#define RFONT_DEF_FACE(rfont_def) AREF (rfont_def, 0)
#define RFONT_DEF_SET_FACE(rfont_def, face_id) \
- ASET ((rfont_def), 0, make_fixnum (face_id))
+ ASET (rfont_def, 0, make_fixnum (face_id))
#define RFONT_DEF_FONT_DEF(rfont_def) AREF (rfont_def, 1)
#define RFONT_DEF_SPEC(rfont_def) FONT_DEF_SPEC (AREF (rfont_def, 1))
#define RFONT_DEF_OBJECT(rfont_def) AREF (rfont_def, 2)
#define RFONT_DEF_SET_OBJECT(rfont_def, object) \
- ASET ((rfont_def), 2, (object))
+ ASET (rfont_def, 2, object)
/* Score of RFONT_DEF is an integer value; the lowest 8 bits represent
the order of listing by font backends, the higher bits represents
the order given by charset priority list. The smaller value is
preferable. */
#define RFONT_DEF_SCORE(rfont_def) XFIXNUM (AREF (rfont_def, 3))
#define RFONT_DEF_SET_SCORE(rfont_def, score) \
- ASET ((rfont_def), 3, make_fixnum (score))
+ ASET (rfont_def, 3, make_fixnum (score))
#define RFONT_DEF_NEW(rfont_def, font_def) \
do { \
(rfont_def) = make_nil_vector (4); \
@@ -295,7 +295,7 @@ font_def_new (Lisp_Object font_spec, Lisp_Object encoding,
#define FONTSET_REF(fontset, c) \
(EQ (fontset, Vdefault_fontset) \
? CHAR_TABLE_REF (fontset, c) \
- : fontset_ref ((fontset), (c)))
+ : fontset_ref (fontset, c))
static Lisp_Object
fontset_ref (Lisp_Object fontset, int c)
@@ -315,7 +315,7 @@ fontset_ref (Lisp_Object fontset, int c)
specifying a range. */
#define FONTSET_SET(fontset, range, elt) \
- Fset_char_table_range ((fontset), (range), (elt))
+ Fset_char_table_range (fontset, range, elt)
/* Modify the elements of FONTSET for characters in RANGE by replacing
@@ -329,7 +329,7 @@ fontset_ref (Lisp_Object fontset, int c)
? (NILP (range) \
? set_fontset_fallback (fontset, make_vector (1, elt)) \
: (void) Fset_char_table_range (fontset, range, make_vector (1, elt))) \
- : fontset_add ((fontset), (range), (elt), (add)))
+ : fontset_add (fontset, range, elt, add))
static void
fontset_add (Lisp_Object fontset, Lisp_Object range, Lisp_Object elt, Lisp_Object add)
@@ -667,8 +667,35 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face,
}
font_object = font_open_for_lface (f, font_entity, face->lface,
FONT_DEF_SPEC (font_def));
+
+ /* If the font registry is not the same as explicitly
+ specified in the font spec, do not cache the font.
+ TrueType fonts have contrived character map selection
+ semantics which makes determining the repertory at font
+ spec matching time unduly expensive. */
+
+ {
+ Lisp_Object spec;
+
+ spec = FONT_DEF_SPEC (font_def);
+
+ if (!NILP (font_object)
+ && !NILP (AREF (spec, FONT_REGISTRY_INDEX))
+ && !NILP (AREF (font_object, FONT_REGISTRY_INDEX))
+ && !EQ (AREF (spec, FONT_REGISTRY_INDEX),
+ AREF (font_object, FONT_REGISTRY_INDEX))
+ /* See sfntfont_registries_compatible_p in
+ sfntfont.c. */
+ && !(EQ (AREF (spec, FONT_REGISTRY_INDEX),
+ Qiso8859_1)
+ && EQ (AREF (font_object, FONT_REGISTRY_INDEX),
+ Qiso10646_1)))
+ goto strangeness;
+ }
+
if (NILP (font_object))
{
+ strangeness:
/* Something strange happened, perhaps because of a
Font-backend problem. To avoid crashing, record
that this spec is unusable. It may be better to find
@@ -1519,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))
{
@@ -1527,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));
@@ -1713,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);
@@ -1722,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");
@@ -1735,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
{
@@ -1789,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))
@@ -1805,14 +1832,19 @@ 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);
+ 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);
{
@@ -1979,7 +2011,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;