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?
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.
要使用字体,它必须是在 say - word 中看到的名称,因此与 Comic Sans 相反,如前所述,它应该是 -comic Sans MS
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.