-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
idle_test: test_fontlist_key() fails if two font families have the same name #83781
Comments
====================================================================== Traceback (most recent call last):
File "/usr/lib64/python3.7/idlelib/idle_test/test_configdialog.py", line 104, in test_fontlist_key
self.assertNotEqual(down_font, font)
AssertionError: 'Cantarell' == 'Cantarell' Example: import tkinter.ttk
import tkinter.font
frame = tkinter.ttk.Frame()
families=sorted(tkinter.font.families(frame))
for family in families:
print(family) Truncated output on my Fedora 31: I'm not sure if it's an issue in the unit test or an issue with the widget itself. Does it make sense to display the same font family name twice? |
I proposed PR 18430 to remove duplicated font family names. |
Serhiy, do you know anything about the tkinter.font.families() tuple having duplicate names? It strikes me as an OS or tk error. On Windows, the tuple has groups of related names with a base name, such as 'Segoe UI' both alone and with suffixes, such as 'light', 'black', and 'symbol'. I wonder if on Fedora 31 the duplicates are related names with the suffixes somehow left off. Cheryl, do you see any of the above duplicated names de-duplicated on Ubuntu with suffixes? Whether the duplicates are true duplicates, (same family repeated) or mistakes (related families missing suffixes), they should be useless to the user. Clicking or scrolling through the duplicates should not change the font sample as 'Font(family=dupname)' will not change. Victor, your example does not create a Listbox, so that cannot be the issue. The only change to ConfigDialog when testing is that it is not made modal. What puzzles me is that test_fontlist_key starts by explicitly activating the first font on the list, so that the first test on the Fedora machine should be 'Android Emoji' != 'Abyssinica SIL'. Perhaps there is a bug in the tk on that machine. Carol Willing merged the PR before I could review and edit. I will add a follow-up after getting backport to work. |
In LibreOffice, I see 4 flavors of "Cantarell" with different *weight* : Cantarell whereas tkinter.font.families(frame) returns 4 times the same string: "Cantarell". The C function of Tk is TkpGetFontFamilies(). The X11 implementation uses XListFonts() which returns a string like "-foundry-family-weight-slant-(...)" but the function only returns the "family" substring: it ignores the foundy and the weight for example. So it's not surprising to get duplicates. Example: "-adobe-helvetica-bold-o-normal--11-80-100-100-p-60-iso8859-1" becomes "helvetica". There is also a Xft implementation which uses XftListFonts(). Then it uses XftPatternGetString() to get a font family. I see no logic in Tcl to exclude duplicated family names of different weights. -- >>> tkinter.font.names(frame)
('TkCaptionFont', 'TkSmallCaptionFont', 'TkTooltipFont', 'TkFixedFont', 'TkHeadingFont', 'TkMenuFont', 'TkIconFont', 'TkTextFont', 'TkDefaultFont') That's something different that I would call unrelated ;-) |
The test failure comes from our build system where very few fonts are limited. For example, you can imagine that only a few variants of Cantarell are installed. Sorry, I forgot to mention that the test failure and the list of strings come from two different machines. The list comes from my laptop where I have many fonts installed. |
I don't see the same duplicates that Victor listed, however I do see some duplicates. (...) |
font.names() lists 'symbolic' family names guaranteed to exist. 'TkDefaultFont' is the default Text widget font on a particular OS. IDLE replaces that with 'TkFixedFont', which is translated to the actual family name on each OS: Courier on Windows (ugh) and something like Monaco on macOS. Thank you for the additional information. For *nix users, removing the useless duplicates should be an improvement. (This is aside from the test issue, which could have been fixed otherwise: perhaps by inserting 'TestFont' at the top of the list and making other adjustments.) |
Cheryl, it appears that only 'weight' words are deleted. For a given family, Tk only has a (user) settable 'bold', so other weight options must be 'baked in' to the family. Perhaps X11 allows more weight settings within a family, even if not exposed in Tk. |
Thanks to everybody who was involved in this issue, it's nice to see a test fixed so quickly, especially when it enhances IDLE UI for end users ;-) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: