/* Fontset handler.
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010
+ 2005, 2006, 2007, 2008, 2009, 2010, 2011
National Institute of Advanced Industrial Science and Technology (AIST)
Registration Number H14PRO021
Copyright (C) 2003, 2006
#define xassert(X) (void) 0
#endif /* not FONTSET_DEBUG */
-EXFUN (Fclear_face_cache, 1);
-
/* FONTSET
A fontset is a collection of font related information to give
/********** VARIABLES and FUNCTION PROTOTYPES **********/
-extern Lisp_Object Qfont;
static Lisp_Object Qfontset;
static Lisp_Object Qfontset_info;
static Lisp_Object Qprepend, Qappend;
font for each character. */
static Lisp_Object Vdefault_fontset;
-Lisp_Object Vfont_encoding_charset_alist;
-Lisp_Object Vuse_default_ascent;
-Lisp_Object Vignore_relative_composition;
-Lisp_Object Valternate_fontname_alist;
-Lisp_Object Vfontset_alias_alist;
-Lisp_Object Vvertical_centering_font_regexp;
-Lisp_Object Votf_script_alist;
-
/* Check if any window system is used now. */
-void (*check_window_system_func) P_ ((void));
+void (*check_window_system_func) (void);
/* Prototype declarations for static functions. */
-static Lisp_Object fontset_add P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
- Lisp_Object));
-static Lisp_Object fontset_find_font P_ ((Lisp_Object, int, struct face *,
- int, int));
-static void reorder_font_vector P_ ((Lisp_Object, struct font *));
-static Lisp_Object fontset_font P_ ((Lisp_Object, int, struct face *, int));
-static Lisp_Object make_fontset P_ ((Lisp_Object, Lisp_Object, Lisp_Object));
-static Lisp_Object fontset_pattern_regexp P_ ((Lisp_Object));
-static void accumulate_script_ranges P_ ((Lisp_Object, Lisp_Object,
- Lisp_Object));
-Lisp_Object find_font_encoding P_ ((Lisp_Object));
-
-static void set_fontset_font P_ ((Lisp_Object, Lisp_Object));
+static Lisp_Object fontset_add (Lisp_Object, Lisp_Object, Lisp_Object,
+ Lisp_Object);
+static Lisp_Object fontset_find_font (Lisp_Object, int, struct face *,
+ int, int);
+static void reorder_font_vector (Lisp_Object, struct font *);
+static Lisp_Object fontset_font (Lisp_Object, int, struct face *, int);
+static Lisp_Object make_fontset (Lisp_Object, Lisp_Object, Lisp_Object);
+static Lisp_Object fontset_pattern_regexp (Lisp_Object);
+static void accumulate_script_ranges (Lisp_Object, Lisp_Object,
+ Lisp_Object);
+static void set_fontset_font (Lisp_Object, Lisp_Object);
#ifdef FONTSET_DEBUG
/* Return 1 if ID is a valid fontset id, else return 0. */
static int
-fontset_id_valid_p (id)
- int id;
+fontset_id_valid_p (int id)
{
return (id >= 0 && id < ASIZE (Vfontset_table) - 1);
}
#define RFONT_DEF_OBJECT(rfont_def) AREF (rfont_def, 2)
#define RFONT_DEF_SET_OBJECT(rfont_def, 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) XINT (AREF (rfont_def, 3))
#define RFONT_DEF_SET_SCORE(rfont_def, score) \
ASET ((rfont_def), 3, make_number (score))
: fontset_ref ((fontset), (c)))
static Lisp_Object
-fontset_ref (fontset, c)
- Lisp_Object fontset;
- int c;
+fontset_ref (Lisp_Object fontset, int c)
{
Lisp_Object elt;
: fontset_add ((fontset), (range), (elt), (add)))
static Lisp_Object
-fontset_add (fontset, range, elt, add)
- Lisp_Object fontset, range, elt, add;
+fontset_add (Lisp_Object fontset, Lisp_Object range, Lisp_Object elt, Lisp_Object add)
{
Lisp_Object args[2];
int idx = (EQ (add, Qappend) ? 0 : 1);
}
static int
-fontset_compare_rfontdef (val1, val2)
- const void *val1, *val2;
+fontset_compare_rfontdef (const void *val1, const void *val2)
{
return (RFONT_DEF_SCORE (*(Lisp_Object *) val1)
- RFONT_DEF_SCORE (*(Lisp_Object *) val2));
If PREFERRED_FAMILY is not nil, that family has the higher priority
if the encoding charsets or languages in font-specs are the same. */
-extern Lisp_Object Fassoc_string ();
-
static void
-reorder_font_vector (font_group, font)
- Lisp_Object font_group;
- struct font *font;
+reorder_font_vector (Lisp_Object font_group, struct font *font)
{
Lisp_Object vec, font_object;
int size;
Lisp_Object font_def = RFONT_DEF_FONT_DEF (rfont_def);
Lisp_Object font_spec = FONT_DEF_SPEC (font_def);
int score = RFONT_DEF_SCORE (rfont_def) & 0xFF;
+ Lisp_Object otf_spec = Ffont_get (font_spec, QCotf);
- if (! font_match_p (font_spec, font_object))
+ if (! NILP (otf_spec))
+ /* A font-spec with :otf is preferable regardless of encoding
+ and language.. */
+ ;
+ else if (! font_match_p (font_spec, font_object))
{
Lisp_Object encoding = FONT_DEF_ENCODING (font_def);
If FALLBACK is nonzero, search only fallback fonts. */
static Lisp_Object
-fontset_find_font (fontset, c, face, id, fallback)
- Lisp_Object fontset;
- int c;
- struct face *face;
- int id, fallback;
+fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, int fallback)
{
Lisp_Object vec, font_group;
int i, charset_matched = 0, found_index;
static Lisp_Object
-fontset_font (fontset, c, face, id)
- Lisp_Object fontset;
- int c;
- struct face *face;
- int id;
+fontset_font (Lisp_Object fontset, int c, struct face *face, int id)
{
Lisp_Object rfont_def, default_rfont_def;
Lisp_Object base_fontset;
BASE. */
static Lisp_Object
-make_fontset (frame, name, base)
- Lisp_Object frame, name, base;
+make_fontset (Lisp_Object frame, Lisp_Object name, Lisp_Object base)
{
Lisp_Object fontset;
int size = ASIZE (Vfontset_table);
/* Return the name of the fontset who has ID. */
Lisp_Object
-fontset_name (id)
- int id;
+fontset_name (int id)
{
Lisp_Object fontset;
/* Return the ASCII font name of the fontset who has ID. */
Lisp_Object
-fontset_ascii (id)
- int id;
+fontset_ascii (int id)
{
Lisp_Object fontset, elt;
}
void
-free_realized_fontset (f, fontset)
- FRAME_PTR f;
- Lisp_Object fontset;
+free_realized_fontset (FRAME_PTR f, Lisp_Object fontset)
{
Lisp_Object tail;
- return;
- for (tail = FONTSET_OBJLIST (fontset); CONSP (tail); tail = XCDR (tail))
- {
- xassert (FONT_OBJECT_P (XCAR (tail)));
- font_close_object (f, XCAR (tail));
- }
+ if (0)
+ for (tail = FONTSET_OBJLIST (fontset); CONSP (tail); tail = XCDR (tail))
+ {
+ xassert (FONT_OBJECT_P (XCAR (tail)));
+ font_close_object (f, XCAR (tail));
+ }
}
/* Free fontset of FACE defined on frame F. Called from
free_realized_face. */
void
-free_face_fontset (f, face)
- FRAME_PTR f;
- struct face *face;
+free_face_fontset (FRAME_PTR f, struct face *face)
{
Lisp_Object fontset;
when C is not an ASCII character. */
int
-face_suitable_for_char_p (face, c)
- struct face *face;
- int c;
+face_suitable_for_char_p (struct face *face, int c)
{
Lisp_Object fontset, rfont_def;
the macro FACE_FOR_CHAR. */
int
-face_for_char (f, face, c, pos, object)
- FRAME_PTR f;
- struct face *face;
- int c, pos;
- Lisp_Object object;
+face_for_char (FRAME_PTR f, struct face *face, int c, int pos, Lisp_Object object)
{
Lisp_Object fontset, rfont_def, charset;
int face_id;
Lisp_Object
-font_for_char (face, c, pos, object)
- struct face *face;
- int c, pos;
- Lisp_Object object;
+font_for_char (struct face *face, int c, int pos, Lisp_Object object)
{
Lisp_Object fontset, rfont_def, charset;
int id;
Called from realize_x_face. */
int
-make_fontset_for_ascii_face (f, base_fontset_id, face)
- FRAME_PTR f;
- int base_fontset_id;
- struct face *face;
+make_fontset_for_ascii_face (FRAME_PTR f, int base_fontset_id, struct face *face)
{
Lisp_Object base_fontset, fontset, frame;
expression corresponding to PATTERN. */
static Lisp_Object
-fontset_pattern_regexp (pattern)
- Lisp_Object pattern;
+fontset_pattern_regexp (Lisp_Object pattern)
{
- if (!index ((char *) SDATA (pattern), '*')
- && !index ((char *) SDATA (pattern), '?'))
+ if (!strchr ((char *) SDATA (pattern), '*')
+ && !strchr ((char *) SDATA (pattern), '?'))
/* PATTERN does not contain any wild cards. */
return Qnil;
*/
int
-fs_query_fontset (name, name_pattern)
- Lisp_Object name;
- int name_pattern;
+fs_query_fontset (Lisp_Object name, int name_pattern)
{
Lisp_Object tem;
int i;
PATTERN can contain `*' or `?' as a wildcard
just as X font name matching algorithm allows.
If REGEXPP is non-nil, PATTERN is a regular expression. */)
- (pattern, regexpp)
- Lisp_Object pattern, regexpp;
+ (Lisp_Object pattern, Lisp_Object regexpp)
{
Lisp_Object fontset;
int id;
/* Return a list of base fontset names matching PATTERN on frame F. */
Lisp_Object
-list_fontsets (f, pattern, size)
- FRAME_PTR f;
- Lisp_Object pattern;
- int size;
+list_fontsets (FRAME_PTR f, Lisp_Object pattern, int size)
{
Lisp_Object frame, regexp, val;
int id;
/* Free all realized fontsets whose base fontset is BASE. */
static void
-free_realized_fontsets (base)
- Lisp_Object base;
+free_realized_fontsets (Lisp_Object base)
{
int id;
Set *FRAME to the actual frame. */
static Lisp_Object
-check_fontset_name (name, frame)
- Lisp_Object name, *frame;
+check_fontset_name (Lisp_Object name, Lisp_Object *frame)
{
int id;
}
static void
-accumulate_script_ranges (arg, range, val)
- Lisp_Object arg, range, val;
+accumulate_script_ranges (Lisp_Object arg, Lisp_Object range, Lisp_Object val)
{
if (EQ (XCAR (arg), val))
{
case. */
static void
-set_fontset_font (arg, range)
- Lisp_Object arg, range;
+set_fontset_font (Lisp_Object arg, Lisp_Object range)
{
Lisp_Object fontset, font_def, add, ascii, script_range_list;
int from = XINT (XCAR (range)), to = XINT (XCDR (range));
ASET (arg, 4, script_range_list);
}
-extern Lisp_Object QCfamily, QCregistry;
-static void update_auto_fontset_alist P_ ((Lisp_Object, Lisp_Object));
+static void update_auto_fontset_alist (Lisp_Object, Lisp_Object);
DEFUN ("set-fontset-font", Fset_fontset_font, Sset_fontset_font, 3, 5, 0,
to the font specifications for TARGET previously set. If it is
`prepend', FONT-SPEC is prepended. If it is `append', FONT-SPEC is
appended. By default, FONT-SPEC overrides the previous settings. */)
- (name, target, font_spec, frame, add)
- Lisp_Object name, target, font_spec, frame, add;
+ (Lisp_Object name, Lisp_Object target, Lisp_Object font_spec, Lisp_Object frame, Lisp_Object add)
{
Lisp_Object fontset;
Lisp_Object font_def, registry, family;
else if (STRINGP (font_spec))
{
Lisp_Object args[2];
- extern Lisp_Object QCname;
fontname = font_spec;
args[0] = QCname;
FONT-SPEC is a vector, a cons, or a string. See the documentation of
`set-fontset-font' for the meaning. */)
- (name, fontlist)
- Lisp_Object name, fontlist;
+ (Lisp_Object name, Lisp_Object fontlist)
{
Lisp_Object fontset;
int id;
user intends to use FONT-OBJECT for Latin characters. */
int
-fontset_from_font (font_object)
- Lisp_Object font_object;
+fontset_from_font (Lisp_Object font_object)
{
Lisp_Object font_name = font_get_name (font_object);
Lisp_Object font_spec = Fcopy_font_spec (font_object);
fontset_from_font. */
static void
-update_auto_fontset_alist (font_object, fontset)
- Lisp_Object font_object, fontset;
+update_auto_fontset_alist (Lisp_Object font_object, Lisp_Object fontset)
{
Lisp_Object prev, tail;
DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
doc: /* For internal use only. */)
- (position, ch)
- Lisp_Object position, ch;
+ (Lisp_Object position, Lisp_Object ch)
{
EMACS_INT pos, pos_byte, dummy;
int face_id;
fontset, the value the extra slot is a char-table containing the
information about the derived fonts from the default fontset. The
format is the same as above. */)
- (fontset, frame)
- Lisp_Object fontset, frame;
+ (Lisp_Object fontset, Lisp_Object frame)
{
FRAME_PTR f;
Lisp_Object *realized[2], fontsets[2], tables[2];
If the 2nd optional arg ALL is non-nil, return a list of all font name
patterns. */)
- (name, ch, all)
- Lisp_Object name, ch, all;
+ (Lisp_Object name, Lisp_Object ch, Lisp_Object all)
{
int c;
Lisp_Object fontset, elt, list, repertory, val;
DEFUN ("fontset-list", Ffontset_list, Sfontset_list, 0, 0, 0,
doc: /* Return a list of all defined fontset names. */)
- ()
+ (void)
{
Lisp_Object fontset, list;
int i;
#ifdef FONTSET_DEBUG
Lisp_Object
-dump_fontset (fontset)
- Lisp_Object fontset;
+dump_fontset (Lisp_Object fontset)
{
Lisp_Object vec;
DEFUN ("fontset-list-all", Ffontset_list_all, Sfontset_list_all, 0, 0, 0,
doc: /* Return a brief summary of all fontsets for debug use. */)
- ()
+ (void)
{
Lisp_Object val;
int i;
#endif /* FONTSET_DEBUG */
void
-syms_of_fontset ()
+syms_of_fontset (void)
{
DEFSYM (Qfontset, "fontset");
Fput (Qfontset, Qchar_table_extra_slots, make_number (9));
auto_fontset_alist = Qnil;
staticpro (&auto_fontset_alist);
- DEFVAR_LISP ("font-encoding-charset-alist", &Vfont_encoding_charset_alist,
+ DEFVAR_LISP ("font-encoding-charset-alist", Vfont_encoding_charset_alist,
doc: /*
Alist of charsets vs the charsets to determine the preferred font encoding.
Each element looks like (CHARSET . ENCODING-CHARSET),
whose encoding corresponds to ENCODING-CHARSET is preferred. */);
Vfont_encoding_charset_alist = Qnil;
- DEFVAR_LISP ("use-default-ascent", &Vuse_default_ascent,
+ DEFVAR_LISP ("use-default-ascent", Vuse_default_ascent,
doc: /*
Char table of characters whose ascent values should be ignored.
If an entry for a character is non-nil, the ascent value of the glyph
such a character is displayed on screen. */);
Vuse_default_ascent = Qnil;
- DEFVAR_LISP ("ignore-relative-composition", &Vignore_relative_composition,
+ DEFVAR_LISP ("ignore-relative-composition", Vignore_relative_composition,
doc: /*
Char table of characters which are not composed relatively.
If an entry for a character is non-nil, a composition sequence
an ascent and descent value of a previous character. */);
Vignore_relative_composition = Qnil;
- DEFVAR_LISP ("alternate-fontname-alist", &Valternate_fontname_alist,
+ DEFVAR_LISP ("alternate-fontname-alist", Valternate_fontname_alist,
doc: /* Alist of fontname vs list of the alternate fontnames.
When a specified font name is not found, the corresponding
alternate fontnames (if any) are tried instead. */);
Valternate_fontname_alist = Qnil;
- DEFVAR_LISP ("fontset-alias-alist", &Vfontset_alias_alist,
+ DEFVAR_LISP ("fontset-alias-alist", Vfontset_alias_alist,
doc: /* Alist of fontset names vs the aliases. */);
Vfontset_alias_alist = Fcons (Fcons (FONTSET_NAME (Vdefault_fontset),
make_pure_c_string ("fontset-default")),
Qnil);
DEFVAR_LISP ("vertical-centering-font-regexp",
- &Vvertical_centering_font_regexp,
+ Vvertical_centering_font_regexp,
doc: /* *Regexp matching font names that require vertical centering on display.
When a character is displayed with such fonts, the character is displayed
at the vertical center of lines. */);
Vvertical_centering_font_regexp = Qnil;
- DEFVAR_LISP ("otf-script-alist", &Votf_script_alist,
+ DEFVAR_LISP ("otf-script-alist", Votf_script_alist,
doc: /* Alist of OpenType script tags vs the corresponding script names. */);
Votf_script_alist = Qnil;
defsubr (&Sfontset_list_all);
#endif
}
-
-/* arch-tag: ea861585-2f5f-4e5b-9849-d04a9c3a3537
- (do not change this comment) */