Minecraft text formatting, parsing, and rendering
Project description
mctext
Minecraft text formatting, parsing, and rendering library. Features all the exact glyphs used ingame, for the fonts of both pre and post-1.13.
Language Support
| Language | Package | Registry |
|---|---|---|
| Rust | mctext |
crates.io |
| Python | mctext |
PyPI |
| JavaScript | @hexze/mctext |
npm |
Features
- Builder API - Fluent interface for constructing formatted text
- Color Support - All 16 named Minecraft colors plus RGB hex colors
- Style Handling - Bold, italic, underlined, strikethrough, obfuscated
- Font Rendering - Measure and render text with authentic Minecraft fonts
- Legacy Support - Parse
§formatting codes and JSON chat components
Font Showcase
Installation
pip install mctext
Quick Start
import mctext
text = mctext.MCText().span("Red ").color("red").then("Bold").color("red").bold().build()
for span in text.spans():
print(f"{span.text}: {span.color}")
API Reference
MCText
| Method | Description |
|---|---|
MCText() |
Create empty MCText |
MCText.parse(text) |
Parse legacy § formatted text |
MCText.parse_json(json) |
Parse JSON chat component |
span(text) |
Start building a span, returns SpanBuilder |
spans() |
Get list of text spans |
plain_text() |
Get text without formatting |
to_legacy() |
Convert to legacy § format |
to_json() |
Convert to JSON chat component |
SpanBuilder
| Method | Description |
|---|---|
color(color) |
Set span color (name like "red" or hex "#FF0000") |
bold() |
Make span bold |
italic() |
Make span italic |
underlined() |
Make span underlined |
strikethrough() |
Make span strikethrough |
obfuscated() |
Make span obfuscated |
then(text) |
Add another span and continue building |
build() |
Finish building and return MCText |
Span
| Property | Type | Description |
|---|---|---|
text |
str | The text content |
color |
Color | Color (named or RGB) |
style |
Style | Formatting flags |
Color
| Property | Type | Description |
|---|---|---|
name |
str | Color name (named colors only) |
code |
str | Format code character (named colors only) |
rgb |
tuple | RGB tuple (r, g, b) |
r, g, b |
int | Individual components |
Style
| Property | Type | Description |
|---|---|---|
bold |
bool | Bold text |
italic |
bool | Italic text |
underlined |
bool | Underlined text |
strikethrough |
bool | Strikethrough text |
obfuscated |
bool | Randomized text |
Utility Functions
| Function | Description |
|---|---|
parse(text) |
Shorthand for MCText.parse(text) |
parse_json(json) |
Shorthand for MCText.parse_json(json) |
strip_codes(text) |
Remove all § codes from text |
count_visible_chars(text) |
Count characters excluding format codes |
named_colors() |
Get all 16 named Minecraft colors |
Rendering
import mctext
text = mctext.MCText().span("Hello ").color("red").then("World").color("red").bold().build()
fonts = mctext.FontSystem.modern()
options = mctext.LayoutOptions(16.0, None, True) # size, max_width, shadow
result = mctext.render(fonts, text, 256, 64, options)
# result.width, result.height - dimensions
# result.data() - RGBA bytes
Rendering API
| Class/Function | Description |
|---|---|
FontSystem.modern() |
Load post-1.13 fonts |
FontSystem.legacy() |
Load pre-1.13 fonts |
FontSystem.measure(text, size) |
Measure text width in pixels |
LayoutOptions(size, max_width, shadow) |
Layout options |
render(fonts, text, width, height, options) |
Render to RGBA buffer |
License
MIT
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mctext-1.3.0.tar.gz.
File metadata
- Download URL: mctext-1.3.0.tar.gz
- Upload date:
- Size: 29.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff7e21a384193ce4b821ab45788b350dbc9eb5170ef2b1a0674423ce40ad5fc5
|
|
| MD5 |
ee93fb9b6a286130acc7f656b7dc54bd
|
|
| BLAKE2b-256 |
dfea86ff361933c3396749db1c8b5d9575ed031625b8f74d0647acda2d055d97
|
File details
Details for the file mctext-1.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: mctext-1.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.6 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7404710155b68e0e9baf99734c01b88d9bc60935f37324e1b6203afc2692d052
|
|
| MD5 |
c260f84635008aa71e36308bdfb67102
|
|
| BLAKE2b-256 |
dc01f0a55ff812bc24770f12734fa8228a095600ae084f51f02a31d39fd79740
|
File details
Details for the file mctext-1.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: mctext-1.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 23.6 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6884806f25f945329f612ecd5b713d65845bdd09a8eef35183ce4fd802a757c6
|
|
| MD5 |
198d2cc0342f4cec516f4ce8d329a0eb
|
|
| BLAKE2b-256 |
f306260bd905a48708e5ed2af5b923e19361e3f7285d5340d57599ee89087001
|
File details
Details for the file mctext-1.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: mctext-1.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b2dea63394f30ba3591a815da87d1534b5b79c71687d414e8e3c2e83e412ff1
|
|
| MD5 |
56009221f4f962ddd8a3d64eff1e5de9
|
|
| BLAKE2b-256 |
089e534601b8020d37e45530ea564394ab8d2859691aa4f7515cda4e99b4cc94
|
File details
Details for the file mctext-1.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: mctext-1.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 23.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45d220803752bc2d2e00f0314c33fb1c01d748b4982a208a2f46e4502d2de963
|
|
| MD5 |
94fc8efdc8412d11976b408f15e78317
|
|
| BLAKE2b-256 |
3414ad9f79508cc79cd2c247d17dbf4d36526934b7125c97f693986703b12bbe
|
File details
Details for the file mctext-1.3.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: mctext-1.3.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 23.4 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a793588bba2e00a7fe0ee7a06b566699a90e822e9841bed4ef41728f5d8d4c8
|
|
| MD5 |
e91bea734ebc0dadd139d5195679591d
|
|
| BLAKE2b-256 |
2244f4d6728a5633da7fbbb4b6d5848e267b3e86b8313cde39b96f351b8078bc
|
File details
Details for the file mctext-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: mctext-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d21164d981ed5a820353f31c9fc42540125383afc82765dcd3bb834efe19df20
|
|
| MD5 |
8c8477bcc0858c5a4c91986c56a41799
|
|
| BLAKE2b-256 |
06af95a72fd4f3cfc8aa63be2709dbcb6756b9d9378a62e102d2abbb5f7d0045
|
File details
Details for the file mctext-1.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: mctext-1.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 23.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c1cb716db2ec506b456079019223fba781e972c1906bbd04359c434a994ac0f
|
|
| MD5 |
886a153b14973baf942edecac4f6ddbc
|
|
| BLAKE2b-256 |
ba9a290523edefedada71db5f44bcf0560e623072327ba8b7dd9444bf6607e5d
|
File details
Details for the file mctext-1.3.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: mctext-1.3.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 24.2 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5148bc8f8da304a010081bc6e822b5476d4f6cd500a0553fd965f2af8976ef7f
|
|
| MD5 |
283df150dd482e519320b73520460045
|
|
| BLAKE2b-256 |
1bf36bf63398e3af9ebce2134bcfecb7340ae73c56a2dede6117e7d90163df81
|
File details
Details for the file mctext-1.3.0-cp311-cp311-macosx_10_12_x86_64.whl.
File metadata
- Download URL: mctext-1.3.0-cp311-cp311-macosx_10_12_x86_64.whl
- Upload date:
- Size: 23.6 MB
- Tags: CPython 3.11, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32a62b22e418e335fcfe61a46ad156428ae5380821d1e365a040372ef26f0b3e
|
|
| MD5 |
47bf8bec525ce857e7bde397f768e790
|
|
| BLAKE2b-256 |
7e4e357524d4af4abddf1722c578bb923ca2beabe0a88991d10b6b7cbacc43e8
|
File details
Details for the file mctext-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: mctext-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.6 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
527b789af610921d895e3ba7d72b94643bbbbc147f58f9ed91a56c70b8c3f741
|
|
| MD5 |
6535eba60696ec128b94b53d191c1532
|
|
| BLAKE2b-256 |
2a6fce7684fd077303ffbbc1cb3a9e7e64aac5153af2eb8754130a00aa43d28c
|
File details
Details for the file mctext-1.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: mctext-1.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 23.6 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53cf8f053225f7056bd8f0085248e8dfec47d5bee936df1265a91389ec2b5dff
|
|
| MD5 |
7b998b9e52ed2cc143f39900473574fd
|
|
| BLAKE2b-256 |
bced351bebcb47a78a75255cbd93cb5db5dacc5cc2ac8dd2e0dbd12fbf6423f4
|
File details
Details for the file mctext-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: mctext-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.6 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38ddd79931f61253459ba2b6e229e3a57a8244eab58b55608333febebcf11bdd
|
|
| MD5 |
662b72a0f6bab91af1d07902a1830ef8
|
|
| BLAKE2b-256 |
42f3f3d60f57f12e9f125f4ddb474beaccb56a61fd0cfc8c911fad022c3d0d5e
|
File details
Details for the file mctext-1.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: mctext-1.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 23.6 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42e0688c28d04270638491501468b390c45200bf3617b8051a65df30118decac
|
|
| MD5 |
c566afd257b9f0801c87a9dae61c5dde
|
|
| BLAKE2b-256 |
259b8f157b8b3ce92d88d83c52107c2d450bfda97b599295760616cb82f8e248
|