Ticket UUID: | c0dbdd3ff35697b57935f7d16e47336ca5043277 | |||
Title: | Tk Compatibility Fonts block access to system fonts | |||
Type: | Bug | Version: | 8.6 | |
Submitter: | MG | Created on: | 2016-11-13 01:19:40 | |
Subsystem: | 44. Generic Fonts | Assigned To: | fvogel | |
Priority: | 6 | Severity: | Minor | |
Status: | Closed | Last Modified: | 2017-02-05 17:36:54 | |
Resolution: | Fixed | Closed By: | fvogel | |
Closed on: | 2017-02-05 17:36:54 | |||
Description: |
It seems that the font names Tk provides for compatability are blocking actual, installed system fonts. From the manpage for the -family option to the [font] command: The case-insensitive font family name. Tk guarantees to support the font families named Courier (a monospaced “typewriter” font), Times (a serifed “newspaper” font), and Helvetica (a sans-serif “European” font). The most closely matching native font family will automatically be substituted when one of the above font families is used. The name may also be the name of a native, platform-specific font family; in that case it will work as desired on one platform but may not display correctly on other platforms. If the family is unspecified or unrecognized, a platform-specific default font will be chosen. I have a font installed actually called "Courier", but it seems to be impossible to use it in Tk: (Mike) 17 % font actual Courier -family {Courier New} -size 12 -weight normal -slant roman -underline 0 -overstrike 0 (Mike) 18 % font actual [list -family Courier] -family {Courier New} -size 12 -weight normal -slant roman -underline 0 -overstrike 0 Tk's compatability name seems to be checked before actual installed fonts, so any attempt to access it's being mapped to Courier New. Especially annoying since the [tk fontchooser], which uses the built in Windows font dialog, does show Courier and Courier New as two distinct and separate fonts. Since Tk provides a number of configurable named fonts these days (TkDefaultFont, etc), perhaps these three should be moved to there (right now they seem to be special, included neither in [font names] nor [font families]), so they can at least be manually edited or removed by applications if desired? | |||
User Comments: |
fvogel added on 2017-02-05 17:36:54:
A second warning sent to Tcl Core list did not trigger any reaction, and no TIP was requested, therefore this is now merged to trunk (only): [678fdae0] fvogel added on 2017-01-29 14:41:05: And on Linux (Debian 8), the changes are fine too (tests results in trunk and in the bugfix branch show the same results, modulo unstable tests). fvogel added on 2017-01-28 21:50:16: I have now also checked that the proposed changes in the bugfix branch are fine for OS X too. fvogel added on 2017-01-28 17:41:41: I have committed the proposed change in branch bug-c0dbdd3ff3, and have fixed all failing tests (checked this on WIn only so far). MG added on 2016-12-20 02:49:32: Ahh, I see. Sounds like it's probably a matter of going through all the test cases and changing the fonts being used in the tests from 'times' to 'Times New Roman', etc, so they still match up with previous behaviour? fvogel added on 2016-12-19 07:24:59: I have attached the Tk test suite results on windows Vista, in Trunk, after removal of the lines ruling out some fonts in FalilyExists(). A few failures are due to what you mention, but most are due to checks based on measuring some distance on screen, which is very sensitive on the font. OK, yes, probably poorly written tests. But this is a lot of work to correct. MG added on 2016-12-18 23:39:22:
Wow. For such a tiny and unremarkable change, that is an impressive number of failures. ;) What are the failures, out of curiousity? If you don't have matching fonts installed, all three should still exist the same way using the fallbacks, shouldn't they? I'm wondering if some of the failures are because you do have a Courier font, and it's checking for fvogel added on 2016-12-18 20:41:44: I received no answer when I prompted the Tcl Core list for opinions on removing this. So I gave it a try. Hmpf. In trunk, on Windows, removing these lines makes 135 tests of the Tk test suite newly fail !!! MG added on 2016-12-06 21:53:25: It looks like the reason it's there is that whoever did it thought the fonts were ugly, from the comments? That seems a really bad idea to block access to those specific fonts at that level, especially since they're not blocked from other places in Tk (such as the built-in Windows font dialog, so people can still try and select it should they wish to and then end up with what seems to be a bug). Back in 1999, Courier at least was likely the crappy version that pixelated, not a proper truetype font (though I've seen plenty of perfectly good fonts called Times and Helvetica on different Windows machines over the years). This just seems really arbitrary, and something much better left to individual program writers to me. fvogel added on 2016-12-02 21:57:37:
Sorry, my link below was in fact not relevant. A less superficial analysis of what is happening when calling
This call first looks (
And in Removing those lines in the source code makes -family Courier -size 12 -weight normal -slant roman -underline 0 -overstrike 0 This has been in Tk since 1999, and the reason why it's there looks valid to me. MG added on 2016-11-14 07:07:07:
Huh, looks like there are a few others there (mincho, gothic, and dingbats) that work in the same way but are also undocumented? Candidates for the same treatment. (Is it worth raising a separate ticket about them being undocumented?) fvogel added on 2016-11-13 10:38:21: Perhaps this is relevant. |
Attachments:
- fonts removed-trunk_tests_results (2017 12 18).txt [download] added by fvogel on 2016-12-19 07:22:39. [details]