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.4.tar.gz (29.2 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.4-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.4-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.4-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.4-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.4-cp311-cp311-win_amd64.whl (12.3 MB view details)

Uploaded CPython 3.11Windows x86-64

mctext-1.1.4-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.4-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.4-cp311-cp311-macosx_11_0_arm64.whl (12.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

mctext-1.1.4-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.4-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.4-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.4-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.4.tar.gz.

File metadata

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

File hashes

Hashes for mctext-1.1.4.tar.gz
Algorithm Hash digest
SHA256 a27ba29673a8d9ed4c4214054970bd3250008ecb5f9db1e37b9622579c61b9c6
MD5 cf0762807969aecec8d1ecd48441c2fe
BLAKE2b-256 4a4834cb697ce7375cd46c3a322204ea1459d77e44a7dc00f7bea0841bcbdbc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4f6ad9cbe9bcc9c35e2cb58edbba96abbe2e86812fbc34a22f409e803660f203
MD5 2955e0089bd23bc5f31b8fac84a07dde
BLAKE2b-256 06cbf0398db84eddb3b3b25ef28552e3e1400164e5a2e223213968ac4c0f485b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e451877673d5a51c34c04c5c9e828f10cf80c3857497b1c9131cf8070d1bc9ba
MD5 6daead6b8f1952fb11392f34cea6fa31
BLAKE2b-256 e8018f4d884343a491ff5147aff75aacfa23eaea8f62a5cb74c36cce6b8230d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 35cea3f20fb85a83868bef136ddc6324ed7d89f5dbca387c3cd399cd6ac315b6
MD5 33c412f59483aa9365dbecc275f37649
BLAKE2b-256 6864ca778935a78233f3a7343edf0115431cc382fd8aa0bfb8e4fdfce250ed18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4c0c9c68db975a4f72c1bbb1d724220ff0b914ef2e75f242adcdb437a9c3c98c
MD5 338a510a9027a0fcf56befe21ada3eaf
BLAKE2b-256 8d6646973be5504256a8a18e538a55459fa6ee86c1c8b1d58ae8011e414012d5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mctext-1.1.4-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.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 02213fdcbbcbf5e0d6ca9aae2cb951e5a110582bfa88f5d297897542ff98afaf
MD5 d82adf18dc6e5b18f9ed51738973dd5d
BLAKE2b-256 a0c85b0838689d43e0a002f06cda6173d2d3e237bfd3263d886b9cc5314385ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e638ad07b9ea532351687772545b61dd72aea7ea15de707573d3668b272c6230
MD5 2265b417a5e1347522540efc4f7c22f2
BLAKE2b-256 87fa6e1191d35d4e92e58c265bfc7d3f197fc674e8d65ca2fca67e337ecf6314

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 44b3e30f9c60fd1715131debd6e4566bc1b628649cdb00f6cffad8a95660b1b9
MD5 12be6de966b084a49f97b4ba0cbc6f95
BLAKE2b-256 89eee86fc04c5adb7bdab2a9b870aad4b518e2a815b24d0398c6213c58e65b65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 93f6a2b7c8d2ba6888d951860176d4cdf54c684dc02d70df79f908fc8af953b0
MD5 62c1ba94ff167f59f4e1bf3cc1e9bf19
BLAKE2b-256 90850eb3d35ca163c15dd8998cfe3f196159c6daa7017c078e31dace67601bd0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.4-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6a1c2ee8d822eb9c28ddef00143846c6c1b5dceb9f3bcdd4b5329ba52d00cbbe
MD5 4ab5aabc8d214370c87933c305e572ca
BLAKE2b-256 cdf0e46c85dfadccf9c8997cdeb176c31862eed85775e429c17970d913436510

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 33565df5bbcb829e69f52f0d7366d68db336b63464f811657ad6dba317b8ea8b
MD5 572deb12a674378dc8aa1ae4f4983947
BLAKE2b-256 ee2fea343d39157799b6c0f02ccc69ca17f9a0b026b1f65e1546c965d0fd2a6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0c634db2b196952db3be896ab5bb4532e4d3db64f5b31a0ff63e31f4017025e6
MD5 f33e86602742aa3f32ccd8aebe1e32b2
BLAKE2b-256 87f72270aaccbab9c3c110d282f073175ddd8bbc92cb9aeb46bf834b0ec3bebc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 11ca44519ac5b3d3132498719b6e522f16bc917c5e8e812067b97ada6ea7db6d
MD5 458960c01b657e227706d8a8f8f9f656
BLAKE2b-256 31bc6dc192008c19f779e348381cccdd8879bba3b46f638489a4c7daa00da26a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 737532ec35cab5d9eb6dccbbcf5feb1b7bdbd6f816302b1dac14bb0f038570a5
MD5 3070266b7021585b4a3ac5de78331624
BLAKE2b-256 ff212f9da82712fe085d290c466e9d45611492fc68759f8ad84043927f3dd34a

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