Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

In linux, copying a tkinter font doubles its size when using Tk 8.6 and a hi-res screen. #128719

Copy link
Copy link
Open
@culler

Description

@culler
Issue body actions

Bug report

Bug description:

>>> import tkinter
>>> from tkinter.font import Font
>>> root = tkinter.Tk()
>>> f1 = Font(name='TkDefaultFont', exists=True)
>>> f1.actual()
{'family': 'Noto Sans', 'size': 20, 'weight': 'normal', 'slant': 'roman', 'underline': 0, 'overstrike': 0}
>>> f2 = f1.copy()
>>> f2.actual()
{'family': 'Noto Sans', 'size': 40, 'weight': 'normal', 'slant': 'roman', 'underline': 0, 'overstrike': 0}
>>> f3 = f2.copy()
>>> f3.actual()
{'family': 'Noto Sans', 'size': 80, 'weight': 'normal', 'slant': 'roman', 'underline': 0, 'overstrike': 0}
>>> f4 = f3.copy()
>>> f4.actual()
{'family': 'Noto Sans', 'size': 160, 'weight': 'normal', 'slant': 'roman', 'underline': 0, 'overstrike': 0}

The example above is from Ubuntu 24.04 running on an Asus Zenbook with EVO screen. The display scaling from the system settings is the default, namely 200%. This does not happen when the display scaling is 100%.

Note that font f1 is already (more than) doubled in size, compared to what wish8.6 (built from 8.6.15 source) reports:

% info patchlevel
8.6.15
% font actual TkDefaultFont
-family {Noto Sans} -size 9 -weight normal -slant roman -underline 0 -overstrike 0
% font config TkDefaultFont
-family sans-serif -size -12 -weight normal -slant roman -underline 0 -overstrike 0

The negative value -12 means that the size is 12 pixels, as opposed to 12 points. I think the intitial expansion being slightly more than a factor of 2 may be caused by rounding when converting pixels to points.

Note that the behavior of Tk 9 is different. Using wish9.0 on the same system produces:

% info patchlevel
9.0.0
% font actual TkDefaultFont
-family {Noto Sans} -size 10 -weight normal -slant roman -underline 0 -overstrike 0
% font config TkDefaultFont
-family sans-serif -size 10 -weight normal -slant roman -underline 0 -overstrike 0

Also, the pending new version of tkinter from #124156 does not have this doubling behavior when used with Tk 9.0. (I have not tested the new tkinter with Tk 8.6, but I expect it to have the broken behavior since I don't think that the PR changes Font.copy.)

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.