… | |
… | |
43 | const char *name; |
43 | const char *name; |
44 | } fallback_fonts[] = { |
44 | } fallback_fonts[] = { |
45 | { CS_ISO8859_1, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-1" }, |
45 | { CS_ISO8859_1, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-1" }, |
46 | { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-15" }, |
46 | { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-15" }, |
47 | { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-fcd8859-15" }, |
47 | { CS_ISO8859_15, "-*-*-*-r-*--*-*-*-*-c-*-fcd8859-15" }, |
48 | |
48 | |
49 | #if ENCODING_EU |
49 | #if ENCODING_EU |
50 | // cyrillic |
50 | // cyrillic |
51 | { CS_KOI8_R, "-*-*-*-r-*--*-*-*-*-c-*-koi8-r" }, |
51 | { CS_KOI8_R, "-*-*-*-r-*--*-*-*-*-c-*-koi8-r" }, |
52 | { CS_KOI8_U, "-*-*-*-r-*--*-*-*-*-c-*-koi8-u" }, |
52 | { CS_KOI8_U, "-*-*-*-r-*--*-*-*-*-c-*-koi8-u" }, |
53 | |
53 | |
54 | { CS_ISO8859_2, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-2" }, |
54 | { CS_ISO8859_2, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-2" }, |
55 | { CS_ISO8859_3, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-3" }, |
55 | { CS_ISO8859_3, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-3" }, |
56 | { CS_ISO8859_4, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-4" }, |
56 | { CS_ISO8859_4, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-4" }, |
57 | { CS_ISO8859_5, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-5" }, |
57 | { CS_ISO8859_5, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-5" }, |
58 | { CS_ISO8859_6, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-6" }, |
58 | { CS_ISO8859_6, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-6" }, |
… | |
… | |
65 | { CS_ISO8859_14, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-14" }, |
65 | { CS_ISO8859_14, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-14" }, |
66 | { CS_ISO8859_16, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-16" }, |
66 | { CS_ISO8859_16, "-*-*-*-r-*--*-*-*-*-c-*-iso8859-16" }, |
67 | |
67 | |
68 | # if XFT |
68 | # if XFT |
69 | { CS_KOI8_U, "xft::lang=ru" }, |
69 | { CS_KOI8_U, "xft::lang=ru" }, |
70 | |
70 | |
71 | { CS_ISO8859_5, "xft::lang=ru" }, |
71 | { CS_ISO8859_5, "xft::lang=ru" }, |
72 | { CS_ISO8859_6, "xft::lang=ar" }, |
72 | { CS_ISO8859_6, "xft::lang=ar" }, |
73 | { CS_ISO8859_7, "xft::lang=el" }, |
73 | { CS_ISO8859_7, "xft::lang=el" }, |
74 | { CS_ISO8859_8, "xft::lang=he" }, |
74 | { CS_ISO8859_8, "xft::lang=he" }, |
75 | { CS_ISO8859_9, "xft::lang=tr" }, |
75 | { CS_ISO8859_9, "xft::lang=tr" }, |
… | |
… | |
231 | void |
231 | void |
232 | rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const |
232 | rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const |
233 | { |
233 | { |
234 | dTermDisplay; |
234 | dTermDisplay; |
235 | dTermGC; |
235 | dTermGC; |
236 | |
236 | |
237 | if (color == Color_bg || color == Color_transparent) |
237 | if (color == Color_bg || color == Color_transparent) |
238 | XClearArea (disp, d, x, y, w, h, false); |
238 | XClearArea (disp, d, x, y, w, h, false); |
239 | else if (color >= 0) |
239 | else if (color >= 0) |
240 | { |
240 | { |
241 | #if XFT |
241 | #if XFT |
|
|
242 | bool done = false; |
|
|
243 | #ifdef HAVE_BG_PIXMAP |
|
|
244 | if (term->bgPixmap.pixmap && color >= 0 && term->pix_colors[color].c.color.alpha < 0x0ff00) |
|
|
245 | { |
|
|
246 | Picture dst = XftDrawPicture (d); |
|
|
247 | if (dst != 0) |
|
|
248 | { |
|
|
249 | XClearArea (disp, d, x, y, w, h, false); |
|
|
250 | Picture solid_color_pict = XftDrawSrcPicture (d, &term->pix_colors[color].c); |
|
|
251 | XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, x, y, w, h); |
|
|
252 | done = true; |
|
|
253 | } |
|
|
254 | } |
|
|
255 | #endif |
|
|
256 | if (!done) |
242 | XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); |
257 | XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); |
243 | #else |
258 | #else |
244 | XSetForeground (disp, gc, term->pix_colors[color]); |
259 | XSetForeground (disp, gc, term->pix_colors[color]); |
245 | XFillRectangle (disp, d, gc, x, y, w, h); |
260 | XFillRectangle (disp, d, gc, x, y, w, h); |
246 | #endif |
261 | #endif |
247 | } |
262 | } |
… | |
… | |
390 | |
405 | |
391 | case 1: // rectangle, possibly stippled |
406 | case 1: // rectangle, possibly stippled |
392 | if (a) |
407 | if (a) |
393 | { |
408 | { |
394 | static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 }; |
409 | static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 }; |
395 | |
410 | |
396 | gcv.fill_style = FillStippled; |
411 | gcv.fill_style = FillStippled; |
397 | gcv.stipple = XCreateBitmapFromData (disp, d, bm + a * 2, 2, 2); |
412 | gcv.stipple = XCreateBitmapFromData (disp, d, bm + a * 2, 2, 2); |
398 | gcv.ts_x_origin = x; |
413 | gcv.ts_x_origin = x; |
399 | gcv.ts_y_origin = y; |
414 | gcv.ts_y_origin = y; |
400 | |
415 | |
… | |
… | |
497 | unsigned long value; |
512 | unsigned long value; |
498 | |
513 | |
499 | if (XGetFontProperty (f, property, &value)) |
514 | if (XGetFontProperty (f, property, &value)) |
500 | return XGetAtomName (term->dpy, value); |
515 | return XGetAtomName (term->dpy, value); |
501 | else |
516 | else |
502 | return rxvt_strdup (repl); |
517 | return repl ? strdup (repl) : 0; |
503 | } |
518 | } |
504 | |
519 | |
505 | rxvt_fontprop |
520 | rxvt_fontprop |
506 | rxvt_font_x11::properties () |
521 | rxvt_font_x11::properties () |
507 | { |
522 | { |
… | |
… | |
659 | f = 0; |
674 | f = 0; |
660 | } |
675 | } |
661 | |
676 | |
662 | if (prop.weight != rxvt_fontprop::unset) |
677 | if (prop.weight != rxvt_fontprop::unset) |
663 | { |
678 | { |
664 | replace_field (fname, name, 2, 0, |
679 | replace_field (fname, name, 2, 0, |
665 | prop.weight < rxvt_fontprop::bold |
680 | prop.weight < rxvt_fontprop::bold |
666 | ? "medium" : "bold"); |
681 | ? "medium" : "bold"); |
667 | set_name (strdup (fname)); |
682 | set_name (strdup (fname)); |
668 | } |
683 | } |
669 | |
684 | |
… | |
… | |
813 | int N = f->max_char_or_byte2 - f->min_char_or_byte2; |
828 | int N = f->max_char_or_byte2 - f->min_char_or_byte2; |
814 | |
829 | |
815 | if (encm) |
830 | if (encm) |
816 | N += (f->max_byte1 - f->min_byte1) |
831 | N += (f->max_byte1 - f->min_byte1) |
817 | * (f->max_char_or_byte2 - f->min_char_or_byte2 + 1); |
832 | * (f->max_char_or_byte2 - f->min_char_or_byte2 + 1); |
818 | |
833 | |
819 | while (N) |
834 | while (N) |
820 | { |
835 | { |
821 | if (f->per_char[N].width > width) |
836 | if (f->per_char[N].width > width) |
822 | width = f->per_char[N].width; |
837 | width = f->per_char[N].width; |
823 | |
838 | |
… | |
… | |
975 | else |
990 | else |
976 | { |
991 | { |
977 | clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); |
992 | clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); |
978 | |
993 | |
979 | XChangeGC (disp, gc, GCForeground | GCFont, &v); |
994 | XChangeGC (disp, gc, GCForeground | GCFont, &v); |
980 | |
995 | |
981 | if (slow) |
996 | if (slow) |
982 | { |
997 | { |
983 | do |
998 | do |
984 | { |
999 | { |
985 | if (xc->byte1 || xc->byte2) |
1000 | if (xc->byte1 || xc->byte2) |
… | |
… | |
1007 | else |
1022 | else |
1008 | { |
1023 | { |
1009 | clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); |
1024 | clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); |
1010 | |
1025 | |
1011 | XChangeGC (disp, gc, GCForeground | GCFont, &v); |
1026 | XChangeGC (disp, gc, GCForeground | GCFont, &v); |
1012 | |
1027 | |
1013 | if (slow) |
1028 | if (slow) |
1014 | { |
1029 | { |
1015 | do |
1030 | do |
1016 | { |
1031 | { |
1017 | if (*xc) |
1032 | if (*xc) |
… | |
… | |
1043 | |
1058 | |
1044 | void draw (rxvt_drawable &d, int x, int y, |
1059 | void draw (rxvt_drawable &d, int x, int y, |
1045 | const text_t *text, int len, |
1060 | const text_t *text, int len, |
1046 | int fg, int bg); |
1061 | int fg, int bg); |
1047 | |
1062 | |
1048 | bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &carefull) const; |
1063 | bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const; |
1049 | |
1064 | |
1050 | protected: |
1065 | protected: |
1051 | XftFont *f; |
1066 | XftFont *f; |
1052 | }; |
1067 | }; |
1053 | |
1068 | |
… | |
… | |
1272 | dTermGC; |
1287 | dTermGC; |
1273 | |
1288 | |
1274 | int w = term->fwidth * len; |
1289 | int w = term->fwidth * len; |
1275 | int h = term->fheight; |
1290 | int h = term->fheight; |
1276 | |
1291 | |
1277 | bool buffered = bg >= 0 // we don't use a transparent bg |
1292 | /* TODO: this logic needs some more thinking, since we no longer do pseudo-transparency. |
|
|
1293 | * Maybe make buffering into a resource flag? Compile time option doesn't seems like a |
|
|
1294 | * good idea from the perspective of packaging for wide variety of user configs. |
|
|
1295 | */ |
|
|
1296 | bool buffered = true |
1278 | #ifndef FORCE_UNBUFFERED_XFT |
1297 | #ifdef FORCE_UNBUFFERED_XFT |
1279 | # ifdef ENABLE_TRANSPARENCY |
1298 | && bg >= 0 |
1280 | || !term->am_transparent // we aren't transparent |
|
|
1281 | # endif |
|
|
1282 | #endif |
1299 | #endif |
1283 | ; |
1300 | ; |
1284 | |
|
|
1285 | // cut trailing spaces |
1301 | // cut trailing spaces |
1286 | while (len && text [len - 1] == ' ') |
1302 | while (len && text [len - 1] == ' ') |
1287 | len--; |
1303 | len--; |
1288 | |
1304 | |
1289 | int x_ = buffered ? 0 : x; |
1305 | int x_ = buffered ? 0 : x; |
… | |
… | |
1294 | int cwidth = term->fwidth; |
1310 | int cwidth = term->fwidth; |
1295 | FcChar32 fc = *text++; len--; |
1311 | FcChar32 fc = *text++; len--; |
1296 | |
1312 | |
1297 | while (len && *text == NOCHAR) |
1313 | while (len && *text == NOCHAR) |
1298 | text++, len--, cwidth += term->fwidth; |
1314 | text++, len--, cwidth += term->fwidth; |
1299 | |
1315 | |
1300 | if (fc != ' ') // skip spaces |
1316 | if (fc != ' ') // skip spaces |
1301 | { |
1317 | { |
1302 | FT_UInt glyph = XftCharIndex (disp, f, fc); |
1318 | FT_UInt glyph = XftCharIndex (disp, f, fc); |
1303 | XftGlyphExtents (disp, f, &glyph, 1, &extents); |
1319 | XftGlyphExtents (disp, f, &glyph, 1, &extents); |
1304 | |
1320 | |
… | |
… | |
1315 | x_ += cwidth; |
1331 | x_ += cwidth; |
1316 | } |
1332 | } |
1317 | |
1333 | |
1318 | if (buffered) |
1334 | if (buffered) |
1319 | { |
1335 | { |
|
|
1336 | bool back_rendered = false; |
1320 | if (ep != enc) |
1337 | if (ep != enc) |
1321 | { |
1338 | { |
1322 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
1339 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
1323 | |
1340 | |
1324 | if (0) |
1341 | #ifdef HAVE_BG_PIXMAP |
1325 | ; |
|
|
1326 | #if defined(ENABLE_TRANSPARENCY) || defined(XPM_BACKGROUND) |
|
|
1327 | else if (bg < 0 && term->bgPixmap.pixmap) |
1342 | if (term->bgPixmap.pixmap) |
1328 | { |
1343 | { |
1329 | if (term->bgPixmap.pmap_width >= x + term->window_vt_x+w |
1344 | Picture dst = 0; |
1330 | && term->bgPixmap.pmap_height >= y + term->window_vt_y+h) |
1345 | |
|
|
1346 | if (bg >= 0 && term->pix_colors[bg].c.color.alpha < 0x0ff00) |
|
|
1347 | dst = XftDrawPicture (d2); |
|
|
1348 | |
|
|
1349 | if (bg < 0 || dst != 0) |
1331 | { |
1350 | { |
|
|
1351 | int src_x = x, src_y = y ; |
|
|
1352 | |
|
|
1353 | if (term->bgPixmap.is_parentOrigin ()) |
|
|
1354 | { |
|
|
1355 | src_x += term->window_vt_x; |
|
|
1356 | src_y += term->window_vt_y; |
|
|
1357 | } |
|
|
1358 | |
|
|
1359 | if (term->bgPixmap.pmap_width >= src_x+w |
|
|
1360 | && term->bgPixmap.pmap_height >= src_y+h) |
|
|
1361 | { |
1332 | XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, |
1362 | XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, |
1333 | x + term->window_vt_x, y + term->window_vt_y, |
|
|
1334 | w, h, 0, 0); |
1363 | src_x, src_y, w, h, 0, 0); |
1335 | } |
1364 | } |
1336 | else |
1365 | else |
1337 | { |
1366 | { |
1338 | XGCValues gcv; |
1367 | XGCValues gcv; |
1339 | |
1368 | |
1340 | gcv.fill_style = FillTiled; |
1369 | gcv.fill_style = FillTiled; |
1341 | gcv.tile = term->bgPixmap.pixmap; |
1370 | gcv.tile = term->bgPixmap.pixmap; |
1342 | gcv.ts_x_origin = -x; |
1371 | gcv.ts_x_origin = -src_x; |
1343 | gcv.ts_y_origin = -y; |
1372 | gcv.ts_y_origin = -src_y; |
1344 | |
1373 | |
1345 | #if 0 |
|
|
1346 | GC gc2 = XCreateGC (disp, d2, |
|
|
1347 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
|
|
1348 | &gcv); |
|
|
1349 | #endif |
|
|
1350 | XChangeGC (disp, gc, |
1374 | XChangeGC (disp, gc, |
1351 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
1375 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
1352 | &gcv); |
1376 | &gcv); |
1353 | |
1377 | |
1354 | XFillRectangle (disp, d2, gc/*gc2*/, 0, 0, w, h); |
1378 | XFillRectangle (disp, d2, gc, 0, 0, w, h); |
1355 | |
1379 | |
1356 | gcv.fill_style = FillSolid; |
1380 | gcv.fill_style = FillSolid; |
1357 | XChangeGC (disp, gc, GCFillStyle, &gcv); |
1381 | XChangeGC (disp, gc, GCFillStyle, &gcv); |
1358 | /* XFreeGC (disp, gc2); */ |
1382 | } |
1359 | |
1383 | |
|
|
1384 | if (bg >= 0) |
|
|
1385 | { |
|
|
1386 | Picture solid_color_pict = XftDrawSrcPicture (d2, &term->pix_colors[bg].c); |
|
|
1387 | XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, 0, 0, w, h); |
|
|
1388 | } |
|
|
1389 | |
|
|
1390 | back_rendered = true; |
1360 | } |
1391 | } |
1361 | } |
1392 | } |
1362 | #endif |
1393 | #endif |
1363 | else |
1394 | |
|
|
1395 | if (bg >= 0 && !back_rendered) |
1364 | XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h); |
1396 | XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h); |
1365 | |
1397 | |
1366 | XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); |
1398 | XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); |
1367 | XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); |
1399 | XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); |
1368 | } |
1400 | } |
… | |
… | |
1413 | |
1445 | |
1414 | rxvt_font * |
1446 | rxvt_font * |
1415 | rxvt_fontset::new_font (const char *name, codeset cs) |
1447 | rxvt_fontset::new_font (const char *name, codeset cs) |
1416 | { |
1448 | { |
1417 | rxvt_font *f; |
1449 | rxvt_font *f; |
1418 | |
1450 | |
1419 | if (!name || !*name) |
1451 | if (!name || !*name) |
1420 | { |
1452 | { |
1421 | name = ""; |
1453 | name = ""; |
1422 | f = new rxvt_font_default (this); |
1454 | f = new rxvt_font_default (this); |
1423 | } |
1455 | } |
… | |
… | |
1642 | if (find_font (font) < 0) |
1674 | if (find_font (font) < 0) |
1643 | { |
1675 | { |
1644 | char fontname[4096]; |
1676 | char fontname[4096]; |
1645 | sprintf (fontname, "xft:%-.4090s", font); |
1677 | sprintf (fontname, "xft:%-.4090s", font); |
1646 | |
1678 | |
1647 | fonts.push_back (new_font (fontname, CS_UNICODE)); |
1679 | fonts.push_back (new_font (fontname, CS_UNICODE)); |
1648 | } |
1680 | } |
1649 | |
1681 | |
1650 | free (font); |
1682 | free (font); |
1651 | } |
1683 | } |
1652 | #endif |
1684 | #endif |