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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

mctext-1.1.5-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.5-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.5-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.5-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.5.tar.gz.

File metadata

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

File hashes

Hashes for mctext-1.1.5.tar.gz
Algorithm Hash digest
SHA256 7d1d780aca96657e83e42cafb898fc940c62c1d29cff1be81aa6dd22e88c8fbc
MD5 60451553abeb0056c21a46bb501790ec
BLAKE2b-256 8b59afc11de092048aabcdc3bd9bbea31b021579dbb6e8771c292ae8dcc5502a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba571a1af242b31d9f7f07b9e540ab39fc72aa18faa720d4ebe016b07b1235eb
MD5 96e317e70822287e20265e7b0d0f6336
BLAKE2b-256 9fdae459b4f07a3c32739d7a61b2655b46f6f1729e177adda7a73ed005b13b04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ba12a2a043ea1bc12d9a8bcba4c39fbd2eca8666e574401a2d548ed7cc2a6e01
MD5 4da6890d8e5343907d59e9d561cefb2a
BLAKE2b-256 9100f45bc80e5115149ce8fb89bee576012992e7fbe17a98980482a355176a13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1523f2109f2977a62dcf9102c1357ae1083f2ddf340cf1191f78fc637835593c
MD5 cc434e84f5516a8c4fc510e4121b503a
BLAKE2b-256 526ecb096692ffc0bfd1d7e3acdc8ff9a4056c884f6b2a89e3a6c846ad5bf7a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 375d7c054a2db96bf3a7fc465f31aba44313456f82fc2bcada853ffd4827f4a0
MD5 0e5befb15cc62a2b970641aeeb5756f4
BLAKE2b-256 f07d722379fe12fcb175238b337b3af7d4082402809bde725a39df2339b3cdd4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mctext-1.1.5-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.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8816d3db623f187eed8c0ebabd4f5f94f683df10e28e6d56e7742f3b28c9f94a
MD5 bf0fcc6ae40fdd4a00f89a851a921a26
BLAKE2b-256 44b8b086703277f9b559f1d05dcf198eafc92121c4071f8d5e27cbb591a6208d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 be3f19318b3e04703fa813f100d00a9ef52c81c6c0909a594a2855276543178f
MD5 e41c0673dbff98060b5c16bb28b2b023
BLAKE2b-256 39a1e2009754a32b724a7c14cc9528f8f2f38a9562e52605ed467bfbdebb0395

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f4a8b0b8ac32ce716b75dd9cd8f28238f50bb989e1cd3b4cd808de63a6d518eb
MD5 b7fc95635669eca909ce6e9739173e64
BLAKE2b-256 42a4e8374457d9662c12cc4f09d77c258a82fc3e7fc79ec3a41c6b4647e02b9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b9853618d3c1718277344882ea6b52956f7236bc46e50796c45b63166d7dfea2
MD5 db205aa81c3907b736e8ab0c4bdbb26b
BLAKE2b-256 84b3a9d55537d1b7bb2bdd67b3f47484cd1963424453b98c4d070b119542975c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.5-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d15e238930f5fd191db27e7333a5cba27372750a30b9d06e94d3f139ba6965f5
MD5 e6a6b176538dc30e333ab1ba36cecf4f
BLAKE2b-256 47d9aae561629fd8744f89aadcf7f96c7b440bef0a006258193be46176764959

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a8c029d0ef7608c97317a8b42e8fc8ccb0387c34ffb7825de8b0ed23621cdb2f
MD5 4fefa4ad688f8eb420ebadca57dc7893
BLAKE2b-256 b7da8518364de8b82aaaab3c55001661688166a0230efa1036f1f88cddc2e4b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a903a01751834d798f5d0fc6755cff866e289c9501c05f9ca339e696aedac83e
MD5 4fa486a53fbaa16b1f9f03352d52aa89
BLAKE2b-256 b6ac40edd560743c6b44afb80361a5627ffd0c5687e772defa3adc8b52efe081

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7214e467eca69fd1c87e88183c60e80e98ced3f605a68d4112527b9415500371
MD5 7acc3e7287b66ef81537bc3cd64e79e4
BLAKE2b-256 8ab55c5fd84d53f9f1229b72f5490ceefbfe29811f5932111c463111cd00a550

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.1.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 64f4c38de774bc96897621cac0298dea97258078fa8b52bdef40ee8c53af839b
MD5 355da6fcabd39ab8aea7b199e0dfef8d
BLAKE2b-256 b692515194cf2b0dd55d6e5ffe5d784c18323a759a0c39f50066f48d850c50be

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