… | |
… | |
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 |
… | |
… | |
250 | Picture solid_color_pict = XftDrawSrcPicture (d, &term->pix_colors[color].c); |
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); |
251 | XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, x, y, w, h); |
252 | done = true; |
252 | done = true; |
253 | } |
253 | } |
254 | } |
254 | } |
255 | #endif |
255 | #endif |
256 | if (!done) |
256 | if (!done) |
257 | XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); |
257 | XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); |
258 | #else |
258 | #else |
259 | XSetForeground (disp, gc, term->pix_colors[color]); |
259 | XSetForeground (disp, gc, term->pix_colors[color]); |
260 | XFillRectangle (disp, d, gc, x, y, w, h); |
260 | XFillRectangle (disp, d, gc, x, y, w, h); |
… | |
… | |
405 | |
405 | |
406 | case 1: // rectangle, possibly stippled |
406 | case 1: // rectangle, possibly stippled |
407 | if (a) |
407 | if (a) |
408 | { |
408 | { |
409 | static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 }; |
409 | static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 }; |
410 | |
410 | |
411 | gcv.fill_style = FillStippled; |
411 | gcv.fill_style = FillStippled; |
412 | gcv.stipple = XCreateBitmapFromData (disp, d, bm + a * 2, 2, 2); |
412 | gcv.stipple = XCreateBitmapFromData (disp, d, bm + a * 2, 2, 2); |
413 | gcv.ts_x_origin = x; |
413 | gcv.ts_x_origin = x; |
414 | gcv.ts_y_origin = y; |
414 | gcv.ts_y_origin = y; |
415 | |
415 | |
… | |
… | |
512 | unsigned long value; |
512 | unsigned long value; |
513 | |
513 | |
514 | if (XGetFontProperty (f, property, &value)) |
514 | if (XGetFontProperty (f, property, &value)) |
515 | return XGetAtomName (term->dpy, value); |
515 | return XGetAtomName (term->dpy, value); |
516 | else |
516 | else |
517 | return rxvt_strdup (repl); |
517 | return repl ? strdup (repl) : 0; |
518 | } |
518 | } |
519 | |
519 | |
520 | rxvt_fontprop |
520 | rxvt_fontprop |
521 | rxvt_font_x11::properties () |
521 | rxvt_font_x11::properties () |
522 | { |
522 | { |
… | |
… | |
674 | f = 0; |
674 | f = 0; |
675 | } |
675 | } |
676 | |
676 | |
677 | if (prop.weight != rxvt_fontprop::unset) |
677 | if (prop.weight != rxvt_fontprop::unset) |
678 | { |
678 | { |
679 | replace_field (fname, name, 2, 0, |
679 | replace_field (fname, name, 2, 0, |
680 | prop.weight < rxvt_fontprop::bold |
680 | prop.weight < rxvt_fontprop::bold |
681 | ? "medium" : "bold"); |
681 | ? "medium" : "bold"); |
682 | set_name (strdup (fname)); |
682 | set_name (strdup (fname)); |
683 | } |
683 | } |
684 | |
684 | |
… | |
… | |
828 | 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; |
829 | |
829 | |
830 | if (encm) |
830 | if (encm) |
831 | N += (f->max_byte1 - f->min_byte1) |
831 | N += (f->max_byte1 - f->min_byte1) |
832 | * (f->max_char_or_byte2 - f->min_char_or_byte2 + 1); |
832 | * (f->max_char_or_byte2 - f->min_char_or_byte2 + 1); |
833 | |
833 | |
834 | while (N) |
834 | while (N) |
835 | { |
835 | { |
836 | if (f->per_char[N].width > width) |
836 | if (f->per_char[N].width > width) |
837 | width = f->per_char[N].width; |
837 | width = f->per_char[N].width; |
838 | |
838 | |
… | |
… | |
990 | else |
990 | else |
991 | { |
991 | { |
992 | clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); |
992 | clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); |
993 | |
993 | |
994 | XChangeGC (disp, gc, GCForeground | GCFont, &v); |
994 | XChangeGC (disp, gc, GCForeground | GCFont, &v); |
995 | |
995 | |
996 | if (slow) |
996 | if (slow) |
997 | { |
997 | { |
998 | do |
998 | do |
999 | { |
999 | { |
1000 | if (xc->byte1 || xc->byte2) |
1000 | if (xc->byte1 || xc->byte2) |
… | |
… | |
1022 | else |
1022 | else |
1023 | { |
1023 | { |
1024 | clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); |
1024 | clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); |
1025 | |
1025 | |
1026 | XChangeGC (disp, gc, GCForeground | GCFont, &v); |
1026 | XChangeGC (disp, gc, GCForeground | GCFont, &v); |
1027 | |
1027 | |
1028 | if (slow) |
1028 | if (slow) |
1029 | { |
1029 | { |
1030 | do |
1030 | do |
1031 | { |
1031 | { |
1032 | if (*xc) |
1032 | if (*xc) |
… | |
… | |
1058 | |
1058 | |
1059 | void draw (rxvt_drawable &d, int x, int y, |
1059 | void draw (rxvt_drawable &d, int x, int y, |
1060 | const text_t *text, int len, |
1060 | const text_t *text, int len, |
1061 | int fg, int bg); |
1061 | int fg, int bg); |
1062 | |
1062 | |
1063 | 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; |
1064 | |
1064 | |
1065 | protected: |
1065 | protected: |
1066 | XftFont *f; |
1066 | XftFont *f; |
1067 | }; |
1067 | }; |
1068 | |
1068 | |
… | |
… | |
1288 | |
1288 | |
1289 | int w = term->fwidth * len; |
1289 | int w = term->fwidth * len; |
1290 | int h = term->fheight; |
1290 | int h = term->fheight; |
1291 | |
1291 | |
1292 | /* TODO: this logic needs some more thinking, since we no longer do pseudo-transparency. |
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 |
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. |
1294 | * good idea from the perspective of packaging for wide variety of user configs. |
1295 | */ |
1295 | */ |
1296 | bool buffered = true |
1296 | bool buffered = true |
1297 | #ifdef FORCE_UNBUFFERED_XFT |
1297 | #ifdef FORCE_UNBUFFERED_XFT |
1298 | && bg >= 0 |
1298 | && bg >= 0 |
… | |
… | |
1310 | int cwidth = term->fwidth; |
1310 | int cwidth = term->fwidth; |
1311 | FcChar32 fc = *text++; len--; |
1311 | FcChar32 fc = *text++; len--; |
1312 | |
1312 | |
1313 | while (len && *text == NOCHAR) |
1313 | while (len && *text == NOCHAR) |
1314 | text++, len--, cwidth += term->fwidth; |
1314 | text++, len--, cwidth += term->fwidth; |
1315 | |
1315 | |
1316 | if (fc != ' ') // skip spaces |
1316 | if (fc != ' ') // skip spaces |
1317 | { |
1317 | { |
1318 | FT_UInt glyph = XftCharIndex (disp, f, fc); |
1318 | FT_UInt glyph = XftCharIndex (disp, f, fc); |
1319 | XftGlyphExtents (disp, f, &glyph, 1, &extents); |
1319 | XftGlyphExtents (disp, f, &glyph, 1, &extents); |
1320 | |
1320 | |
… | |
… | |
1343 | { |
1343 | { |
1344 | Picture dst = 0; |
1344 | Picture dst = 0; |
1345 | |
1345 | |
1346 | if (bg >= 0 && term->pix_colors[bg].c.color.alpha < 0x0ff00) |
1346 | if (bg >= 0 && term->pix_colors[bg].c.color.alpha < 0x0ff00) |
1347 | dst = XftDrawPicture (d2); |
1347 | dst = XftDrawPicture (d2); |
1348 | |
1348 | |
1349 | if (bg < 0 || dst != 0) |
1349 | if (bg < 0 || dst != 0) |
1350 | { |
1350 | { |
1351 | int src_x = x, src_y = y ; |
1351 | int src_x = x, src_y = y ; |
1352 | |
1352 | |
1353 | if (term->bgPixmap.is_parentOrigin ()) |
1353 | if (term->bgPixmap.is_parentOrigin ()) |
1354 | { |
1354 | { |
1355 | src_x += term->window_vt_x; |
1355 | src_x += term->window_vt_x; |
1356 | src_y += term->window_vt_y; |
1356 | src_y += term->window_vt_y; |
1357 | } |
1357 | } |
1358 | |
1358 | |
1359 | if (term->bgPixmap.pmap_width >= src_x+w |
1359 | if (term->bgPixmap.pmap_width >= src_x+w |
1360 | && term->bgPixmap.pmap_height >= src_y+h) |
1360 | && term->bgPixmap.pmap_height >= src_y+h) |
1361 | { |
1361 | { |
1362 | XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, |
1362 | XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, |
1363 | src_x, src_y, w, h, 0, 0); |
1363 | src_x, src_y, w, h, 0, 0); |
… | |
… | |
1445 | |
1445 | |
1446 | rxvt_font * |
1446 | rxvt_font * |
1447 | rxvt_fontset::new_font (const char *name, codeset cs) |
1447 | rxvt_fontset::new_font (const char *name, codeset cs) |
1448 | { |
1448 | { |
1449 | rxvt_font *f; |
1449 | rxvt_font *f; |
1450 | |
1450 | |
1451 | if (!name || !*name) |
1451 | if (!name || !*name) |
1452 | { |
1452 | { |
1453 | name = ""; |
1453 | name = ""; |
1454 | f = new rxvt_font_default (this); |
1454 | f = new rxvt_font_default (this); |
1455 | } |
1455 | } |
… | |
… | |
1674 | if (find_font (font) < 0) |
1674 | if (find_font (font) < 0) |
1675 | { |
1675 | { |
1676 | char fontname[4096]; |
1676 | char fontname[4096]; |
1677 | sprintf (fontname, "xft:%-.4090s", font); |
1677 | sprintf (fontname, "xft:%-.4090s", font); |
1678 | |
1678 | |
1679 | fonts.push_back (new_font (fontname, CS_UNICODE)); |
1679 | fonts.push_back (new_font (fontname, CS_UNICODE)); |
1680 | } |
1680 | } |
1681 | |
1681 | |
1682 | free (font); |
1682 | free (font); |
1683 | } |
1683 | } |
1684 | #endif |
1684 | #endif |