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).with_shadow(True)
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 |
FontSystem.measure_family(text, size, family) |
Measure text with specific font family |
LayoutOptions(size) |
Create layout options with font size |
.with_shadow(bool) |
Enable drop shadow |
.with_max_width(width) |
Enable text wrapping |
.with_align(align) |
Set alignment ("left", "center", "right") |
.with_line_spacing(spacing) |
Set line spacing |
render(fonts, text, width, height, options) |
Render to RGBA buffer |
render_family(fonts, text, family, width, height, options) |
Render with specific font family |
Font Families
| Family | Description |
|---|---|
FontFamily.Minecraft |
Standard Minecraft font |
FontFamily.Enchanting |
Enchanting table font |
FontFamily.Illager |
Illager runes font |
License
MIT
Release files for mctext 1.3.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 | |
|---|---|---|---|
| mctext-1.3.2.tar.gz | 29.8 kB | Details |
Built distributions (wheels)
Total release size:307.2 MB
Release files / mctext-1.3.2.tar.gz
| Download URL | mctext-1.3.2.tar.gz |
|---|---|
| Size | 29.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
925c01d709c38cbf297e9b82b3a5c9bd4063f54be3e7d6bf04e5ced49db3293c
|
|
BLAKE2b-256 checksum How to use checksums |
c9a15715d48dcb2a39948523f97d73997c80550875cc5edebe92c20ccda81e00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / mctext-1.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mctext-1.3.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 23.6 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
dfacbdf0a1e9c0916e5e651f979e959ea6cc7f47f6d4d89a44f78feaa4c0caf8
|
|
BLAKE2b-256 checksum How to use checksums |
baa12ad6a42deb51fc305efa98790a4079b37b59c0fcef8e759289aee9bbc402
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / mctext-1.3.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | mctext-1.3.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 23.6 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
50f9d85085df11c011e807d36208ae1486550a900799a72edef93d9d3c227f96
|
|
BLAKE2b-256 checksum How to use checksums |
f59a2ebfcc4e5bb87b70f76bf7813055ba7ff4d332f99ddbac966ae0632b71de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / mctext-1.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mctext-1.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 23.6 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
fab8c04aa5d40d4f0153cf37e8fb62c08e534b7d57b36fda49a6c71f391c37c3
|
|
BLAKE2b-256 checksum How to use checksums |
cd85f24f1e7f8c220cda80238fb7e6cfec0ea55f781163f8c58faddeed76769d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / mctext-1.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | mctext-1.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 23.6 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
0313b1c35dd9abee7d3992ff445f8f5b495d30e0e8489aac8d86090d5ffb9ba7
|
|
BLAKE2b-256 checksum How to use checksums |
48b78128f5d4ff2a767c2caa87cd3c19e8645d4b27f4641a83c4d30e4746e989
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / mctext-1.3.2-cp311-cp311-win_amd64.whl
| Download URL | mctext-1.3.2-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 23.4 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b01083e8d86cb18256c638fd54e7508e0ea97f96fc140a7e1861bb3b4339249f
|
|
BLAKE2b-256 checksum How to use checksums |
632b9e0db3a03e2c5221944ab4c47899a89c4bfd8be3ca3a9a29f817d92a3827
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / mctext-1.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mctext-1.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 23.6 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
4e7b5ff0f65df7c7ce24fff0941a2a6c729dc3da2e5139657557427a96ef2b0e
|
|
BLAKE2b-256 checksum How to use checksums |
0189fa6de2da65959d4013109996b6ba2c5a0cb9fa139db9792387e4d3024ec9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / mctext-1.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | mctext-1.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 23.6 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
bdbd5d6eb7589daf84fcb8f567aee9fd01096d76baf37aca578a11dfee1b2b02
|
|
BLAKE2b-256 checksum How to use checksums |
b22cd384be7cf33fb3fa861e3d6e4d478b0da40f867785064169b5185e281b6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / mctext-1.3.2-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | mctext-1.3.2-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 24.2 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e36317e1cc0d83d817a3ee22efa7b3af48b32b56fb96fdea09d0b86968f72615
|
|
BLAKE2b-256 checksum How to use checksums |
cb1a4e3d6a5d70dcf03976138c8adb89d09bccc4cb819e84e37bed0358882fed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / mctext-1.3.2-cp311-cp311-macosx_10_12_x86_64.whl
| Download URL | mctext-1.3.2-cp311-cp311-macosx_10_12_x86_64.whl |
|---|---|
| Size | 23.6 MB |
| Tags | CPython 3.11 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
81268fb7a4d2d2825b1173a300392add2fee8a6437e9fa12f4ef6be848e71db0
|
|
BLAKE2b-256 checksum How to use checksums |
19d9359642e33305c3824b647678005a6a3706237c54d754259767c23088fcf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / mctext-1.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mctext-1.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 23.6 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
1e13f1b061c9ae43e75f767027f095da93254e9d669666d8083eabb40ba6e99c
|
|
BLAKE2b-256 checksum How to use checksums |
84ae7e6adf5b1e0cdb9e1e49e70c1c21bda9790c3860a1ab96fa18801e7bb8d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / mctext-1.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | mctext-1.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 23.6 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
fa5df394f0acb548d61f27f638175da485608d3c12d05b57f4a70ccb2da4bf7f
|
|
BLAKE2b-256 checksum How to use checksums |
cdb193e81fe3fc37d779f5f76e5492733c4a6ab5932ee75946ef43aba2cf31e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / mctext-1.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mctext-1.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 23.6 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
38599934989ace93583763ef331438f3db0e072e551ec664ead32aaf0255d7d3
|
|
BLAKE2b-256 checksum How to use checksums |
16df1884a7bc2666ce9cf87a844a62cb66f75911aeaf00faaf0eb0be826243c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / mctext-1.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | mctext-1.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 23.6 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
e06fea0a23a0d68a877266b7681c6dc12a335536af756765229c5b28f84fb365
|
|
BLAKE2b-256 checksum How to use checksums |
ed524eadf8c625138f7ec643f4a485a03fe44772a51282c847711c492b4efb29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|