ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtfont.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtfont.C (file contents):
Revision 1.220 by root, Sat Jul 3 04:47:08 2021 UTC vs.
Revision 1.224 by root, Thu Jan 4 19:52:37 2024 UTC

152 { CS_UNKNOWN, 0 } 152 { CS_UNKNOWN, 0 }
153}; 153};
154 154
155// these characters are used to guess the font height and width 155// these characters are used to guess the font height and width
156// pango uses a similar algorithm and doesn't trust the font either. 156// pango uses a similar algorithm and doesn't trust the font either.
157static uint16_t extent_test_chars[] = { 157static uint32_t extent_test_chars[] = {
158 '0', '1', '8', 'a', 'd', 'x', 'm', 'y', 'g', 'W', 'X', '\'', '_', 158 '0', '1', '8', 'a', 'd', 'x', 'm', 'y', 'g', 'W', 'X', '\'', '_',
159 0x00cd, 0x00d5, 0x0114, 0x0177, 0x0643, // ÍÕĔŷﻙ 159 0x00cd, 0x00d5, 0x0114, 0x0177, 0x0643, // ÍÕĔŷﻙ
160 0x304c, 0x672c, // が本 160 0x304c, 0x672c, // が本
161 0x1f600, // 😀
161}; 162};
162 163
163#define dTermDisplay Display *disp = term->dpy 164#define dTermDisplay Display *disp = term->dpy
164#define dTermGC GC gc = term->gc 165#define dTermGC GC gc = term->gc
165 166
517 } 518 }
518 519
519 bool load (const rxvt_fontprop &prop, bool force_prop) 520 bool load (const rxvt_fontprop &prop, bool force_prop)
520 { 521 {
521 width = 1; height = 1; 522 width = 1; height = 1;
522 ascent = 1; descent = 0; 523 ascent = 1;
524 descent = (*fs)[2]->descent;
523 525
524 set_name (strdup ("built-in rendition overflow font")); 526 set_name (strdup ("built-in rendition overflow font"));
525 527
526 return true; 528 return true;
527 } 529 }
935 } 937 }
936#endif 938#endif
937 939
938 width = 1; 940 width = 1;
939 941
940 for (uint16_t *t = extent_test_chars; t < extent_test_chars + ecb_array_length (extent_test_chars); t++) 942 for (uint32_t *t = extent_test_chars; t < extent_test_chars + ecb_array_length (extent_test_chars); t++)
941 { 943 {
942 if (FROM_UNICODE (cs, *t) == NOCHAR) 944 if (FROM_UNICODE (cs, *t) == NOCHAR)
943 continue; 945 continue;
944 946
945 // ignore characters we wouldn't use anyways 947 // ignore characters we wouldn't use anyways
1263 break; 1265 break;
1264 } 1266 }
1265 1267
1266 FT_Face face = XftLockFace (f); 1268 FT_Face face = XftLockFace (f);
1267 1269
1270 // fuck me plenty: XftLockFace can actually return 0. try not to crash.
1271 // we also assume blindly that if the first lock succeeds, then subsequent
1272 // locks will also succeed.
1273 if (!face)
1274 {
1275 XftFontClose (disp, f);
1276 success = false;
1277 break;
1278 }
1279
1268 ascent = (face->size->metrics.ascender + 63) >> 6; 1280 ascent = (face->size->metrics.ascender + 63) >> 6;
1269 descent = (-face->size->metrics.descender + 63) >> 6; 1281 descent = (-face->size->metrics.descender + 63) >> 6;
1270 height = max (ascent + descent, (face->size->metrics.height + 63) >> 6); 1282 height = max (ascent + descent, (face->size->metrics.height + 63) >> 6);
1271 width = 0; 1283 width = 0;
1272 1284
1274 1286
1275 XftUnlockFace (f); 1287 XftUnlockFace (f);
1276 1288
1277 int glheight = height; 1289 int glheight = height;
1278 1290
1279 for (uint16_t *t = extent_test_chars; t < extent_test_chars + ecb_array_length (extent_test_chars); t++) 1291 for (uint32_t *t = extent_test_chars; t < extent_test_chars + ecb_array_length (extent_test_chars); t++)
1280 { 1292 {
1281 FcChar16 ch = *t; 1293 FcChar32 ch = *t;
1282 1294
1283 if (cs != CS_UNICODE 1295 if (cs != CS_UNICODE
1284 && ch > 0x100 1296 && ch > 0x100
1285 && FROM_UNICODE (cs, ch) == NOCHAR) 1297 && FROM_UNICODE (cs, ch) == NOCHAR)
1286 continue; 1298 continue;
1289 bool careful; 1301 bool careful;
1290 if (!has_char (*t, &prop, careful)) 1302 if (!has_char (*t, &prop, careful))
1291 continue; 1303 continue;
1292 1304
1293 XGlyphInfo g; 1305 XGlyphInfo g;
1294 XftTextExtents16 (disp, f, &ch, 1, &g); 1306 XftTextExtents32 (disp, f, &ch, 1, &g);
1295 1307
1296 g.width -= g.x; 1308 g.width -= g.x;
1297 1309
1298 int wcw = WCWIDTH (ch); 1310 int wcw = WCWIDTH (ch);
1299 if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; 1311 if (wcw > 0) g.width = (g.width + wcw - 1) / wcw;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines