Pygame displays blank boxes instead of correct character

271 Views Asked by At

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.

1

There are 1 best solutions below

0
Desktop Firework On

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.