1 | /*----------------------------------------------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: rxvtfont.C |
2 | * File: rxvtfont.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * Copyright (c) 2003-2008 Marc Lehmann <pcg@goof.com> |
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 2 of the License, or |
… | |
… | |
241 | { |
241 | { |
242 | #if XFT |
242 | #if XFT |
243 | Picture dst; |
243 | Picture dst; |
244 | |
244 | |
245 | # ifdef HAVE_BG_PIXMAP |
245 | # ifdef HAVE_BG_PIXMAP |
246 | if (term->bgPixmap.pixmap |
246 | if (term->bg_pixmap |
247 | && !term->pix_colors[color].is_opaque () |
247 | && !term->pix_colors[color].is_opaque () |
248 | && ((dst = XftDrawPicture (d)))) |
248 | && ((dst = XftDrawPicture (d)))) |
249 | { |
249 | { |
250 | XClearArea (disp, d, x, y, w, h, false); |
250 | XClearArea (disp, d, x, y, w, h, false); |
251 | |
251 | |
… | |
… | |
524 | |
524 | |
525 | void draw (rxvt_drawable &d, int x, int y, |
525 | void draw (rxvt_drawable &d, int x, int y, |
526 | const text_t *text, int len, |
526 | const text_t *text, int len, |
527 | int fg, int bg) |
527 | int fg, int bg) |
528 | { |
528 | { |
529 | while (len--) |
529 | while (len) |
530 | { |
530 | { |
531 | int fid = fs->find_font_idx (*text); |
531 | int fid = fs->find_font_idx (*text); |
|
|
532 | int w = 1; |
|
|
533 | while (w < len && text[w] == NOCHAR) |
|
|
534 | w++; |
532 | (*fs)[fid]->draw (d, x, y, text, 1, fg, bg); |
535 | (*fs)[fid]->draw (d, x, y, text, w, fg, bg); |
533 | ++text; |
536 | text += w; |
|
|
537 | len -= w; |
534 | x += term->fwidth; |
538 | x += term->fwidth * w; |
535 | } |
539 | } |
536 | } |
540 | } |
537 | }; |
541 | }; |
538 | |
542 | |
539 | ///////////////////////////////////////////////////////////////////////////// |
543 | ///////////////////////////////////////////////////////////////////////////// |
… | |
… | |
967 | } |
971 | } |
968 | |
972 | |
969 | bool |
973 | bool |
970 | rxvt_font_x11::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const |
974 | rxvt_font_x11::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const |
971 | { |
975 | { |
|
|
976 | careful = false; |
|
|
977 | |
972 | uint32_t ch = FROM_UNICODE (cs, unicode); |
978 | uint32_t ch = FROM_UNICODE (cs, unicode); |
973 | |
979 | |
974 | if (ch == NOCHAR) |
980 | if (ch == NOCHAR) |
975 | return false; |
981 | return false; |
976 | |
982 | |
… | |
… | |
1218 | int ftheight = 0; |
1224 | int ftheight = 0; |
1219 | bool success = true; |
1225 | bool success = true; |
1220 | |
1226 | |
1221 | for (;;) |
1227 | for (;;) |
1222 | { |
1228 | { |
|
|
1229 | p = FcPatternDuplicate (match); |
1223 | f = XftFontOpenPattern (disp, FcPatternDuplicate (match)); |
1230 | f = XftFontOpenPattern (disp, p); |
1224 | |
1231 | |
1225 | if (!f) |
1232 | if (!f) |
1226 | { |
1233 | { |
|
|
1234 | FcPatternDestroy (p); |
1227 | success = false; |
1235 | success = false; |
1228 | break; |
1236 | break; |
1229 | } |
1237 | } |
1230 | |
1238 | |
1231 | FT_Face face = XftLockFace (f); |
1239 | FT_Face face = XftLockFace (f); |
… | |
… | |
1404 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
1412 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
1405 | |
1413 | |
1406 | #ifdef HAVE_BG_PIXMAP |
1414 | #ifdef HAVE_BG_PIXMAP |
1407 | Picture dst = 0; // the only assignment is done conditionally in the following if condition |
1415 | Picture dst = 0; // the only assignment is done conditionally in the following if condition |
1408 | |
1416 | |
1409 | if (term->bgPixmap.pixmap |
1417 | if (term->bg_pixmap |
1410 | && (bg == Color_transparent || bg == Color_bg |
1418 | && (bg == Color_transparent || bg == Color_bg |
1411 | || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) |
1419 | || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) |
1412 | { |
1420 | { |
1413 | int src_x = x, src_y = y; |
1421 | int src_x = x, src_y = y; |
1414 | |
1422 | |
1415 | if (term->bgPixmap.flags & bgPixmap_t::isTransparent) |
1423 | if (term->bg_flags & rxvt_term::BG_IS_TRANSPARENT) |
1416 | { |
1424 | { |
1417 | src_x += term->window_vt_x; |
1425 | src_x += term->window_vt_x; |
1418 | src_y += term->window_vt_y; |
1426 | src_y += term->window_vt_y; |
1419 | } |
1427 | } |
1420 | |
1428 | |
1421 | if (term->bgPixmap.pmap_width >= src_x + w |
1429 | if (term->bg_pmap_width >= src_x + w |
1422 | && term->bgPixmap.pmap_height >= src_y + h) |
1430 | && term->bg_pmap_height >= src_y + h) |
1423 | { |
1431 | { |
1424 | XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, |
1432 | XCopyArea (disp, term->bg_pixmap, d2, gc, |
1425 | src_x, src_y, w, h, 0, 0); |
1433 | src_x, src_y, w, h, 0, 0); |
1426 | } |
1434 | } |
1427 | else |
1435 | else |
1428 | { |
1436 | { |
1429 | XGCValues gcv; |
1437 | XGCValues gcv; |
1430 | |
1438 | |
1431 | gcv.fill_style = FillTiled; |
1439 | gcv.fill_style = FillTiled; |
1432 | gcv.tile = term->bgPixmap.pixmap; |
1440 | gcv.tile = term->bg_pixmap; |
1433 | gcv.ts_x_origin = -src_x; |
1441 | gcv.ts_x_origin = -src_x; |
1434 | gcv.ts_y_origin = -src_y; |
1442 | gcv.ts_y_origin = -src_y; |
1435 | |
1443 | |
1436 | XChangeGC (disp, gc, |
1444 | XChangeGC (disp, gc, |
1437 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
1445 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
… | |
… | |
1612 | buf[end - desc] = 0; |
1620 | buf[end - desc] = 0; |
1613 | |
1621 | |
1614 | push_font (new_font (buf, cs)); |
1622 | push_font (new_font (buf, cs)); |
1615 | } |
1623 | } |
1616 | else |
1624 | else |
1617 | rxvt_warn ("fontset element too long (>511 bytes), ignored."); |
1625 | rxvt_warn ("fontset element too long (>511 bytes), ignored.\n"); |
1618 | |
1626 | |
1619 | desc = end + 1; |
1627 | desc = end + 1; |
1620 | } |
1628 | } |
1621 | while (*end); |
1629 | while (*end); |
1622 | } |
1630 | } |