Commit a4fe9c70 authored by Alexander Gramiak's avatar Alexander Gramiak

Replace XChar2b with unsigned in all font backends

The xfont backend using XChar2b in its API doesn't mean that we should
use it everywhere else.

* src/dispextern.h (glyph_string):
* src/ftcrfont.c (ftcrfont_draw):
* src/ftxfont.c (ftxfont_draw):
* src/w32term.c (w32_draw_glyphless_glyph_string_foreground):
* src/xdisp.c (init_glyph_string, get_char_face_and_encoding)
(get_glyph_face_and_encoding, get_char_glyph_code)
(fill_gstring_glyph_string, fill_stretch_glyph_string)
(normal_char_ascent_descent, gui_get_glyph_overhangs)
(compute_overhangs_and_x, gui_produce_glyphs):
* src/xfont.c (xfont_get_pcm, xfont_chars_supported, xfont_open)
(xfont_encode_char, xfont_text_extents, xfont_draw)
* src/xftfont.c (xftfont_draw):
* src/xterm.c (x_compute_glyph_string_overhangs)
(x_draw_glyphless_glyph_string_foreground): Use unsigned over XChar2b.

* src/nsgui.h:
* src/w32gui.h:
* src/xterm.h: Remove XChar2b, STORE_XCHAR2B, XCHAR2B_BYTE1, and
XCHAR2B_BYTE2 typedefs and macros.

* src/font.h (font_driver):
(ftfont_text_extents)
* src/ftcrfont.c (ftcrfont_text_extents):
* src/ftfont.c (ftfont_text_extents):
* src/macfont.m (macfont_text_extents):
* src/nsfont.m (nsfont_text_extents):
* src/w32font.h (w32_font_text_extents):
* src/font.c (xfont_text_extents):
* src/xftfont.c (xftfont_text_extents): Make code parameter const.
parent b3d3c0da
...@@ -1317,7 +1317,7 @@ struct glyph_string ...@@ -1317,7 +1317,7 @@ struct glyph_string
enum glyph_row_area area; enum glyph_row_area area;
/* Characters to be drawn, and number of characters. */ /* Characters to be drawn, and number of characters. */
XChar2b *char2b; unsigned *char2b;
int nchars; int nchars;
/* A face-override for drawing cursors, mouse face and similar. */ /* A face-override for drawing cursors, mouse face and similar. */
......
...@@ -647,7 +647,7 @@ struct font_driver ...@@ -647,7 +647,7 @@ struct font_driver
the font FONT and the sequence of glyph codes CODE, and store the the font FONT and the sequence of glyph codes CODE, and store the
result in METRICS. */ result in METRICS. */
void (*text_extents) (struct font *font, void (*text_extents) (struct font *font,
unsigned *code, int nglyphs, const unsigned *code, int nglyphs,
struct font_metrics *metrics); struct font_metrics *metrics);
#ifdef HAVE_WINDOW_SYSTEM #ifdef HAVE_WINDOW_SYSTEM
...@@ -894,7 +894,7 @@ extern Lisp_Object ftfont_shape (Lisp_Object); ...@@ -894,7 +894,7 @@ extern Lisp_Object ftfont_shape (Lisp_Object);
extern unsigned ftfont_encode_char (struct font *, int); extern unsigned ftfont_encode_char (struct font *, int);
extern void ftfont_close (struct font *); extern void ftfont_close (struct font *);
extern void ftfont_filter_properties (Lisp_Object, Lisp_Object); extern void ftfont_filter_properties (Lisp_Object, Lisp_Object);
extern void ftfont_text_extents (struct font *, unsigned *, int, extern void ftfont_text_extents (struct font *, const unsigned *, int,
struct font_metrics *); struct font_metrics *);
extern void syms_of_ftfont (void); extern void syms_of_ftfont (void);
#endif /* HAVE_FREETYPE */ #endif /* HAVE_FREETYPE */
......
...@@ -242,7 +242,7 @@ ftcrfont_close (struct font *font) ...@@ -242,7 +242,7 @@ ftcrfont_close (struct font *font)
static void static void
ftcrfont_text_extents (struct font *font, ftcrfont_text_extents (struct font *font,
unsigned *code, const unsigned *code,
int nglyphs, int nglyphs,
struct font_metrics *metrics) struct font_metrics *metrics)
{ {
...@@ -341,13 +341,12 @@ ftcrfont_draw (struct glyph_string *s, ...@@ -341,13 +341,12 @@ ftcrfont_draw (struct glyph_string *s,
glyphs = alloca (sizeof (cairo_glyph_t) * len); glyphs = alloca (sizeof (cairo_glyph_t) * len);
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
unsigned code = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8) glyphs[i].index = s->char2b[from + i];
| XCHAR2B_BYTE2 (s->char2b + from + i));
glyphs[i].index = code;
glyphs[i].x = x; glyphs[i].x = x;
glyphs[i].y = y; glyphs[i].y = y;
x += (s->padding_p ? 1 : ftcrfont_glyph_extents (s->font, code, NULL)); x += (s->padding_p ? 1 : ftcrfont_glyph_extents (s->font,
glyphs[i].index,
NULL));
} }
x_set_cr_source_with_gc_foreground (f, s->gc); x_set_cr_source_with_gc_foreground (f, s->gc);
......
...@@ -1353,7 +1353,7 @@ ftfont_encode_char (struct font *font, int c) ...@@ -1353,7 +1353,7 @@ ftfont_encode_char (struct font *font, int c)
} }
void void
ftfont_text_extents (struct font *font, unsigned int *code, ftfont_text_extents (struct font *font, const unsigned int *code,
int nglyphs, struct font_metrics *metrics) int nglyphs, struct font_metrics *metrics)
{ {
struct font_info *ftfont_info = (struct font_info *) font; struct font_info *ftfont_info = (struct font_info *) font;
......
...@@ -252,7 +252,7 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, ...@@ -252,7 +252,7 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y,
struct font *font = s->font; struct font *font = s->font;
XPoint p[0x700]; XPoint p[0x700];
int n[7]; int n[7];
unsigned *code; unsigned *code = s->char2b + from;
int len = to - from; int len = to - from;
int i; int i;
GC *gcs; GC *gcs;
...@@ -260,14 +260,9 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, ...@@ -260,14 +260,9 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y,
n[0] = n[1] = n[2] = n[3] = n[4] = n[5] = n[6] = 0; n[0] = n[1] = n[2] = n[3] = n[4] = n[5] = n[6] = 0;
USE_SAFE_ALLOCA;
SAFE_NALLOCA (code, 1, len);
block_input (); block_input ();
if (with_background) if (with_background)
ftxfont_draw_background (f, font, s->gc, x, y, s->width); ftxfont_draw_background (f, font, s->gc, x, y, s->width);
for (i = 0; i < len; i++)
code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8)
| XCHAR2B_BYTE2 (s->char2b + from + i));
if (face->gc == s->gc) if (face->gc == s->gc)
{ {
...@@ -312,7 +307,6 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, ...@@ -312,7 +307,6 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y,
} }
unblock_input (); unblock_input ();
SAFE_FREE ();
return len; return len;
} }
......
...@@ -1639,7 +1639,7 @@ static CGGlyph macfont_get_glyph_for_cid (struct font *font, ...@@ -1639,7 +1639,7 @@ static CGGlyph macfont_get_glyph_for_cid (struct font *font,
static void macfont_close (struct font *); static void macfont_close (struct font *);
static int macfont_has_char (Lisp_Object, int); static int macfont_has_char (Lisp_Object, int);
static unsigned macfont_encode_char (struct font *, int); static unsigned macfont_encode_char (struct font *, int);
static void macfont_text_extents (struct font *, unsigned int *, int, static void macfont_text_extents (struct font *, const unsigned int *, int,
struct font_metrics *); struct font_metrics *);
static int macfont_draw (struct glyph_string *, int, int, int, int, bool); static int macfont_draw (struct glyph_string *, int, int, int, int, bool);
static Lisp_Object macfont_shape (Lisp_Object); static Lisp_Object macfont_shape (Lisp_Object);
...@@ -2735,7 +2735,7 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no ...@@ -2735,7 +2735,7 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
} }
static void static void
macfont_text_extents (struct font *font, unsigned int *code, int nglyphs, macfont_text_extents (struct font *font, const unsigned int *code, int nglyphs,
struct font_metrics *metrics) struct font_metrics *metrics)
{ {
int width, i; int width, i;
......
...@@ -945,7 +945,7 @@ when setting family in ns_spec_to_descriptor(). */ ...@@ -945,7 +945,7 @@ when setting family in ns_spec_to_descriptor(). */
of METRICS. The glyphs are specified by their glyph codes in of METRICS. The glyphs are specified by their glyph codes in
CODE (length NGLYPHS). */ CODE (length NGLYPHS). */
static void static void
nsfont_text_extents (struct font *font, unsigned int *code, nsfont_text_extents (struct font *font, const unsigned int *code,
int nglyphs, struct font_metrics *metrics) int nglyphs, struct font_metrics *metrics)
{ {
struct nsfont_info *font_info = (struct nsfont_info *)font; struct nsfont_info *font_info = (struct nsfont_info *)font;
......
...@@ -58,21 +58,6 @@ typedef struct _XCharStruct ...@@ -58,21 +58,6 @@ typedef struct _XCharStruct
int descent; int descent;
} XCharStruct; } XCharStruct;
/* Fake structure from Xlib.h to represent two-byte characters. */
#ifndef __OBJC__
typedef unsigned short unichar;
#endif
typedef unichar XChar2b;
#define STORE_XCHAR2B(chp, b1, b2) \
(*(chp) = ((XChar2b)((((b1) & 0x00ff) << 8) | ((b2) & 0x00ff))))
#define XCHAR2B_BYTE1(chp) \
((*(chp) & 0xff00) >> 8)
#define XCHAR2B_BYTE2(chp) \
(*(chp) & 0x00ff)
/* Used in xdisp.c when comparing faces and frame colors. */ /* Used in xdisp.c when comparing faces and frame colors. */
extern unsigned long ns_color_index_to_rgba(int idx, struct frame *f); extern unsigned long ns_color_index_to_rgba(int idx, struct frame *f);
......
...@@ -433,7 +433,7 @@ w32font_encode_char (struct font *font, int c) ...@@ -433,7 +433,7 @@ w32font_encode_char (struct font *font, int c)
CODE (length NGLYPHS). Apparently metrics can be NULL, in this CODE (length NGLYPHS). Apparently metrics can be NULL, in this
case just return the overall width. */ case just return the overall width. */
void void
w32font_text_extents (struct font *font, unsigned *code, w32font_text_extents (struct font *font, const unsigned *code,
int nglyphs, struct font_metrics *metrics) int nglyphs, struct font_metrics *metrics)
{ {
int i; int i;
......
...@@ -74,7 +74,7 @@ int w32font_open_internal (struct frame *f, Lisp_Object font_entity, ...@@ -74,7 +74,7 @@ int w32font_open_internal (struct frame *f, Lisp_Object font_entity,
int pixel_size, Lisp_Object font_object); int pixel_size, Lisp_Object font_object);
void w32font_close (struct font *font); void w32font_close (struct font *font);
int w32font_has_char (Lisp_Object entity, int c); int w32font_has_char (Lisp_Object entity, int c);
void w32font_text_extents (struct font *font, unsigned *code, int nglyphs, void w32font_text_extents (struct font *font, const unsigned *code, int nglyphs,
struct font_metrics *metrics); struct font_metrics *metrics);
int w32font_draw (struct glyph_string *s, int from, int to, int w32font_draw (struct glyph_string *s, int from, int to,
int x, int y, bool with_background); int x, int y, bool with_background);
......
...@@ -33,19 +33,6 @@ typedef HWND Window; ...@@ -33,19 +33,6 @@ typedef HWND Window;
typedef HDC Display; /* HDC so it doesn't conflict with xpm lib. */ typedef HDC Display; /* HDC so it doesn't conflict with xpm lib. */
typedef HCURSOR Emacs_Cursor; typedef HCURSOR Emacs_Cursor;
#define XChar2b wchar_t
/* Dealing with bits of wchar_t as if they were an XChar2b. */
#define STORE_XCHAR2B(chp, byte1, byte2) \
((*(chp)) = ((XChar2b)((((byte1) & 0x00ff) << 8) | ((byte2) & 0x00ff))))
#define XCHAR2B_BYTE1(chp) \
(((*(chp)) & 0xff00) >> 8)
#define XCHAR2B_BYTE2(chp) \
((*(chp)) & 0x00ff)
/* Windows equivalent of XImage. */ /* Windows equivalent of XImage. */
typedef struct _XImage typedef struct _XImage
{ {
......
...@@ -1097,14 +1097,10 @@ w32_compute_glyph_string_overhangs (struct glyph_string *s) ...@@ -1097,14 +1097,10 @@ w32_compute_glyph_string_overhangs (struct glyph_string *s)
&& s->first_glyph->type == CHAR_GLYPH && s->first_glyph->type == CHAR_GLYPH
&& !s->font_not_found_p) && !s->font_not_found_p)
{ {
unsigned *code = alloca (sizeof (unsigned) * s->nchars);
struct font *font = s->font; struct font *font = s->font;
struct font_metrics metrics; struct font_metrics metrics;
int i;
for (i = 0; i < s->nchars; i++) font->driver->text_extents (font, s->char2b, s->nchars, &metrics);
code[i] = s->char2b[i];
font->driver->text_extents (font, code, s->nchars, &metrics);
s->right_overhang = (metrics.rbearing > metrics.width s->right_overhang = (metrics.rbearing > metrics.width
? metrics.rbearing - metrics.width : 0); ? metrics.rbearing - metrics.width : 0);
s->left_overhang = metrics.lbearing < 0 ? -metrics.lbearing : 0; s->left_overhang = metrics.lbearing < 0 ? -metrics.lbearing : 0;
...@@ -1349,7 +1345,7 @@ static void ...@@ -1349,7 +1345,7 @@ static void
w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s) w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
{ {
struct glyph *glyph = s->first_glyph; struct glyph *glyph = s->first_glyph;
XChar2b char2b[8]; unsigned char2b[8];
int x, i, j; int x, i, j;
bool with_background; bool with_background;
...@@ -1406,16 +1402,12 @@ w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s) ...@@ -1406,16 +1402,12 @@ w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
{ {
struct font *font = s->font; struct font *font = s->font;
int upper_len = (len + 1) / 2; int upper_len = (len + 1) / 2;
unsigned code;
HFONT old_font; HFONT old_font;
old_font = SelectObject (s->hdc, FONT_HANDLE (font)); old_font = SelectObject (s->hdc, FONT_HANDLE (font));
/* It is certain that all LEN characters in STR are ASCII. */ /* It is certain that all LEN characters in STR are ASCII. */
for (j = 0; j < len; j++) for (j = 0; j < len; j++)
{ char2b[j] = font->driver->encode_char (font, str[j]) & 0xFFFF;
code = font->driver->encode_char (font, str[j]);
STORE_XCHAR2B (char2b + j, code >> 8, code & 0xFF);
}
font->driver->draw (s, 0, upper_len, font->driver->draw (s, 0, upper_len,
x + glyph->slice.glyphless.upper_xoff, x + glyph->slice.glyphless.upper_xoff,
s->ybase + glyph->slice.glyphless.upper_yoff, s->ybase + glyph->slice.glyphless.upper_yoff,
......
...@@ -25914,7 +25914,7 @@ dump_glyph_string (struct glyph_string *s) ...@@ -25914,7 +25914,7 @@ dump_glyph_string (struct glyph_string *s)
#endif /* GLYPH_DEBUG */ #endif /* GLYPH_DEBUG */
/* Initialize glyph string S. CHAR2B is a suitably allocated vector /* Initialize glyph string S. CHAR2B is a suitably allocated vector
of XChar2b structures for S; it can't be allocated in of 2-byte unsigned integers for S; it can't be allocated in
init_glyph_string because it must be allocated via `alloca'. W init_glyph_string because it must be allocated via `alloca'. W
is the window on which S is drawn. ROW and AREA are the glyph row is the window on which S is drawn. ROW and AREA are the glyph row
and area within the row from which S is constructed. START is the and area within the row from which S is constructed. START is the
...@@ -25944,7 +25944,7 @@ init_glyph_string (struct glyph_string *s, ...@@ -25944,7 +25944,7 @@ init_glyph_string (struct glyph_string *s,
#ifdef HAVE_NTGUI #ifdef HAVE_NTGUI
HDC hdc, HDC hdc,
#endif #endif
XChar2b *char2b, struct window *w, struct glyph_row *row, unsigned *char2b, struct window *w, struct glyph_row *row,
enum glyph_row_area area, int start, enum draw_glyphs_face hl) enum glyph_row_area area, int start, enum draw_glyphs_face hl)
{ {
memset (s, 0, sizeof *s); memset (s, 0, sizeof *s);
...@@ -26023,7 +26023,7 @@ append_glyph_string (struct glyph_string **head, struct glyph_string **tail, ...@@ -26023,7 +26023,7 @@ append_glyph_string (struct glyph_string **head, struct glyph_string **tail,
static struct face * static struct face *
get_char_face_and_encoding (struct frame *f, int c, int face_id, get_char_face_and_encoding (struct frame *f, int c, int face_id,
XChar2b *char2b, bool display_p) unsigned *char2b, bool display_p)
{ {
struct face *face = FACE_FROM_ID (f, face_id); struct face *face = FACE_FROM_ID (f, face_id);
unsigned code = 0; unsigned code = 0;
...@@ -26035,7 +26035,8 @@ get_char_face_and_encoding (struct frame *f, int c, int face_id, ...@@ -26035,7 +26035,8 @@ get_char_face_and_encoding (struct frame *f, int c, int face_id,
if (code == FONT_INVALID_CODE) if (code == FONT_INVALID_CODE)
code = 0; code = 0;
} }
STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); /* Ensure that the code is only 2 bytes wide. */
*char2b = code & 0xFFFF;
/* Make sure X resources of the face are allocated. */ /* Make sure X resources of the face are allocated. */
#ifdef HAVE_X_WINDOWS #ifdef HAVE_X_WINDOWS
...@@ -26056,7 +26057,7 @@ get_char_face_and_encoding (struct frame *f, int c, int face_id, ...@@ -26056,7 +26057,7 @@ get_char_face_and_encoding (struct frame *f, int c, int face_id,
static struct face * static struct face *
get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph, get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph,
XChar2b *char2b) unsigned *char2b)
{ {
struct face *face; struct face *face;
unsigned code = 0; unsigned code = 0;
...@@ -26078,7 +26079,8 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph, ...@@ -26078,7 +26079,8 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph,
code = 0; code = 0;
} }
STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); /* Ensure that the code is only 2 bytes wide. */
*char2b = code & 0xFFFF;
return face; return face;
} }
...@@ -26087,7 +26089,7 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph, ...@@ -26087,7 +26089,7 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph,
Return true iff FONT has a glyph for C. */ Return true iff FONT has a glyph for C. */
static bool static bool
get_char_glyph_code (int c, struct font *font, XChar2b *char2b) get_char_glyph_code (int c, struct font *font, unsigned *char2b)
{ {
unsigned code; unsigned code;
...@@ -26098,7 +26100,9 @@ get_char_glyph_code (int c, struct font *font, XChar2b *char2b) ...@@ -26098,7 +26100,9 @@ get_char_glyph_code (int c, struct font *font, XChar2b *char2b)
if (code == FONT_INVALID_CODE) if (code == FONT_INVALID_CODE)
return false; return false;
STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
/* Ensure that the code is only 2 bytes wide. */
*char2b = code & 0xFFFF;
return true; return true;
} }
...@@ -26211,7 +26215,8 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id, ...@@ -26211,7 +26215,8 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id,
Lisp_Object lglyph = LGSTRING_GLYPH (lgstring, i); Lisp_Object lglyph = LGSTRING_GLYPH (lgstring, i);
unsigned code = LGLYPH_CODE (lglyph); unsigned code = LGLYPH_CODE (lglyph);
STORE_XCHAR2B ((s->char2b + i), code >> 8, code & 0xFF); /* Ensure that the code is only 2 bytes wide. */
s->char2b[i] = code & 0xFFFF;
} }
s->width = composition_gstring_width (lgstring, s->cmp_from, s->cmp_to, NULL); s->width = composition_gstring_width (lgstring, s->cmp_from, s->cmp_to, NULL);
return glyph - s->row->glyphs[s->area]; return glyph - s->row->glyphs[s->area];
...@@ -26390,17 +26395,16 @@ fill_stretch_glyph_string (struct glyph_string *s, int start, int end) ...@@ -26390,17 +26395,16 @@ fill_stretch_glyph_string (struct glyph_string *s, int start, int end)
} }
static struct font_metrics * static struct font_metrics *
get_per_char_metric (struct font *font, XChar2b *char2b) get_per_char_metric (struct font *font, const unsigned *char2b)
{ {
static struct font_metrics metrics; static struct font_metrics metrics;
unsigned code;
if (! font) if (! font)
return NULL; return NULL;
code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b); if (*char2b == FONT_INVALID_CODE)
if (code == FONT_INVALID_CODE)
return NULL; return NULL;
font->driver->text_extents (font, &code, 1, &metrics);
font->driver->text_extents (font, char2b, 1, &metrics);
return &metrics; return &metrics;
} }
...@@ -26418,7 +26422,7 @@ normal_char_ascent_descent (struct font *font, int c, int *ascent, int *descent) ...@@ -26418,7 +26422,7 @@ normal_char_ascent_descent (struct font *font, int c, int *ascent, int *descent)
if (FONT_TOO_HIGH (font)) if (FONT_TOO_HIGH (font))
{ {
XChar2b char2b; unsigned char2b;
/* Get metrics of C, defaulting to a reasonably sized ASCII /* Get metrics of C, defaulting to a reasonably sized ASCII
character. */ character. */
...@@ -26465,7 +26469,7 @@ gui_get_glyph_overhangs (struct glyph *glyph, struct frame *f, int *left, int *r ...@@ -26465,7 +26469,7 @@ gui_get_glyph_overhangs (struct glyph *glyph, struct frame *f, int *left, int *r
if (glyph->type == CHAR_GLYPH) if (glyph->type == CHAR_GLYPH)
{ {
XChar2b char2b; unsigned char2b;
struct face *face = get_glyph_face_and_encoding (f, glyph, &char2b); struct face *face = get_glyph_face_and_encoding (f, glyph, &char2b);
if (face->font) if (face->font)
{ {
...@@ -26779,7 +26783,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p) ...@@ -26779,7 +26783,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
do \ do \
{ \ { \
int face_id; \ int face_id; \
XChar2b *char2b; \ unsigned *char2b; \
\ \
face_id = (row)->glyphs[area][START].face_id; \ face_id = (row)->glyphs[area][START].face_id; \
\ \
...@@ -26808,7 +26812,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p) ...@@ -26808,7 +26812,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
struct face *base_face = FACE_FROM_ID (f, face_id); \ struct face *base_face = FACE_FROM_ID (f, face_id); \
ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id; \ ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id; \
struct composition *cmp = composition_table[cmp_id]; \ struct composition *cmp = composition_table[cmp_id]; \
XChar2b *char2b; \ unsigned *char2b; \
struct glyph_string *first_s = NULL; \ struct glyph_string *first_s = NULL; \
int n; \ int n; \
\ \
...@@ -26840,7 +26844,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p) ...@@ -26840,7 +26844,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
#define BUILD_GSTRING_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \ #define BUILD_GSTRING_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
do { \ do { \
int face_id; \ int face_id; \
XChar2b *char2b; \ unsigned *char2b; \
Lisp_Object gstring; \ Lisp_Object gstring; \
\ \
face_id = (row)->glyphs[area][START].face_id; \ face_id = (row)->glyphs[area][START].face_id; \
...@@ -28433,7 +28437,7 @@ gui_produce_glyphs (struct it *it) ...@@ -28433,7 +28437,7 @@ gui_produce_glyphs (struct it *it)
if (it->what == IT_CHARACTER) if (it->what == IT_CHARACTER)
{ {
XChar2b char2b; unsigned char2b;
struct face *face = FACE_FROM_ID (it->f, it->face_id); struct face *face = FACE_FROM_ID (it->f, it->face_id);
struct font *font = face->font; struct font *font = face->font;
struct font_metrics *pcm = NULL; struct font_metrics *pcm = NULL;
...@@ -28832,7 +28836,7 @@ gui_produce_glyphs (struct it *it) ...@@ -28832,7 +28836,7 @@ gui_produce_glyphs (struct it *it)
int lbearing, rbearing; int lbearing, rbearing;
int i, width, ascent, descent; int i, width, ascent, descent;
int c; int c;
XChar2b char2b; unsigned char2b;
struct font_metrics *pcm; struct font_metrics *pcm;
ptrdiff_t pos; ptrdiff_t pos;
...@@ -46,18 +46,20 @@ struct xfont_info ...@@ -46,18 +46,20 @@ struct xfont_info
/* Prototypes of support functions. */ /* Prototypes of support functions. */
static XCharStruct *xfont_get_pcm (XFontStruct *, XChar2b *); static XCharStruct *xfont_get_pcm (XFontStruct *, unsigned char2b);
/* Get metrics of character CHAR2B in XFONT. Value is null if CHAR2B /* Get metrics of character CHAR2B in XFONT. Value is null if CHAR2B
is not contained in the font. */ is not contained in the font. */
static XCharStruct * static XCharStruct *
xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b) xfont_get_pcm (XFontStruct *xfont, unsigned char2b)
{ {
/* The result metric information. */ /* The result metric information. */
XCharStruct *pcm = NULL; XCharStruct *pcm = NULL;
const unsigned char byte1 = char2b >> 8;
const unsigned char byte2 = char2b & 0xFF;
eassert (xfont && char2b); eassert (xfont);
if (xfont->per_char != NULL) if (xfont->per_char != NULL)
{ {
...@@ -66,13 +68,13 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b) ...@@ -66,13 +68,13 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b)
/* min_char_or_byte2 specifies the linear character index /* min_char_or_byte2 specifies the linear character index
corresponding to the first element of the per_char array, corresponding to the first element of the per_char array,
max_char_or_byte2 is the index of the last character. A max_char_or_byte2 is the index of the last character. A
character with non-zero CHAR2B->byte1 is not in the font. character with non-zero byte1 is not in the font.
A character with byte2 less than min_char_or_byte2 or A character with byte2 less than min_char_or_byte2 or
greater max_char_or_byte2 is not in the font. */ greater max_char_or_byte2 is not in the font. */
if (char2b->byte1 == 0 if (byte1 == 0
&& char2b->byte2 >= xfont->min_char_or_byte2 && byte2 >= xfont->min_char_or_byte2
&& char2b->byte2 <= xfont->max_char_or_byte2) && byte2 <= xfont->max_char_or_byte2)
pcm = xfont->per_char + char2b->byte2 - xfont->min_char_or_byte2; pcm = xfont->per_char + byte2 - xfont->min_char_or_byte2;
} }
else else
{ {
...@@ -89,14 +91,14 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b) ...@@ -89,14 +91,14 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b)
D = max_char_or_byte2 - min_char_or_byte2 + 1 D = max_char_or_byte2 - min_char_or_byte2 + 1
/ = integer division / = integer division
\ = integer modulus */ \ = integer modulus */
if (char2b->byte1 >= xfont->min_byte1 if (byte1 >= xfont->min_byte1
&& char2b->byte1 <= xfont->max_byte1 && byte1 <= xfont->max_byte1
&& char2b->byte2 >= xfont->min_char_or_byte2 && byte2 >= xfont->min_char_or_byte2
&& char2b->byte2 <= xfont->max_char_or_byte2) && byte2 <= xfont->max_char_or_byte2)
pcm = (xfont->per_char pcm = (xfont->per_char
+ ((xfont->max_char_or_byte2 - xfont->min_char_or_byte2 + 1) + ((xfont->max_char_or_byte2 - xfont->min_char_or_byte2 + 1)
* (char2b->byte1 - xfont->min_byte1)) * (byte1 - xfont->min_byte1))
+ (char2b->byte2 - xfont->min_char_or_byte2)); + (byte2 - xfont->min_char_or_byte2));
} }
} }
else else
...@@ -104,8 +106,8 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b) ...@@ -104,8 +106,8 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b)
/* If the per_char pointer is null, all glyphs between the first /* If the per_char pointer is null, all glyphs between the first
and last character indexes inclusive have the same and last character indexes inclusive have the same