0

I am having trouble with changing the font in turtle. I want the font to be Comic Sans, but when I run this code the text is in Arial:

write("Turtle Racer", align="center", font=("Comic Sans", 80, "normal"))

What fonts are available for turtle?

cdlane
  • 40,441
  • 5
  • 32
  • 81
  • 2
    Possible duplicate of [List available font families in \`tkinter\`](https://stackoverflow.com/questions/39614027/list-available-font-families-in-tkinter) –  Jan 10 '18 at 18:19
  • 1
    `turtle` uses `tkinter` behind the scenes. –  Jan 10 '18 at 18:21

3 Answers3

1

This works on my system:

import turtle

turtle.write("Turtle Racer", align="center", font=("Comic Sans MS", 80, "normal"))

turtle.done()

And is consistent with the family name returned by the code @hop left a link to in the comments.

cdlane
  • 40,441
  • 5
  • 32
  • 81
-2

to use a font, it has to be the name as seen in say - word, so as opposed to Comic Sans, it would be, as previously stated - comic Sans MS

NEO
  • 1
-2

The below code works in my system. I have included the screen class to help visualize and for you to test it out.

from turtle import Turtle, Screen

screen = Screen()
t = Turtle()
t.hideturtle()
t.write(arg="Your Text", align="left", font=("Comic Sans", 10, "normal"))

screen.exitonclick()

If I see your code, you may have missed to call the object on which the write method is being called.

  • 1
    Welcome to Stack Overflow! :^) Glad to have you here. Please note, this answer appears to be a duplicate of the accepted answer. If you'd like to post additional clarity on the answer, I'd suggest commenting on the previously accepted answer. – Frodnar May 06 '21 at 21:07
  • @Frodnar Thanks for the info and sorry for not using the correct area to write. – Siddhartha May 10 '21 at 18:16