Bitmap fonts, and in the future more for Pyxel.
Project description
PyxelXL
I am using this for my own game dev purposes, and this is beta-quality software.
Fast TTF drawing for Pyxel, including support for antialiasing. This library is in the works to become a general purpose "bloated" set of extensions for Pyxel, but for now it only includes a font rendering extension.
Installation
You can install PyxelXL using pip:
pip install pyxelxl
Usage
To use a TTF font in your Pyxel application:
import pyxel
from pyxelxl.font import Font
from pyxelxl import LayoutOpts
roboto = Font("/path/to/Roboto-Regular.ttf")
zh_font = Font("/path/to/zpix.ttf")
class App:
def __init__(self):
pyxel.init(160, 120, title="PyxelXL Example")
pyxel.run(self.update, self.draw)
def update(self):
pass
def draw(self):
pyxel.cls(1)
roboto.text(
0,
0,
"Hello, World! Antialiased",
7,
font_size=16,
layout=LayoutOpts(max_width=160, horizontal_align="center"),
)
zh_font.text(
0,
40,
"我能吞下玻璃而不伤身体" * 5,
7,
font_size=12,
layout=LayoutOpts(max_width=160),
)
roboto.text(
0, 80, "Hello, World! Not antialiased", 15, font_size=16, threshold=128
) # layout is optional. Thresholding makes the text look pixelated.
App()
LayoutOpts, Text Wrapping, and Alignment
LayoutOpts
is a class used to define layout options for text rendering in pyxelxl
.
Attributes
-
max_width
:Optional[int]
- The maximum width of the text layout in pixels. If
None
, the width is not constrained. Wrapping will occur if the text exceeds this width.
- The maximum width of the text layout in pixels. If
-
max_height
:Optional[int]
- The maximum height of the text layout in pixels. If
None
, the height is not constrained.
- The maximum height of the text layout in pixels. If
-
horizontal_align
:str
- The horizontal alignment of the text. It can be one of the following values:
"left"
"center"
"right"
- Default is
"left"
.
- The horizontal alignment of the text. It can be one of the following values:
-
vertical_align
:str
- The vertical alignment of the text. It can be one of the following values:
"top"
"center"
"bottom"
- Default is
"top"
.
- The vertical alignment of the text. It can be one of the following values:
-
line_height_mult
:Optional[float]
- The multiplier for line height. If
None
, the line height is determined by the font size.
- The multiplier for line height. If
Advantages
- Fast
- Easy multi-font size support
- Anti-aliasing algorithm for non-pixel fonts
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyxelxl-0.0.10.tar.gz
(19.5 kB
view hashes)
Built Distributions
pyxelxl-0.0.10-cp37-abi3-win32.whl
(295.9 kB
view hashes)
Close
Hashes for pyxelxl-0.0.10-cp37-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 833214ef7ef456e35176f3a3c2a512254f56dfb525c9730ca3c48504ec36134b |
|
MD5 | f808d922f366abe0b34c7fd8c98570b5 |
|
BLAKE2b-256 | 08277979a2c009c69052864e6199dfe34d20763d520469a394beb83a34ef706b |
Close
Hashes for pyxelxl-0.0.10-cp37-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6c23b40f5f2bda9cda2bc6d6abc9e516c36e4bae32433673b74d095f77c722e |
|
MD5 | 4fc151bc1b57117c514e103e0e826fe1 |
|
BLAKE2b-256 | bbcb6e4c514edbf40ef9fef4613aded5f6cc1a534726246004a4f3d6753a2ba4 |
Close
Hashes for pyxelxl-0.0.10-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 665756cccf6e3f373ff02b18f7f0f62407303f479c5d41741cdc4c397b3dab34 |
|
MD5 | e14433cc5f2aa8df5d779f31fcd7f5c5 |
|
BLAKE2b-256 | 0e115e3278408ff590fa0219bb266886eb794af843633e6ec736007d854d09a9 |
Close
Hashes for pyxelxl-0.0.10-cp37-abi3-musllinux_1_2_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb3ff9249ba62aafa056430a12e78ed83b17cd8a8c315cf196257e71df1a5e8b |
|
MD5 | 4d4002f89e87c2952689f9f9032404cc |
|
BLAKE2b-256 | 1cbae0393440a602f28392b9f79a56ae463a15bc6151561d9543f0b702ce18be |
Close
Hashes for pyxelxl-0.0.10-cp37-abi3-musllinux_1_2_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c94e183d12068a197139d656c24fef1524f4581b62bfe1d2e22e2688d74cadd |
|
MD5 | 3d369fda57f54393361a397fddfc2a6b |
|
BLAKE2b-256 | 13b8d1ef14a3d1d461f1c7677ab6cc19fdb3d65f3639809fef4979b332163f63 |
Close
Hashes for pyxelxl-0.0.10-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1925e0e2bcef69f165bb5e98a15250dbe977cda26e06d253caa8b6e8ed4c97fe |
|
MD5 | c1c4de1a4667d9a3ad8a014813e5a73b |
|
BLAKE2b-256 | ad3af6d02ed8a3d6c8e8d3860458e8b79c2299a266b4768d10f324a40a50c9f5 |
Close
Hashes for pyxelxl-0.0.10-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d822deda6d102779f07acec27d6fe2efb3d7022ffd8f686babd63a55b7f4bb5 |
|
MD5 | da57aba6085c617563c0f3a4836d11ef |
|
BLAKE2b-256 | f528639be9806c1c9f0fb9d08f267fb24fabf75f2be427d79cb5c0f1d98a604c |
Close
Hashes for pyxelxl-0.0.10-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39c3638497b35b092bc02c2d9e6d955a15784902816fb7871fcf5397a067f445 |
|
MD5 | 166d615a763db369c153cc0e71c5905a |
|
BLAKE2b-256 | 1c2fefcd0c015c7391f122dca2b9d0145cb28dbf96082c4ace152be93df505e7 |
Close
Hashes for pyxelxl-0.0.10-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9acd5838992ca3f075d2ad5f92313c6eafd3fd06c14ab889e1741a02ec501a0e |
|
MD5 | ff04a056dead596db0f541dfc440502f |
|
BLAKE2b-256 | fd0342fe50cc33ab292baaf46af2ebf4162cf2d844306f152dabc62449474d0e |
Close
Hashes for pyxelxl-0.0.10-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b87a98299bf10400df1d45b680b1af1bc4ab90592d1b1ec1066145cd040641a |
|
MD5 | d499961e3fbf5f0750848c6535653233 |
|
BLAKE2b-256 | c558ed479dffa8b36cdaebfb6293c0d5909ee67c912de7641edd14668142347f |
Close
Hashes for pyxelxl-0.0.10-cp37-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c8b93b1bf7fbd6d8b3c840c1943c950c07169aa4a854d05d130987cdbe16db9 |
|
MD5 | 69861bf8e298f1fe08d29c7d6b493266 |
|
BLAKE2b-256 | cd25a89440dccfff19f8ffe15f356db45cf32cc21ffdd9f133828423448edcc3 |
Close
Hashes for pyxelxl-0.0.10-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd9c86583826b036332239ba6d886a1c8bbe9253e94afb7fc66032b3cf43e70b |
|
MD5 | 5e41e7a5e086b800ec01040df37b3058 |
|
BLAKE2b-256 | a45fe4b622c93de4a36455996171a16bcc52730c079fa40329e33abea1e381de |