Mercurial > emacs
comparison src/xterm.c @ 27974:d443ad369a18
(PER_CHAR_METRIC): Removed.
(x_per_char_metric_1, x_default_char): New functions.
(x_per_char_metric): If font's default char is invalid, return
metrics of a suitably chosen usable default char.
(x_draw_glyph_string_foreground): If font has an invalid default
char, replace occurrences of that char with a suitably chosen
usable default char.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 03 Mar 2000 13:49:32 +0000 |
parents | 7d61ff2d1530 |
children | 4ba445af210b |
comparison
equal
deleted
inserted
replaced
27973:cf535f97695d | 27974:d443ad369a18 |
---|---|
1095 static struct face *x_get_glyph_face_and_encoding P_ ((struct frame *, | 1095 static struct face *x_get_glyph_face_and_encoding P_ ((struct frame *, |
1096 struct glyph *, | 1096 struct glyph *, |
1097 XChar2b *)); | 1097 XChar2b *)); |
1098 static struct face *x_get_char_face_and_encoding P_ ((struct frame *, int, | 1098 static struct face *x_get_char_face_and_encoding P_ ((struct frame *, int, |
1099 int, XChar2b *, int)); | 1099 int, XChar2b *, int)); |
1100 static XCharStruct *x_per_char_metric_1 P_ ((XFontStruct *, XChar2b *)); | |
1100 static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *)); | 1101 static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *)); |
1101 static void x_encode_char P_ ((int, XChar2b *, struct font_info *)); | 1102 static void x_encode_char P_ ((int, XChar2b *, struct font_info *)); |
1102 static void x_append_glyph P_ ((struct it *)); | 1103 static void x_append_glyph P_ ((struct it *)); |
1103 static void x_append_composite_glyph P_ ((struct it *)); | 1104 static void x_append_composite_glyph P_ ((struct it *)); |
1104 static void x_append_stretch_glyph P_ ((struct it *it, Lisp_Object, | 1105 static void x_append_stretch_glyph P_ ((struct it *it, Lisp_Object, |
1105 int, int, double)); | 1106 int, int, double)); |
1106 static void x_produce_glyphs P_ ((struct it *)); | 1107 static void x_produce_glyphs P_ ((struct it *)); |
1107 static void x_produce_image_glyph P_ ((struct it *it)); | 1108 static void x_produce_image_glyph P_ ((struct it *it)); |
1108 | 1109 static XCharStruct *x_default_char P_ ((XFontStruct *, XChar2b *)); |
1109 | 1110 |
1110 /* Return a pointer to per-char metric information in FONT of a | 1111 |
1111 character pointed by B which is a pointer to an XChar2b. */ | 1112 /* Get metrics of character CHAR2B in FONT. Value is null if CHAR2B |
1112 | 1113 is not contained in the font. */ |
1113 #define PER_CHAR_METRIC(font, b) \ | |
1114 ((font)->per_char \ | |
1115 ? ((font)->per_char + (b)->byte2 - (font)->min_char_or_byte2 \ | |
1116 + (((font)->min_byte1 || (font)->max_byte1) \ | |
1117 ? (((b)->byte1 - (font)->min_byte1) \ | |
1118 * ((font)->max_char_or_byte2 - (font)->min_char_or_byte2 + 1)) \ | |
1119 : 0)) \ | |
1120 : &((font)->max_bounds)) | |
1121 | |
1122 | |
1123 /* Get metrics of character CHAR2B in FONT. Value is always non-null. | |
1124 If CHAR2B is not contained in FONT, the font's default character | |
1125 metric is returned. */ | |
1126 | 1114 |
1127 static INLINE XCharStruct * | 1115 static INLINE XCharStruct * |
1128 x_per_char_metric (font, char2b) | 1116 x_per_char_metric_1 (font, char2b) |
1129 XFontStruct *font; | 1117 XFontStruct *font; |
1130 XChar2b *char2b; | 1118 XChar2b *char2b; |
1131 { | 1119 { |
1132 /* The result metric information. */ | 1120 /* The result metric information. */ |
1133 XCharStruct *pcm = NULL; | 1121 XCharStruct *pcm = NULL; |
1184 if (char2b->byte2 >= font->min_char_or_byte2 | 1172 if (char2b->byte2 >= font->min_char_or_byte2 |
1185 && char2b->byte2 <= font->max_char_or_byte2) | 1173 && char2b->byte2 <= font->max_char_or_byte2) |
1186 pcm = &font->max_bounds; | 1174 pcm = &font->max_bounds; |
1187 } | 1175 } |
1188 | 1176 |
1189 | 1177 if (pcm && pcm->width == 0) |
1190 if (pcm == NULL || pcm->width == 0) | 1178 pcm = NULL; |
1179 | |
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 | |
1190 static INLINE XCharStruct * | |
1191 x_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 | |
1232 static INLINE XCharStruct * | |
1233 x_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) | |
1191 { | 1240 { |
1192 /* Character not contained in the font. FONT->default_char | 1241 /* Character not contained in the font. FONT->default_char |
1193 gives the character that will be printed. FONT->default_char | 1242 gives the character that will be printed. FONT->default_char |
1194 is a 16-bit character code with byte1 in the most significant | 1243 is a 16-bit character code with byte1 in the most significant |
1195 byte and byte2 in the least significant byte. */ | 1244 byte and byte2 in the least significant byte. */ |
1196 XChar2b default_char; | 1245 XChar2b default_char; |
1197 default_char.byte1 = (font->default_char >> BITS_PER_CHAR) & 0xff; | 1246 |
1198 default_char.byte2 = font->default_char & 0xff; | 1247 pcm = x_default_char (font, &default_char); |
1199 | 1248 if (pcm == NULL) |
1200 /* Avoid an endless recursion if FONT->default_char itself | 1249 pcm = x_per_char_metric_1 (font, &default_char); |
1201 hasn't per char metrics. handa@etl.go.jp reports that some | |
1202 fonts have this problem. */ | |
1203 if (default_char.byte1 != char2b->byte1 | |
1204 || default_char.byte2 != char2b->byte2) | |
1205 pcm = x_per_char_metric (font, &default_char); | |
1206 else | |
1207 pcm = &font->max_bounds; | |
1208 } | 1250 } |
1209 | 1251 |
1252 xassert (pcm != NULL); | |
1210 return pcm; | 1253 return pcm; |
1211 } | 1254 } |
1212 | 1255 |
1213 | 1256 |
1214 /* Encode CHAR2B using encoding information from FONT_INFO. CHAR2B is | 1257 /* Encode CHAR2B using encoding information from FONT_INFO. CHAR2B is |
3047 } | 3090 } |
3048 else | 3091 else |
3049 { | 3092 { |
3050 char *char1b = (char *) s->char2b; | 3093 char *char1b = (char *) s->char2b; |
3051 int boff = s->font_info->baseline_offset; | 3094 int boff = s->font_info->baseline_offset; |
3095 XChar2b default_char; | |
3052 | 3096 |
3053 if (s->font_info->vertical_centering) | 3097 if (s->font_info->vertical_centering) |
3054 boff = VCENTER_BASELINE_OFFSET (s->font, s->f) - boff; | 3098 boff = VCENTER_BASELINE_OFFSET (s->font, s->f) - boff; |
3099 | |
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; | |
3055 | 3109 |
3056 /* If we can use 8-bit functions, condense S->char2b. */ | 3110 /* If we can use 8-bit functions, condense S->char2b. */ |
3057 if (!s->two_byte_p) | 3111 if (!s->two_byte_p) |
3058 for (i = 0; i < s->nchars; ++i) | 3112 for (i = 0; i < s->nchars; ++i) |
3059 char1b[i] = s->char2b[i].byte2; | 3113 char1b[i] = s->char2b[i].byte2; |