Skip to content

AceBee007/PyxelUnicode

Repository files navigation

Downloads

PyxelUnicode

a unicode pixel font builder for pyxel

[English | 日本語 | 中文]

Introduction

PyxelUnicode is a pixel style unicode font builder for Pyxel.

Pyxel is a really good game engine. It's simple and easy enough for a python beginner and game creator. I like it very much.

But there's a problem. The built-in function pyxel.text() only supports the basic ASCII characters. If I want to print some characters which are not in ASCII table(generally, Unicode character), I have to design and make a hard coding for these characters. This work really annoying me a lot. So I made this little utility library to do this work instead.

These kinds of simple games are always made by or for some who are young, they may not be familiar with English. The local language text display is needed.

Demo

some image some image some image

How To Install

Install PyxelUnicode with the following pip command

pip install pyxelunicode

How To Use

The examples below show you how to use it.

general usage

import pyxel
from pyxelunicode import PyxelUnicode

pyxel.init(256, 256, caption="PyxelUnicode General Usage")
pyxel.cls(0)

font_path = "PATH_TO_YOUR_FONT_FILE.ttf"
font_size = 12  # set the most suitable size of this font

# make a pyxelunicode instance
pyuni = PyxelUnicode(font_path, font_size)
y = 20

# print the text 'HELLO PyxelUnicode' at (x,y)=(15,20), 
# default fg_color is 7 (white) and no background color
pyuni.text(15, y, 'HELLO PyxelUnicode!')

# you can get font height as below
y += pyuni.font_height + 10

# print the text 'BYE PyxelUnicode' at (x,y)=(15,20+font_height+10), 
# use foreground color 3, background color 5
pyuni.text(15, y, 'BYE PyxelUnicode!', 3, 5)

pyxel.show()

find the most suitable font size

If you do not know the most suitable font size, try the code below. It shows the font size and how it looks.

import pyxel
from pyxelunicode import PyxelUnicode

pyxel.init(256, 256, caption="PyxelUnicode find font size")
pyxel.cls(0)

font_path = "PATH_TO_YOUR_FONT_FILE.ttf"

y = 0
# check how it looks like when the size are [8,10,12,14,16.....]
for s in range(8,36, 2):
    pyuni = PyxelUnicode(font_path, original_size=s)
    pyxel.text(0, y, str(s), 7)
    pyuni.text(10, y, s='DUMMY TEXT, dummy text.')
    y += pyuni.font_height

pyxel.show()

In some languages(e.g. Cyrillic, Thai, invalid Japanese), the characters may be made by a main character (base character) and several diacritics. In this case, you have to tell the program which character is a unicode combining character.

It may not work perfectly, and I do not know why. I welcome any kinds of imporvement.

import pyxel
from pyxelunicode import PyxelUnicode

pyxel.init(256, 256, caption="PyxelUnicode General Usage")
pyxel.cls(0)

font_path = "PATH_TO_YOUR_FONT_FILE.ttf"
font_size = 12  # set the most suitable size of this font

pyuni = PyxelUnicode(font_path, font_size)
# use a list of unicode-combining-characters as string
pyuni.text(10, 50, ['นั่', 'น', 'คื', 'ā', 'ć', 'ģ'])

pyxel.show()

unicode pixel font sources

PLEASE READ THE LINCESES BEFORE USING

You could find the licenses in their relative pages.

Font Name Mainly Supported Characters size(px) Download Relative Pages
Pixel UniCode Greek
Cyrillic
Arabic
16 download release page
Zpix Traditional Chinese
Simplified Chinese
Japanese
12 download github
review
美咲フォント(8x8) Japanese 8 download home page
PixelMplus Japanese 10
12
download blog
Neo둥근모 프로젝트 Korean 16
32
download home page
github
DungGeunMo(둥근모꼴+ Fixedsys) Korean 16 download home page
ZoodHarit4Bit Thai 21 download release page

About

a unicode pixel font builder for pyxel

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages