Tk Source Code

View Ticket
Login
2026-11-14
16:47 • Ticket [220796ff] -stipple option for canvas text item disrupts positioning, b status still Closed with 5 other changes artifact: 0b293cb9 user: jan.nijtmans
16:45
Fix CFG_FONTSYSTEM in combination withHAVE_BIDI. see [220796] (Thanks, Serhiy) check-in: 03c66d84 user: jan.nijtmans tags: trunk, main
09:41 • Ticket [220796ff] -stipple option for canvas text item disrupts positioning, b status still Closed with 3 other changes artifact: 236671e5 user: serhiy.storchaka
2026-11-02
16:51 • Closed ticket [220796ff]. artifact: ad9b4550 user: nemethi
15:00
Fix [220796]: -stipple option for canvas text item disrupts positioning check-in: 89594d45 user: csaba tags: core-8-6-branch
14:45
Fix [220796]: -stipple option for canvas text item disrupts positioning check-in: 29e1638b user: csaba tags: core-9-0-branch
13:31 • Ticket [220796ff] -stipple option for canvas text item disrupts positioning, b status still Open with 3 other changes artifact: 8e407e0c user: serhiy.storchaka
13:16
Fix [220796ffff] for 9.0: -stipple option for canvas text item disrupts positioning on Windows. Stippled text was not drawn, and angled stippled text was misplaced: the text was drawn into the destination instead of the memory DC. Text with a stipple is now drawn into a memory DC and copied through the stipple pattern, as in 9.1 [99b9c92a0a]. Test canvText-21.1. closed check-in: 4fd43983 user: serhiy.storchaka tags: win-text-stipple-9.0
12:42 • Ticket [220796ff] -stipple option for canvas text item disrupts positioning, b status still Open with 3 other changes artifact: 808066c4 user: kevin_walzer
12:33 • Ticket [220796ff]: 3 changes artifact: 95ee7258 user: jan.nijtmans
10:44 • Ticket [220796ff]: 4 changes artifact: 2f45665c user: nemethi
2026-10-27
20:34 • Ticket [220796ff]: 3 changes artifact: a5d25f46 user: jan.nijtmans
18:02 • Ticket [220796ff]: 3 changes artifact: e0917a92 user: serhiy.storchaka
17:56
canvText-21.1 (bug [220796]): the text, given in points, did not fit in the 200x60 canvas at a high screen resolution, so countPixels read outside of the canvas ("coordinates 9,60 are outside window"). Use a 200x200 canvas and a single M, which also makes counting its pixels fast, and remove the knownBug constraint. Check the two bounds of the ratio separately. check-in: 5b8a1053 user: serhiy.storchaka tags: trunk, main
16:47
Fix [220796]: -stipple option for canvas text item disrupts positioning. Testcase not complete yet check-in: fde93bd2 user: jan.nijtmans tags: trunk, main
16:44 • Ticket [220796ff] -stipple option for canvas text item disrupts positioning, b status still Open with 7 other changes artifact: 65e8b060 user: jan.nijtmans
2026-10-22
22:49 • Ticket [220796ff]: 4 changes artifact: 69fe4d28 user: serhiy.storchaka
2026-09-22
07:48 • Ticket [220796ff]: 4 changes artifact: b50b65fa user: serhiy.storchaka
07:44
Fix [220796]: -stipple option for canvas text item disrupts positioning on Windows

Text was drawn without the stipple, and angled text with the stipple was misplaced. Text with a stipple is now drawn into a memory DC and copied through the stipple pattern, in the same way as other stippled objects, for both the Uniscribe and the angled text path. check-in: 99b9c92a user: serhiy.storchaka tags: win-text-stipple

07:35
Fix [220796]: -stipple option for canvas text item disrupts positioning on Windows

Text was drawn without the stipple, and angled text with the stipple was misplaced. Text with a stipple is now drawn into a memory DC and copied through the stipple pattern, in the same way as other stippled objects, for both the Uniscribe and the angled text path. closed check-in: 390febee user: serhiy.storchaka tags: mistake

2007-06-04
18:56 • Ticket [220796ff] -stipple option for canvas text item disrupts positioning, b status still Open with 1 other change artifact: bd51878b user: das
2004-03-28
10:32 • Ticket [220796ff]: 4 changes artifact: efa3951b user: nobody
2003-11-13
06:48 • Ticket [220796ff]: 1 change artifact: 0eef0a53 user: dgp
06:48 • Ticket [220796ff]: 1 change artifact: 1e763180 user: dgp
2001-03-24
03:29 • Ticket [220796ff]: 1 change artifact: 5ec1449e user: dgp
2000-11-01
00:54 • New ticket [220796ff]. artifact: 6a6449b9 user: welch

Ticket UUID: 220796
Title: -stipple option for canvas text item disrupts positioning, b
Type: Bug Version: 8.1b2, 8.6.18, 9.0.5, 9.1.0
Submitter: welch Created on: 2000-11-01 00:54:14
Subsystem: 05. Canvas Items Assigned To: aku
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-11-14 16:47:38
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2026-11-14 16:47:38
Description:
OriginalBugID: 1522 Bug
Version: 8.1b2
SubmitDate: '1999-03-18'
LastModified: '2000-04-03'
Severity: SER
Status: Assigned
Submitter: pat
ChangedBy: ericm
OS: Windows 95
OSVersion: OSR2, US English
Machine: X86


Name:
Bill Schongar

Extensions:
None

CustomShell:
None

ReproducibleScript:
    pack [canvas .c]
    .c create text 10 10 "Foo" -tags a
    .c create text 90 10 "Foo" -stipple gray12 -tags b
    eval .c create rectangle [.c bbox b] -fill green
    



ObservedBehavior:
    1) The text is not stippled, it appears in a "selected" state
    2) The text with the '-stipple' option applied does not occupy the
      bounds reported by bbox, as shown by the rectangle drawn to occupy
      that reported space.
    



DesiredBehavior:
    1) Text stippled based on the bitmap pattern specified
    2) Text occupies spaces which it's supposed to, and which it
      reports that it is.
    





    Not unique to 8.1b2, occurs in 8.1b1
---
Only occurs on Windows.  Unix is OK.    
There are two interesting bugs that appear in this report.  In interactive mode, enter in the following lines:

BUG #1
-----------
    pack [canvas .c]
    .c create text 20 10 -text "Default" -tags a
    .c create text 90 10 -text "Stipple Off" -tags b

Notice that both strings are drawn at even Y-axis.  Now enter:

    .c create text 90 10 -text "Stipple ON" -stipple gray12 -tags b

The stippled test, although it has the same coords, is drawn with a different Y-axis.
Now enter:

    eval .c create rectangle [.c bbox b] -fill green

Notice we did a bbox on the stipppled text.  However we got the coords for the non-stippled text.

BUG #2
-----------
Notice that the stippled text is cropped.  Resize the window and the full text is now displayed.

03/25/1999 12:06 - surles -
User Comments: jan.nijtmans added on 2026-11-14 16:47:38:

> canvText-21.1 fails on Linux CI since [c748282b96]

Thanks! Should be corrected now


serhiy.storchaka added on 2026-11-14 09:41:14:

canvText-21.1 fails on Linux CI since [c748282b96] ("fontsystem had no relation to bidi"). A build with bidi defines HAVE_BIDI but not HAVE_XFT, and it uses Xft for drawing (tkUnixBidiFont.c). Since that change tk::pkgconfig get fontsystem returns "x11" for it, so the constraint withXft is false, and tests which depend on it run or are skipped wrongly: canvText-21.1 (!withXft) now runs with antialiased text. For Tk on X11, HAVE_BIDI means the Xft font system, so the old condition defined(HAVE_XFT) || defined(HAVE_BIDI) was right.


nemethi (claiming to be Csaba Nemethi) added on 2026-11-02 16:51:19:

Serhiy, many, many thanks for providing the 9.0 version of your fix! This worked immediately, without any code change. The fix is now merged into main, core-9-0-branch, and core-8-6-branch by commits [fde93bd2] (Jan), [29e1638b], and [89594d45]. Closing the ticket.


serhiy.storchaka added on 2026-11-02 13:31:27:

The 9.0 version is on branch win-text-stipple-9.0, [4fd4398349]. In 9.0, Tk_DrawChars() and TkDrawAngledChars() drew stippled text into the destination instead of the memory DC, so it was not drawn at all; they now use the same BeginStippledText()/EndStippledText() as 9.1.


kevin_walzer added on 2026-11-02 12:42:07:
Or, maybe we don’t backport?

jan.nijtmans added on 2026-11-02 12:33:39:

I tried the backport to 9.0 as well. Same result :-(


nemethi (claiming to be Csaba Nemethi) added on 2026-11-02 10:44:18:

I have tried to cherrypick Jan's commit from main into core-9-0-branch, but after several hours I had to give up because of the file win/tkWinFont.c, which, due to the bidi/shaping stuff, in Tk 9.1 is much more complicated than in Tk 9.0.

I see two possible ways for backporting to core-9-0-branch:

1. Someone more proficient in fonts and bidi/shaping on Windows masters the cherrypick;

2. Serhiy kindly provides a version of the bugfix which is ready for merge into core-9-0-branch.


jan.nijtmans added on 2026-10-27 20:34:49:

Thanks! Confirming the testcase works for me now. I also fixed frame-12.3 from the "tests-high-dpi" branch, which was also failing for me and now passed.

Let's see tomorrows CI run. If it passes, it can be backported to 9.0 and 8.6.


serhiy.storchaka added on 2026-10-27 18:02:34:

The failure of canvText-21.1 was in the test: the text is given in points, and from 200% display scaling it no longer fits in the 200×60 canvas, so countPixels read outside of it. Fixed in [5b8a105362]: a 200×200 canvas and a single "M", and the knownBug constraint removed. On Windows 11 with tk scaling 1.0 to 4.67 (350%), the test passes with the fix (half of the pixels are drawn, as expected) and fails without it.

Jan, many other tests fail at a high display scale for similar reasons, see [deca13e833]. Some of the fixes from branch tests-high-dpi were merged, but not those for fonts and sizes in points, scrollbar arrows and the default sizes in tk.tcl; the toplevel minimum width is addressed by branch tests-min-width. Could you have a look at them?


jan.nijtmans added on 2026-10-27 16:44:41:

Running the testcase on Windows 11, I see:

canvText.test
==== canvText-21.1 stippled text - bug 220796 FAILED
==== Contents of test case:
    .c create text 10 10 -anchor nw -text MMMM -font {Courier 30 bold} -fill black
    update
    set bbox [.c bbox 1]
    set plain [countPixels .c {*}$bbox]
    .c itemconfigure 1 -stipple gray50
    update
    set stippled [countPixels .c {*}$bbox]
    # About half of the pixels are drawn with a gray50 stipple.
    list [expr {[.c bbox 1] eq $bbox}]  [expr {$stippled * 10 > $plain * 3 && $stippled * 10 < $plain * 7}]
---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: coordinates 9,60 are outside window ".c"
    while executing
"testpixel $w $x $y"
    (procedure "countPixels" line 5)
    invoked from within
"countPixels .c {*}$bbox"
    ("uplevel" body line 5)
    invoked from within
"uplevel 1 $script"
---- errorCode: NONE
==== canvText-21.1 FAILED

Manually running the code in the bug description works fine, so I suspect the problem is somewhere in the testcase. Therefore - for now - I will add the knownBug constraint.


serhiy.storchaka added on 2026-10-22 22:49:16:

Re-tested on Windows 11 with today's main: stippled text is still drawn solid, and angled stippled text is not drawn at all. With branch win-text-stipple both are stippled and the bounding box does not change; canvText.test, font.test and winFont.test pass with it.


serhiy.storchaka added on 2026-09-22 07:48:54:

There were more bugs here than reported. On Windows the stipple was ignored altogether for text drawn through the text layout (canvas text items, text widget), so the text was solid. Angled text with a stipple took a different path in TkDrawAngledChars(), which had three bugs of its own: it drew the text into the destination instead of the memory DC (so it was solid too), it measured the text on a DC without the font selected, and it passed the UTF-8 bytes to GetTextExtentPointA(); the last two gave a wrong size and position, which is the misplacement in the report.

Fixed in [99b9c92a0a] (branch win-text-stipple): text with a stipple is drawn into a memory DC and copied through the stipple pattern, like other stippled objects, in both paths; the size of the memory DC is taken from Tk_MeasureChars() and the font metrics. The bbox is not affected. Test canvText-21.1 (Windows and X11 without Xft; Xft and Aqua do not support stippled text).


nobody added on 2004-03-28 10:32:24:
Logged In: NO 

CL's willing to pay for progress on this.  Contact <[email protected]>.