Skip to content
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 show different symbol for the same unicode character depending on which character is used first #101032

Closed
patrik-gustavsson opened this issue Jan 14, 2023 · 1 comment

Comments

@patrik-gustavsson
Copy link

Depending on which character is used first in a font instance, that will set the look for the symbols for other unicode characters. To demonstrate this behavior see the following code (I have tested on windows 10 and 11, python 3.11.1):

import tkinter as tk
from tkinter.font import Font

app = tk.Tk()

arial1 = Font(family="Arial", size=32)
arial2 = Font(family="Arial", size=32)

tk.Label(app, text="\u25b6 \u23EE \u270E", font=arial1).pack()
tk.Label(app, text="\u23EE \u25b6 \u270E", font=arial1).pack()
tk.Label(app, text="\u23EE \u25b6 \u270E", font=arial2).pack()
tk.Label(app, text="\u25b6 \u23EE \u270E", font=arial2).pack()

app.mainloop()

This is my understanding of the problem: If a font instance does not support a unicode character, then the font instance will select a fallback font-family. However, depending on which unicode character that is used, I believe different fallback font-families are selected and therefore the look of the characters may differ.

I do not know if this is a bug in tkinter because I noticed this behavior in VSCode, IDLE, Google Chrome, Edge and Slack.

I asked this question on stackoverflow if you want to read more on the comments we had, see https://stackoverflow.com/questions/75026676/why-does-some-unicode-characters-change-shape-depending-on-which-character-is-fi/.

@serhiy-storchaka
Copy link
Member

Tkinter is a thin wrapper around the Tcl/Tk library. It is not responsible of rendering characters, can not and should not interfere with it. If it is a bug, file a report on the Tk bug tracker. Although, I think that they are not responsible of this too and just use system libraries to output characters. If you see this behavior in programs which do not use Tk, it is most likely not related to Tk. Also, it may not be a bug at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants