Skip to main content

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mctext-1.1.3.tar.gz (29.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mctext-1.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

mctext-1.1.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

mctext-1.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

mctext-1.1.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

mctext-1.1.3-cp311-cp311-win_amd64.whl (12.3 MB view details)

Uploaded CPython 3.11Windows x86-64

mctext-1.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

mctext-1.1.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

mctext-1.1.3-cp311-cp311-macosx_11_0_arm64.whl (12.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

mctext-1.1.3-cp311-cp311-macosx_10_12_x86_64.whl (12.5 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

mctext-1.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

mctext-1.1.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

mctext-1.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

mctext-1.1.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

Details for the file mctext-1.1.3.tar.gz.

File metadata

  • Download URL: mctext-1.1.3.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for mctext-1.1.3.tar.gz
Algorithm Hash digest
SHA256 28d52f05b7b5b08221a84aafcafaa8c01c25019f4596cc698d49eb32d2cb42e4
MD5 f2fe209876678904c4d83082cfafb370
BLAKE2b-256 e3593d25f7c3991ac40db1465d41485e841b86ba330a40b047acc83c1b175e08

See more details on using hashes here.

File details

Details for the file mctext-1.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mctext-1.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb779d78ebc5f10c38f1d7fc85519bea0cba6b1dd39c141c22943760ec69c739
MD5 3595411e643ac1a166ee570e5c4302df
BLAKE2b-256 f77b59f82b7ba8339f2de45908a2546aebb5f2ed4d6c9878be5e6a9f7c269ff7

See more details on using hashes here.

File details

Details for the file mctext-1.1.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mctext-1.1.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 20393ee5a0cf7cb69e4931abba2f118b38490018c1436d6019be04d3facd3177
MD5 1c3ad1d62b0f68c735bf7f98a93c7207
BLAKE2b-256 a14d869d2f8c8c28d0e4b923eabe9a33d976544fd95874d2c52b73bcd45b4fdb

See more details on using hashes here.

File details

Details for the file mctext-1.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mctext-1.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eee175f1b30ab661ca7847895f7a5f36e32ee1f665a793d66f3d9b0fd3e35242
MD5 e3916fe530c82e6aec35448cf9f7035f
BLAKE2b-256 cb3e3c26bdbae290712785cce9e9cae493dda7880d5eb131c7fc74d1c3fa2e50

See more details on using hashes here.

File details

Details for the file mctext-1.1.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mctext-1.1.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c220b2acd67139079adba444170b64613a07d652fefdf161f9fe1ec7d875e535
MD5 f9f6cbb5a180507d7c171e69aaadf4e5
BLAKE2b-256 095e1df71899e49793b47ebbb4b586b6f9b687af01b776c10fbc28c680a4d7fe

See more details on using hashes here.

File details

Details for the file mctext-1.1.3-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: mctext-1.1.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 12.3 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for mctext-1.1.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d366e8dfdc96ed03ec092166156112cf72bc543b8aaf926ce55a82cfbb12f2ca
MD5 2803f8ced5345a69feb73195ed26a65c
BLAKE2b-256 8886669430876de431e60c671a72311be46d91793fd68e295b7b875f0ee5fa49

See more details on using hashes here.

File details

Details for the file mctext-1.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mctext-1.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f2528b34deed5372629036c144af727090cfaf7db07a8d674f68285cd3e9e2ca
MD5 1b62ed1e4cf78b02f0057e88cd13e39e
BLAKE2b-256 33ad58d10543775f1d0f16fe898c853f3739b0c65f738c84198e95e7d5f8a6eb

See more details on using hashes here.

File details

Details for the file mctext-1.1.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mctext-1.1.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9445de0a3e1a4655d4f570d70b803cb7a6a13531ccc0a2dadf108e48464a02ce
MD5 609733dd555428573ac5dbfbb0a39ea6
BLAKE2b-256 5e7b92bc8a70d20900babc0e5e90df6516c585c2b618cb8b993c23ed10f678d1

See more details on using hashes here.

File details

Details for the file mctext-1.1.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mctext-1.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ee8905f2a381cd4eec45c179384d3d80ba71152ab1f7fcf2608fea56c01ce1b1
MD5 f849141c802a442fbb0782ed8535d552
BLAKE2b-256 d0508251791b82470b29c9db143376f4934fadef6c2806a6c3513e4f2436ee81

See more details on using hashes here.

File details

Details for the file mctext-1.1.3-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for mctext-1.1.3-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cec30cea20a78e81c899dd85bc63889aae35a49669a75aba8195384e85d37880
MD5 4e5a3667adee37620b3306ed87fa1351
BLAKE2b-256 3929c13161b745bacfc7ab7079b1e680af600e303a3d1c4af56ecd5b9a0c7018

See more details on using hashes here.

File details

Details for the file mctext-1.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mctext-1.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5bc978d7faa2d5b16a8d77c30f601da25cecdbbf3f92273165ac822a86be4381
MD5 5d2e22acda0625adedcaa29aee868333
BLAKE2b-256 32d90f7b7eca0383ac92ccfaa61ffc0c6b09e8b6291e2b6800c7eb0f1a42e82f

See more details on using hashes here.

File details

Details for the file mctext-1.1.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mctext-1.1.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 77029c2338e6559072d151b84817b0b51693fa10b3e0b534798c4789c93fb378
MD5 86f661801b13df4f4e9c4c08394271f7
BLAKE2b-256 a102c7dfe3b886b986d18e514df3ef667a3c0d9829721cabdba322776ebb2b9c

See more details on using hashes here.

File details

Details for the file mctext-1.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mctext-1.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 88f9af3564210ffd7fc4edaa735f445a55b106cbb9545f3db82d15f372ae04de
MD5 2612ed1e126145b4b21f24c9c345c5db
BLAKE2b-256 087a4bddb7bc110059244413fa7582119c75a2ae37078a189e355410a9ab214e

See more details on using hashes here.

File details

Details for the file mctext-1.1.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mctext-1.1.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 aaf2a062ea95901ed3051e9f55de14a4cfdecd8ccb35a950e587ac8b3df97bf7
MD5 a57e3a4f863a5cfd57c857199add24c7
BLAKE2b-256 f87bd9910bf1b3a8c7349e08cc3ac76f4e54619920f3e134566a52ac7970ec47

See more details on using hashes here.

Supported by

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