summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixRFont.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-06-12 08:29:27 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-06-12 08:29:27 (GMT)
commitfde697af64aae8450b540fb7eeb4f0f19aa3f005 (patch)
tree152cc41513346198a20a352370b2d8b0fe9dd1d0 /unix/tkUnixRFont.c
parent725e61cc4033c4fd2cccb831bac3c997fa61e712 (diff)
downloadtk-fde697af64aae8450b540fb7eeb4f0f19aa3f005.zip
tk-fde697af64aae8450b540fb7eeb4f0f19aa3f005.tar.gz
tk-fde697af64aae8450b540fb7eeb4f0f19aa3f005.tar.bz2
Fix text clipping when working with the Xft-based renderer.
Diffstat (limited to 'unix/tkUnixRFont.c')
-rw-r--r--unix/tkUnixRFont.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c
index 134bb45..deecceb 100644
--- a/unix/tkUnixRFont.c
+++ b/unix/tkUnixRFont.c
@@ -33,6 +33,16 @@ typedef struct {
XftDraw *ftDraw;
XftColor color;
} UnixFtFont;
+
+/*
+ * Used to describe the current clipping box. Can't be passed normally because
+ * the information isn't retrievable from the GC.
+ */
+
+typedef struct ThreadSpecificData {
+ Region clipRegion; /* The clipping region, or None. */
+} ThreadSpecificData;
+static Tcl_ThreadDataKey dataKey;
/*
* Package initialization:
@@ -712,6 +722,8 @@ Tk_DrawChars(
int clen, nspec, xStart = x;
XftGlyphFontSpec specs[NUM_SPEC];
XGlyphInfo metrics;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (fontPtr->ftDraw == 0) {
#if DEBUG_FONTSEL
@@ -738,6 +750,9 @@ Tk_DrawChars(
fontPtr->color.color.alpha = 0xffff;
fontPtr->color.pixel = values.foreground;
}
+ if (tsdPtr->clipRegion != None) {
+ XftDrawSetClip(fontPtr->ftDraw, tsdPtr->clipRegion);
+ }
nspec = 0;
while (numBytes > 0 && x <= maxCoord && y <= maxCoord) {
XftFont *ftFont;
@@ -775,6 +790,9 @@ Tk_DrawChars(
if (nspec) {
XftDrawGlyphFontSpec(fontPtr->ftDraw, &fontPtr->color, specs, nspec);
}
+ if (tsdPtr->clipRegion != None) {
+ XftDrawSetClip(fontPtr->ftDraw, None);
+ }
doUnderlineStrikeout:
if (fontPtr->font.fa.underline != 0) {
@@ -789,3 +807,13 @@ Tk_DrawChars(
(unsigned) fontPtr->font.underlineHeight);
}
}
+
+void
+TkUnixSetXftClipRegion(
+ Region clipRegion) /* The clipping region to install. */
+{
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+
+ tsdPtr->clipRegion = clipRegion;
+}