問題は、使用しているプラットフォームとフォントでUnicodeを処理していることが原因です。 説明したようにon wikipedia:以前はLatin-1 で扱われていた上付き1,2,3のフォントは異なるフォントをサポートしています。
私は固定サイズの問題に気付きませんでしたが、ほとんどのフォント(LinuxおよびMacOS上)では1,2,3が4-9と正しく位置合わせされていません。
あなたのニーズに合ったフォントを選択することをお勧めします(高品質なフォントを提供するDejaVuファミリーをご覧ください)。
フォントやサイズが異なる上付き文字の処理方法を示すためのアプリケーションです。
from Tkinter import *
import tkFont
master = Tk()
canvas = Canvas(master, width=600, height=150)
canvas.grid(row=0, column=0, columnspan=2, sticky=W+N+E+S)
list = Listbox(master)
for f in sorted(tkFont.families()):
list.insert(END, f)
list.grid(row=1, column=0)
font_size= IntVar()
ruler = Scale(master, orient=HORIZONTAL, from_=1, to=200, variable=font_size)
ruler.grid(row=1, column=1, sticky=W+E)
def font_changed(*args):
sel = list.curselection()
font_name = list.get(sel[0]) if len(sel) > 0 else "Times"
canvas.itemconfig(text_item, font=(font_name,font_size.get()))
#force redrawing of the whole Canvas
# dirty rectangle of text items has bug with "superscript" character
canvas.event_generate("<Configure>")
def draw():
supernumber_exception={1:u'\u00b9', 2:u'\u00b2', 3:u'\u00b3'}
mytext =""
for i in range(10):
mytext += u'U'+ (supernumber_exception[i] if i in supernumber_exception else unichr(8304+i))+" "
return canvas.create_text(50, 50,text = mytext, anchor=NW)
text_item = draw()
list.bind("<<ListboxSelect>>", font_changed)
font_size.trace("w", font_changed)
font_size.set(30)
master.grid_columnconfigure(0, weight=0)
master.grid_columnconfigure(1, weight=1)
master.grid_rowconfigure(0, weight=1)
master.grid_rowconfigure(1, weight=0)
master.mainloop()
美しく動作します。ありがとうございました! –