Attachment "canvas_aliasing.patch" to
ticket [968725ff]
added by
mdejong
2004-06-08 15:48:57.
Index: generic/tkCanvText.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkCanvText.c,v
retrieving revision 1.15
diff -u -r1.15 tkCanvText.c
--- generic/tkCanvText.c 9 Feb 2003 07:48:22 -0000 1.15
+++ generic/tkCanvText.c 8 Jun 2004 07:40:33 -0000
@@ -853,21 +853,30 @@
/*
- * Display the text in two pieces: draw the entire text item, then
- * draw the selected text on top of it. The selected text then
- * will only need to be drawn if it has different attributes (such
- * as foreground color) than regular text.
+ * If there is no selected text or the selected text foreground
+ * is the same as the regular text foreground, then draw one
+ * text string. If there is selected text and the foregrounds
+ * differ, draw the regular text up to the selection, draw
+ * the selection, then draw the rest of the regular text.
+ * Drawing the regular text and then the selected text over
+ * it would causes problems with anti-aliased text because the
+ * two anti-aliasing colors would blend together.
*/
Tk_CanvasDrawableCoords(canvas, (double) textPtr->leftEdge,
(double) textPtr->header.y1, &drawableX, &drawableY);
- Tk_DrawTextLayout(display, drawable, textPtr->gc, textPtr->textLayout,
- drawableX, drawableY, 0, -1);
if ((selFirstChar >= 0) && (textPtr->selTextGC != textPtr->gc)) {
+ Tk_DrawTextLayout(display, drawable, textPtr->gc, textPtr->textLayout,
+ drawableX, drawableY, 0, selFirstChar);
Tk_DrawTextLayout(display, drawable, textPtr->selTextGC,
textPtr->textLayout, drawableX, drawableY, selFirstChar,
selLastChar + 1);
+ Tk_DrawTextLayout(display, drawable, textPtr->gc, textPtr->textLayout,
+ drawableX, drawableY, selLastChar + 1, -1);
+ } else {
+ Tk_DrawTextLayout(display, drawable, textPtr->gc, textPtr->textLayout,
+ drawableX, drawableY, 0, -1);
}
if (stipple != None) {