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).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

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.3.1.tar.gz (29.8 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.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

mctext-1.3.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (23.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

mctext-1.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

mctext-1.3.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (23.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

mctext-1.3.1-cp311-cp311-win_amd64.whl (23.4 MB view details)

Uploaded CPython 3.11Windows x86-64

mctext-1.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

mctext-1.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (23.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

mctext-1.3.1-cp311-cp311-macosx_11_0_arm64.whl (24.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

mctext-1.3.1-cp311-cp311-macosx_10_12_x86_64.whl (23.6 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

mctext-1.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

mctext-1.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (23.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

mctext-1.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

mctext-1.3.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (23.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

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

File hashes

Hashes for mctext-1.3.1.tar.gz
Algorithm Hash digest
SHA256 470a176a9d987294a0b6d8b748c00e2acf32eab7f9a499832451e7c6e8c62b70
MD5 316d04f0322a535d15704153c63147d6
BLAKE2b-256 b3b9652695c07d211f21780dbd868cd10563231067b38226062923c7285522a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3f4fa79512bf970aab46f289060c915b413d0775ca2228897188c042dc1ba37d
MD5 f7f6dfd23c38cc666bd3c055f84cdc54
BLAKE2b-256 f906684ff885e22d80833d7ec10f6b926f1f8b03372efacaac9a2cecc494f55a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.3.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a31d81c93113c0ea1c43d26a69c87726f5189ea815d509755b697fbb21d78665
MD5 6988c9de0707b46d30dbadc8ba3b979e
BLAKE2b-256 63eedea46e418b7c4658e05d44d137c04ef7a94feed1c6591077de4c14b9582e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b87204821274cfee16bfb3f9e84583122a63fd2875bdf718bc3775ce6bdab62b
MD5 7c156ca53b1aa624e148a285c95ac25d
BLAKE2b-256 774b60fa35bd909696fcc87394a64f87553540b2e401107be180c134859b9aee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.3.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5123cf79e7621cb4b9e5d9297d1e9b957b54e1848b1d95cb6eb79328dda65522
MD5 34b5c096bcff3a219feac6c3eb54a697
BLAKE2b-256 1cf37ca7dc813f1cbe2edce4db190f65203fcd58728710d0f4ae25dcef19dc55

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mctext-1.3.1-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

Hashes for mctext-1.3.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c7e7f468046ae9e081c60e1aeb7f0043aeeb66651d279a9ff41ffd6c290b2bf1
MD5 d7dd4aa61b3ada4fcfc0dd47d9729c83
BLAKE2b-256 d5d8f2d06740015f8359381ac14f78e965bbdd4266094d19dd3877d7db5bef45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2ae9e6aeccb25f42e61e6949116527c6f523f03db9ac3b4eb66b5eda4d191a3b
MD5 1e8d5f2250abc0347d4fcdfb04052db9
BLAKE2b-256 9d13c2d53194b6291415813c7811dcec4d080944c1d311358416a951567e0b44

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d11cc029eba0812678d49ab207e7b544be58591c6dd5130af0c0a9a09a42f10d
MD5 562fbc55340b639a460ac24717d70390
BLAKE2b-256 5120f321731a53cff535c0753d33e909abadeadbb752a280d0080cbe62f5ef12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.3.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4de031e1e06110a878f8b5a8213041558e4e598f8f516b91a541c9135bed5dc1
MD5 3cff578ec67078791f7bcb33e460b0f6
BLAKE2b-256 3165854f9ba644cc2845a424520d91fdfa6ae4a3f4df11534ced6882de9f4485

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.3.1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2f6e6f7e24360d561bf1bd0da9873d3360cbc01e261dcfbb09af7bc5ddefd418
MD5 1979c165805f0cc36afd49a341e6b820
BLAKE2b-256 339f1219985a177e4ea6a59a405a5da340059ffeba1a53f170d8d681393adeae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4cbfed7cbedcf60646b1babac42298c595af3312e1d22462c3f7718c46412b31
MD5 ecb92800e979c73740f2394fb550b950
BLAKE2b-256 85ad723570c80c74a8686fadb406789dbf33f6a6ad979de420d30ffbac83970e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d0884edbbe50e6c02e523961936381f8d87b57bb58f07ff046c6ab3c5f825553
MD5 1d1f6a28589302dd5882618cd245186f
BLAKE2b-256 92c443216cb5f565bdc89d41ccfdb60c842208a053ac7f81289ddd19f7925141

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 40351c9643cb85b3f02a4a81a5580029b2c00eada175aeed1eaad502be2870e0
MD5 5197453160710ca9b85e01b7e316dff1
BLAKE2b-256 4588d8c0171dfd78bf52db624aeefe3a7ef1e165f993a72391da381398f3d826

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mctext-1.3.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c2b51201a70f1a6a2ee7dee4405912678618471b708d1aa57e9d9e3dc89a9044
MD5 bd219d8ceebcc9203f8f51d2cc3a0fbc
BLAKE2b-256 cc387a7663ce816757504f46a8e62eb024f1e0f84e3afca9163a4a82e8b777aa

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