diff options
| author | Alexander Gramiak | 2019-05-10 09:45:57 -0600 |
|---|---|---|
| committer | Alexander Gramiak | 2019-05-19 19:50:32 -0600 |
| commit | a4fe9c70af7a60117480d3361541550341da801a (patch) | |
| tree | f9c082b94c2af6df79f7aa66dbcce4a97eabbbbd /src | |
| parent | b3d3c0daa49f5cbed7c58c7508d4d36dba3757e5 (diff) | |
| download | emacs-a4fe9c70af7a60117480d3361541550341da801a.tar.gz emacs-a4fe9c70af7a60117480d3361541550341da801a.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dispextern.h | 2 | ||||
| -rw-r--r-- | src/font.h | 4 | ||||
| -rw-r--r-- | src/ftcrfont.c | 11 | ||||
| -rw-r--r-- | src/ftfont.c | 2 | ||||
| -rw-r--r-- | src/ftxfont.c | 8 | ||||
| -rw-r--r-- | src/macfont.m | 4 | ||||
| -rw-r--r-- | src/nsfont.m | 2 | ||||
| -rw-r--r-- | src/nsgui.h | 15 | ||||
| -rw-r--r-- | src/w32font.c | 2 | ||||
| -rw-r--r-- | src/w32font.h | 2 | ||||
| -rw-r--r-- | src/w32gui.h | 13 | ||||
| -rw-r--r-- | src/w32term.c | 14 | ||||
| -rw-r--r-- | src/xdisp.c | 46 | ||||
| -rw-r--r-- | src/xfont.c | 101 | ||||
| -rw-r--r-- | src/xftfont.c | 5 | ||||
| -rw-r--r-- | src/xterm.c | 15 | ||||
| -rw-r--r-- | src/xterm.h | 9 |
17 files changed, 103 insertions, 152 deletions
diff --git a/src/dispextern.h b/src/dispextern.h index 05e09301b06..eee515f2d24 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -1317,7 +1317,7 @@ struct glyph_string | |||
| 1317 | enum glyph_row_area area; | 1317 | enum glyph_row_area area; |
| 1318 | 1318 | ||
| 1319 | /* Characters to be drawn, and number of characters. */ | 1319 | /* Characters to be drawn, and number of characters. */ |
| 1320 | XChar2b *char2b; | 1320 | unsigned *char2b; |
| 1321 | int nchars; | 1321 | int nchars; |
| 1322 | 1322 | ||
| 1323 | /* A face-override for drawing cursors, mouse face and similar. */ | 1323 | /* A face-override for drawing cursors, mouse face and similar. */ |
diff --git a/src/font.h b/src/font.h index 3720650a2e1..9ca0c97dc52 100644 --- a/src/font.h +++ b/src/font.h | |||
| @@ -647,7 +647,7 @@ struct font_driver | |||
| 647 | the font FONT and the sequence of glyph codes CODE, and store the | 647 | the font FONT and the sequence of glyph codes CODE, and store the |
| 648 | result in METRICS. */ | 648 | result in METRICS. */ |
| 649 | void (*text_extents) (struct font *font, | 649 | void (*text_extents) (struct font *font, |
| 650 | unsigned *code, int nglyphs, | 650 | const unsigned *code, int nglyphs, |
| 651 | struct font_metrics *metrics); | 651 | struct font_metrics *metrics); |
| 652 | 652 | ||
| 653 | #ifdef HAVE_WINDOW_SYSTEM | 653 | #ifdef HAVE_WINDOW_SYSTEM |
| @@ -894,7 +894,7 @@ extern Lisp_Object ftfont_shape (Lisp_Object); | |||
| 894 | extern unsigned ftfont_encode_char (struct font *, int); | 894 | extern unsigned ftfont_encode_char (struct font *, int); |
| 895 | extern void ftfont_close (struct font *); | 895 | extern void ftfont_close (struct font *); |
| 896 | extern void ftfont_filter_properties (Lisp_Object, Lisp_Object); | 896 | extern void ftfont_filter_properties (Lisp_Object, Lisp_Object); |
| 897 | extern void ftfont_text_extents (struct font *, unsigned *, int, | 897 | extern void ftfont_text_extents (struct font *, const unsigned *, int, |
| 898 | struct font_metrics *); | 898 | struct font_metrics *); |
| 899 | extern void syms_of_ftfont (void); | 899 | extern void syms_of_ftfont (void); |
| 900 | #endif /* HAVE_FREETYPE */ | 900 | #endif /* HAVE_FREETYPE */ |
diff --git a/src/ftcrfont.c b/src/ftcrfont.c index e7c73eac4d3..606db0b949b 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c | |||
| @@ -242,7 +242,7 @@ ftcrfont_close (struct font *font) | |||
| 242 | 242 | ||
| 243 | static void | 243 | static void |
| 244 | ftcrfont_text_extents (struct font *font, | 244 | ftcrfont_text_extents (struct font *font, |
| 245 | unsigned *code, | 245 | const unsigned *code, |
| 246 | int nglyphs, | 246 | int nglyphs, |
| 247 | struct font_metrics *metrics) | 247 | struct font_metrics *metrics) |
| 248 | { | 248 | { |
| @@ -341,13 +341,12 @@ ftcrfont_draw (struct glyph_string *s, | |||
| 341 | glyphs = alloca (sizeof (cairo_glyph_t) * len); | 341 | glyphs = alloca (sizeof (cairo_glyph_t) * len); |
| 342 | for (i = 0; i < len; i++) | 342 | for (i = 0; i < len; i++) |
| 343 | { | 343 | { |
| 344 | unsigned code = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8) | 344 | glyphs[i].index = s->char2b[from + i]; |
| 345 | | XCHAR2B_BYTE2 (s->char2b + from + i)); | ||
| 346 | |||
| 347 | glyphs[i].index = code; | ||
| 348 | glyphs[i].x = x; | 345 | glyphs[i].x = x; |
| 349 | glyphs[i].y = y; | 346 | glyphs[i].y = y; |
| 350 | x += (s->padding_p ? 1 : ftcrfont_glyph_extents (s->font, code, NULL)); | 347 | x += (s->padding_p ? 1 : ftcrfont_glyph_extents (s->font, |
| 348 | glyphs[i].index, | ||
| 349 | NULL)); | ||
| 351 | } | 350 | } |
| 352 | 351 | ||
| 353 | x_set_cr_source_with_gc_foreground (f, s->gc); | 352 | x_set_cr_source_with_gc_foreground (f, s->gc); |
diff --git a/src/ftfont.c b/src/ftfont.c index 4770c3c40b3..f17bd9ab3f7 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -1353,7 +1353,7 @@ ftfont_encode_char (struct font *font, int c) | |||
| 1353 | } | 1353 | } |
| 1354 | 1354 | ||
| 1355 | void | 1355 | void |
| 1356 | ftfont_text_extents (struct font *font, unsigned int *code, | 1356 | ftfont_text_extents (struct font *font, const unsigned int *code, |
| 1357 | int nglyphs, struct font_metrics *metrics) | 1357 | int nglyphs, struct font_metrics *metrics) |
| 1358 | { | 1358 | { |
| 1359 | struct font_info *ftfont_info = (struct font_info *) font; | 1359 | struct font_info *ftfont_info = (struct font_info *) font; |
diff --git a/src/ftxfont.c b/src/ftxfont.c index f9a69c35151..8bce7f10f1e 100644 --- a/src/ftxfont.c +++ b/src/ftxfont.c | |||
| @@ -252,7 +252,7 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 252 | struct font *font = s->font; | 252 | struct font *font = s->font; |
| 253 | XPoint p[0x700]; | 253 | XPoint p[0x700]; |
| 254 | int n[7]; | 254 | int n[7]; |
| 255 | unsigned *code; | 255 | unsigned *code = s->char2b + from; |
| 256 | int len = to - from; | 256 | int len = to - from; |
| 257 | int i; | 257 | int i; |
| 258 | GC *gcs; | 258 | GC *gcs; |
| @@ -260,14 +260,9 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 260 | 260 | ||
| 261 | n[0] = n[1] = n[2] = n[3] = n[4] = n[5] = n[6] = 0; | 261 | n[0] = n[1] = n[2] = n[3] = n[4] = n[5] = n[6] = 0; |
| 262 | 262 | ||
| 263 | USE_SAFE_ALLOCA; | ||
| 264 | SAFE_NALLOCA (code, 1, len); | ||
| 265 | block_input (); | 263 | block_input (); |
| 266 | if (with_background) | 264 | if (with_background) |
| 267 | ftxfont_draw_background (f, font, s->gc, x, y, s->width); | 265 | ftxfont_draw_background (f, font, s->gc, x, y, s->width); |
| 268 | for (i = 0; i < len; i++) | ||
| 269 | code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8) | ||
| 270 | | XCHAR2B_BYTE2 (s->char2b + from + i)); | ||
| 271 | 266 | ||
| 272 | if (face->gc == s->gc) | 267 | if (face->gc == s->gc) |
| 273 | { | 268 | { |
| @@ -312,7 +307,6 @@ ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 312 | } | 307 | } |
| 313 | 308 | ||
| 314 | unblock_input (); | 309 | unblock_input (); |
| 315 | SAFE_FREE (); | ||
| 316 | 310 | ||
| 317 | return len; | 311 | return len; |
| 318 | } | 312 | } |
diff --git a/src/macfont.m b/src/macfont.m index 0ade77e7337..d69af679813 100644 --- a/src/macfont.m +++ b/src/macfont.m | |||
| @@ -1639,7 +1639,7 @@ static Lisp_Object macfont_open (struct frame *, Lisp_Object, int); | |||
| 1639 | static void macfont_close (struct font *); | 1639 | static void macfont_close (struct font *); |
| 1640 | static int macfont_has_char (Lisp_Object, int); | 1640 | static int macfont_has_char (Lisp_Object, int); |
| 1641 | static unsigned macfont_encode_char (struct font *, int); | 1641 | static unsigned macfont_encode_char (struct font *, int); |
| 1642 | static void macfont_text_extents (struct font *, unsigned int *, int, | 1642 | static void macfont_text_extents (struct font *, const unsigned int *, int, |
| 1643 | struct font_metrics *); | 1643 | struct font_metrics *); |
| 1644 | static int macfont_draw (struct glyph_string *, int, int, int, int, bool); | 1644 | static int macfont_draw (struct glyph_string *, int, int, int, int, bool); |
| 1645 | static Lisp_Object macfont_shape (Lisp_Object); | 1645 | static Lisp_Object macfont_shape (Lisp_Object); |
| @@ -2735,7 +2735,7 @@ macfont_encode_char (struct font *font, int c) | |||
| 2735 | } | 2735 | } |
| 2736 | 2736 | ||
| 2737 | static void | 2737 | static void |
| 2738 | macfont_text_extents (struct font *font, unsigned int *code, int nglyphs, | 2738 | macfont_text_extents (struct font *font, const unsigned int *code, int nglyphs, |
| 2739 | struct font_metrics *metrics) | 2739 | struct font_metrics *metrics) |
| 2740 | { | 2740 | { |
| 2741 | int width, i; | 2741 | int width, i; |
diff --git a/src/nsfont.m b/src/nsfont.m index 9721e489357..eca97ab86cc 100644 --- a/src/nsfont.m +++ b/src/nsfont.m | |||
| @@ -945,7 +945,7 @@ nsfont_encode_char (struct font *font, int c) | |||
| 945 | of METRICS. The glyphs are specified by their glyph codes in | 945 | of METRICS. The glyphs are specified by their glyph codes in |
| 946 | CODE (length NGLYPHS). */ | 946 | CODE (length NGLYPHS). */ |
| 947 | static void | 947 | static void |
| 948 | nsfont_text_extents (struct font *font, unsigned int *code, | 948 | nsfont_text_extents (struct font *font, const unsigned int *code, |
| 949 | int nglyphs, struct font_metrics *metrics) | 949 | int nglyphs, struct font_metrics *metrics) |
| 950 | { | 950 | { |
| 951 | struct nsfont_info *font_info = (struct nsfont_info *)font; | 951 | struct nsfont_info *font_info = (struct nsfont_info *)font; |
diff --git a/src/nsgui.h b/src/nsgui.h index 87c06e68a22..c21953593ad 100644 --- a/src/nsgui.h +++ b/src/nsgui.h | |||
| @@ -58,21 +58,6 @@ typedef struct _XCharStruct | |||
| 58 | int descent; | 58 | int descent; |
| 59 | } XCharStruct; | 59 | } XCharStruct; |
| 60 | 60 | ||
| 61 | /* Fake structure from Xlib.h to represent two-byte characters. */ | ||
| 62 | #ifndef __OBJC__ | ||
| 63 | typedef unsigned short unichar; | ||
| 64 | #endif | ||
| 65 | typedef unichar XChar2b; | ||
| 66 | |||
| 67 | #define STORE_XCHAR2B(chp, b1, b2) \ | ||
| 68 | (*(chp) = ((XChar2b)((((b1) & 0x00ff) << 8) | ((b2) & 0x00ff)))) | ||
| 69 | |||
| 70 | #define XCHAR2B_BYTE1(chp) \ | ||
| 71 | ((*(chp) & 0xff00) >> 8) | ||
| 72 | |||
| 73 | #define XCHAR2B_BYTE2(chp) \ | ||
| 74 | (*(chp) & 0x00ff) | ||
| 75 | |||
| 76 | /* Used in xdisp.c when comparing faces and frame colors. */ | 61 | /* Used in xdisp.c when comparing faces and frame colors. */ |
| 77 | extern unsigned long ns_color_index_to_rgba(int idx, struct frame *f); | 62 | extern unsigned long ns_color_index_to_rgba(int idx, struct frame *f); |
| 78 | 63 | ||
diff --git a/src/w32font.c b/src/w32font.c index 848016da1ca..bd68e22cc90 100644 --- a/src/w32font.c +++ b/src/w32font.c | |||
| @@ -433,7 +433,7 @@ w32font_encode_char (struct font *font, int c) | |||
| 433 | CODE (length NGLYPHS). Apparently metrics can be NULL, in this | 433 | CODE (length NGLYPHS). Apparently metrics can be NULL, in this |
| 434 | case just return the overall width. */ | 434 | case just return the overall width. */ |
| 435 | void | 435 | void |
| 436 | w32font_text_extents (struct font *font, unsigned *code, | 436 | w32font_text_extents (struct font *font, const unsigned *code, |
| 437 | int nglyphs, struct font_metrics *metrics) | 437 | int nglyphs, struct font_metrics *metrics) |
| 438 | { | 438 | { |
| 439 | int i; | 439 | int i; |
diff --git a/src/w32font.h b/src/w32font.h index 65f42a3178d..c7bb7f30570 100644 --- a/src/w32font.h +++ b/src/w32font.h | |||
| @@ -74,7 +74,7 @@ int w32font_open_internal (struct frame *f, Lisp_Object font_entity, | |||
| 74 | int pixel_size, Lisp_Object font_object); | 74 | int pixel_size, Lisp_Object font_object); |
| 75 | void w32font_close (struct font *font); | 75 | void w32font_close (struct font *font); |
| 76 | int w32font_has_char (Lisp_Object entity, int c); | 76 | int w32font_has_char (Lisp_Object entity, int c); |
| 77 | void w32font_text_extents (struct font *font, unsigned *code, int nglyphs, | 77 | void w32font_text_extents (struct font *font, const unsigned *code, int nglyphs, |
| 78 | struct font_metrics *metrics); | 78 | struct font_metrics *metrics); |
| 79 | int w32font_draw (struct glyph_string *s, int from, int to, | 79 | int w32font_draw (struct glyph_string *s, int from, int to, |
| 80 | int x, int y, bool with_background); | 80 | int x, int y, bool with_background); |
diff --git a/src/w32gui.h b/src/w32gui.h index 5e1730b92c7..62bad33c19b 100644 --- a/src/w32gui.h +++ b/src/w32gui.h | |||
| @@ -33,19 +33,6 @@ typedef HWND Window; | |||
| 33 | typedef HDC Display; /* HDC so it doesn't conflict with xpm lib. */ | 33 | typedef HDC Display; /* HDC so it doesn't conflict with xpm lib. */ |
| 34 | typedef HCURSOR Emacs_Cursor; | 34 | typedef HCURSOR Emacs_Cursor; |
| 35 | 35 | ||
| 36 | #define XChar2b wchar_t | ||
| 37 | |||
| 38 | /* Dealing with bits of wchar_t as if they were an XChar2b. */ | ||
| 39 | #define STORE_XCHAR2B(chp, byte1, byte2) \ | ||
| 40 | ((*(chp)) = ((XChar2b)((((byte1) & 0x00ff) << 8) | ((byte2) & 0x00ff)))) | ||
| 41 | |||
| 42 | #define XCHAR2B_BYTE1(chp) \ | ||
| 43 | (((*(chp)) & 0xff00) >> 8) | ||
| 44 | |||
| 45 | #define XCHAR2B_BYTE2(chp) \ | ||
| 46 | ((*(chp)) & 0x00ff) | ||
| 47 | |||
| 48 | |||
| 49 | /* Windows equivalent of XImage. */ | 36 | /* Windows equivalent of XImage. */ |
| 50 | typedef struct _XImage | 37 | typedef struct _XImage |
| 51 | { | 38 | { |
diff --git a/src/w32term.c b/src/w32term.c index 4a93b2a4043..5726124b0ed 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -1097,14 +1097,10 @@ w32_compute_glyph_string_overhangs (struct glyph_string *s) | |||
| 1097 | && s->first_glyph->type == CHAR_GLYPH | 1097 | && s->first_glyph->type == CHAR_GLYPH |
| 1098 | && !s->font_not_found_p) | 1098 | && !s->font_not_found_p) |
| 1099 | { | 1099 | { |
| 1100 | unsigned *code = alloca (sizeof (unsigned) * s->nchars); | ||
| 1101 | struct font *font = s->font; | 1100 | struct font *font = s->font; |
| 1102 | struct font_metrics metrics; | 1101 | struct font_metrics metrics; |
| 1103 | int i; | ||
| 1104 | 1102 | ||
| 1105 | for (i = 0; i < s->nchars; i++) | 1103 | font->driver->text_extents (font, s->char2b, s->nchars, &metrics); |
| 1106 | code[i] = s->char2b[i]; | ||
| 1107 | font->driver->text_extents (font, code, s->nchars, &metrics); | ||
| 1108 | s->right_overhang = (metrics.rbearing > metrics.width | 1104 | s->right_overhang = (metrics.rbearing > metrics.width |
| 1109 | ? metrics.rbearing - metrics.width : 0); | 1105 | ? metrics.rbearing - metrics.width : 0); |
| 1110 | s->left_overhang = metrics.lbearing < 0 ? -metrics.lbearing : 0; | 1106 | s->left_overhang = metrics.lbearing < 0 ? -metrics.lbearing : 0; |
| @@ -1349,7 +1345,7 @@ static void | |||
| 1349 | w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s) | 1345 | w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s) |
| 1350 | { | 1346 | { |
| 1351 | struct glyph *glyph = s->first_glyph; | 1347 | struct glyph *glyph = s->first_glyph; |
| 1352 | XChar2b char2b[8]; | 1348 | unsigned char2b[8]; |
| 1353 | int x, i, j; | 1349 | int x, i, j; |
| 1354 | bool with_background; | 1350 | bool with_background; |
| 1355 | 1351 | ||
| @@ -1406,16 +1402,12 @@ w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s) | |||
| 1406 | { | 1402 | { |
| 1407 | struct font *font = s->font; | 1403 | struct font *font = s->font; |
| 1408 | int upper_len = (len + 1) / 2; | 1404 | int upper_len = (len + 1) / 2; |
| 1409 | unsigned code; | ||
| 1410 | HFONT old_font; | 1405 | HFONT old_font; |
| 1411 | 1406 | ||
| 1412 | old_font = SelectObject (s->hdc, FONT_HANDLE (font)); | 1407 | old_font = SelectObject (s->hdc, FONT_HANDLE (font)); |
| 1413 | /* It is certain that all LEN characters in STR are ASCII. */ | 1408 | /* It is certain that all LEN characters in STR are ASCII. */ |
| 1414 | for (j = 0; j < len; j++) | 1409 | for (j = 0; j < len; j++) |
| 1415 | { | 1410 | char2b[j] = font->driver->encode_char (font, str[j]) & 0xFFFF; |
| 1416 | code = font->driver->encode_char (font, str[j]); | ||
| 1417 | STORE_XCHAR2B (char2b + j, code >> 8, code & 0xFF); | ||
| 1418 | } | ||
| 1419 | font->driver->draw (s, 0, upper_len, | 1411 | font->driver->draw (s, 0, upper_len, |
| 1420 | x + glyph->slice.glyphless.upper_xoff, | 1412 | x + glyph->slice.glyphless.upper_xoff, |
| 1421 | s->ybase + glyph->slice.glyphless.upper_yoff, | 1413 | s->ybase + glyph->slice.glyphless.upper_yoff, |
diff --git a/src/xdisp.c b/src/xdisp.c index 6929ca4b4bf..c561ea9e36c 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -25914,7 +25914,7 @@ dump_glyph_string (struct glyph_string *s) | |||
| 25914 | #endif /* GLYPH_DEBUG */ | 25914 | #endif /* GLYPH_DEBUG */ |
| 25915 | 25915 | ||
| 25916 | /* Initialize glyph string S. CHAR2B is a suitably allocated vector | 25916 | /* Initialize glyph string S. CHAR2B is a suitably allocated vector |
| 25917 | of XChar2b structures for S; it can't be allocated in | 25917 | of 2-byte unsigned integers for S; it can't be allocated in |
| 25918 | init_glyph_string because it must be allocated via `alloca'. W | 25918 | init_glyph_string because it must be allocated via `alloca'. W |
| 25919 | is the window on which S is drawn. ROW and AREA are the glyph row | 25919 | is the window on which S is drawn. ROW and AREA are the glyph row |
| 25920 | and area within the row from which S is constructed. START is the | 25920 | 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 | #ifdef HAVE_NTGUI | 25944 | #ifdef HAVE_NTGUI |
| 25945 | HDC hdc, | 25945 | HDC hdc, |
| 25946 | #endif | 25946 | #endif |
| 25947 | XChar2b *char2b, struct window *w, struct glyph_row *row, | 25947 | unsigned *char2b, struct window *w, struct glyph_row *row, |
| 25948 | enum glyph_row_area area, int start, enum draw_glyphs_face hl) | 25948 | enum glyph_row_area area, int start, enum draw_glyphs_face hl) |
| 25949 | { | 25949 | { |
| 25950 | memset (s, 0, sizeof *s); | 25950 | memset (s, 0, sizeof *s); |
| @@ -26023,7 +26023,7 @@ append_glyph_string (struct glyph_string **head, struct glyph_string **tail, | |||
| 26023 | 26023 | ||
| 26024 | static struct face * | 26024 | static struct face * |
| 26025 | get_char_face_and_encoding (struct frame *f, int c, int face_id, | 26025 | get_char_face_and_encoding (struct frame *f, int c, int face_id, |
| 26026 | XChar2b *char2b, bool display_p) | 26026 | unsigned *char2b, bool display_p) |
| 26027 | { | 26027 | { |
| 26028 | struct face *face = FACE_FROM_ID (f, face_id); | 26028 | struct face *face = FACE_FROM_ID (f, face_id); |
| 26029 | unsigned code = 0; | 26029 | unsigned code = 0; |
| @@ -26035,7 +26035,8 @@ get_char_face_and_encoding (struct frame *f, int c, int face_id, | |||
| 26035 | if (code == FONT_INVALID_CODE) | 26035 | if (code == FONT_INVALID_CODE) |
| 26036 | code = 0; | 26036 | code = 0; |
| 26037 | } | 26037 | } |
| 26038 | STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); | 26038 | /* Ensure that the code is only 2 bytes wide. */ |
| 26039 | *char2b = code & 0xFFFF; | ||
| 26039 | 26040 | ||
| 26040 | /* Make sure X resources of the face are allocated. */ | 26041 | /* Make sure X resources of the face are allocated. */ |
| 26041 | #ifdef HAVE_X_WINDOWS | 26042 | #ifdef HAVE_X_WINDOWS |
| @@ -26056,7 +26057,7 @@ get_char_face_and_encoding (struct frame *f, int c, int face_id, | |||
| 26056 | 26057 | ||
| 26057 | static struct face * | 26058 | static struct face * |
| 26058 | get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph, | 26059 | get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph, |
| 26059 | XChar2b *char2b) | 26060 | unsigned *char2b) |
| 26060 | { | 26061 | { |
| 26061 | struct face *face; | 26062 | struct face *face; |
| 26062 | unsigned code = 0; | 26063 | unsigned code = 0; |
| @@ -26078,7 +26079,8 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph, | |||
| 26078 | code = 0; | 26079 | code = 0; |
| 26079 | } | 26080 | } |
| 26080 | 26081 | ||
| 26081 | STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); | 26082 | /* Ensure that the code is only 2 bytes wide. */ |
| 26083 | *char2b = code & 0xFFFF; | ||
| 26082 | return face; | 26084 | return face; |
| 26083 | } | 26085 | } |
| 26084 | 26086 | ||
| @@ -26087,7 +26089,7 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph, | |||
| 26087 | Return true iff FONT has a glyph for C. */ | 26089 | Return true iff FONT has a glyph for C. */ |
| 26088 | 26090 | ||
| 26089 | static bool | 26091 | static bool |
| 26090 | get_char_glyph_code (int c, struct font *font, XChar2b *char2b) | 26092 | get_char_glyph_code (int c, struct font *font, unsigned *char2b) |
| 26091 | { | 26093 | { |
| 26092 | unsigned code; | 26094 | unsigned code; |
| 26093 | 26095 | ||
| @@ -26098,7 +26100,9 @@ get_char_glyph_code (int c, struct font *font, XChar2b *char2b) | |||
| 26098 | 26100 | ||
| 26099 | if (code == FONT_INVALID_CODE) | 26101 | if (code == FONT_INVALID_CODE) |
| 26100 | return false; | 26102 | return false; |
| 26101 | STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF)); | 26103 | |
| 26104 | /* Ensure that the code is only 2 bytes wide. */ | ||
| 26105 | *char2b = code & 0xFFFF; | ||
| 26102 | return true; | 26106 | return true; |
| 26103 | } | 26107 | } |
| 26104 | 26108 | ||
| @@ -26211,7 +26215,8 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id, | |||
| 26211 | Lisp_Object lglyph = LGSTRING_GLYPH (lgstring, i); | 26215 | Lisp_Object lglyph = LGSTRING_GLYPH (lgstring, i); |
| 26212 | unsigned code = LGLYPH_CODE (lglyph); | 26216 | unsigned code = LGLYPH_CODE (lglyph); |
| 26213 | 26217 | ||
| 26214 | STORE_XCHAR2B ((s->char2b + i), code >> 8, code & 0xFF); | 26218 | /* Ensure that the code is only 2 bytes wide. */ |
| 26219 | s->char2b[i] = code & 0xFFFF; | ||
| 26215 | } | 26220 | } |
| 26216 | s->width = composition_gstring_width (lgstring, s->cmp_from, s->cmp_to, NULL); | 26221 | s->width = composition_gstring_width (lgstring, s->cmp_from, s->cmp_to, NULL); |
| 26217 | return glyph - s->row->glyphs[s->area]; | 26222 | return glyph - s->row->glyphs[s->area]; |
| @@ -26390,17 +26395,16 @@ fill_stretch_glyph_string (struct glyph_string *s, int start, int end) | |||
| 26390 | } | 26395 | } |
| 26391 | 26396 | ||
| 26392 | static struct font_metrics * | 26397 | static struct font_metrics * |
| 26393 | get_per_char_metric (struct font *font, XChar2b *char2b) | 26398 | get_per_char_metric (struct font *font, const unsigned *char2b) |
| 26394 | { | 26399 | { |
| 26395 | static struct font_metrics metrics; | 26400 | static struct font_metrics metrics; |
| 26396 | unsigned code; | ||
| 26397 | 26401 | ||
| 26398 | if (! font) | 26402 | if (! font) |
| 26399 | return NULL; | 26403 | return NULL; |
| 26400 | code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b); | 26404 | if (*char2b == FONT_INVALID_CODE) |
| 26401 | if (code == FONT_INVALID_CODE) | ||
| 26402 | return NULL; | 26405 | return NULL; |
| 26403 | font->driver->text_extents (font, &code, 1, &metrics); | 26406 | |
| 26407 | font->driver->text_extents (font, char2b, 1, &metrics); | ||
| 26404 | return &metrics; | 26408 | return &metrics; |
| 26405 | } | 26409 | } |
| 26406 | 26410 | ||
| @@ -26418,7 +26422,7 @@ normal_char_ascent_descent (struct font *font, int c, int *ascent, int *descent) | |||
| 26418 | 26422 | ||
| 26419 | if (FONT_TOO_HIGH (font)) | 26423 | if (FONT_TOO_HIGH (font)) |
| 26420 | { | 26424 | { |
| 26421 | XChar2b char2b; | 26425 | unsigned char2b; |
| 26422 | 26426 | ||
| 26423 | /* Get metrics of C, defaulting to a reasonably sized ASCII | 26427 | /* Get metrics of C, defaulting to a reasonably sized ASCII |
| 26424 | character. */ | 26428 | character. */ |
| @@ -26465,7 +26469,7 @@ gui_get_glyph_overhangs (struct glyph *glyph, struct frame *f, int *left, int *r | |||
| 26465 | 26469 | ||
| 26466 | if (glyph->type == CHAR_GLYPH) | 26470 | if (glyph->type == CHAR_GLYPH) |
| 26467 | { | 26471 | { |
| 26468 | XChar2b char2b; | 26472 | unsigned char2b; |
| 26469 | struct face *face = get_glyph_face_and_encoding (f, glyph, &char2b); | 26473 | struct face *face = get_glyph_face_and_encoding (f, glyph, &char2b); |
| 26470 | if (face->font) | 26474 | if (face->font) |
| 26471 | { | 26475 | { |
| @@ -26779,7 +26783,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p) | |||
| 26779 | do \ | 26783 | do \ |
| 26780 | { \ | 26784 | { \ |
| 26781 | int face_id; \ | 26785 | int face_id; \ |
| 26782 | XChar2b *char2b; \ | 26786 | unsigned *char2b; \ |
| 26783 | \ | 26787 | \ |
| 26784 | face_id = (row)->glyphs[area][START].face_id; \ | 26788 | face_id = (row)->glyphs[area][START].face_id; \ |
| 26785 | \ | 26789 | \ |
| @@ -26808,7 +26812,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p) | |||
| 26808 | struct face *base_face = FACE_FROM_ID (f, face_id); \ | 26812 | struct face *base_face = FACE_FROM_ID (f, face_id); \ |
| 26809 | ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id; \ | 26813 | ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id; \ |
| 26810 | struct composition *cmp = composition_table[cmp_id]; \ | 26814 | struct composition *cmp = composition_table[cmp_id]; \ |
| 26811 | XChar2b *char2b; \ | 26815 | unsigned *char2b; \ |
| 26812 | struct glyph_string *first_s = NULL; \ | 26816 | struct glyph_string *first_s = NULL; \ |
| 26813 | int n; \ | 26817 | int n; \ |
| 26814 | \ | 26818 | \ |
| @@ -26840,7 +26844,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p) | |||
| 26840 | #define BUILD_GSTRING_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \ | 26844 | #define BUILD_GSTRING_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \ |
| 26841 | do { \ | 26845 | do { \ |
| 26842 | int face_id; \ | 26846 | int face_id; \ |
| 26843 | XChar2b *char2b; \ | 26847 | unsigned *char2b; \ |
| 26844 | Lisp_Object gstring; \ | 26848 | Lisp_Object gstring; \ |
| 26845 | \ | 26849 | \ |
| 26846 | face_id = (row)->glyphs[area][START].face_id; \ | 26850 | face_id = (row)->glyphs[area][START].face_id; \ |
| @@ -28433,7 +28437,7 @@ gui_produce_glyphs (struct it *it) | |||
| 28433 | 28437 | ||
| 28434 | if (it->what == IT_CHARACTER) | 28438 | if (it->what == IT_CHARACTER) |
| 28435 | { | 28439 | { |
| 28436 | XChar2b char2b; | 28440 | unsigned char2b; |
| 28437 | struct face *face = FACE_FROM_ID (it->f, it->face_id); | 28441 | struct face *face = FACE_FROM_ID (it->f, it->face_id); |
| 28438 | struct font *font = face->font; | 28442 | struct font *font = face->font; |
| 28439 | struct font_metrics *pcm = NULL; | 28443 | struct font_metrics *pcm = NULL; |
| @@ -28832,7 +28836,7 @@ gui_produce_glyphs (struct it *it) | |||
| 28832 | int lbearing, rbearing; | 28836 | int lbearing, rbearing; |
| 28833 | int i, width, ascent, descent; | 28837 | int i, width, ascent, descent; |
| 28834 | int c; | 28838 | int c; |
| 28835 | XChar2b char2b; | 28839 | unsigned char2b; |
| 28836 | struct font_metrics *pcm; | 28840 | struct font_metrics *pcm; |
| 28837 | ptrdiff_t pos; | 28841 | ptrdiff_t pos; |
| 28838 | 28842 | ||
diff --git a/src/xfont.c b/src/xfont.c index ff80df407d7..a402f770630 100644 --- a/src/xfont.c +++ b/src/xfont.c | |||
| @@ -46,18 +46,20 @@ struct xfont_info | |||
| 46 | 46 | ||
| 47 | /* Prototypes of support functions. */ | 47 | /* Prototypes of support functions. */ |
| 48 | 48 | ||
| 49 | static XCharStruct *xfont_get_pcm (XFontStruct *, XChar2b *); | 49 | static XCharStruct *xfont_get_pcm (XFontStruct *, unsigned char2b); |
| 50 | 50 | ||
| 51 | /* Get metrics of character CHAR2B in XFONT. Value is null if CHAR2B | 51 | /* Get metrics of character CHAR2B in XFONT. Value is null if CHAR2B |
| 52 | is not contained in the font. */ | 52 | is not contained in the font. */ |
| 53 | 53 | ||
| 54 | static XCharStruct * | 54 | static XCharStruct * |
| 55 | xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b) | 55 | xfont_get_pcm (XFontStruct *xfont, unsigned char2b) |
| 56 | { | 56 | { |
| 57 | /* The result metric information. */ | 57 | /* The result metric information. */ |
| 58 | XCharStruct *pcm = NULL; | 58 | XCharStruct *pcm = NULL; |
| 59 | const unsigned char byte1 = char2b >> 8; | ||
| 60 | const unsigned char byte2 = char2b & 0xFF; | ||
| 59 | 61 | ||
| 60 | eassert (xfont && char2b); | 62 | eassert (xfont); |
| 61 | 63 | ||
| 62 | if (xfont->per_char != NULL) | 64 | if (xfont->per_char != NULL) |
| 63 | { | 65 | { |
| @@ -66,13 +68,13 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b) | |||
| 66 | /* min_char_or_byte2 specifies the linear character index | 68 | /* min_char_or_byte2 specifies the linear character index |
| 67 | corresponding to the first element of the per_char array, | 69 | corresponding to the first element of the per_char array, |
| 68 | max_char_or_byte2 is the index of the last character. A | 70 | max_char_or_byte2 is the index of the last character. A |
| 69 | character with non-zero CHAR2B->byte1 is not in the font. | 71 | character with non-zero byte1 is not in the font. |
| 70 | A character with byte2 less than min_char_or_byte2 or | 72 | A character with byte2 less than min_char_or_byte2 or |
| 71 | greater max_char_or_byte2 is not in the font. */ | 73 | greater max_char_or_byte2 is not in the font. */ |
| 72 | if (char2b->byte1 == 0 | 74 | if (byte1 == 0 |
| 73 | && char2b->byte2 >= xfont->min_char_or_byte2 | 75 | && byte2 >= xfont->min_char_or_byte2 |
| 74 | && char2b->byte2 <= xfont->max_char_or_byte2) | 76 | && byte2 <= xfont->max_char_or_byte2) |
| 75 | pcm = xfont->per_char + char2b->byte2 - xfont->min_char_or_byte2; | 77 | pcm = xfont->per_char + byte2 - xfont->min_char_or_byte2; |
| 76 | } | 78 | } |
| 77 | else | 79 | else |
| 78 | { | 80 | { |
| @@ -89,14 +91,14 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b) | |||
| 89 | D = max_char_or_byte2 - min_char_or_byte2 + 1 | 91 | D = max_char_or_byte2 - min_char_or_byte2 + 1 |
| 90 | / = integer division | 92 | / = integer division |
| 91 | \ = integer modulus */ | 93 | \ = integer modulus */ |
| 92 | if (char2b->byte1 >= xfont->min_byte1 | 94 | if (byte1 >= xfont->min_byte1 |
| 93 | && char2b->byte1 <= xfont->max_byte1 | 95 | && byte1 <= xfont->max_byte1 |
| 94 | && char2b->byte2 >= xfont->min_char_or_byte2 | 96 | && byte2 >= xfont->min_char_or_byte2 |
| 95 | && char2b->byte2 <= xfont->max_char_or_byte2) | 97 | && byte2 <= xfont->max_char_or_byte2) |
| 96 | pcm = (xfont->per_char | 98 | pcm = (xfont->per_char |
| 97 | + ((xfont->max_char_or_byte2 - xfont->min_char_or_byte2 + 1) | 99 | + ((xfont->max_char_or_byte2 - xfont->min_char_or_byte2 + 1) |
| 98 | * (char2b->byte1 - xfont->min_byte1)) | 100 | * (byte1 - xfont->min_byte1)) |
| 99 | + (char2b->byte2 - xfont->min_char_or_byte2)); | 101 | + (byte2 - xfont->min_char_or_byte2)); |
| 100 | } | 102 | } |
| 101 | } | 103 | } |
| 102 | else | 104 | else |
| @@ -104,8 +106,8 @@ xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b) | |||
| 104 | /* If the per_char pointer is null, all glyphs between the first | 106 | /* If the per_char pointer is null, all glyphs between the first |
| 105 | and last character indexes inclusive have the same | 107 | and last character indexes inclusive have the same |
| 106 | information, as given by both min_bounds and max_bounds. */ | 108 | information, as given by both min_bounds and max_bounds. */ |
| 107 | if (char2b->byte2 >= xfont->min_char_or_byte2 | 109 | if (byte2 >= xfont->min_char_or_byte2 |
| 108 | && char2b->byte2 <= xfont->max_char_or_byte2) | 110 | && byte2 <= xfont->max_char_or_byte2) |
| 109 | pcm = &xfont->max_bounds; | 111 | pcm = &xfont->max_bounds; |
| 110 | } | 112 | } |
| 111 | 113 | ||
| @@ -193,7 +195,6 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont, | |||
| 193 | { | 195 | { |
| 194 | int c = XFIXNUM (XCAR (chars)); | 196 | int c = XFIXNUM (XCAR (chars)); |
| 195 | unsigned code = ENCODE_CHAR (charset, c); | 197 | unsigned code = ENCODE_CHAR (charset, c); |
| 196 | XChar2b char2b; | ||
| 197 | 198 | ||
| 198 | if (code == CHARSET_INVALID_CODE (charset)) | 199 | if (code == CHARSET_INVALID_CODE (charset)) |
| 199 | break; | 200 | break; |
| @@ -201,9 +202,7 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont, | |||
| 201 | continue; | 202 | continue; |
| 202 | if (code >= 0x10000) | 203 | if (code >= 0x10000) |
| 203 | break; | 204 | break; |
| 204 | char2b.byte1 = code >> 8; | 205 | if (! xfont_get_pcm (xfont, code)) |
| 205 | char2b.byte2 = code & 0xFF; | ||
| 206 | if (! xfont_get_pcm (xfont, &char2b)) | ||
| 207 | break; | 206 | break; |
| 208 | } | 207 | } |
| 209 | return (NILP (chars)); | 208 | return (NILP (chars)); |
| @@ -216,7 +215,6 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont, | |||
| 216 | { | 215 | { |
| 217 | int c = XFIXNUM (AREF (chars, i)); | 216 | int c = XFIXNUM (AREF (chars, i)); |
| 218 | unsigned code = ENCODE_CHAR (charset, c); | 217 | unsigned code = ENCODE_CHAR (charset, c); |
| 219 | XChar2b char2b; | ||
| 220 | 218 | ||
| 221 | if (code == CHARSET_INVALID_CODE (charset)) | 219 | if (code == CHARSET_INVALID_CODE (charset)) |
| 222 | continue; | 220 | continue; |
| @@ -224,9 +222,7 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont, | |||
| 224 | break; | 222 | break; |
| 225 | if (code >= 0x10000) | 223 | if (code >= 0x10000) |
| 226 | continue; | 224 | continue; |
| 227 | char2b.byte1 = code >> 8; | 225 | if (xfont_get_pcm (xfont, code)) |
| 228 | char2b.byte2 = code & 0xFF; | ||
| 229 | if (xfont_get_pcm (xfont, &char2b)) | ||
| 230 | break; | 226 | break; |
| 231 | } | 227 | } |
| 232 | return (i >= 0); | 228 | return (i >= 0); |
| @@ -801,11 +797,9 @@ xfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 801 | else | 797 | else |
| 802 | { | 798 | { |
| 803 | XCharStruct *pcm; | 799 | XCharStruct *pcm; |
| 804 | XChar2b char2b; | ||
| 805 | Lisp_Object val; | 800 | Lisp_Object val; |
| 806 | 801 | ||
| 807 | char2b.byte1 = 0x00, char2b.byte2 = 0x20; | 802 | pcm = xfont_get_pcm (xfont, 0x20); |
| 808 | pcm = xfont_get_pcm (xfont, &char2b); | ||
| 809 | if (pcm) | 803 | if (pcm) |
| 810 | font->space_width = pcm->width; | 804 | font->space_width = pcm->width; |
| 811 | else | 805 | else |
| @@ -823,8 +817,8 @@ xfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 823 | { | 817 | { |
| 824 | int width = font->space_width, n = pcm != NULL; | 818 | int width = font->space_width, n = pcm != NULL; |
| 825 | 819 | ||
| 826 | for (char2b.byte2 = 33; char2b.byte2 <= 126; char2b.byte2++) | 820 | for (unsigned char2b = 33; char2b <= 126; ++char2b) |
| 827 | if ((pcm = xfont_get_pcm (xfont, &char2b)) != NULL) | 821 | if ((pcm = xfont_get_pcm (xfont, char2b)) != NULL) |
| 828 | width += pcm->width, n++; | 822 | width += pcm->width, n++; |
| 829 | if (n > 0) | 823 | if (n > 0) |
| 830 | font->average_width = width / n; | 824 | font->average_width = width / n; |
| @@ -934,7 +928,6 @@ xfont_encode_char (struct font *font, int c) | |||
| 934 | XFontStruct *xfont = ((struct xfont_info *) font)->xfont; | 928 | XFontStruct *xfont = ((struct xfont_info *) font)->xfont; |
| 935 | struct charset *charset; | 929 | struct charset *charset; |
| 936 | unsigned code; | 930 | unsigned code; |
| 937 | XChar2b char2b; | ||
| 938 | 931 | ||
| 939 | charset = CHARSET_FROM_ID (font->encoding_charset); | 932 | charset = CHARSET_FROM_ID (font->encoding_charset); |
| 940 | code = ENCODE_CHAR (charset, c); | 933 | code = ENCODE_CHAR (charset, c); |
| @@ -946,13 +939,11 @@ xfont_encode_char (struct font *font, int c) | |||
| 946 | return (ENCODE_CHAR (charset, c) != CHARSET_INVALID_CODE (charset) | 939 | return (ENCODE_CHAR (charset, c) != CHARSET_INVALID_CODE (charset) |
| 947 | ? code : FONT_INVALID_CODE); | 940 | ? code : FONT_INVALID_CODE); |
| 948 | } | 941 | } |
| 949 | char2b.byte1 = code >> 8; | 942 | return (xfont_get_pcm (xfont, code) ? code : FONT_INVALID_CODE); |
| 950 | char2b.byte2 = code & 0xFF; | ||
| 951 | return (xfont_get_pcm (xfont, &char2b) ? code : FONT_INVALID_CODE); | ||
| 952 | } | 943 | } |
| 953 | 944 | ||
| 954 | static void | 945 | static void |
| 955 | xfont_text_extents (struct font *font, unsigned int *code, | 946 | xfont_text_extents (struct font *font, const unsigned int *code, |
| 956 | int nglyphs, struct font_metrics *metrics) | 947 | int nglyphs, struct font_metrics *metrics) |
| 957 | { | 948 | { |
| 958 | XFontStruct *xfont = ((struct xfont_info *) font)->xfont; | 949 | XFontStruct *xfont = ((struct xfont_info *) font)->xfont; |
| @@ -961,13 +952,11 @@ xfont_text_extents (struct font *font, unsigned int *code, | |||
| 961 | 952 | ||
| 962 | for (i = 0, first = true; i < nglyphs; i++) | 953 | for (i = 0, first = true; i < nglyphs; i++) |
| 963 | { | 954 | { |
| 964 | XChar2b char2b; | ||
| 965 | static XCharStruct *pcm; | 955 | static XCharStruct *pcm; |
| 966 | 956 | ||
| 967 | if (code[i] >= 0x10000) | 957 | if (code[i] >= 0x10000) |
| 968 | continue; | 958 | continue; |
| 969 | char2b.byte1 = code[i] >> 8, char2b.byte2 = code[i] & 0xFF; | 959 | pcm = xfont_get_pcm (xfont, code[i]); |
| 970 | pcm = xfont_get_pcm (xfont, &char2b); | ||
| 971 | if (! pcm) | 960 | if (! pcm) |
| 972 | continue; | 961 | continue; |
| 973 | if (first) | 962 | if (first) |
| @@ -1017,7 +1006,7 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1017 | USE_SAFE_ALLOCA; | 1006 | USE_SAFE_ALLOCA; |
| 1018 | char *str = SAFE_ALLOCA (len); | 1007 | char *str = SAFE_ALLOCA (len); |
| 1019 | for (i = 0; i < len ; i++) | 1008 | for (i = 0; i < len ; i++) |
| 1020 | str[i] = XCHAR2B_BYTE2 (s->char2b + from + i); | 1009 | str[i] = s->char2b[from + i] & 0xFF; |
| 1021 | block_input (); | 1010 | block_input (); |
| 1022 | if (with_background) | 1011 | if (with_background) |
| 1023 | { | 1012 | { |
| @@ -1049,21 +1038,41 @@ xfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1049 | { | 1038 | { |
| 1050 | if (s->padding_p) | 1039 | if (s->padding_p) |
| 1051 | for (i = 0; i < len; i++) | 1040 | for (i = 0; i < len; i++) |
| 1052 | XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f), | 1041 | { |
| 1053 | gc, x + i, y, s->char2b + from + i, 1); | 1042 | const unsigned code = s->char2b[from + i]; |
| 1043 | const XChar2b char2b = { .byte1 = code >> 8, | ||
| 1044 | .byte2 = code & 0xFF }; | ||
| 1045 | XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f), | ||
| 1046 | gc, x + i, y, &char2b, 1); | ||
| 1047 | } | ||
| 1054 | else | 1048 | else |
| 1055 | XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f), | 1049 | { |
| 1056 | gc, x, y, s->char2b + from, len); | 1050 | const unsigned code = s->char2b[from]; |
| 1051 | const XChar2b char2b = { .byte1 = code >> 8, | ||
| 1052 | .byte2 = code & 0xFF }; | ||
| 1053 | XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f), | ||
| 1054 | gc, x, y, &char2b, len); | ||
| 1055 | } | ||
| 1057 | } | 1056 | } |
| 1058 | else | 1057 | else |
| 1059 | { | 1058 | { |
| 1060 | if (s->padding_p) | 1059 | if (s->padding_p) |
| 1061 | for (i = 0; i < len; i++) | 1060 | for (i = 0; i < len; i++) |
| 1062 | XDrawString16 (display, FRAME_X_DRAWABLE (s->f), | 1061 | { |
| 1063 | gc, x + i, y, s->char2b + from + i, 1); | 1062 | const unsigned code = s->char2b[from + i]; |
| 1063 | const XChar2b char2b = { .byte1 = code >> 8, | ||
| 1064 | .byte2 = code & 0xFF }; | ||
| 1065 | XDrawString16 (display, FRAME_X_DRAWABLE (s->f), | ||
| 1066 | gc, x + i, y, &char2b, 1); | ||
| 1067 | } | ||
| 1064 | else | 1068 | else |
| 1065 | XDrawString16 (display, FRAME_X_DRAWABLE (s->f), | 1069 | { |
| 1066 | gc, x, y, s->char2b + from, len); | 1070 | const unsigned code = s->char2b[from]; |
| 1071 | const XChar2b char2b = { .byte1 = code >> 8, | ||
| 1072 | .byte2 = code & 0xFF }; | ||
| 1073 | XDrawString16 (display, FRAME_X_DRAWABLE (s->f), | ||
| 1074 | gc, x, y, &char2b, len); | ||
| 1075 | } | ||
| 1067 | } | 1076 | } |
| 1068 | unblock_input (); | 1077 | unblock_input (); |
| 1069 | 1078 | ||
diff --git a/src/xftfont.c b/src/xftfont.c index 8a4516f7f91..2edc51fe356 100644 --- a/src/xftfont.c +++ b/src/xftfont.c | |||
| @@ -536,7 +536,7 @@ xftfont_encode_char (struct font *font, int c) | |||
| 536 | } | 536 | } |
| 537 | 537 | ||
| 538 | static void | 538 | static void |
| 539 | xftfont_text_extents (struct font *font, unsigned int *code, | 539 | xftfont_text_extents (struct font *font, const unsigned int *code, |
| 540 | int nglyphs, struct font_metrics *metrics) | 540 | int nglyphs, struct font_metrics *metrics) |
| 541 | { | 541 | { |
| 542 | struct font_info *xftfont_info = (struct font_info *) font; | 542 | struct font_info *xftfont_info = (struct font_info *) font; |
| @@ -621,8 +621,7 @@ xftfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 621 | } | 621 | } |
| 622 | code = alloca (sizeof (FT_UInt) * len); | 622 | code = alloca (sizeof (FT_UInt) * len); |
| 623 | for (i = 0; i < len; i++) | 623 | for (i = 0; i < len; i++) |
| 624 | code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8) | 624 | code[i] = s->char2b[from + i]; |
| 625 | | XCHAR2B_BYTE2 (s->char2b + from + i)); | ||
| 626 | 625 | ||
| 627 | if (s->padding_p) | 626 | if (s->padding_p) |
| 628 | for (i = 0; i < len; i++) | 627 | for (i = 0; i < len; i++) |
diff --git a/src/xterm.c b/src/xterm.c index 2de6198359c..bff9f74a17b 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -1599,13 +1599,8 @@ x_compute_glyph_string_overhangs (struct glyph_string *s) | |||
| 1599 | 1599 | ||
| 1600 | if (s->first_glyph->type == CHAR_GLYPH) | 1600 | if (s->first_glyph->type == CHAR_GLYPH) |
| 1601 | { | 1601 | { |
| 1602 | unsigned *code = alloca (sizeof (unsigned) * s->nchars); | ||
| 1603 | struct font *font = s->font; | 1602 | struct font *font = s->font; |
| 1604 | int i; | 1603 | font->driver->text_extents (font, s->char2b, s->nchars, &metrics); |
| 1605 | |||
| 1606 | for (i = 0; i < s->nchars; i++) | ||
| 1607 | code[i] = (s->char2b[i].byte1 << 8) | s->char2b[i].byte2; | ||
| 1608 | font->driver->text_extents (font, code, s->nchars, &metrics); | ||
| 1609 | } | 1604 | } |
| 1610 | else | 1605 | else |
| 1611 | { | 1606 | { |
| @@ -1831,7 +1826,7 @@ static void | |||
| 1831 | x_draw_glyphless_glyph_string_foreground (struct glyph_string *s) | 1826 | x_draw_glyphless_glyph_string_foreground (struct glyph_string *s) |
| 1832 | { | 1827 | { |
| 1833 | struct glyph *glyph = s->first_glyph; | 1828 | struct glyph *glyph = s->first_glyph; |
| 1834 | XChar2b char2b[8]; | 1829 | unsigned char2b[8]; |
| 1835 | int x, i, j; | 1830 | int x, i, j; |
| 1836 | 1831 | ||
| 1837 | /* If first glyph of S has a left box line, start drawing the text | 1832 | /* If first glyph of S has a left box line, start drawing the text |
| @@ -1882,14 +1877,10 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s) | |||
| 1882 | if (str) | 1877 | if (str) |
| 1883 | { | 1878 | { |
| 1884 | int upper_len = (len + 1) / 2; | 1879 | int upper_len = (len + 1) / 2; |
| 1885 | unsigned code; | ||
| 1886 | 1880 | ||
| 1887 | /* It is assured that all LEN characters in STR is ASCII. */ | 1881 | /* It is assured that all LEN characters in STR is ASCII. */ |
| 1888 | for (j = 0; j < len; j++) | 1882 | for (j = 0; j < len; j++) |
| 1889 | { | 1883 | char2b[j] = s->font->driver->encode_char (s->font, str[j]) & 0xFFFF; |
| 1890 | code = s->font->driver->encode_char (s->font, str[j]); | ||
| 1891 | STORE_XCHAR2B (char2b + j, code >> 8, code & 0xFF); | ||
| 1892 | } | ||
| 1893 | s->font->driver->draw (s, 0, upper_len, | 1884 | s->font->driver->draw (s, 0, upper_len, |
| 1894 | x + glyph->slice.glyphless.upper_xoff, | 1885 | x + glyph->slice.glyphless.upper_xoff, |
| 1895 | s->ybase + glyph->slice.glyphless.upper_yoff, | 1886 | s->ybase + glyph->slice.glyphless.upper_yoff, |
diff --git a/src/xterm.h b/src/xterm.h index 54473045787..ce1443c381c 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -1262,15 +1262,6 @@ extern void x_session_close (void); | |||
| 1262 | 1262 | ||
| 1263 | #define FRAME_X_EMBEDDED_P(f) (FRAME_X_OUTPUT(f)->explicit_parent != 0) | 1263 | #define FRAME_X_EMBEDDED_P(f) (FRAME_X_OUTPUT(f)->explicit_parent != 0) |
| 1264 | 1264 | ||
| 1265 | #define STORE_XCHAR2B(chp, b1, b2) \ | ||
| 1266 | ((chp)->byte1 = (b1), (chp)->byte2 = (b2)) | ||
| 1267 | |||
| 1268 | #define XCHAR2B_BYTE1(chp) \ | ||
| 1269 | ((chp)->byte1) | ||
| 1270 | |||
| 1271 | #define XCHAR2B_BYTE2(chp) \ | ||
| 1272 | ((chp)->byte2) | ||
| 1273 | |||
| 1274 | #define STORE_NATIVE_RECT(nr,rx,ry,rwidth,rheight) \ | 1265 | #define STORE_NATIVE_RECT(nr,rx,ry,rwidth,rheight) \ |
| 1275 | ((nr).x = (rx), \ | 1266 | ((nr).x = (rx), \ |
| 1276 | (nr).y = (ry), \ | 1267 | (nr).y = (ry), \ |