FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Different pixel-specified font sizes in tkinter · Issue #143990 · python/cpython · GitHub

Repository navigation

Different pixel-specified font sizes in tkinter #143990

Closed

Description

Bug report

Bug description:

import tkinter as tk
import tkinter.font as tkfont

root = tk.Tk()

font_tuple = ("Calibri", -14)
font = tkfont.Font(root, font_tuple)

lb1 = tk.Label(root, text="Hello", font=font_tuple)
lb1.pack()
lb2 = tk.Label(root, text="Hello", font=font)
lb2.pack()

root.update()
print(lb1.winfo_width(), lb1.winfo_height())
print(lb2.winfo_width(), lb2.winfo_height())

root.mainloop()

The font size differs between tuples and Font objects.
The documentation states it can be specified in pixels, but is this a bug?

CPython versions tested on:

3.14

Operating systems tested on:

Windows

Linked PRs

Activity

  1. added a commit that references this issue on Jan 18, 2026
  2. added 2 commits that reference this issue on Jan 18, 2026
  3. added
    3.13only security fixes
    3.14bugs and security fixes
    3.15bugs and security fixes
    on Jan 20, 2026
  4. serhiy-storchaka commented on Jan 20, 2026

    Member

    This is more complex issue. Font description can be not only a tuple, but also a string like "TkTextFont -21 bold". It can also be in other format, like "-adobe-avant garde gothic-book-o-normal--0-0-0-0-p-0-iso8859-1".

    The problem is that some font subcommants support font description, while others only font name. The Font class tries to provide object oriented interface for this, and by default creates a new font from a file description. Then the name of this font instead of the original font description is used in font actual, font measure and font metrics. There is a loss of precision between font actual and font create.

  5. added a commit that references this issue on Jun 23, 2026
  6. serhiy-storchaka commented on Jun 23, 2026

    Member

    #152025 allows to wrap a font description, not only a named font.

  7. added a commit that references this issue on Jul 7, 2026
  8. serhiy-storchaka commented on Jul 7, 2026

    Member

    Addressed by #152025 and #153267. There are two parts to this:

    So a Font built from a bare description still reports the resolved size by design, with exists=True as the exact-preservation path.

  9. added 2 commits that reference this issue on Jul 7, 2026
  10. encukou commented on Jul 8, 2026

    Member

    The Alpine buildbot is broken, likely because of this change. See e.g. https://buildbot.python.org/#/builders/301/builds/15551

  11. added a commit that references this issue on Jul 8, 2026
  12. serhiy-storchaka commented on Jul 8, 2026

  13. encukou commented on Jul 8, 2026

  14. serhiy-storchaka commented on Jul 8, 2026

    Member

    Should be fixed by #153322.

  15. added 6 commits that reference this issue on Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

3.13only security fixes3.14bugs and security fixes3.15bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-tkintertype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL