1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-05-09 21:52:10 -05:00

GTK: clear target Pixmap for X font rendering with Cairo

CreatePixmap returns a Pixmap with undefined contents, and ImageText16
doesn't quite erase the whole rectangle covered by the text (and hence
the whole Pixmap.  So to be on the safe side we should make sure to
erase the entire Pixmap before drawing the text.

Conveniently, ImageText16 ignores the function specified in the GC, so
we can set that to GXclear and avoid needing to change the GC
thereafter.
This commit is contained in:
Ben Harris 2025-04-26 22:14:49 +01:00
parent c3e2bf980f
commit 10fdd29fea

View File

@ -643,11 +643,13 @@ static void x11font_cairo_init_gc(x11font_individual *xfi, Display *disp,
if (xfi->gc == None) {
XGCValues gcvals;
gcvals.function = GXclear;
gcvals.foreground = 1;
gcvals.background = 0;
gcvals.font = xfi->xfs->fid;
xfi->gc = XCreateGC(disp, pixmap,
GCForeground | GCBackground | GCFont, &gcvals);
GCFunction | GCForeground | GCBackground | GCFont,
&gcvals);
}
}
@ -670,6 +672,7 @@ static void x11font_cairo_draw_16(
pixmap = XCreatePixmap(disp, GDK_DRAWABLE_XID(widgetwin),
pixwidth, pixheight, 1);
x11font_cairo_init_gc(xfi, disp, pixmap);
XFillRectangle(disp, pixmap, xfi->gc, 0, 0, pixwidth, pixheight);
XDrawImageString16(disp, pixmap, xfi->gc,
-bounds.lbearing, bounds.ascent,
string+start, length);
@ -709,6 +712,7 @@ static void x11font_cairo_draw_8(
pixmap = XCreatePixmap(disp, GDK_DRAWABLE_XID(widgetwin),
pixwidth, pixheight, 1);
x11font_cairo_init_gc(xfi, disp, pixmap);
XFillRectangle(disp, pixmap, xfi->gc, 0, 0, pixwidth, pixheight);
XDrawImageString(disp, pixmap, xfi->gc,
-bounds.lbearing, bounds.ascent,
string+start, length);