如何找出 Turtle 中可用的字体?

发布于 2025-01-17 03:50:15 字数 113 浏览 0 评论 0原文

我正在使用 python 的海龟模块并想要加载不同的字体。我读到乌龟使用 tkinter 的字体,但其中一些应该可用的字体实际上并不可用。有谁知道如何添加字体或获取可用字体列表?我特别想写阿拉伯语、希伯来语字体。

I'm working with python's turtle module and want to load different fonts. I've read that turtle uses tkinter's fonts but some of these fonts that should be available are in fact not. Does anyone know how I can add fonts or get a list of available ones? I would especially like to write arabic, hebrew fonts.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

∞琼窗梦回ˉ 2025-01-24 03:50:15

试试这个来列出字体。

import tkinter as tk
r = tk.Tk()
print(list(tk.font.families()))

Turtle 基于 tkinter,因此您列出了 tkinter 字体。

Try this to list fonts.

import tkinter as tk
r = tk.Tk()
print(list(tk.font.families()))

Turtle is based on tkinter, so you list the tkinter fonts.

等风来 2025-01-24 03:50:15
  1. 要添加字体,请首先下载所需的字体并将其安装到您的系统上。

  2. 然后您可以在代码中使用此字体,如示例所示。

from turtle import Screen, Turtle

screen = Screen()
turtle = Turtle()

turtle.write("Pacifico Font", align='center', font=('Pacifico', 48))

screen.mainloop()

我希望它对您添加新字体有所帮助。

参考:如何在 Python Turtle 中使用自定义本地字体?

另外,您可以检查这个也出来了。

  1. To add a font, first download the font you want and install it on your system.

  2. Then you can use this font in your code as shown in the example.

from turtle import Screen, Turtle

screen = Screen()
turtle = Turtle()

turtle.write("Pacifico Font", align='center', font=('Pacifico', 48))

screen.mainloop()

I hope it helps you about adding a new font.

Reference: How can I use custom local fonts in Python Turtle?

Also, you can check this out too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文