Skip to main content

Truetype fonts, sprite rotation, and in the future more extensions for Pyxel.

Project description

PyxelXL

I am using this for my own game dev purposes, and this is beta-quality software.

"Bloat"-ish extensions for Pyxel, that might not fit the retro game-dev aesthetic, but fits more for the "let's throw up some constraints for our game jam so we can focus" aesthetic.

Fast TTF drawing for Pyxel, including support for layout (align, wrapping) and experimental support for anti-aliasing. 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 and a center-rotation extension.

alt screenshot

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.
  • max_height: Optional[int]

    • The maximum height of the text layout in pixels. If None, the height is not constrained.
  • horizontal_align: str

    • The horizontal alignment of the text. It can be one of the following values:
      • "left"
      • "center"
      • "right"
    • Default is "left".
  • vertical_align: str

    • The vertical alignment of the text. It can be one of the following values:
      • "top"
      • "center"
      • "bottom"
    • Default is "top".
  • line_height_mult: Optional[float]

    • The multiplier for line height. If None, the line height is determined by the font size.

Center Rotation

from pyxelxl.rotate import blt
blt(80 - 32, 60 - 32, self.square, 0, 0, 64, 64, colkey=0, rot=self.angle)
# The rotation center is at (80, 60) in the global coordinate system.

Advantages

  • Fast for font rendering
  • Easy multi-font size support
  • Anti-aliasing algorithm for non-pixel fonts

Acknowledgements

Heavy-lifting done by fontdue, and obviously this library will not be here if not for Pyxel.

Project details


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.18.tar.gz (165.3 kB view details)

Uploaded Source

Built Distributions

pyxelxl-0.0.18-cp37-abi3-win_amd64.whl (320.5 kB view details)

Uploaded CPython 3.7+ Windows x86-64

pyxelxl-0.0.18-cp37-abi3-win32.whl (312.3 kB view details)

Uploaded CPython 3.7+ Windows x86

pyxelxl-0.0.18-cp37-abi3-musllinux_1_2_x86_64.whl (662.7 kB view details)

Uploaded CPython 3.7+ musllinux: musl 1.2+ x86-64

pyxelxl-0.0.18-cp37-abi3-musllinux_1_2_i686.whl (687.9 kB view details)

Uploaded CPython 3.7+ musllinux: musl 1.2+ i686

pyxelxl-0.0.18-cp37-abi3-musllinux_1_2_armv7l.whl (758.0 kB view details)

Uploaded CPython 3.7+ musllinux: musl 1.2+ ARMv7l

pyxelxl-0.0.18-cp37-abi3-musllinux_1_2_aarch64.whl (669.3 kB view details)

Uploaded CPython 3.7+ musllinux: musl 1.2+ ARM64

pyxelxl-0.0.18-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (491.5 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ x86-64

pyxelxl-0.0.18-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (494.9 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARMv7l

pyxelxl-0.0.18-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (492.4 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

pyxelxl-0.0.18-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl (515.6 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.5+ i686

pyxelxl-0.0.18-cp37-abi3-macosx_11_0_arm64.whl (429.9 kB view details)

Uploaded CPython 3.7+ macOS 11.0+ ARM64

pyxelxl-0.0.18-cp37-abi3-macosx_10_12_x86_64.whl (436.6 kB view details)

Uploaded CPython 3.7+ macOS 10.12+ x86-64

File details

Details for the file pyxelxl-0.0.18.tar.gz.

File metadata

  • Download URL: pyxelxl-0.0.18.tar.gz
  • Upload date:
  • Size: 165.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.0

File hashes

Hashes for pyxelxl-0.0.18.tar.gz
Algorithm Hash digest
SHA256 b5e3b63c3d4e18066d5c081e54e22b730a2d81d59204bbb2a5ca2f6bf71ea06f
MD5 4f3707890277dec385739be633fc77b1
BLAKE2b-256 49f454037c44406263ba46fa40143f8effab01bc0e98dfc553211d1fb7d6f4c0

See more details on using hashes here.

File details

Details for the file pyxelxl-0.0.18-cp37-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for pyxelxl-0.0.18-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 63769b7103b003e662253bb7e7c7405b0e7f898ee64220b9c9f29f29a7412fa9
MD5 a36cc2c68073a3d72688fda90f1f00a2
BLAKE2b-256 92be682080b55da2921259b7695c01392131a3e1e8a70a26589b9e962bbc4a7b

See more details on using hashes here.

File details

Details for the file pyxelxl-0.0.18-cp37-abi3-win32.whl.

File metadata

  • Download URL: pyxelxl-0.0.18-cp37-abi3-win32.whl
  • Upload date:
  • Size: 312.3 kB
  • Tags: CPython 3.7+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.0

File hashes

Hashes for pyxelxl-0.0.18-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 9c0f92da73b23c8ccce17630ae3391508fcbea0b3e28e6d01d1dd1c701f60115
MD5 80f2f4a402e33c247518295d5f6b6214
BLAKE2b-256 ba0cf69352c3ce4527bd8af3fcb69fd938bd891063415673805847dde74553b5

See more details on using hashes here.

File details

Details for the file pyxelxl-0.0.18-cp37-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyxelxl-0.0.18-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 581beabbb1c26e3b34c302759cb2845f90b667102e614ebb6fd634a5488ec664
MD5 a2a1eea3075853a9ff45185ff349e1f7
BLAKE2b-256 4718e43cc2b1372c7ededfc9d0ee9ed15fd48aaaeb33ccb6178bdc7a015c30ea

See more details on using hashes here.

File details

Details for the file pyxelxl-0.0.18-cp37-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for pyxelxl-0.0.18-cp37-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 cba56f12277d156cd0079f2fbd830204c120a4fd6d1487676376c1ad2bafb684
MD5 78521391d149daf18f6a7bfb50fcfb10
BLAKE2b-256 099f8c83778a5ee683cb531f36d763b83bb1747ef13f8775109feb1017acde56

See more details on using hashes here.

File details

Details for the file pyxelxl-0.0.18-cp37-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for pyxelxl-0.0.18-cp37-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 be69149b0ca9fabb15a200294274bddbd11c26aa02ae8bde806fd35f9edecc7a
MD5 6b78b6cc607455804ed34da0a2324d5d
BLAKE2b-256 519a3e3c861e056312be0adccfcc2237b80e08ed5c7c91c6f9daf5ed78282ec1

See more details on using hashes here.

File details

Details for the file pyxelxl-0.0.18-cp37-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyxelxl-0.0.18-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 53ce6f217b8f1de69870bd9dce06e3d494328e7ad30c5f9941a4cec0b2c290a8
MD5 e1e8ecbfd3307866ab638d5789b1f4db
BLAKE2b-256 dc477207f8573e737c952431d38f9ec5d193a2f59dc24c752a3e1fce7ada839d

See more details on using hashes here.

File details

Details for the file pyxelxl-0.0.18-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyxelxl-0.0.18-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7950ac26397c2f8e2d22a21cd22b989117a8d201195a7db549e369271944ce58
MD5 71ceb4510a1aa9c19f32303942ba391a
BLAKE2b-256 49c6c26294ca4b7e7dbb46cc9c0e0186cc661845c0f87a8aee19033178fb80a6

See more details on using hashes here.

File details

Details for the file pyxelxl-0.0.18-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for pyxelxl-0.0.18-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 3de72854c69d5b461729cf120f39e3467ba9101d2856d8d23963964940efd043
MD5 3159966891b5b2d0a0ae0243d515d482
BLAKE2b-256 cebbc7e9dfe3e83f5a6719e47a91603b9fe66b85425dc1a51b8ee118eedce1cd

See more details on using hashes here.

File details

Details for the file pyxelxl-0.0.18-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyxelxl-0.0.18-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 57f5fa86c3a644666ade67161822dc385897e48aee9fb9979de5e1f26bae0c82
MD5 c3ba11e5a938d55d3ce2621ec7b75196
BLAKE2b-256 65707ea30a9533d060de56acd86ee1a42a3d054213e3326dfb5d4657eeb06c05

See more details on using hashes here.

File details

Details for the file pyxelxl-0.0.18-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for pyxelxl-0.0.18-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 2b2cc374c6233b6ff24f820f3d5b5d064bddc21545d651e0ee79473df22720e4
MD5 abb488d24952271fc8a0d7eaf5abe3ee
BLAKE2b-256 74ef39106862a7a5f7d1bedbf98f93f4ad5db49c4b78d1dd7b4e7b608cfc9abb

See more details on using hashes here.

File details

Details for the file pyxelxl-0.0.18-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyxelxl-0.0.18-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e3cb4b5b4734429f90e183021f76ec36775225128347f04e89f86cab51ba5f4d
MD5 0f5c0e61ed2e86eb92af607aeee4a643
BLAKE2b-256 e1ccebd58e3737ffdf580c003d23b2bd682a14b154d5a511edd0d709e48ed13d

See more details on using hashes here.

File details

Details for the file pyxelxl-0.0.18-cp37-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyxelxl-0.0.18-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fd5e62c7ce8703957dc7c267b3c6b195fa73258a0f8d63946d2232d0b100b5c9
MD5 2f72f9eb14c6f2b9178932d95c709536
BLAKE2b-256 78a3cadd871b92ede4917524f790247ea27e64a40558d5cbf58f3c5a4b505c62

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page