This program essentially tests whether or not texts in various languages are being rendered correctly by pygame. Please see this thread as to why.
Essentially, this renders the same text-on-a-solid-background png
using pygame
and gimp
using the exact same font, color, font-size, dimensions, etc, and checks the similarity of the rendered png
s using perceptual hash function (allowing for a slight dissimilarity threshold).
$ ./main.py
This mostly uses the standard python library modules but there are a few other modules/libraries and fonts that are required:
GIMP
(alsogimp-python
, if it is not installed with GIMP)pillow
(pip install pillow
)imagehash
(pip install ImageHash
)pygame
(pip install pygame
), obviously.
To check the rendering of other languages/scripts, all one needs to do is to add the text to text.json
file. The file is simple and the syntax is:
[
{
"script": "<SCRIPT - 'Devanagari', 'Latin', etc.>",
"font": "<Font to render the text with. Should be pre-installed>",
"text": [
"TEXT1",
"TEXT2",
"TEXTS CAN ALSO HAVE SPACES"
]
}
]
This file specifies the image dimensions, text size, text colour, background colour, etc.