BMText
Render text with BMFont generated bitmap fonts.
Status: The core of this code is reasonably well tested, but it's at an early stage, it's basically just been thrown up online, and you use it at your own risk.
Why???
I wanted kerning, and I wanted support for a widespread bitmap font format. BMFont is used to generate bitmap fonts from Truetype fonts, and the format it uses seems reasonably well supported.
I have vague plans to extend the format slightly to allow pre-rendered glyphs - so characters could be multi-colored or embossed, for example.
Using it
Install it with:
python -m pip install bmtext
Currently the API matches ImageDraw.text as closely as possible (given the limited feature-set).
from PIL import Image
from bmtext.meta import parse_file
from bmtext.pil import BMText
im = Image.new('RGB', (320, 180), color=(160, 160, 255))
drawer = BMText(im)
font = parse_file("tests/fixtures/raleway-30/raleway-thin-32.fnt")
# FIXME: Overlapping glyphs remove part of previous char.
drawer.text((5, 5), "Antidisestablishmentarianism\nThorough\nSHOUTING!!!\nTomato?", font, fill='blue')
im.show()
To Do
- FNT Compatibility:
- Handle binary font metadata formats.
- Test with multiple pages
- Multiple channel support
- Outline support (2-pass rendering)
- Improve error handling:
- Malformed fnt files
- Missing characters from font (replace/error)
- Features:
- Allow arrangement of pre-rendered characters (rather than single-color alpha characters).
- Implement textsize
- Implement alignment
- Implement anchor
- More testing:
- Test with older versions of pillow
- Port to Python 3.5+ (remove the walrus operator)
Developing
Run the following to install the project (and dev dependencies) into your active virtualenv:
pip install -e .[dev]
Metadata
Release files for bmtext 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| bmtext-0.0.2.tar.gz | 44.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bmtext-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 49.7 kB
Release files / bmtext-0.0.2.tar.gz
| Download URL | bmtext-0.0.2.tar.gz |
|---|---|
| Size | 44.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
141a4dd59a5c4d08ad3960ccb4ac8d044225ab0c24505ab99d79ec67eca3ff01
|
|
BLAKE2b-256 checksum How to use checksums |
0b1118410ed9172d33b2044dc6bc156e6e4a5c8da7bbab04bf55f1ca6226fad3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
|
Release files / bmtext-0.0.2-py3-none-any.whl
| Download URL | bmtext-0.0.2-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
31638429c7c5c0c333fc04b08cd08d48eec102d2c41a7a733b7898737af32913
|
|
BLAKE2b-256 checksum How to use checksums |
422d27c490418c44b5729750e0683e6b137ba8854fa5bcfae81566cd04ee4b7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
|
Security for bmtext 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.