+2012-09-06 Paul Eggert <eggert@cs.ucla.edu>
+
+ Use bool for booleans in font-related modules.
+ * font.c (font_intern_prop, font_style_to_value)
+ (font_style_symbolic, font_parse_xlfd, font_parse_fcname)
+ (generate_otf_features, font_check_otf_features, font_check_otf)
+ (font_match_p, font_list_entities, font_at):
+ * fontset.c (fontset_id_valid_p, reorder_font_vector
+ (fontset_find_font, Fset_fontset_font)
+ (face_suitable_for_char_p) [0]:
+ * ftfont.c (fc_initialized, ftfont_get_open_type_spec)
+ (ftfont_open, ftfont_text_extents, ftfont_check_otf):
+ (m17n_flt_initialized, ftfont_shape_by_flt):
+ * ftxfont.c (ftxfont_draw_bitmap, ftxfont_draw):
+ * nsfont.m (nsfont_draw):
+ * w32font.c (w32font_draw):
+ * w32term.c (x_draw_glyphless_glyph_string_foreground):
+ Use bool for booleans.
+ * font.h: Adjust to above API changes.
+ (struct font, struct font_driver, struct font_driver_list):
+ Use bool for booleans.
+ (struct font): Remove useless member encoding_type.
+ All users removed.
+ * fontset.c, xftfont.c: Omit unnecessary static decls.
+
2012-09-06 Dmitry Antipov <dmantipov@yandex.ru>
* alloc.c (mark_object): Revert window marking code
/* Return a Lispy value of a font property value at STR and LEN bytes.
- If STR is "*", return nil.
- If FORCE_SYMBOL is zero and all characters in STR are digits,
- return an integer. Otherwise, return a symbol interned from
- STR. */
+ If STR is "*", return nil. If FORCE_SYMBOL, or if STR does not
+ consist entirely of one or more digits, return a symbol interned
+ from STR. Otherwise, return an integer. */
Lisp_Object
-font_intern_prop (const char *str, ptrdiff_t len, int force_symbol)
+font_intern_prop (const char *str, ptrdiff_t len, bool force_symbol)
{
ptrdiff_t i;
Lisp_Object tem;
VAL is an integer. */
int
-font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror)
+font_style_to_value (enum font_property_index prop, Lisp_Object val,
+ bool noerror)
{
Lisp_Object table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX);
int len;
}
Lisp_Object
-font_style_symbolic (Lisp_Object font, enum font_property_index prop, int for_face)
+font_style_symbolic (Lisp_Object font, enum font_property_index prop,
+ bool for_face)
{
Lisp_Object val = AREF (font, prop);
Lisp_Object table, elt;
}
else
{
- int wild_card_found = 0;
+ bool wild_card_found = 0;
Lisp_Object prop[XLFD_LAST_INDEX];
if (FONT_ENTITY_P (font))
}
else if (*p == '-')
{
- int decimal = 0, size_found = 1;
+ bool decimal = 0, size_found = 1;
for (q = p + 1; *q && *q != ':'; q++)
if (! c_isdigit (*q))
{
{
Lisp_Object val;
char *p;
- int asterisk;
+ bool asterisk;
p = features;
*p = '\0';
}
}
-static int
-font_check_otf_features (Lisp_Object script, Lisp_Object langsys, Lisp_Object features, Lisp_Object table)
+static bool
+font_check_otf_features (Lisp_Object script, Lisp_Object langsys,
+ Lisp_Object features, Lisp_Object table)
{
Lisp_Object val;
- int negative;
+ bool negative;
table = assq_no_quit (script, table);
if (NILP (table))
/* Check if OTF_CAPABILITY satisfies SPEC (otf-spec). */
-static int
+static bool
font_check_otf (Lisp_Object spec, Lisp_Object otf_capability)
{
Lisp_Object script, langsys = Qnil, gsub = Qnil, gpos = Qnil;
/* Check if FONT (font-entity or font-object) matches with the font
specification SPEC. */
-int
+bool
font_match_p (Lisp_Object spec, Lisp_Object font)
{
Lisp_Object prop[FONT_SPEC_MAX], *props;
Lisp_Object ftype, val;
Lisp_Object list = Qnil;
int size;
- int need_filtering = 0;
+ bool need_filtering = 0;
int i;
eassert (FONT_SPEC_P (spec));
{
Lisp_Object font_entity;
Lisp_Object prefer;
- int result, i;
+ int i;
FRAME_PTR f = XFRAME (frame);
if (NILP (XCDR (entities))
&& ASIZE (XCAR (entities)) == 1)
{
font_entity = AREF (XCAR (entities), 0);
- if (c < 0
- || (result = font_has_char (f, font_entity, c)) > 0)
+ if (c < 0 || font_has_char (f, font_entity, c) > 0)
return font_entity;
return Qnil;
}
Lisp_Object string)
{
FRAME_PTR f;
- int multibyte;
+ bool multibyte;
Lisp_Object font_object;
multibyte = (NILP (string)
negative if that information is not in the font. */
int underline_position;
- /* 1 if `vertical-centering-font-regexp' matches this font name.
+ /* True if `vertical-centering-font-regexp' matches this font name.
In this case, we render characters at vertical center positions
of lines. */
- int vertical_centering;
-
- /* Encoding type of the font. The value is one of
- 0, 1, 2, or 3:
- 0: code points 0x20..0x7F or 0x2020..0x7F7F are used
- 1: code points 0xA0..0xFF or 0xA0A0..0xFFFF are used
- 2: code points 0x20A0..0x7FFF are used
- 3: code points 0xA020..0xFF7F are used
- If the member `font_encoder' is not NULL, this member is ignored. */
- unsigned char encoding_type;
+ bool vertical_centering;
/* The baseline position of a font is normally `ascent' value of the
font. However, there exist many fonts which don't set `ascent' to
/* Symbol indicating the type of the font-driver. */
Lisp_Object type;
- /* 1 iff the font's foundry, family, and adstyle names are case
+ /* True iff the font's foundry, family, and adstyle names are case
sensitive. */
- int case_sensitive;
+ bool case_sensitive;
/* Return a cache of font-entities on frame F. The cache must be a
cons whose cdr part is the actual cache area. */
/* Optional.
Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
- position of frame F with S->FACE and S->GC. If WITH_BACKGROUND
- is nonzero, fill the background in advance. It is assured that
- WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). */
+ position of frame F with S->FACE and S->GC. If WITH_BACKGROUND,
+ fill the background in advance. It is assured that WITH_BACKGROUND
+ is false when (FROM > 0 || TO < S->nchars). */
int (*draw) (struct glyph_string *s, int from, int to,
- int x, int y, int with_background);
+ int x, int y, bool with_background);
/* Optional.
Store bitmap data for glyph-code CODE of FONT in BITMAP. It is
short, return -1. */
int (*otf_drive) (struct font *font, Lisp_Object features,
Lisp_Object gstring_in, int from, int to,
- Lisp_Object gstring_out, int idx, int alternate_subst);
+ Lisp_Object gstring_out, int idx, bool alternate_subst);
/* Optional.
Make the font driver ready for frame F. Usually this function
Return non-zero if FONT_OBJECT can be used as a (cached) font
for ENTITY on frame F. */
- int (*cached_font_ok) (struct frame *f,
- Lisp_Object font_object,
- Lisp_Object entity);
+ bool (*cached_font_ok) (struct frame *f,
+ Lisp_Object font_object,
+ Lisp_Object entity);
};
struct font_driver_list
{
- /* 1 iff this driver is currently used. It is ignored in the global
+ /* True iff this driver is currently used. It is ignored in the global
font driver list.*/
- int on;
+ bool on;
/* Pointer to the font driver. */
struct font_driver *driver;
/* Pointer to the next element of the chain. */
extern int font_registry_charsets (Lisp_Object, struct charset **,
struct charset **);
extern int font_style_to_value (enum font_property_index prop,
- Lisp_Object name, int noerror);
+ Lisp_Object name, bool noerror);
extern Lisp_Object font_style_symbolic (Lisp_Object font,
enum font_property_index prop,
- int for_face);
+ bool for_face);
-extern int font_match_p (Lisp_Object spec, Lisp_Object font);
+extern bool font_match_p (Lisp_Object spec, Lisp_Object font);
extern Lisp_Object font_list_entities (Lisp_Object frame,
Lisp_Object spec);
extern Lisp_Object font_open_by_name (FRAME_PTR f, Lisp_Object name);
extern Lisp_Object font_intern_prop (const char *str, ptrdiff_t len,
- int force_symbol);
+ bool force_symbol);
extern void font_update_sort_order (int *order);
extern void font_parse_family_registry (Lisp_Object family,
/* Prototype declarations for static functions. */
-static void 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);
-/* Return 1 if ID is a valid fontset id, else return 0.
+/* Return true if ID is a valid fontset id.
Optimized away if ENABLE_CHECKING is not defined. */
-static int
+static bool
fontset_id_valid_p (int id)
{
return (id >= 0 && id < ASIZE (Vfontset_table) - 1);
Lisp_Object vec, font_object;
int size;
int i;
- int score_changed = 0;
+ bool score_changed = 0;
if (font)
XSETFONT (font_object, font);
ID is a charset-id that must be preferred, or -1 meaning no
preference.
- If FALLBACK is nonzero, search only fallback fonts. */
+ If FALLBACK, search only fallback fonts. */
static Lisp_Object
-fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, int fallback)
+fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id,
+ bool fallback)
{
Lisp_Object vec, font_group;
int i, charset_matched = 0, found_index;
#if 0
-/* Return 1 if FACE is suitable for displaying character C.
- Otherwise return 0. Called from the macro FACE_SUITABLE_FOR_CHAR_P
+/* Return true if FACE is suitable for displaying character C.
+ Called from the macro FACE_SUITABLE_FOR_CHAR_P
when C is not an ASCII character. */
-int
+bool
face_suitable_for_char_p (struct face *face, int c)
{
Lisp_Object fontset, rfont_def;
Lisp_Object range_list;
struct charset *charset = NULL;
Lisp_Object fontname;
- int ascii_changed = 0;
+ bool ascii_changed = 0;
fontset = check_fontset_name (name, &frame);
static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif;
/* Flag to tell if FcInit is already called or not. */
-static int fc_initialized;
+static bool fc_initialized;
/* Handle to a FreeType library instance. */
static FT_Library ft_library;
#ifdef HAVE_LIBOTF
/* The following four members must be here in this order to be
compatible with struct xftfont_info (in xftfont.c). */
- int maybe_otf; /* Flag to tell if this may be OTF or not. */
+ bool maybe_otf; /* Flag to tell if this may be OTF or not. */
OTF *otf;
#endif /* HAVE_LIBOTF */
FT_Size ft_size;
/* We can't draw a text without device dependent functions. */
NULL, /* draw */
ftfont_get_bitmap,
- NULL, /* get_bitmap */
NULL, /* free_bitmap */
NULL, /* get_outline */
+ NULL, /* free_outline */
ftfont_anchor_point,
#ifdef HAVE_LIBOTF
ftfont_otf_capability,
{
struct OpenTypeSpec *spec = malloc (sizeof *spec);
Lisp_Object val;
- int i, j, negative;
+ int i, j;
+ bool negative;
if (! spec)
return NULL;
FT_Size ft_size;
FT_UInt size;
Lisp_Object val, filename, idx, cache, font_object;
- int scalable;
+ bool scalable;
int spacing;
char name[256];
int i, len;
ftfont_info->ft_size = ft_face->size;
ftfont_info->index = XINT (idx);
#ifdef HAVE_LIBOTF
- ftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT;
+ ftfont_info->maybe_otf = (ft_face->face_flags & FT_FACE_FLAG_SFNT) != 0;
ftfont_info->otf = NULL;
#endif /* HAVE_LIBOTF */
/* This means that there's no need of transformation. */
struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
FT_Face ft_face = ftfont_info->ft_size->face;
int width = 0;
- int i, first;
+ int i;
+ bool first;
if (ftfont_info->ft_size != ft_face->size)
FT_Activate_Size (ftfont_info->ft_size);
struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font;
OTF *otf = flt_font_ft->otf;
OTF_Tag *tags;
- int i, n, negative;
+ int i, n;
+ bool negative;
if (FEATURE_ANY (0) && FEATURE_ANY (1))
- /* Return 1 iff any of GSUB or GPOS support the script (and language). */
+ /* Return true iff any of GSUB or GPOS support the script (and
+ language). */
return (otf
&& (OTF_check_features (otf, 0, spec->script, spec->langsys,
NULL, 0) > 0
static MFLTGlyphString gstring;
-static int m17n_flt_initialized;
+static bool m17n_flt_initialized;
static Lisp_Object
ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
ptrdiff_t i;
struct MFLTFontFT flt_font_ft;
MFLT *flt = NULL;
- int with_variation_selector = 0;
+ bool with_variation_selector = 0;
if (! m17n_flt_initialized)
{
break;
c = LGLYPH_CHAR (g);
if (CHAR_VARIATION_SELECTOR_P (c))
- with_variation_selector++;
+ with_variation_selector = 1;
}
len = i;
#endif
struct font_driver ftxfont_driver;
-/* Prototypes for helper function. */
-static GC *ftxfont_get_gcs (FRAME_PTR, unsigned long, unsigned long);
-static int ftxfont_draw_bitmap (FRAME_PTR, GC, GC *, struct font *,
- unsigned, int, int, XPoint *, int, int *,
- int);
-static void ftxfont_draw_background (FRAME_PTR, struct font *, GC,
- int, int, int);
-
struct ftxfont_frame_data
{
/* Background and foreground colors. */
}
static int
-ftxfont_draw_bitmap (FRAME_PTR f, GC gc_fore, GC *gcs, struct font *font, unsigned int code, int x, int y, XPoint *p, int size, int *n, int flush)
+ftxfont_draw_bitmap (FRAME_PTR f, GC gc_fore, GC *gcs, struct font *font,
+ unsigned int code, int x, int y, XPoint *p, int size,
+ int *n, bool flush)
{
struct font_bitmap bitmap;
unsigned char *b;
XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.foreground);
}
-/* Prototypes for font-driver methods. */
-static Lisp_Object ftxfont_list (Lisp_Object, Lisp_Object);
-static Lisp_Object ftxfont_match (Lisp_Object, Lisp_Object);
-static Lisp_Object ftxfont_open (FRAME_PTR, Lisp_Object, int);
-static void ftxfont_close (FRAME_PTR, struct font *);
-static int ftxfont_draw (struct glyph_string *, int, int, int, int, int);
-
static Lisp_Object
ftxfont_list (Lisp_Object frame, Lisp_Object spec)
{
}
static int
-ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background)
+ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y,
+ bool with_background)
{
FRAME_PTR f = s->f;
struct face *face = s->face;
static int nsfont_text_extents (struct font *font, unsigned int *code,
int nglyphs, struct font_metrics *metrics);
static int nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
- int with_background);
+ bool with_background);
struct font_driver nsfont_driver =
{
font = (struct font *) font_info;
font->pixel_size = [sfont pointSize];
font->driver = &nsfont_driver;
- font->encoding_type = FONT_ENCODING_NOT_DECIDED;
font->encoding_charset = -1;
font->repertory_charset = -1;
font->default_ascent = 0;
/* Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
- position of frame F with S->FACE and S->GC. If WITH_BACKGROUND
- is nonzero, fill the background in advance. It is assured that
- WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). */
+ position of frame F with S->FACE and S->GC. If WITH_BACKGROUND,
+ fill the background in advance. It is assured that WITH_BACKGROUND
+ is false when (FROM > 0 || TO < S->nchars). */
static int
nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
- int with_background)
+ bool with_background)
/* NOTE: focus and clip must be set
also, currently assumed (true in nsterm.m call) from ==0, to ==nchars */
{
/* w32 implementation of draw for font backend.
Optional.
Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
- position of frame F with S->FACE and S->GC. If WITH_BACKGROUND
- is nonzero, fill the background in advance. It is assured that
- WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars).
+ position of frame F with S->FACE and S->GC. If WITH_BACKGROUND,
+ fill the background in advance. It is assured that WITH_BACKGROUND
+ is false when (FROM > 0 || TO < S->nchars).
TODO: Currently this assumes that the colors and fonts are already
set in the DC. This seems to be true now, but maybe only due to
int
w32font_draw (struct glyph_string *s, int from, int to,
- int x, int y, int with_background)
+ int x, int y, bool with_background)
{
UINT options;
HRGN orig_clip = NULL;
w32font_otf_drive (struct font *font, Lisp_Object features,
Lisp_Object gstring_in, int from, int to,
Lisp_Object gstring_out, int idx,
- int alternate_subst);
+ bool alternate_subst);
*/
/* Internal implementation of w32font_list.
font->space_width = font->average_width = w32_font->metrics.tmAveCharWidth;
font->vertical_centering = 0;
- font->encoding_type = 0;
font->baseline_offset = 0;
font->relative_compose = 0;
font->default_ascent = w32_font->metrics.tmAscent;
int w32font_text_extents (struct font *font, unsigned *code, int nglyphs,
struct font_metrics *metrics);
int w32font_draw (struct glyph_string *s, int from, int to,
- int x, int y, int with_background);
+ int x, int y, bool with_background);
int uniscribe_check_otf (LOGFONT *font, Lisp_Object otf_spec);
static unsigned xfont_encode_char (struct font *, int);
static int xfont_text_extents (struct font *, unsigned *, int,
struct font_metrics *);
-static int xfont_draw (struct glyph_string *, int, int, int, int, int);
+static int xfont_draw (struct glyph_string *, int, int, int, int, bool);
static int xfont_check (FRAME_PTR, struct font *);
struct font_driver xfont_driver =
/* Check if CHARS (cons or vector) is supported by XFONT whose
encoding charset is ENCODING (XFONT is NULL) or by a font whose
registry corresponds to ENCODING and REPERTORY.
- Return 1 if supported, return 0 otherwise. */
+ Return true if supported. */
-static int
+static bool
xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont,
struct charset *encoding, struct charset *repertory)
{
}
static int
-xfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background)
+xfont_draw (struct glyph_string *s, int from, int to, int x, int y,
+ bool with_background)
{
XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont;
int len = to - from;
for (i = 0; i < len ; i++)
str[i] = XCHAR2B_BYTE2 (s->char2b + from + i);
BLOCK_INPUT;
- if (with_background > 0)
+ if (with_background)
{
if (s->padding_p)
for (i = 0; i < len; i++)
}
BLOCK_INPUT;
- if (with_background > 0)
+ if (with_background)
{
if (s->padding_p)
for (i = 0; i < len; i++)
/* The following five members must be here in this order to be
compatible with struct ftfont_info (in ftfont.c). */
#ifdef HAVE_LIBOTF
- int maybe_otf; /* Flag to tell if this may be OTF or not. */
+ bool maybe_otf; /* Flag to tell if this may be OTF or not. */
OTF *otf;
#endif /* HAVE_LIBOTF */
FT_Size ft_size;
else
{
XGCValues xgcv;
- int fg_done = 0, bg_done = 0;
+ bool fg_done = 0, bg_done = 0;
BLOCK_INPUT;
XGetGCValues (FRAME_X_DISPLAY (f), gc,
*bg = xftface_info->xft_fg, bg_done = 1;
}
- if (fg_done + bg_done < 2)
+ if (! (fg_done & bg_done))
{
XColor colors[2];
}
-static Lisp_Object xftfont_list (Lisp_Object, Lisp_Object);
-static Lisp_Object xftfont_match (Lisp_Object, Lisp_Object);
-static Lisp_Object xftfont_open (FRAME_PTR, Lisp_Object, int);
-static void xftfont_close (FRAME_PTR, struct font *);
-static int xftfont_prepare_face (FRAME_PTR, struct face *);
-static void xftfont_done_face (FRAME_PTR, struct face *);
-static int xftfont_has_char (Lisp_Object, int);
-static unsigned xftfont_encode_char (struct font *, int);
-static int xftfont_text_extents (struct font *, unsigned *, int,
- struct font_metrics *);
-static int xftfont_draw (struct glyph_string *, int, int, int, int, int);
-static int xftfont_end_for_frame (FRAME_PTR f);
-
struct font_driver xftfont_driver;
static Lisp_Object
font->underline_thickness = 0;
}
#ifdef HAVE_LIBOTF
- xftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT;
+ xftfont_info->maybe_otf = (ft_face->face_flags & FT_FACE_FLAG_SFNT) != 0;
xftfont_info->otf = NULL;
#endif /* HAVE_LIBOTF */
xftfont_info->ft_size = ft_face->size;
}
static int
-xftfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background)
+xftfont_draw (struct glyph_string *s, int from, int to, int x, int y,
+ bool with_background)
{
FRAME_PTR f = s->f;
struct face *face = s->face;
return 0;
}
-static int
-xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object, Lisp_Object entity)
+static bool
+xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object,
+ Lisp_Object entity)
{
struct xftfont_info *info = (struct xftfont_info *) XFONT_OBJECT (font_object);
FcPattern *oldpat = info->xftfont->pattern;
Display *display = FRAME_X_DISPLAY (f);
FcPattern *pat = FcPatternCreate ();
FcBool b1, b2;
- int ok = 0, i1, i2, r1, r2;
+ bool ok = 0;
+ int i1, i2, r1, r2;
xftfont_add_rendering_parameters (pat, entity);
XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat);