| Ticket UUID: | c81e0ccee2b971b01f58a9adb8bfa42ae66b785e | |||
| Title: | Named font late creation | |||
| Type: | Bug | Version: | >= 8.0 | |
| Submitter: | chw | Created on: | 2025-06-06 05:46:08 | |
| Subsystem: | 44. Generic Fonts | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | Important | |
| Status: | Closed | Last Modified: | 2026-10-24 14:22:21 | |
| Resolution: | Fixed | Closed By: | nemethi | |
| Closed on: | 2026-10-24 14:22:21 | |||
| Description: |
Named fonts are not configured properly when the font name is used in a widget prior to the creation of the named font by the
The expected outcome would be the first two labels having
So there's some confusion in the font subsystem regarding caching of named and unnamed fonts and when to perform updates. Therefore I attach a proposed fix as a patch against core-8-6-branch. | |||
| User Comments: |
nemethi (claiming to be Csaba Nemethi) added on 2026-10-24 14:22:21:
Christian, Harald, and Serhiy, many thanks! Merged into main, core-9-0-branch, and core-8-6-branch by commits [f89023e3ee], [3e71cad9], and [a344fe53]. serhiy.storchaka added on 2026-10-24 14:08:24: Thank you, Marc. Which check-in did you test? The fix was merged into main in [f89023e3ee] and into core-9-0-branch in [3e71cad966] today. If your build includes it, the first script should show the labels in Helvetica 30 after a second. marc_culler (claiming to be Marc Culler) added on 2026-10-24 13:52:31: On macOS, * With the first script I see two labels appear in a small Helvetica font. Then one second later the third appears, also in the small Helvetica font. * With the second script I see the first two labels appear in a large Helvetica font. Then after a second they change to Courier in the same size. Then after another second a third label appears in Courier. I think that means that the problem is the same on macOS, which is consistent with the claim that the problem is in tkFont.c. serhiy.storchaka added on 2026-09-26 17:54:51: The patch looks good, but has a few conflicts with main, so I created a rebased branch named-font-late-creation with two more low-level tests, one of them for a regression from [8da7af2f8e]. The examples from the ticket (including ttk) work on Linux, and the font and ttk tests pass. The regression: if a font name was used before font create with that name (e.g. by font actual), the unused font, which is now kept in the cache until idle time, shadowed the new named font. The patch fixes it too. If there are issues with this patch, I can create a separate fix for the regression. oehhar added on 2025-06-06 13:39:30: Christian, I see your reson. But then, most tests should do so. AFAIK, we have a test start argument, to run tests individually. I suppose, the reason why this is not done systematically is test time. Don Ported does that and finds dependencies between the tests. Thanks for all, Harald chw added on 2025-06-06 13:29:37: Harald, while I can live with the test, doing this in another oehhar added on 2025-06-06 12:47:49: Thanks ! Added test by commit [c81e0cce]. I simplified the test (removing the interpreter) and commented it, so even I do understand it ;-). If you resist in writing to branches directly, you have to live with my stupid commits.... Thanks for all, Harald chw added on 2025-06-06 12:16:21: Without further instrumentation it might be possible to test it somehow unsharp with this approach
but this is a sketch only. Please refine. oehhar added on 2025-06-06 11:36:54: Yes. Could you provide a test case? I think, with a test case, this may quickly be merged. Thanks, Harald chw added on 2025-06-06 11:23:41: Harald, thanks for testing. Indeed is this problem as old as Tk 8.0 as far as can be seen in oehhar added on 2025-06-06 10:59:59: I can confirm, that the patch is effective, and that the additional "font delete" is not required any more. My environment: win32+MS-VC6 on MS-Win11 64 bit GER. I can also confirm, that the bug is also present in Tk 9.0.1 Comments and tests welcome Great job, Christian ! Harald oehhar added on 2025-06-06 10:00:11: Pathch now in commit [ed0d5d23], VC6 optimized. Tests pass with MS-VC6 Thanks, Harald | |||
Attachments:
- tkFont.diff [download] added by chw on 2025-06-06 05:46:22. [details]
