英文:
Why does some unicode characters change shape depending on which character is first used in tkinter?
问题
我正在使用Windows 11和Python 3.11.1。一些Unicode字符的外观会根据在tkinter中的字体中首先使用的字符而变化。下面的代码展示了这种行为:
import tkinter as tk
from tkinter.font import Font
app = tk.Tk()
tk.Label(app, text="\u25b6 \u23EE \u270E", font=Font()).pack(side="top")
tk.Label(app, text="\u23EE \u25b6 \u270E", font=Font()).pack(side="top")
app.mainloop()
输出如下:
为什么会发生这种情况?是否有一种方法可以设置字体中字符的默认外观,而不必先添加一个临时字符?
英文:
I'm using Windows 11 and python 3.11.1. Some unicode characters change look depending on which character is used first in tkinter per font. The code below show the behavior:
import tkinter as tk
from tkinter.font import Font
app = tk.Tk()
tk.Label(app, text="\u25b6 \u23EE \u270E", font=Font()).pack(side="top")
tk.Label(app, text="\u23EE \u25b6 \u270E", font=Font()).pack(side="top")
app.mainloop()
The output is the following:
Why does this happen? Is there a way to set the default look of characters in a font without adding a temporary character first?
答案1
得分: 1
I did some tests and eventually when trying unicode characters with Google Chrome I realized that this issue has nothing to do with tkinter or Python. It seems to be a larger problem with unicode characters in general. Here is what happens if you play around with the following unicode characters (⏮▶▶) in google chrome search bar.
Edit:
As Mike 'Pomax' Kamermans pointed out, this problem does not appear when using a font that supports all unicode characters that are used. For example GNU Unifont, http://unifoundry.com/unifont/, supports the unicode characters mentioned in the question and the shape for those characters are always the same when using that font.
The most probable reason this happens is depending on which unicode character is first used then different fallback fonts are used and therefore the shape may differ.
英文:
I did some tests and eventually when trying unicode characters with Google Chrome I realized that this issue has nothing to do with tkinter or Python. It seems to be a larger problem with unicode characters in general. Here is what happens if you play around with the following unicode characters (⏮▶▶) in google chrome search bar.
Edit:
As Mike 'Pomax' Kamermans pointed out, this problem does not appear when using a font that supports all unicode characters that are used. For example GNU Unifont, http://unifoundry.com/unifont/, supports the unicode characters mentioned in the question and the shape for those characters are always the same when using that font.
The most probable reason this happens is depending on which unicode character is first used then different fallback fonts are used and therefore the shape may differ.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论