0

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.

  • The font size is far to large try 64 instead of 1024. If that doesn't work, then try a different font: `font = pygame.font.SysFont(None, font_size)` – Rabbid76 Mar 08 '22 at 05:59
  • Be sure the font you're using supports the characters you want to use. The pygame default font will not support Hindi characters. – Starbuck5 Mar 08 '22 at 09:41
  • I was found that websites like Twitter are using the system font `Leelawadee UI` to display the word `ថ្ងៃ`, But it still doesn't work after I specify the supported font in the script. @Starbuck5 – jerrylin07 Mar 08 '22 at 22:35
  • @jerrylin07 Pygame has trouble supporting it: https://github.com/pygame/pygame/issues/464 – Starbuck5 Mar 09 '22 at 07:49

1 Answers1

0

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.