Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7796493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:23:20+00:00 2026-06-01T23:23:20+00:00

I am trying to use canvas.create_text(…) to add text to a drawing. I have

  • 0

I am trying to use canvas.create_text(…) to add text to a drawing. I have been somewhat successful using unicode in the following way:

mytext = u'U\u2076'  #U^6
canvas.create_text(xPos,yPos,text = mytext, font = ("Times","30")
canvas.pack()

It works, but when increasing the font size, superscripts 4,5,6,7,8,9,0 do not increase in size. Only 1,2,3 work. I’m assuming it’s the same for subscripts. Also, when I save the canvas as a postscript, the problem superscripts are gone…but when I print out that saved image, the superscripts return.

Am I just completely wrong with my approach? I’m just looking to make this work so any help would be greatly appreciated. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:23:22+00:00Added an answer on June 1, 2026 at 11:23 pm

    Your problem comes from the handling of Unicode on your platform and in your fonts.
    As explained on wikipedia : superscript 1,2 and 3 where previously handled in Latin-1
    and thus get different support in fonts.

    I did not notice fixed size issue, but on most fonts (on Linux and MacOS), 1,2,3 are not properly aligned with 4-9.

    My advice would be to select a font that match your need (you may look at DejaVu family, which provide libre high quality fonts).

    Here is a litte application to illustrate the handling of superscripts with different fonts or size.

    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()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to use various canvas / svg libraries such as raphaeljs to
I am trying to create a canvas game using the proccessing.js library. I use
I am currently trying to program an online drawing program using the HTML5 canvas.
I am trying to use the HTML5 canvas element to draw some arcs and
I am trying to get my canvas to use a fill style from an
I am trying use gem tire to search in my application. I have tables
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Hi I'm trying use a datepicker on a field I have. I'm trying to
I want to use the canvas.drawText() method to draw some text frame after frame.
I'm trying to write a basic drawing widget using the Tkinter library. The very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.