--- rxvt-unicode/src/rxvtfont.C 2011/07/29 09:41:22 1.182 +++ rxvt-unicode/src/rxvtfont.C 2021/06/16 22:51:55 1.198 @@ -6,7 +6,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -24,7 +24,7 @@ #include "rxvtutil.h" #include "rxvtfont.h" -#include +#include #include @@ -241,8 +241,8 @@ #if XFT Picture dst; -# ifdef HAVE_BG_PIXMAP - if (term->bg_pixmap +# ifdef HAVE_IMG + if (term->bg_img && !term->pix_colors[color].is_opaque () && ((dst = XftDrawPicture (d)))) { @@ -476,6 +476,15 @@ case NOCHAR: break; + /* + * If the base font does not support variation selectors, treat them as ZWC. + * a point could be made to do this for all wcwidth == 0 characters, but I + * decided against that until more data is available. + */ + case 0xfe00: case 0xfe01: case 0xfe02: case 0xfe03: case 0xfe04: case 0xfe05: case 0xfe06: case 0xfe07: + case 0xfe08: case 0xfe09: case 0xfe0a: case 0xfe0b: case 0xfe0c: case 0xfe0d: case 0xfe0e: case 0xfe0f: + break; + default: XDrawRectangle (disp, d, gc, x + 2, y + 2, fwidth - 4, term->fheight - 4); @@ -818,10 +827,10 @@ // this loop only iterates when the guessed font-size is too small for (;;) { - font_weight *best = fonts + count - 1; + font_weight *best = fonts; - for (font_weight *w = fonts; w < best; w++) - if (w->diff <= best->diff) + for (font_weight *w = fonts + 1; w < fonts + count; w++) + if (w->diff < best->diff) best = w; if (!best->name @@ -936,7 +945,8 @@ if (!has_char (*t, &prop, careful)) continue; - XChar2b ch = { *t >> 8, *t }; + // the casts are needed in C++11 (see 8.5.1) + XChar2b ch = { (unsigned char)(*t >> 8), (unsigned char)*t }; XCharStruct g; int dir_ret, asc_ret, des_ret; @@ -1046,7 +1056,8 @@ bool slow = this->slow || width != term->fwidth - || height != term->fheight; + || height != term->fheight + || ascent != f->ascent; int base = ascent; // sorry, incorrect: term->fbase; @@ -1410,10 +1421,10 @@ { rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); -#ifdef HAVE_BG_PIXMAP +#ifdef HAVE_IMG Picture dst = 0; // the only assignment is done conditionally in the following if condition - if (term->bg_pixmap + if (term->bg_img && (bg == Color_transparent || bg == Color_bg || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) { @@ -1425,10 +1436,10 @@ src_y += term->window_vt_y; } - if (term->bg_pmap_width >= src_x + w - && term->bg_pmap_height >= src_y + h) + if (term->bg_img->w >= src_x + w + && term->bg_img->h >= src_y + h) { - XCopyArea (disp, term->bg_pixmap, d2, gc, + XCopyArea (disp, term->bg_img->pm, d2, gc, src_x, src_y, w, h, 0, 0); } else @@ -1436,7 +1447,7 @@ XGCValues gcv; gcv.fill_style = FillTiled; - gcv.tile = term->bg_pixmap; + gcv.tile = term->bg_img->pm; gcv.ts_x_origin = -src_x; gcv.ts_y_origin = -src_y; @@ -1606,7 +1617,7 @@ rxvt_warn ("unknown parameter '%s' in font specification, skipping.\n", spec); desc++; - while (*desc <= ' ') desc++; + while (*desc <= ' ' && *desc) desc++; } end = strchr (desc, ','); @@ -1734,6 +1745,7 @@ // TODO: this is a real resource hog, xft takes ages(?) #if XFT && USE_SLOW_LOOKUP // grab the first xft font that seems suitable + // TOOD: should go first for cellchar (spacing 110) then mono, then else FcPattern *p = FcPatternCreate (); FcCharSet *s = FcCharSetCreate (); @@ -1787,7 +1799,7 @@ if (!fmap[hi]) { - fmap[hi] = (pagemap *)new pagemap; + fmap[hi] = new pagemap; memset (fmap[hi], 0xff, sizeof (pagemap)); }