… | |
… | |
4 | * Copyright (c) 2003-2008 Marc Lehmann <schmorp@schmorp.de> |
4 | * Copyright (c) 2003-2008 Marc Lehmann <schmorp@schmorp.de> |
5 | * - original version. |
5 | * - original version. |
6 | * |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
9 | * the Free Software Foundation; either version 3 of the License, or |
10 | * (at your option) any later version. |
10 | * (at your option) any later version. |
11 | * |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
… | |
… | |
239 | else if (color >= 0) |
239 | else if (color >= 0) |
240 | { |
240 | { |
241 | #if XFT |
241 | #if XFT |
242 | Picture dst; |
242 | Picture dst; |
243 | |
243 | |
244 | # ifdef HAVE_BG_PIXMAP |
244 | # ifdef HAVE_IMG |
245 | if (term->bg_pixmap |
245 | if (term->bg_img |
246 | && !term->pix_colors[color].is_opaque () |
246 | && !term->pix_colors[color].is_opaque () |
247 | && ((dst = XftDrawPicture (d)))) |
247 | && ((dst = XftDrawPicture (d)))) |
248 | { |
248 | { |
249 | XClearArea (disp, d, x, y, w, h, false); |
249 | XClearArea (disp, d, x, y, w, h, false); |
250 | |
250 | |
… | |
… | |
262 | } |
262 | } |
263 | } |
263 | } |
264 | |
264 | |
265 | ///////////////////////////////////////////////////////////////////////////// |
265 | ///////////////////////////////////////////////////////////////////////////// |
266 | |
266 | |
267 | struct rxvt_font_default : rxvt_font { |
267 | struct rxvt_font_default : rxvt_font |
|
|
268 | { |
268 | struct rxvt_fontset *fs; |
269 | struct rxvt_fontset *fs; |
269 | |
270 | |
270 | rxvt_font_default (rxvt_fontset *fs) |
271 | rxvt_font_default (rxvt_fontset *fs) |
271 | : rxvt_font () |
272 | : rxvt_font () |
272 | { |
273 | { |
… | |
… | |
474 | case '\t': |
475 | case '\t': |
475 | case ZERO_WIDTH_CHAR: |
476 | case ZERO_WIDTH_CHAR: |
476 | case NOCHAR: |
477 | case NOCHAR: |
477 | break; |
478 | break; |
478 | |
479 | |
|
|
480 | /* |
|
|
481 | * If the base font does not support variation selectors, treat them as ZWC. |
|
|
482 | * a point could be made to do this for all wcwidth == 0 characters, but I |
|
|
483 | * decided against that until more data is available. |
|
|
484 | */ |
|
|
485 | case 0xfe00: case 0xfe01: case 0xfe02: case 0xfe03: case 0xfe04: case 0xfe05: case 0xfe06: case 0xfe07: |
|
|
486 | case 0xfe08: case 0xfe09: case 0xfe0a: case 0xfe0b: case 0xfe0c: case 0xfe0d: case 0xfe0e: case 0xfe0f: |
|
|
487 | break; |
|
|
488 | |
479 | default: |
489 | default: |
480 | XDrawRectangle (disp, d, gc, x + 2, y + 2, |
490 | XDrawRectangle (disp, d, gc, x + 2, y + 2, |
481 | fwidth - 4, term->fheight - 4); |
491 | fwidth - 4, term->fheight - 4); |
482 | } |
492 | } |
483 | |
493 | |
484 | x += fwidth; |
494 | x += fwidth; |
485 | } |
495 | } |
486 | } |
496 | } |
487 | |
497 | |
488 | struct rxvt_font_overflow : rxvt_font { |
498 | struct rxvt_font_overflow : rxvt_font |
|
|
499 | { |
489 | struct rxvt_fontset *fs; |
500 | struct rxvt_fontset *fs; |
490 | |
501 | |
491 | rxvt_font_overflow (rxvt_fontset *fs) |
502 | rxvt_font_overflow (rxvt_fontset *fs) |
492 | : rxvt_font () |
503 | : rxvt_font () |
493 | { |
504 | { |
… | |
… | |
539 | } |
550 | } |
540 | }; |
551 | }; |
541 | |
552 | |
542 | ///////////////////////////////////////////////////////////////////////////// |
553 | ///////////////////////////////////////////////////////////////////////////// |
543 | |
554 | |
544 | struct rxvt_font_x11 : rxvt_font { |
555 | struct rxvt_font_x11 : rxvt_font |
|
|
556 | { |
545 | rxvt_font_x11 () { f = 0; } |
557 | rxvt_font_x11 () { f = 0; } |
546 | |
558 | |
547 | void clear (); |
559 | void clear (); |
548 | |
560 | |
549 | rxvt_fontprop properties (); |
561 | rxvt_fontprop properties (); |
… | |
… | |
934 | // ignore characters we wouldn't use anyways |
946 | // ignore characters we wouldn't use anyways |
935 | bool careful; |
947 | bool careful; |
936 | if (!has_char (*t, &prop, careful)) |
948 | if (!has_char (*t, &prop, careful)) |
937 | continue; |
949 | continue; |
938 | |
950 | |
939 | XChar2b ch = { *t >> 8, *t }; |
951 | // the casts are needed in C++11 (see 8.5.1) |
|
|
952 | XChar2b ch = { (unsigned char)(*t >> 8), (unsigned char)*t }; |
940 | |
953 | |
941 | XCharStruct g; |
954 | XCharStruct g; |
942 | int dir_ret, asc_ret, des_ret; |
955 | int dir_ret, asc_ret, des_ret; |
943 | XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); |
956 | XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); |
944 | |
957 | |
… | |
… | |
1044 | dTermDisplay; |
1057 | dTermDisplay; |
1045 | dTermGC; |
1058 | dTermGC; |
1046 | |
1059 | |
1047 | bool slow = this->slow |
1060 | bool slow = this->slow |
1048 | || width != term->fwidth |
1061 | || width != term->fwidth |
1049 | || height != term->fheight; |
1062 | || height != term->fheight |
|
|
1063 | || ascent != f->ascent; |
1050 | |
1064 | |
1051 | int base = ascent; // sorry, incorrect: term->fbase; |
1065 | int base = ascent; // sorry, incorrect: term->fbase; |
1052 | |
1066 | |
1053 | XGCValues v; |
1067 | XGCValues v; |
1054 | v.foreground = term->pix_colors[fg]; |
1068 | v.foreground = term->pix_colors[fg]; |
… | |
… | |
1122 | |
1136 | |
1123 | ///////////////////////////////////////////////////////////////////////////// |
1137 | ///////////////////////////////////////////////////////////////////////////// |
1124 | |
1138 | |
1125 | #if XFT |
1139 | #if XFT |
1126 | |
1140 | |
1127 | struct rxvt_font_xft : rxvt_font { |
1141 | struct rxvt_font_xft : rxvt_font |
|
|
1142 | { |
1128 | rxvt_font_xft () { f = 0; } |
1143 | rxvt_font_xft () |
|
|
1144 | { |
|
|
1145 | f = 0; |
|
|
1146 | } |
1129 | |
1147 | |
1130 | void clear (); |
1148 | void clear (); |
1131 | |
1149 | |
1132 | rxvt_fontprop properties (); |
1150 | rxvt_fontprop properties (); |
1133 | |
1151 | |
… | |
… | |
1408 | { |
1426 | { |
1409 | if (ep != enc) |
1427 | if (ep != enc) |
1410 | { |
1428 | { |
1411 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
1429 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
1412 | |
1430 | |
1413 | #ifdef HAVE_BG_PIXMAP |
1431 | #ifdef HAVE_IMG |
1414 | Picture dst = 0; // the only assignment is done conditionally in the following if condition |
1432 | Picture dst = 0; // the only assignment is done conditionally in the following if condition |
1415 | |
1433 | |
1416 | if (term->bg_pixmap |
1434 | if (term->bg_img |
1417 | && (bg == Color_transparent || bg == Color_bg |
1435 | && (bg == Color_transparent || bg == Color_bg |
1418 | || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) |
1436 | || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) |
1419 | { |
1437 | { |
1420 | int src_x = x, src_y = y; |
1438 | int src_x = x, src_y = y; |
1421 | |
1439 | |
… | |
… | |
1423 | { |
1441 | { |
1424 | src_x += term->window_vt_x; |
1442 | src_x += term->window_vt_x; |
1425 | src_y += term->window_vt_y; |
1443 | src_y += term->window_vt_y; |
1426 | } |
1444 | } |
1427 | |
1445 | |
1428 | if (term->bg_pmap_width >= src_x + w |
1446 | if (term->bg_img->w >= src_x + w |
1429 | && term->bg_pmap_height >= src_y + h) |
1447 | && term->bg_img->h >= src_y + h) |
1430 | { |
1448 | { |
1431 | XCopyArea (disp, term->bg_pixmap, d2, gc, |
1449 | XCopyArea (disp, term->bg_img->pm, d2, gc, |
1432 | src_x, src_y, w, h, 0, 0); |
1450 | src_x, src_y, w, h, 0, 0); |
1433 | } |
1451 | } |
1434 | else |
1452 | else |
1435 | { |
1453 | { |
1436 | XGCValues gcv; |
1454 | XGCValues gcv; |
1437 | |
1455 | |
1438 | gcv.fill_style = FillTiled; |
1456 | gcv.fill_style = FillTiled; |
1439 | gcv.tile = term->bg_pixmap; |
1457 | gcv.tile = term->bg_img->pm; |
1440 | gcv.ts_x_origin = -src_x; |
1458 | gcv.ts_x_origin = -src_x; |
1441 | gcv.ts_y_origin = -src_y; |
1459 | gcv.ts_y_origin = -src_y; |
1442 | |
1460 | |
1443 | XChangeGC (disp, gc, |
1461 | XChangeGC (disp, gc, |
1444 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
1462 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
… | |
… | |
1499 | |
1517 | |
1500 | for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) |
1518 | for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) |
1501 | (*i)->unref (); |
1519 | (*i)->unref (); |
1502 | |
1520 | |
1503 | for (pagemap **p = fmap.begin (); p != fmap.end (); p++) |
1521 | for (pagemap **p = fmap.begin (); p != fmap.end (); p++) |
1504 | delete [] *p; |
1522 | delete *p; |
1505 | |
1523 | |
1506 | free (fontdesc); fontdesc = 0; |
1524 | free (fontdesc); fontdesc = 0; |
1507 | |
1525 | |
1508 | fonts.clear (); |
1526 | fonts.clear (); |
1509 | |
1527 | |
… | |
… | |
1604 | cs = codeset_from_name (spec + sizeof ("codeset=") - 1); |
1622 | cs = codeset_from_name (spec + sizeof ("codeset=") - 1); |
1605 | else |
1623 | else |
1606 | rxvt_warn ("unknown parameter '%s' in font specification, skipping.\n", spec); |
1624 | rxvt_warn ("unknown parameter '%s' in font specification, skipping.\n", spec); |
1607 | |
1625 | |
1608 | desc++; |
1626 | desc++; |
1609 | while (*desc <= ' ') desc++; |
1627 | while (*desc <= ' ' && *desc) desc++; |
1610 | } |
1628 | } |
1611 | |
1629 | |
1612 | end = strchr (desc, ','); |
1630 | end = strchr (desc, ','); |
1613 | if (!end) |
1631 | if (!end) |
1614 | end = desc + strlen (desc); |
1632 | end = desc + strlen (desc); |
… | |
… | |
1732 | // way to configure this and xft is easier to hack in, |
1750 | // way to configure this and xft is easier to hack in, |
1733 | // while x11 has more framework in place already. |
1751 | // while x11 has more framework in place already. |
1734 | // TODO: this is a real resource hog, xft takes ages(?) |
1752 | // TODO: this is a real resource hog, xft takes ages(?) |
1735 | #if XFT && USE_SLOW_LOOKUP |
1753 | #if XFT && USE_SLOW_LOOKUP |
1736 | // grab the first xft font that seems suitable |
1754 | // grab the first xft font that seems suitable |
|
|
1755 | // TOOD: should go first for cellchar (spacing 110) then mono, then else |
1737 | FcPattern *p = FcPatternCreate (); |
1756 | FcPattern *p = FcPatternCreate (); |
1738 | |
1757 | |
1739 | FcCharSet *s = FcCharSetCreate (); |
1758 | FcCharSet *s = FcCharSetCreate (); |
1740 | FcCharSetAddChar (s, unicode); |
1759 | FcCharSetAddChar (s, unicode); |
1741 | FcPatternAddCharSet (p, FC_CHARSET, s); |
1760 | FcPatternAddCharSet (p, FC_CHARSET, s); |
… | |
… | |
1785 | while (hi >= fmap.size ()) |
1804 | while (hi >= fmap.size ()) |
1786 | fmap.push_back (0); |
1805 | fmap.push_back (0); |
1787 | |
1806 | |
1788 | if (!fmap[hi]) |
1807 | if (!fmap[hi]) |
1789 | { |
1808 | { |
1790 | // C++ has no separate new and new [] - we need the "new" form, |
|
|
1791 | // just like the syntax implies, but since pagemap is char[], |
|
|
1792 | // C++ chooses the wrong new, so we need the cast and delete []. |
|
|
1793 | fmap[hi] = (pagemap *)new pagemap; |
1809 | fmap[hi] = new pagemap; |
1794 | memset (fmap[hi], 0xff, sizeof (pagemap)); |
1810 | memset (fmap[hi], 0xff, sizeof (pagemap)); |
1795 | } |
1811 | } |
1796 | |
1812 | |
1797 | (*fmap[hi])[unicode & 0xff] = i; |
1813 | (*fmap[hi])[unicode & 0xff] = i; |
1798 | } |
1814 | } |