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
tkinter.font.Font.measure() broken in 3.5 #68596
Comments
>>> import tkinter, tkinter.font
>>> tk = tkinter.Tk()
>>> tkinter.font.nametofont("TkHeadingFont").measure("string")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/proj/python/cpython/Lib/tkinter/font.py", line 154, in measure
return self._root.tk.getint(self._call("font", "measure", self.name, *args))
AttributeError: 'Font' object has no attribute '_root' This appears to be broken by revision cb80dd82d3da, bpo-23880, which included this change at the end of the measure() method: -return int(self._call("font", "measure", self.name, *args)) The Font class does not have a “_root” attribute. |
New changeset fb05c1355a90 by Serhiy Storchaka in branch '3.5': New changeset 0dd70c2c44b4 by Serhiy Storchaka in branch 'default': |
Thank you for your report Martin. Unfortunately tests for tkinter.Font are almost not existing. Here is a patch that adds more tests (it should be applied to all versions). |
Thanks for the prompt fix! The patch with the tests looks good. I left a query about the existing code. |
New changeset 7e2a7f3fecdf by Serhiy Storchaka in branch '3.4': New changeset 24bb564469b4 by Serhiy Storchaka in branch '3.5': New changeset 47f321ec69dc by Serhiy Storchaka in branch 'default': New changeset ae1bc5b65e65 by Serhiy Storchaka in branch '2.7': |
Test fails on OS X (10.10) with Cocoa Tk 8.6(.4) and 8.5(.18): ====================================================================== Traceback (most recent call last):
File "/py/dev/27/root/fwd/Library/Frameworks/pytest_10.10.framework/Versions/2.7/lib/python2.7/lib-tk/test/test_tkinter/test_font.py", line 79, in test_families
self.assertIn(self.font.actual('family'), families)
AssertionError: '.Helvetica Neue DeskInterface' not found in ('Academy Engraved LET', 'Al Bayan', 'Al Nile', 'Al Tarikh', 'American Typewriter', 'Andale Mono', 'Arial', 'Arial Black', 'Arial Hebrew', 'Arial Hebrew Scholar', 'Arial Narrow', 'Arial Rounded MT Bold', 'Arial Unicode MS', 'Athelas', 'Avenir', 'Avenir Next', 'Avenir Next Condensed', 'Ayuthaya', 'Baghdad', 'Bangla MN', 'Bangla Sangam MN', 'Bank Gothic', 'Baoli SC', 'Baskerville', 'Beirut', 'Big Caslon', 'Blackmoor LET', 'BlairMdITC TT', 'Bodoni 72', 'Bodoni 72 Oldstyle', 'Bodoni 72 Smallcaps', 'Bodoni Ornaments', 'Bordeaux Roman Bold LET', 'Bradley Hand', 'Brush Script MT', 'Capitals', 'Chalkboard', 'Chalkboard SE', 'Chalkduster', 'Charter', 'Cochin', 'Comic Sans MS', 'Copperplate', 'Corsiva Hebrew', 'Courier', 'Courier New', 'Damascus', 'DecoType Naskh', 'Devanagari MT', 'Devanagari Sangam MN', 'Didot', 'DIN Alternate', 'DIN Condensed', 'Diwan Kufi', 'Diwan Thuluth', 'Euphemia UCAS', 'Farah', 'Farisi', 'Futura', 'GB18030 Bitmap', 'Geeza Pro', 'Geneva', 'Georgia', 'Gill Sans', 'Gujarati MT', 'Gujarati Sangam MN', 'GungSeo', 'Gurmukhi MN', 'Gurmukhi MT', 'Gurmukhi Sangam MN', 'Hannotate SC', 'Hannotate TC', 'HanziPen SC', 'HanziPen TC', 'HeadLineA', 'Heiti SC', 'Heiti TC', 'Helvetica', 'Helvetica Neue', 'Herculanum', 'Hiragino Kaku Gothic Pro', [...] |
Some quick googling suggests this “.Helvetica Neue DeskInterface” font is real, and because it begins with a full stop it may be normally hidden from the normal list of fonts. Perhaps the test could be modified to just check the two functions separately:
|
Here is a patch to decouple the families() and Font.actual("family") tests as I suggested. Ned, can you confirm if this works on the failing OS X setup? I expect it should be fine. |
New changeset 8e90f3ffa784 by Serhiy Storchaka in branch '2.7': New changeset 014ee2df443a by Serhiy Storchaka in branch '3.4': New changeset 5b037f934e40 by Serhiy Storchaka in branch '3.5': New changeset 2d072d07dfe2 by Serhiy Storchaka in branch 'default': |
Thank you Ned and Martin. |
New changeset 20c9290a5de4 by Ned Deily in branch '2.7': |
Thanks for the fix, Martin and Serhiy. With Tk 8.4 on OS X, at least, it is possible to have non-ascii font names. I extended the 2.7 test to account for that. |
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: