… | |
… | |
212 | } |
212 | } |
213 | |
213 | |
214 | ///////////////////////////////////////////////////////////////////////////// |
214 | ///////////////////////////////////////////////////////////////////////////// |
215 | |
215 | |
216 | rxvt_font::rxvt_font () |
216 | rxvt_font::rxvt_font () |
217 | : name(0), width(rxvt_fontprop::unset), height(rxvt_fontprop::unset) |
217 | : name(0), width(rxvt_fontprop::unset), height(rxvt_fontprop::unset), can_compose(false) |
218 | { |
218 | { |
219 | } |
219 | } |
220 | |
220 | |
221 | void |
221 | void |
222 | rxvt_font::set_name (char *name_) |
222 | rxvt_font::set_name (char *name_) |
… | |
… | |
313 | if (unicode >= 0x2500 && unicode <= 0x259f && |
313 | if (unicode >= 0x2500 && unicode <= 0x259f && |
314 | !term->option (Opt_skipBuiltinGlyphs)) |
314 | !term->option (Opt_skipBuiltinGlyphs)) |
315 | return true; |
315 | return true; |
316 | #endif |
316 | #endif |
317 | |
317 | |
318 | if (IS_COMPOSE (unicode)) |
318 | // we do not check for IS_COMPOSE here, as this would |
319 | return true; |
319 | // rob other fonts from taking over. |
320 | |
320 | |
321 | switch (unicode) |
321 | switch (unicode) |
322 | { |
322 | { |
323 | case ZERO_WIDTH_CHAR: |
323 | case ZERO_WIDTH_CHAR: |
324 | case NOCHAR: |
324 | case NOCHAR: |
… | |
… | |
345 | |
345 | |
346 | XSetForeground (disp, gc, term->pix_colors[fg]); |
346 | XSetForeground (disp, gc, term->pix_colors[fg]); |
347 | |
347 | |
348 | while (len) |
348 | while (len) |
349 | { |
349 | { |
|
|
350 | const text_t *tp = text; |
|
|
351 | text_t t = *tp; |
|
|
352 | |
|
|
353 | while (++text, --len && *text == NOCHAR) |
|
|
354 | ; |
|
|
355 | |
350 | #if ENABLE_COMBINING |
356 | #if ENABLE_COMBINING |
351 | compose_char *cc; |
357 | compose_char *cc; |
352 | #endif |
358 | #endif |
353 | const text_t *tp = text; |
|
|
354 | text_t t = *tp; |
|
|
355 | |
|
|
356 | while (++text, --len && *text == NOCHAR) |
|
|
357 | ; |
|
|
358 | |
|
|
359 | int width = text - tp; |
359 | int width = text - tp; |
360 | int fwidth = term->fwidth * width; |
360 | int fwidth = term->fwidth * width; |
361 | |
361 | |
362 | #ifdef BUILTIN_GLYPHS |
362 | #ifdef BUILTIN_GLYPHS |
363 | if (0x2500 <= t && t <= 0x259f) |
363 | if (0x2500 <= t && t <= 0x259f) |
… | |
… | |
446 | #if ENABLE_COMBINING |
446 | #if ENABLE_COMBINING |
447 | else if (IS_COMPOSE (t) && (cc = rxvt_composite[t])) |
447 | else if (IS_COMPOSE (t) && (cc = rxvt_composite[t])) |
448 | { |
448 | { |
449 | min_it (width, 2); // we only support wcwidth up to 2 |
449 | min_it (width, 2); // we only support wcwidth up to 2 |
450 | |
450 | |
|
|
451 | #if NOT_YET |
|
|
452 | vector<text_t> chrs; |
|
|
453 | chrs.reserve (rxvt_composite.expand (t)); |
|
|
454 | rxvt_composite.expand (t, &chrs[0]); |
|
|
455 | |
|
|
456 | while (!chrs.empty ()) |
|
|
457 | { |
|
|
458 | rxvt_font *f1 = fs->find_font_idx (chrs[0]) |
|
|
459 | |
|
|
460 | int i = 0; |
|
|
461 | while (i < chrs.size () - 1 |
|
|
462 | && f1->can_combine |
|
|
463 | && f1->has-char (chrs[i + 1], careful) |
|
|
464 | && !careful |
|
|
465 | ++i; |
|
|
466 | |
|
|
467 | (*fs)[f1]->draw (d, x, y, &chrs[0], width, fg, bg); |
|
|
468 | chrs.erase (&chrs[0], &chrs[i]); |
|
|
469 | } |
|
|
470 | #endif |
|
|
471 | |
|
|
472 | #if 1 |
451 | text_t chrs[2]; |
473 | text_t chrs[2]; |
452 | chrs [1] = NOCHAR; |
474 | chrs [1] = NOCHAR; |
453 | |
475 | |
454 | *chrs = cc->c1; |
476 | *chrs = cc->c1; |
455 | rxvt_font *f1 = (*fs)[fs->find_font_idx (cc->c1)]; |
477 | rxvt_font *f1 = (*fs)[fs->find_font_idx (cc->c1)]; |
… | |
… | |
465 | ? f1 |
487 | ? f1 |
466 | : (*fs)[fs->find_font_idx (cc->c2)]; |
488 | : (*fs)[fs->find_font_idx (cc->c2)]; |
467 | |
489 | |
468 | f2->draw (d, x, y, chrs, width, fg, Color_none); |
490 | f2->draw (d, x, y, chrs, width, fg, Color_none); |
469 | } |
491 | } |
|
|
492 | #endif |
470 | } |
493 | } |
471 | #endif |
494 | #endif |
472 | else |
495 | else |
473 | switch (t) |
496 | switch (t) |
474 | { |
497 | { |
… | |
… | |
1140 | |
1163 | |
1141 | struct rxvt_font_xft : rxvt_font |
1164 | struct rxvt_font_xft : rxvt_font |
1142 | { |
1165 | { |
1143 | rxvt_font_xft () |
1166 | rxvt_font_xft () |
1144 | { |
1167 | { |
|
|
1168 | can_compose = true; |
1145 | f = 0; |
1169 | f = 0; |
1146 | } |
1170 | } |
1147 | |
1171 | |
1148 | void clear (); |
1172 | void clear (); |
1149 | |
1173 | |
… | |
… | |
1293 | if (glheight < g.height - g.y) glheight = g.height - g.y; |
1317 | if (glheight < g.height - g.y) glheight = g.height - g.y; |
1294 | } |
1318 | } |
1295 | |
1319 | |
1296 | if (!width) |
1320 | if (!width) |
1297 | { |
1321 | { |
1298 | rxvt_warn ("unable to calculate font width for '%s', ignoring.\n", name); |
1322 | rxvt_warn ("unable to calculate font width for '%s', using max_advance_width.\n", name); |
1299 | |
1323 | width = f->max_advance_width; |
1300 | XftFontClose (disp, f); |
|
|
1301 | f = 0; |
|
|
1302 | |
|
|
1303 | success = false; |
|
|
1304 | break; |
1324 | break; |
1305 | } |
1325 | } |
1306 | |
1326 | |
1307 | if (prop.height == rxvt_fontprop::unset |
1327 | if (prop.height == rxvt_fontprop::unset |
1308 | || (height <= prop.height && glheight <= prop.height) |
1328 | || (height <= prop.height && glheight <= prop.height) |
… | |
… | |
1343 | bool |
1363 | bool |
1344 | rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const |
1364 | rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const |
1345 | { |
1365 | { |
1346 | careful = false; |
1366 | careful = false; |
1347 | |
1367 | |
|
|
1368 | #if ENABLE_COMBINING && !UNICODE_3 |
|
|
1369 | if (ecb_expect_false (IS_COMPOSE (unicode))) |
|
|
1370 | if (compose_char *cc = rxvt_composite[unicode]) |
|
|
1371 | if (cc->c2 == NOCHAR) |
|
|
1372 | unicode = cc->c1; |
|
|
1373 | #endif |
|
|
1374 | |
1348 | if (!XftCharExists (term->dpy, f, unicode)) |
1375 | if (!XftCharExists (term->dpy, f, unicode)) |
1349 | return false; |
1376 | return false; |
1350 | |
1377 | |
1351 | if (!prop || prop->width == rxvt_fontprop::unset) |
1378 | if (!prop || prop->width == rxvt_fontprop::unset) |
1352 | return true; |
1379 | return true; |
… | |
… | |
1398 | |
1425 | |
1399 | while (len) |
1426 | while (len) |
1400 | { |
1427 | { |
1401 | int cwidth = term->fwidth; |
1428 | int cwidth = term->fwidth; |
1402 | FcChar32 fc = *text++; len--; |
1429 | FcChar32 fc = *text++; len--; |
|
|
1430 | |
|
|
1431 | #if ENABLE_COMBINING && !UNICODE_3 |
|
|
1432 | if (ecb_expect_false (IS_COMPOSE (fc))) |
|
|
1433 | if (compose_char *cc = rxvt_composite[fc]) // should always be true, but better be safe than sorry |
|
|
1434 | fc = cc->c1; // c2 must be NOCHAR, as has_char handles it that way |
|
|
1435 | #endif |
1403 | |
1436 | |
1404 | while (len && *text == NOCHAR) |
1437 | while (len && *text == NOCHAR) |
1405 | text++, len--, cwidth += term->fwidth; |
1438 | text++, len--, cwidth += term->fwidth; |
1406 | |
1439 | |
1407 | if (fc != ' ') // skip spaces |
1440 | if (fc != ' ') // skip spaces |
… | |
… | |
1693 | } |
1726 | } |
1694 | |
1727 | |
1695 | int |
1728 | int |
1696 | rxvt_fontset::find_font_idx (unicode_t unicode) |
1729 | rxvt_fontset::find_font_idx (unicode_t unicode) |
1697 | { |
1730 | { |
1698 | if (unicode >= 1<<20) |
1731 | // this limits fmap size. it has to accomodate COMPOSE_HI when UNICODE_3 |
|
|
1732 | if (unicode > 0x1fffff) |
1699 | return 0; |
1733 | return 0; |
1700 | |
1734 | |
1701 | unicode_t hi = unicode >> 8; |
1735 | unicode_t hi = unicode >> 8; |
1702 | |
1736 | |
1703 | if (hi < fmap.size () |
1737 | if (hi < fmap.size ()) |
1704 | && fmap[hi] |
1738 | if (pagemap *pm = fmap[hi]) |
1705 | && (*fmap[hi])[unicode & 0xff] != 0xff) |
1739 | if ((*pm)[unicode & 0xff] != 0xff) |
1706 | return (*fmap[hi])[unicode & 0xff]; |
1740 | return (*pm)[unicode & 0xff]; |
1707 | |
1741 | |
1708 | unsigned int i; |
1742 | unsigned int i; |
1709 | |
1743 | |
1710 | for (i = 0; i < fonts.size (); i++) |
1744 | for (i = 0; i < fonts.size (); i++) |
1711 | { |
1745 | { |
… | |
… | |
1735 | } |
1769 | } |
1736 | |
1770 | |
1737 | next_font: |
1771 | next_font: |
1738 | if (i == fonts.size () - 1) |
1772 | if (i == fonts.size () - 1) |
1739 | { |
1773 | { |
|
|
1774 | // compose characters are handled by the default font, unless another font takes over |
|
|
1775 | // we do not go via the fallback list for speed reasons. |
|
|
1776 | if (IS_COMPOSE (unicode)) |
|
|
1777 | return 0; |
|
|
1778 | |
1740 | if (fallback->name) |
1779 | if (fallback->name) |
1741 | { |
1780 | { |
1742 | // search through the fallback list |
1781 | // search through the fallback list |
1743 | push_font (new_font (fallback->name, fallback->cs)); |
1782 | push_font (new_font (fallback->name, fallback->cs)); |
1744 | fallback++; |
1783 | fallback++; |