/* Fontset handler.
-Copyright (C) 2001-2011 Free Software Foundation, Inc.
+Copyright (C) 2001-2012 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2006, 2007, 2008, 2009, 2010, 2011
National Institute of Advanced Industrial Science and Technology (AIST)
You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
-/* #define FONTSET_DEBUG */
-
#include <config.h>
#include <stdio.h>
#include <setjmp.h>
#include "lisp.h"
#include "blockinput.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "charset.h"
#include "ccl.h"
#include "keyboard.h"
#include "font.h"
-#undef xassert
-#ifdef FONTSET_DEBUG
-#define xassert(X) do {if (!(X)) abort ();} while (0)
-#else /* not FONTSET_DEBUG */
-#define xassert(X) (void) 0
-#endif /* not FONTSET_DEBUG */
-
/* FONTSET
A fontset is a collection of font related information to give
These structures are hidden from the other codes than this file.
The other codes handle fontsets only by their ID numbers. They
usually use the variable name `fontset' for IDs. But, in this
- file, we always use varialbe name `id' for IDs, and name `fontset'
+ file, we always use variable name `id' for IDs, and name `fontset'
for an actual fontset object, i.e., char-table.
*/
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. */
+/* Return 1 if ID is a valid fontset id, else return 0.
+ Optimized away if ENABLE_CHECKING is not defined. */
static int
fontset_id_valid_p (int id)
return (id >= 0 && id < ASIZE (Vfontset_table) - 1);
}
-#endif
-
\f
/********** MACROS AND FUNCTIONS TO HANDLE FONTSET **********/
Lisp_Object base_fontset;
int from = 0, to = MAX_CHAR, i;
- xassert (! BASE_FONTSET_P (fontset));
+ eassert (! BASE_FONTSET_P (fontset));
if (c >= 0)
font_group = CHAR_TABLE_REF (fontset, c);
else
{
/* Something strange happened, perhaps because of a
Font-backend problem. Too avoid crashing, record
- that this spec is unsable. It may be better to find
+ that this spec is unusable. It may be better to find
another font of the same spec, but currently we don't
have such an API. */
RFONT_DEF_SET_FACE (rfont_def, -1);
if (font_has_char (f, font_object, c))
goto found;
- /* Find a font already opened, maching with the current spec,
+ /* Find a font already opened, matching with the current spec,
and supporting C. */
font_def = RFONT_DEF_FONT_DEF (rfont_def);
for (; found_index + 1 < ASIZE (vec); found_index++)
if (0)
for (tail = FONTSET_OBJLIST (fontset); CONSP (tail); tail = XCDR (tail))
{
- xassert (FONT_OBJECT_P (XCAR (tail)));
+ eassert (FONT_OBJECT_P (XCAR (tail)));
font_close_object (f, XCAR (tail));
}
#endif
fontset = FONTSET_FROM_ID (face->fontset);
if (NILP (fontset))
return;
- xassert (! BASE_FONTSET_P (fontset));
- xassert (f == XFRAME (FONTSET_FRAME (fontset)));
+ eassert (! BASE_FONTSET_P (fontset));
+ eassert (f == XFRAME (FONTSET_FRAME (fontset)));
free_realized_fontset (f, fontset);
ASET (Vfontset_table, face->fontset, Qnil);
if (face->fontset < next_fontset_id)
int id = XINT (FONTSET_ID (FONTSET_DEFAULT (fontset)));
fontset = AREF (Vfontset_table, id);
- xassert (!NILP (fontset) && ! BASE_FONTSET_P (fontset));
- xassert (f == XFRAME (FONTSET_FRAME (fontset)));
+ eassert (!NILP (fontset) && ! BASE_FONTSET_P (fontset));
+ eassert (f == XFRAME (FONTSET_FRAME (fontset)));
free_realized_fontset (f, fontset);
ASET (Vfontset_table, id, Qnil);
if (id < next_fontset_id)
/* Return ID of face suitable for displaying character C on frame F.
- FACE must be reazlied for ASCII characters in advance. Called from
+ FACE must be realized for ASCII characters in advance. Called from
the macro FACE_FOR_CHAR. */
int
if (ASCII_CHAR_P (c) || face->fontset < 0)
return face->ascii_face->id;
- xassert (fontset_id_valid_p (face->fontset));
+ eassert (fontset_id_valid_p (face->fontset));
fontset = FONTSET_FROM_ID (face->fontset);
- xassert (!BASE_FONTSET_P (fontset));
+ eassert (!BASE_FONTSET_P (fontset));
if (pos < 0)
{
FONTSET_NOFONT_FACE (fontset) = make_number (face_id);
}
}
- xassert (face_id >= 0);
+ eassert (face_id >= 0);
return face_id;
}
return font_object;
}
- xassert (fontset_id_valid_p (face->fontset));
+ eassert (fontset_id_valid_p (face->fontset));
fontset = FONTSET_FROM_ID (face->fontset);
- xassert (!BASE_FONTSET_P (fontset));
+ eassert (!BASE_FONTSET_P (fontset));
if (pos < 0)
{
id = -1;
nescs++;
}
- /* If PATTERN is not full XLFD we conert "*" to ".*". Otherwise
+ /* If PATTERN is not full XLFD we convert "*" to ".*". Otherwise
we convert "*" to "[^-]*" which is much faster in regular
expression matching. */
if (ndashes < 14)
- p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 2 * nstars + 2 * nescs + 1);
+ p1 = regex = alloca (SBYTES (pattern) + 2 * nstars + 2 * nescs + 1);
else
- p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 2 * nescs + 1);
+ p1 = regex = alloca (SBYTES (pattern) + 5 * nstars + 2 * nescs + 1);
*p1++ = '^';
for (p0 = SDATA (pattern); *p0; p0++)
In FONTSET, set FONT_DEF in a fashion specified by ADD for
characters in RANGE and ranges in SCRIPT_RANGE_LIST before RANGE.
- The consumed ranges are poped up from SCRIPT_RANGE_LIST, and the
+ The consumed ranges are popped up from SCRIPT_RANGE_LIST, and the
new SCRIPT_RANGE_LIST is stored in ARG.
If ASCII is nil, don't set FONT_DEF for ASCII characters. It is
Fset_char_table_range (fontset, Qt, Qnil);
}
- for (; ! NILP (fontlist); fontlist = Fcdr (fontlist))
+ for (; CONSP (fontlist); fontlist = XCDR (fontlist))
{
Lisp_Object elt, script;
/* Number of automatically created fontsets. */
static ptrdiff_t num_auto_fontsets;
-/* Retun a fontset synthesized from FONT-OBJECT. This is called from
+/* Return a fontset synthesized from FONT-OBJECT. This is called from
x_new_font when FONT-OBJECT is used for the default ASCII font of a
frame, and the returned fontset is used for the default fontset of
that frame. The fontset specifies a font of the same registry as
/* Return a cons (FONT-OBJECT . GLYPH-CODE).
FONT-OBJECT is the font for the character at POSITION in the current
buffer. This is computed from all the text properties and overlays
- that apply to POSITION. POSTION may be nil, in which case,
+ that apply to POSITION. POSITION may be nil, in which case,
FONT-SPEC is the font for displaying the character CH with the
default face.
/* Recode fontsets realized on FRAME from the base fontset FONTSET
in the table `realized'. */
- realized[0] = (Lisp_Object *) alloca (sizeof (Lisp_Object)
- * ASIZE (Vfontset_table));
+ realized[0] = alloca (sizeof (Lisp_Object) * ASIZE (Vfontset_table));
for (i = j = 0; i < ASIZE (Vfontset_table); i++)
{
elt = FONTSET_FROM_ID (i);
}
realized[0][j] = Qnil;
- realized[1] = (Lisp_Object *) alloca (sizeof (Lisp_Object)
- * ASIZE (Vfontset_table));
+ realized[1] = alloca (sizeof (Lisp_Object) * ASIZE (Vfontset_table));
for (i = j = 0; ! NILP (realized[0][i]); i++)
{
elt = FONTSET_DEFAULT (realized[0][i]);
}
-#ifdef FONTSET_DEBUG
+#ifdef ENABLE_CHECKING
Lisp_Object dump_fontset (Lisp_Object) EXTERNALLY_VISIBLE;
val = Fcons (dump_fontset (AREF (Vfontset_table, i)), val);
return (Fnreverse (val));
}
-#endif /* FONTSET_DEBUG */
+#endif /* ENABLE_CHECKING */
void
syms_of_fontset (void)
staticpro (&Vdefault_fontset);
FONTSET_ID (Vdefault_fontset) = make_number (0);
FONTSET_NAME (Vdefault_fontset)
- = make_pure_c_string ("-*-*-*-*-*-*-*-*-*-*-*-*-fontset-default");
+ = build_pure_c_string ("-*-*-*-*-*-*-*-*-*-*-*-*-fontset-default");
ASET (Vfontset_table, 0, Vdefault_fontset);
next_fontset_id = 1;
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")),
+ build_pure_c_string ("fontset-default")),
Qnil);
DEFVAR_LISP ("vertical-centering-font-regexp",
Vvertical_centering_font_regexp,
- doc: /* *Regexp matching font names that require vertical centering on display.
+ 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;
defsubr (&Sfontset_info);
defsubr (&Sfontset_font);
defsubr (&Sfontset_list);
-#ifdef FONTSET_DEBUG
+#ifdef ENABLE_CHECKING
defsubr (&Sfontset_list_all);
#endif
}