Pygame 显示空白框而不是正确的字符

发布于 2025-01-12 06:58:00 字数 765 浏览 3 评论 0原文

我正在使用 PyGame 绘制一些印地语以及印度或马拉雅拉姆语中使用的其他语言(等ថ្ងៃ)。我检查了像 Twitter 这样支持多种语言的网站,使用 Leelawadee UI 字体来显示文本,所以我将其添加到脚本中,但出现了空格,例如 这个

#!/usr/bin/python
import pygame
pygame.init()
font_size = 1024
font = pygame.font.SysFont('LeelawUI', font_size)
text = font.render(text, True, (27, 149, 224), background)
pygame.image.save(text, output_path)

我尝试了另一种字体,并得到了一个不同的空格框,例如 this

另外,还有一个库可以处理这种语言中错误标记的重音或元音吗?当我输入类似 കേരളബ്ലാസ്റസ്റ്റേഴ്സ് 时,程序似乎没有正确理解这是一个词而不是一个离散的字母。

提前致谢。

I'm using PyGame to draw some Hindi and other languages used in India or Malayalam (etc. ថ្ងៃ). I checked websites like Twitter which supports multiple languages, uses the Leelawadee UI font to display text, so I added it to the script but got blank space like this.

#!/usr/bin/python
import pygame
pygame.init()
font_size = 1024
font = pygame.font.SysFont('LeelawUI', font_size)
text = font.render(text, True, (27, 149, 224), background)
pygame.image.save(text, output_path)

I've tried another font and got a different space box like this

Also, ts there a library that can handle the mis-marked stress or vowels in this language? When I type-in word like കേരളബ്ലാസ്റ്റേഴ്സ്, it seems the program doesn't understand correctly that this is a word and not a discrete letter.

Thanks in advance.

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

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

发布评论

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

评论(1

二智少女猫性小仙女 2025-01-19 06:58:00

我建议使用 Unifont 作为字体。我测试了它,.ttf 文件应该可以工作。您只需将其安装到您的系统上即可。

它的外观如下:

Unifont 呈现字符。

I suggest using Unifont as font. I tested it, the .ttf file should work. You just need to install it on your system, and it's done.

Here's how it looks:

Unifont renders the characters.

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