Tkinter 中真正的自定义字体 [英] Truly custom font in Tkinter

查看:20
本文介绍了Tkinter 中真正的自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Tkinter 中制作一个界面,我需要自定义字体.不仅仅是特定大小的 Helvetica 或其他字体,而是在任何给定平台上通常可用的字体以外的字体.这将作为图像文件或(最好)Truetype 字体文件或类似文件与程序一起保存.我不想在要使用该程序的每台机器上都安装所需的字体,我只想将它们与程序放在同一目录中.

I am making an interface in Tkinter and I need to have custom fonts. Not just, say, Helvetica at a certain size or whatever, but fonts other than what would normally be available on any given platform. This would be something that would be kept with the program as an image file or (preferably) Truetype font file or similar. I don't want to have to install the desired fonts on every machine that is going to use the program, I just want to carry them around with the program in the same directory.

tkFont 模块看起来应该做这样的事情,但我看不出它会在哪里为运行程序的系统通常无法访问的字体取文件名.预先感谢您的帮助.

The tkFont module looks like it ought to do something like this, but I can't see where it would take a filename for a font not normally accessible to the system running the program. Thanks in advance for your help.

推荐答案

我找到了 这个讨论 他们介绍了如何将一行文本用作图像并使用 PIL 将其放入窗口中.那可能是一个解决方案.

I found this discussion where they cover how to use a line of text as an image and use PIL to place it into the window. That might be a solution.

我找不到使用 tkFont 在 tkFont 手册页.

I could not find a way to use tkFont to import a bundled font in the tkFont man page.

这篇关于Tkinter 中真正的自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆