aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2000-03-21 00:43:55 +0000
committerKenichi Handa2000-03-21 00:43:55 +0000
commitee569018cb952173bd3f224ad884640ecaed644c (patch)
tree74d707ad9f0be445d2c6d77f7d8358244022aed3 /src
parent395063480234fcc29845e0fd0ca2310c6a3eee3e (diff)
downloademacs-ee569018cb952173bd3f224ad884640ecaed644c.tar.gz
emacs-ee569018cb952173bd3f224ad884640ecaed644c.zip
Include fontset.h after dispextern.h.
(x_per_char_metric): Don't try FONT->default_char. Even if pcm->width is zero, glyph bits may exist. (x_encode_char): Always initialize char2b->byte1. (x_get_char_face_and_encoding): Call FACE_FOR_CHAR to get face_id. (x_get_glyph_face_and_encoding): New arg two_byte_p. Caller changed. (x_append_glyph): Set glyph->glyph_not_available_p. (x_produce_glyphs): Set it->glyph_not_available_p. Don't set it->charset. Handle the case that per char metric is not available. If it->multibyte_p is zero and it->c is a multibyte character, convert it to a unibyte character. (struct glyph_string): Delete member `charset'. (x_set_mouse_face_gc): Call FACE_FOR_CHAR to get face_id. Handle the case that per char metric is not available correctly. (x_fill_glyph_string): Handle the case that the specific glyph is not available correctly. (BUILD_CHAR_GLYPH_STRINGS): Don't set s->charset. (BUILD_COMPOSITE_GLYPH_STRING): Likewise. (x_new_font): Call FS_LOAD_FONT, not fs_load_font. (x_new_fontset): Call fontset_ascii to get ASCII font name of the fontset. Don't call FS_LOAD_FONT.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c318
1 files changed, 124 insertions, 194 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 575461b751f..9516de7e033 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -72,8 +72,8 @@ Boston, MA 02111-1307, USA. */
72#include "charset.h" 72#include "charset.h"
73#include "ccl.h" 73#include "ccl.h"
74#include "frame.h" 74#include "frame.h"
75#include "fontset.h"
76#include "dispextern.h" 75#include "dispextern.h"
76#include "fontset.h"
77#include "termhooks.h" 77#include "termhooks.h"
78#include "termopts.h" 78#include "termopts.h"
79#include "termchar.h" 79#include "termchar.h"
@@ -1094,10 +1094,10 @@ XTcursor_to (vpos, hpos, y, x)
1094 1094
1095static struct face *x_get_glyph_face_and_encoding P_ ((struct frame *, 1095static struct face *x_get_glyph_face_and_encoding P_ ((struct frame *,
1096 struct glyph *, 1096 struct glyph *,
1097 XChar2b *)); 1097 XChar2b *,
1098 int *));
1098static struct face *x_get_char_face_and_encoding P_ ((struct frame *, int, 1099static struct face *x_get_char_face_and_encoding P_ ((struct frame *, int,
1099 int, XChar2b *, int)); 1100 int, XChar2b *, int));
1100static XCharStruct *x_per_char_metric_1 P_ ((XFontStruct *, XChar2b *));
1101static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *)); 1101static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *));
1102static void x_encode_char P_ ((int, XChar2b *, struct font_info *)); 1102static void x_encode_char P_ ((int, XChar2b *, struct font_info *));
1103static void x_append_glyph P_ ((struct it *)); 1103static void x_append_glyph P_ ((struct it *));
@@ -1106,14 +1106,26 @@ static void x_append_stretch_glyph P_ ((struct it *it, Lisp_Object,
1106 int, int, double)); 1106 int, int, double));
1107static void x_produce_glyphs P_ ((struct it *)); 1107static void x_produce_glyphs P_ ((struct it *));
1108static void x_produce_image_glyph P_ ((struct it *it)); 1108static void x_produce_image_glyph P_ ((struct it *it));
1109static XCharStruct *x_default_char P_ ((XFontStruct *, XChar2b *)); 1109
1110
1111/* Return a pointer to per-char metric information in FONT of a
1112 character pointed by B which is a pointer to an XChar2b. */
1113
1114#define PER_CHAR_METRIC(font, b) \
1115 ((font)->per_char \
1116 ? ((font)->per_char + (b)->byte2 - (font)->min_char_or_byte2 \
1117 + (((font)->min_byte1 || (font)->max_byte1) \
1118 ? (((b)->byte1 - (font)->min_byte1) \
1119 * ((font)->max_char_or_byte2 - (font)->min_char_or_byte2 + 1)) \
1120 : 0)) \
1121 : &((font)->max_bounds))
1110 1122
1111 1123
1112/* Get metrics of character CHAR2B in FONT. Value is null if CHAR2B 1124/* Get metrics of character CHAR2B in FONT. Value is null if CHAR2B
1113 is not contained in the font. */ 1125 is not contained in the font. */
1114 1126
1115static INLINE XCharStruct * 1127static INLINE XCharStruct *
1116x_per_char_metric_1 (font, char2b) 1128x_per_char_metric (font, char2b)
1117 XFontStruct *font; 1129 XFontStruct *font;
1118 XChar2b *char2b; 1130 XChar2b *char2b;
1119{ 1131{
@@ -1174,83 +1186,9 @@ x_per_char_metric_1 (font, char2b)
1174 pcm = &font->max_bounds; 1186 pcm = &font->max_bounds;
1175 } 1187 }
1176 1188
1177 if (pcm && pcm->width == 0) 1189 return ((pcm == NULL
1178 pcm = NULL; 1190 || pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0)
1179 1191 ? NULL : pcm);
1180 return pcm;
1181}
1182
1183
1184/* Return in *DEFAULT_CHAR the default char to use for characters not
1185 contained in FONT. This is either FONT->default_char if that is
1186 valid, or some suitable other character if FONT->default_char is
1187 invalid. Value is a pointer to the XCharStruct of
1188 FONT->default_char or null if FONT->default_char is invalid. */
1189
1190static INLINE XCharStruct *
1191x_default_char (font, default_char)
1192 XFontStruct *font;
1193 XChar2b *default_char;
1194{
1195 XCharStruct *pcm;
1196
1197 /* FONT->default_char is a 16-bit character code with byte1 in the
1198 most significant byte and byte2 in the least significant
1199 byte. */
1200 default_char->byte1 = (font->default_char >> BITS_PER_CHAR) & 0xff;
1201 default_char->byte2 = font->default_char & 0xff;
1202 pcm = x_per_char_metric_1 (font, default_char);
1203
1204 /* If FONT->default_char is invalid, choose a better one. */
1205 if (pcm == NULL)
1206 {
1207 if (font->per_char)
1208 {
1209 if (font->min_byte1 == 0 && font->max_byte1 == 0)
1210 {
1211 default_char->byte1 = 0;
1212 default_char->byte2 = font->min_char_or_byte2;
1213 }
1214 else
1215 {
1216 default_char->byte1 = font->min_byte1;
1217 default_char->byte2 = font->min_char_or_byte2;
1218 }
1219 }
1220 else
1221 default_char->byte2 = font->min_char_or_byte2;
1222 }
1223
1224 return pcm;
1225}
1226
1227
1228/* Get metrics of character CHAR2B in FONT. Value is always non-null.
1229 If CHAR2B is not contained in FONT, a default character metric is
1230 returned. */
1231
1232static INLINE XCharStruct *
1233x_per_char_metric (font, char2b)
1234 XFontStruct *font;
1235 XChar2b *char2b;
1236{
1237 XCharStruct *pcm = x_per_char_metric_1 (font, char2b);
1238
1239 if (pcm == NULL)
1240 {
1241 /* Character not contained in the font. FONT->default_char
1242 gives the character that will be printed. FONT->default_char
1243 is a 16-bit character code with byte1 in the most significant
1244 byte and byte2 in the least significant byte. */
1245 XChar2b default_char;
1246
1247 pcm = x_default_char (font, &default_char);
1248 if (pcm == NULL)
1249 pcm = x_per_char_metric_1 (font, &default_char);
1250 }
1251
1252 xassert (pcm != NULL);
1253 return pcm;
1254} 1192}
1255 1193
1256 1194
@@ -1291,7 +1229,7 @@ x_encode_char (c, char2b, font_info)
1291 /* We assume that MSBs are appropriately set/reset by CCL 1229 /* We assume that MSBs are appropriately set/reset by CCL
1292 program. */ 1230 program. */
1293 if (font->max_byte1 == 0) /* 1-byte font */ 1231 if (font->max_byte1 == 0) /* 1-byte font */
1294 char2b->byte2 = ccl->reg[1]; 1232 char2b->byte1 = 0, char2b->byte2 = ccl->reg[1];
1295 else 1233 else
1296 char2b->byte1 = ccl->reg[1], char2b->byte2 = ccl->reg[2]; 1234 char2b->byte1 = ccl->reg[1], char2b->byte2 = ccl->reg[2];
1297 } 1235 }
@@ -1331,12 +1269,8 @@ x_get_char_face_and_encoding (f, c, face_id, char2b, multibyte_p)
1331 sure to use a face suitable for unibyte. */ 1269 sure to use a face suitable for unibyte. */
1332 char2b->byte1 = 0; 1270 char2b->byte1 = 0;
1333 char2b->byte2 = c; 1271 char2b->byte2 = c;
1334 1272 face_id = FACE_FOR_CHAR (f, face, c);
1335 if (!FACE_SUITABLE_FOR_CHARSET_P (face, -1)) 1273 face = FACE_FROM_ID (f, face_id);
1336 {
1337 face_id = FACE_FOR_CHARSET (f, face_id, -1);
1338 face = FACE_FROM_ID (f, face_id);
1339 }
1340 } 1274 }
1341 else if (c < 128 && face_id < BASIC_FACE_ID_SENTINEL) 1275 else if (c < 128 && face_id < BASIC_FACE_ID_SENTINEL)
1342 { 1276 {
@@ -1356,32 +1290,13 @@ x_get_char_face_and_encoding (f, c, face_id, char2b, multibyte_p)
1356 else 1290 else
1357 char2b->byte1 = 0, char2b->byte2 = c1; 1291 char2b->byte1 = 0, char2b->byte2 = c1;
1358 1292
1359 /* Get the face for displaying C. If `face' is not suitable for
1360 charset, get the one that fits. (This can happen for the
1361 translations of a composition where the glyph
1362 specifies a face for the first component, but the other
1363 components have a different charset.) */
1364 if (!FACE_SUITABLE_FOR_CHARSET_P (face, charset))
1365 {
1366 face_id = FACE_FOR_CHARSET (f, face_id, charset);
1367 face = FACE_FROM_ID (f, face_id);
1368 }
1369
1370 /* Maybe encode the character in *CHAR2B. */ 1293 /* Maybe encode the character in *CHAR2B. */
1371 if (charset != CHARSET_ASCII) 1294 if (face->font != NULL)
1372 { 1295 {
1373 struct font_info *font_info 1296 struct font_info *font_info
1374 = FONT_INFO_FROM_ID (f, face->font_info_id); 1297 = FONT_INFO_FROM_ID (f, face->font_info_id);
1375 if (font_info) 1298 if (font_info)
1376 { 1299 x_encode_char (c, char2b, font_info);
1377 x_encode_char (c, char2b, font_info);
1378 if (charset == charset_latin_iso8859_1)
1379 {
1380 xassert (((XFontStruct *) font_info->font)->max_char_or_byte2
1381 >= 0x80);
1382 char2b->byte2 |= 0x80;
1383 }
1384 }
1385 } 1300 }
1386 } 1301 }
1387 1302
@@ -1398,16 +1313,20 @@ x_get_char_face_and_encoding (f, c, face_id, char2b, multibyte_p)
1398 a pointer to a realized face that is ready for display. */ 1313 a pointer to a realized face that is ready for display. */
1399 1314
1400static INLINE struct face * 1315static INLINE struct face *
1401x_get_glyph_face_and_encoding (f, glyph, char2b) 1316x_get_glyph_face_and_encoding (f, glyph, char2b, two_byte_p)
1402 struct frame *f; 1317 struct frame *f;
1403 struct glyph *glyph; 1318 struct glyph *glyph;
1404 XChar2b *char2b; 1319 XChar2b *char2b;
1320 int *two_byte_p;
1405{ 1321{
1406 struct face *face; 1322 struct face *face;
1407 1323
1408 xassert (glyph->type == CHAR_GLYPH); 1324 xassert (glyph->type == CHAR_GLYPH);
1409 face = FACE_FROM_ID (f, glyph->face_id); 1325 face = FACE_FROM_ID (f, glyph->face_id);
1410 1326
1327 if (two_byte_p)
1328 *two_byte_p = 0;
1329
1411 if (!glyph->multibyte_p) 1330 if (!glyph->multibyte_p)
1412 { 1331 {
1413 /* Unibyte case. We don't have to encode, but we have to make 1332 /* Unibyte case. We don't have to encode, but we have to make
@@ -1442,8 +1361,9 @@ x_get_glyph_face_and_encoding (f, glyph, char2b)
1442 if (font_info) 1361 if (font_info)
1443 { 1362 {
1444 x_encode_char (glyph->u.ch, char2b, font_info); 1363 x_encode_char (glyph->u.ch, char2b, font_info);
1445 if (charset == charset_latin_iso8859_1) 1364 if (two_byte_p)
1446 char2b->byte2 |= 0x80; 1365 *two_byte_p
1366 = ((XFontStruct *) (font_info->font))->max_byte1 > 0;
1447 } 1367 }
1448 } 1368 }
1449 } 1369 }
@@ -1488,6 +1408,7 @@ x_append_glyph (it)
1488 glyph->multibyte_p = it->multibyte_p; 1408 glyph->multibyte_p = it->multibyte_p;
1489 glyph->overlaps_vertically_p = (it->phys_ascent > it->ascent 1409 glyph->overlaps_vertically_p = (it->phys_ascent > it->ascent
1490 || it->phys_descent > it->descent); 1410 || it->phys_descent > it->descent);
1411 glyph->glyph_not_available_p = it->glyph_not_available_p;
1491 ++it->glyph_row->used[area]; 1412 ++it->glyph_row->used[area];
1492 } 1413 }
1493} 1414}
@@ -1834,32 +1755,45 @@ static void
1834x_produce_glyphs (it) 1755x_produce_glyphs (it)
1835 struct it *it; 1756 struct it *it;
1836{ 1757{
1758 it->glyph_not_available_p = 0;
1759
1837 if (it->what == IT_CHARACTER) 1760 if (it->what == IT_CHARACTER)
1838 { 1761 {
1839 XChar2b char2b; 1762 XChar2b char2b;
1840 XFontStruct *font; 1763 XFontStruct *font;
1841 struct face *face; 1764 struct face *face = FACE_FROM_ID (it->f, it->face_id);
1842 XCharStruct *pcm; 1765 XCharStruct *pcm;
1843 int font_not_found_p; 1766 int font_not_found_p;
1844 struct font_info *font_info; 1767 struct font_info *font_info;
1845 int boff; /* baseline offset */ 1768 int boff; /* baseline offset */
1846 1769
1847 /* Maybe translate single-byte characters to multibyte. */ 1770 /* Maybe translate single-byte characters to multibyte, or the
1771 other way. */
1848 it->char_to_display = it->c; 1772 it->char_to_display = it->c;
1849 if (unibyte_display_via_language_environment 1773 if (!ASCII_BYTE_P (it->c))
1850 && SINGLE_BYTE_CHAR_P (it->c)
1851 && (it->c >= 0240
1852 || (it->c >= 0200
1853 && !NILP (Vnonascii_translation_table))))
1854 { 1774 {
1855 it->char_to_display = unibyte_char_to_multibyte (it->c); 1775 if (unibyte_display_via_language_environment
1856 it->charset = CHAR_CHARSET (it->char_to_display); 1776 && SINGLE_BYTE_CHAR_P (it->c)
1777 && (it->c >= 0240
1778 || !NILP (Vnonascii_translation_table)))
1779 {
1780 it->char_to_display = unibyte_char_to_multibyte (it->c);
1781 it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display);
1782 face = FACE_FROM_ID (it->f, it->face_id);
1783 }
1784 else if (!SINGLE_BYTE_CHAR_P (it->c)
1785 && !it->multibyte_p)
1786 {
1787 it->char_to_display = multibyte_char_to_unibyte (it->c, Qnil);
1788 it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display);
1789 face = FACE_FROM_ID (it->f, it->face_id);
1790 }
1857 } 1791 }
1858 1792
1859 /* Get face and font to use. Encode IT->char_to_display. */ 1793 /* Get font to use. Encode IT->char_to_display. */
1860 face = x_get_char_face_and_encoding (it->f, it->char_to_display, 1794 x_get_char_face_and_encoding (it->f, it->char_to_display,
1861 it->face_id, &char2b, 1795 it->face_id, &char2b,
1862 it->multibyte_p); 1796 it->multibyte_p);
1863 font = face->font; 1797 font = face->font;
1864 1798
1865 /* When no suitable font found, use the default font. */ 1799 /* When no suitable font found, use the default font. */
@@ -1991,19 +1925,29 @@ x_produce_glyphs (it)
1991 from the charset width; this is what old redisplay code 1925 from the charset width; this is what old redisplay code
1992 did. */ 1926 did. */
1993 pcm = x_per_char_metric (font, &char2b); 1927 pcm = x_per_char_metric (font, &char2b);
1994 it->pixel_width = pcm->width; 1928 if (font_not_found_p || !pcm)
1995 if (font_not_found_p) 1929 {
1996 it->pixel_width *= CHARSET_WIDTH (it->charset); 1930 int charset = CHAR_CHARSET (it->char_to_display);
1931
1932 it->glyph_not_available_p = 1;
1933 it->pixel_width = (FONT_WIDTH (FRAME_FONT (it->f))
1934 * CHARSET_WIDTH (charset));
1935 it->phys_ascent = font->ascent + boff;
1936 it->phys_descent = font->descent - boff;
1937 }
1938 else
1939 {
1940 it->pixel_width = pcm->width;
1941 it->phys_ascent = pcm->ascent + boff;
1942 it->phys_descent = pcm->descent - boff;
1943 if (it->glyph_row
1944 && (pcm->lbearing < 0
1945 || pcm->rbearing > pcm->width))
1946 it->glyph_row->contains_overlapping_glyphs_p = 1;
1947 }
1997 it->nglyphs = 1; 1948 it->nglyphs = 1;
1998 it->ascent = font->ascent + boff; 1949 it->ascent = font->ascent + boff;
1999 it->descent = font->descent - boff; 1950 it->descent = font->descent - boff;
2000 it->phys_ascent = pcm->ascent + boff;
2001 it->phys_descent = pcm->descent - boff;
2002 if (it->glyph_row
2003 && (pcm->lbearing < 0
2004 || pcm->rbearing > pcm->width))
2005 it->glyph_row->contains_overlapping_glyphs_p = 1;
2006
2007 if (face->box != FACE_NO_BOX) 1951 if (face->box != FACE_NO_BOX)
2008 { 1952 {
2009 int thick = face->box_line_width; 1953 int thick = face->box_line_width;
@@ -2033,7 +1977,7 @@ x_produce_glyphs (it)
2033 glyph matrix. There are no padding glyphs. */ 1977 glyph matrix. There are no padding glyphs. */
2034 XChar2b char2b; 1978 XChar2b char2b;
2035 XFontStruct *font; 1979 XFontStruct *font;
2036 struct face *face; 1980 struct face *face = FACE_FROM_ID (it->f, it->face_id);
2037 XCharStruct *pcm; 1981 XCharStruct *pcm;
2038 int font_not_found_p; 1982 int font_not_found_p;
2039 struct font_info *font_info; 1983 struct font_info *font_info;
@@ -2049,13 +1993,13 @@ x_produce_glyphs (it)
2049 && !NILP (Vnonascii_translation_table)))) 1993 && !NILP (Vnonascii_translation_table))))
2050 { 1994 {
2051 it->char_to_display = unibyte_char_to_multibyte (it->c); 1995 it->char_to_display = unibyte_char_to_multibyte (it->c);
2052 it->charset = CHAR_CHARSET (it->char_to_display);
2053 } 1996 }
2054 1997
2055 /* Get face and font to use. Encode IT->char_to_display. */ 1998 /* Get face and font to use. Encode IT->char_to_display. */
2056 face = x_get_char_face_and_encoding (it->f, it->char_to_display, 1999 it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display);
2057 it->face_id, &char2b, 2000 face = FACE_FROM_ID (it->f, it->face_id);
2058 it->multibyte_p); 2001 x_get_char_face_and_encoding (it->f, it->char_to_display,
2002 it->face_id, &char2b, it->multibyte_p);
2059 font = face->font; 2003 font = face->font;
2060 2004
2061 /* When no suitable font found, use the default font. */ 2005 /* When no suitable font found, use the default font. */
@@ -2125,10 +2069,11 @@ x_produce_glyphs (it)
2125 { 2069 {
2126 int left, right, btm, top; 2070 int left, right, btm, top;
2127 int ch = COMPOSITION_GLYPH (cmp, i); 2071 int ch = COMPOSITION_GLYPH (cmp, i);
2128 2072 int face_id = FACE_FOR_CHAR (it->f, face, ch);
2129 face = x_get_char_face_and_encoding (it->f, ch, 2073
2130 it->face_id, &char2b, 2074 face = FACE_FROM_ID (it->f, face_id);
2131 it->multibyte_p); 2075 x_get_char_face_and_encoding (it->f, ch, face->id, &char2b,
2076 it->multibyte_p);
2132 font = face->font; 2077 font = face->font;
2133 if (font == NULL) 2078 if (font == NULL)
2134 { 2079 {
@@ -2367,9 +2312,6 @@ struct glyph_string
2367 XChar2b *char2b; 2312 XChar2b *char2b;
2368 int nchars; 2313 int nchars;
2369 2314
2370 /* Character set of this glyph string. */
2371 int charset;
2372
2373 /* A face-override for drawing cursors, mouse face and similar. */ 2315 /* A face-override for drawing cursors, mouse face and similar. */
2374 enum draw_glyphs_face hl; 2316 enum draw_glyphs_face hl;
2375 2317
@@ -2629,10 +2571,12 @@ x_set_mouse_face_gc (s)
2629 struct glyph_string *s; 2571 struct glyph_string *s;
2630{ 2572{
2631 int face_id; 2573 int face_id;
2574 struct face *face;
2632 2575
2633 /* What face has to be used for the mouse face? */ 2576 /* What face has to be used for the mouse face? */
2634 face_id = FRAME_X_DISPLAY_INFO (s->f)->mouse_face_face_id; 2577 face_id = FRAME_X_DISPLAY_INFO (s->f)->mouse_face_face_id;
2635 face_id = FACE_FOR_CHARSET (s->f, face_id, s->charset); 2578 face = FACE_FROM_ID (s->f, face_id);
2579 face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch);
2636 s->face = FACE_FROM_ID (s->f, face_id); 2580 s->face = FACE_FROM_ID (s->f, face_id);
2637 PREPARE_FACE_FOR_DISPLAY (s->f, s->face); 2581 PREPARE_FACE_FOR_DISPLAY (s->f, s->face);
2638 2582
@@ -2877,14 +2821,14 @@ x_get_glyph_overhangs (glyph, f, left, right)
2877 struct face *face; 2821 struct face *face;
2878 struct font_info *font_info; 2822 struct font_info *font_info;
2879 XChar2b char2b; 2823 XChar2b char2b;
2880 2824 XCharStruct *pcm;
2881 face = x_get_glyph_face_and_encoding (f, glyph, &char2b); 2825
2826 face = x_get_glyph_face_and_encoding (f, glyph, &char2b, NULL);
2882 font = face->font; 2827 font = face->font;
2883 font_info = FONT_INFO_FROM_ID (f, face->font_info_id); 2828 font_info = FONT_INFO_FROM_ID (f, face->font_info_id);
2884 if (font) 2829 if (font
2830 && (pcm = x_per_char_metric (font, &char2b)))
2885 { 2831 {
2886 XCharStruct *pcm = x_per_char_metric (font, &char2b);
2887
2888 if (pcm->rbearing > pcm->width) 2832 if (pcm->rbearing > pcm->width)
2889 *right = pcm->rbearing - pcm->width; 2833 *right = pcm->rbearing - pcm->width;
2890 if (pcm->lbearing < 0) 2834 if (pcm->lbearing < 0)
@@ -3092,21 +3036,10 @@ x_draw_glyph_string_foreground (s)
3092 { 3036 {
3093 char *char1b = (char *) s->char2b; 3037 char *char1b = (char *) s->char2b;
3094 int boff = s->font_info->baseline_offset; 3038 int boff = s->font_info->baseline_offset;
3095 XChar2b default_char;
3096 3039
3097 if (s->font_info->vertical_centering) 3040 if (s->font_info->vertical_centering)
3098 boff = VCENTER_BASELINE_OFFSET (s->font, s->f) - boff; 3041 boff = VCENTER_BASELINE_OFFSET (s->font, s->f) - boff;
3099 3042
3100 /* If S->font has an invalid default char, X might output some
3101 characters with zero width which is highly undesirable.
3102 Choose another default char in this case, and replace all
3103 occurrences of invalid characters in the string with that
3104 char. */
3105 if (!x_default_char (s->font, &default_char))
3106 for (i = 0; i < s->nchars; ++i)
3107 if (!x_per_char_metric_1 (s->font, s->char2b + i))
3108 s->char2b[i] = default_char;
3109
3110 /* If we can use 8-bit functions, condense S->char2b. */ 3043 /* If we can use 8-bit functions, condense S->char2b. */
3111 if (!s->two_byte_p) 3044 if (!s->two_byte_p)
3112 for (i = 0; i < s->nchars; ++i) 3045 for (i = 0; i < s->nchars; ++i)
@@ -4170,6 +4103,7 @@ x_fill_glyph_string (s, face_id, start, end, overlaps_p)
4170{ 4103{
4171 struct glyph *glyph, *last; 4104 struct glyph *glyph, *last;
4172 int voffset; 4105 int voffset;
4106 int glyph_not_available_p;
4173 4107
4174 xassert (s->f == XFRAME (s->w->frame)); 4108 xassert (s->f == XFRAME (s->w->frame));
4175 xassert (s->nchars == 0); 4109 xassert (s->nchars == 0);
@@ -4180,17 +4114,21 @@ x_fill_glyph_string (s, face_id, start, end, overlaps_p)
4180 last = s->row->glyphs[s->area] + end; 4114 last = s->row->glyphs[s->area] + end;
4181 voffset = glyph->voffset; 4115 voffset = glyph->voffset;
4182 4116
4117 glyph_not_available_p = glyph->glyph_not_available_p;
4118
4183 while (glyph < last 4119 while (glyph < last
4184 && glyph->type == CHAR_GLYPH 4120 && glyph->type == CHAR_GLYPH
4185 && glyph->voffset == voffset 4121 && glyph->voffset == voffset
4186 /* Same face id implies same charset, nowadays. */ 4122 /* Same face id implies same font, nowadays. */
4187 && glyph->face_id == face_id) 4123 && glyph->face_id == face_id
4124 && glyph->glyph_not_available_p == glyph_not_available_p)
4188 { 4125 {
4126 int two_byte_p;
4127
4189 s->face = x_get_glyph_face_and_encoding (s->f, glyph, 4128 s->face = x_get_glyph_face_and_encoding (s->f, glyph,
4190 s->char2b + s->nchars); 4129 s->char2b + s->nchars,
4191 if (s->char2b[s->nchars].byte2 != 0) 4130 &two_byte_p);
4192 s->two_byte_p = 1; 4131 s->two_byte_p = two_byte_p;
4193
4194 ++s->nchars; 4132 ++s->nchars;
4195 xassert (s->nchars <= end - start); 4133 xassert (s->nchars <= end - start);
4196 s->width += glyph->pixel_width; 4134 s->width += glyph->pixel_width;
@@ -4204,7 +4142,7 @@ x_fill_glyph_string (s, face_id, start, end, overlaps_p)
4204 but record the fact that we couldn't load it in 4142 but record the fact that we couldn't load it in
4205 S->font_not_found_p so that we can draw rectangles for the 4143 S->font_not_found_p so that we can draw rectangles for the
4206 characters of the glyph string. */ 4144 characters of the glyph string. */
4207 if (s->font == NULL) 4145 if (s->font == NULL || glyph_not_available_p)
4208 { 4146 {
4209 s->font_not_found_p = 1; 4147 s->font_not_found_p = 1;
4210 s->font = FRAME_FONT (s->f); 4148 s->font = FRAME_FONT (s->f);
@@ -4382,14 +4320,12 @@ x_set_glyph_string_background_width (s, start, last_x)
4382 XChar2b *char2b; \ 4320 XChar2b *char2b; \
4383 \ 4321 \
4384 c = (ROW)->glyphs[AREA][START].u.ch; \ 4322 c = (ROW)->glyphs[AREA][START].u.ch; \
4385 charset = CHAR_CHARSET (c); \
4386 face_id = (ROW)->glyphs[AREA][START].face_id; \ 4323 face_id = (ROW)->glyphs[AREA][START].face_id; \
4387 \ 4324 \
4388 s = (struct glyph_string *) alloca (sizeof *s); \ 4325 s = (struct glyph_string *) alloca (sizeof *s); \
4389 char2b = (XChar2b *) alloca ((END - START) * sizeof *char2b); \ 4326 char2b = (XChar2b *) alloca ((END - START) * sizeof *char2b); \
4390 x_init_glyph_string (s, char2b, W, ROW, AREA, START, HL); \ 4327 x_init_glyph_string (s, char2b, W, ROW, AREA, START, HL); \
4391 x_append_glyph_string (&HEAD, &TAIL, s); \ 4328 x_append_glyph_string (&HEAD, &TAIL, s); \
4392 s->charset = charset; \
4393 s->x = (X); \ 4329 s->x = (X); \
4394 START = x_fill_glyph_string (s, face_id, START, END, \ 4330 START = x_fill_glyph_string (s, face_id, START, END, \
4395 OVERLAPS_P); \ 4331 OVERLAPS_P); \
@@ -4410,6 +4346,7 @@ x_set_glyph_string_background_width (s, start, last_x)
4410 do { \ 4346 do { \
4411 int cmp_id = (ROW)->glyphs[AREA][START].u.cmp_id; \ 4347 int cmp_id = (ROW)->glyphs[AREA][START].u.cmp_id; \
4412 int face_id = (ROW)->glyphs[AREA][START].face_id; \ 4348 int face_id = (ROW)->glyphs[AREA][START].face_id; \
4349 struct face *base_face = FACE_FROM_ID (XFRAME (w->frame), face_id); \
4413 struct composition *cmp = composition_table[cmp_id]; \ 4350 struct composition *cmp = composition_table[cmp_id]; \
4414 int glyph_len = cmp->glyph_len; \ 4351 int glyph_len = cmp->glyph_len; \
4415 XChar2b *char2b; \ 4352 XChar2b *char2b; \
@@ -4417,14 +4354,17 @@ x_set_glyph_string_background_width (s, start, last_x)
4417 struct glyph_string *first_s = NULL; \ 4354 struct glyph_string *first_s = NULL; \
4418 int n; \ 4355 int n; \
4419 \ 4356 \
4357 base_face = base_face->ascii_face; \
4420 char2b = (XChar2b *) alloca ((sizeof *char2b) * glyph_len); \ 4358 char2b = (XChar2b *) alloca ((sizeof *char2b) * glyph_len); \
4421 faces = (struct face **) alloca ((sizeof *faces) * glyph_len); \ 4359 faces = (struct face **) alloca ((sizeof *faces) * glyph_len); \
4422 /* At first, fill in `char2b' and `faces'. */ \ 4360 /* At first, fill in `char2b' and `faces'. */ \
4423 for (n = 0; n < glyph_len; n++) \ 4361 for (n = 0; n < glyph_len; n++) \
4424 { \ 4362 { \
4425 int c = COMPOSITION_GLYPH (cmp, n); \ 4363 int c = COMPOSITION_GLYPH (cmp, n); \
4426 faces[n] = x_get_char_face_and_encoding (XFRAME (w->frame), c, \ 4364 int this_face_id = FACE_FOR_CHAR (XFRAME (w->frame), base_face, c); \
4427 face_id, char2b + n, 1); \ 4365 faces[n] = FACE_FROM_ID (XFRAME (w->frame), this_face_id); \
4366 x_get_char_face_and_encoding (XFRAME (w->frame), c, \
4367 this_face_id, char2b + n, 1); \
4428 } \ 4368 } \
4429 \ 4369 \
4430 /* Make glyph_strings for each glyph sequence that is drawable by \ 4370 /* Make glyph_strings for each glyph sequence that is drawable by \
@@ -4436,7 +4376,6 @@ x_set_glyph_string_background_width (s, start, last_x)
4436 x_append_glyph_string (&(HEAD), &(TAIL), s); \ 4376 x_append_glyph_string (&(HEAD), &(TAIL), s); \
4437 s->cmp = cmp; \ 4377 s->cmp = cmp; \
4438 s->gidx = n; \ 4378 s->gidx = n; \
4439 s->charset = 0; \
4440 s->x = (X); \ 4379 s->x = (X); \
4441 \ 4380 \
4442 if (n == 0) \ 4381 if (n == 0) \
@@ -10876,7 +10815,7 @@ x_new_font (f, fontname)
10876 register char *fontname; 10815 register char *fontname;
10877{ 10816{
10878 struct font_info *fontp 10817 struct font_info *fontp
10879 = fs_load_font (f, FRAME_X_FONT_TABLE (f), CHARSET_ASCII, fontname, -1); 10818 = FS_LOAD_FONT (f, 0, fontname, -1);
10880 10819
10881 if (!fontp) 10820 if (!fontp)
10882 return Qnil; 10821 return Qnil;
@@ -10928,9 +10867,9 @@ x_new_fontset (f, fontsetname)
10928 struct frame *f; 10867 struct frame *f;
10929 char *fontsetname; 10868 char *fontsetname;
10930{ 10869{
10931 int fontset = fs_query_fontset (f, fontsetname); 10870 int fontset = fs_query_fontset (build_string (fontsetname), 0);
10932 struct fontset_info *fontsetp;
10933 Lisp_Object result; 10871 Lisp_Object result;
10872 char *fontname;
10934 10873
10935 if (fontset < 0) 10874 if (fontset < 0)
10936 return Qnil; 10875 return Qnil;
@@ -10938,15 +10877,9 @@ x_new_fontset (f, fontsetname)
10938 if (f->output_data.x->fontset == fontset) 10877 if (f->output_data.x->fontset == fontset)
10939 /* This fontset is already set in frame F. There's nothing more 10878 /* This fontset is already set in frame F. There's nothing more
10940 to do. */ 10879 to do. */
10941 return build_string (fontsetname); 10880 return fontset_name (fontset);
10942
10943 fontsetp = FRAME_FONTSET_DATA (f)->fontset_table[fontset];
10944
10945 if (!fontsetp->fontname[CHARSET_ASCII])
10946 /* This fontset doesn't contain ASCII font. */
10947 return Qnil;
10948 10881
10949 result = x_new_font (f, fontsetp->fontname[CHARSET_ASCII]); 10882 result = x_new_font (f, (XSTRING (fontset_ascii (fontset))->data));
10950 10883
10951 if (!STRINGP (result)) 10884 if (!STRINGP (result))
10952 /* Can't load ASCII font. */ 10885 /* Can't load ASCII font. */
@@ -10954,13 +10887,11 @@ x_new_fontset (f, fontsetname)
10954 10887
10955 /* Since x_new_font doesn't update any fontset information, do it now. */ 10888 /* Since x_new_font doesn't update any fontset information, do it now. */
10956 f->output_data.x->fontset = fontset; 10889 f->output_data.x->fontset = fontset;
10957 FS_LOAD_FONT (f, FRAME_X_FONT_TABLE (f),
10958 CHARSET_ASCII, fontsetp->fontname[CHARSET_ASCII], fontset);
10959 10890
10960#ifdef HAVE_X_I18N 10891#ifdef HAVE_X_I18N
10961 if (FRAME_XIC (f) 10892 if (FRAME_XIC (f)
10962 && (FRAME_XIC_STYLE (f) & (XIMPreeditPosition | XIMStatusArea))) 10893 && (FRAME_XIC_STYLE (f) & (XIMPreeditPosition | XIMStatusArea)))
10963 xic_set_xfontset (f, fontsetp->fontname[CHARSET_ASCII]); 10894 xic_set_xfontset (f, XSTRING (fontset_ascii (fontset))->data);
10964#endif 10895#endif
10965 10896
10966 return build_string (fontsetname); 10897 return build_string (fontsetname);
@@ -12670,9 +12601,8 @@ x_load_font (f, fontname, size)
12670 12601
12671 /* The slot `encoding' specifies how to map a character 12602 /* The slot `encoding' specifies how to map a character
12672 code-points (0x20..0x7F or 0x2020..0x7F7F) of each charset to 12603 code-points (0x20..0x7F or 0x2020..0x7F7F) of each charset to
12673 the font code-points (0:0x20..0x7F, 1:0xA0..0xFF, 0:0x2020..0x7F7F, 12604 the font code-points (0:0x20..0x7F, 1:0xA0..0xFF), or
12674 the font code-points (0:0x20..0x7F, 1:0xA0..0xFF, 12605 (0:0x2020..0x7F7F, 1:0xA0A0..0xFFFF, 3:0x20A0..0x7FFF,
12675 0:0x2020..0x7F7F, 1:0xA0A0..0xFFFF, 3:0x20A0..0x7FFF, or
12676 2:0xA020..0xFF7F). For the moment, we don't know which charset 12606 2:0xA020..0xFF7F). For the moment, we don't know which charset
12677 uses this font. So, we set information in fontp->encoding[1] 12607 uses this font. So, we set information in fontp->encoding[1]
12678 which is never used by any charset. If mapping can't be 12608 which is never used by any charset. If mapping can't be