docs.rs failed to build mctext-1.0.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
mctext
Minecraft text formatting, parsing, and rendering.
Features
- Text Parsing: Parse legacy formatting codes and JSON chat components
- 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 Minecraft fonts (modern + legacy)
Usage
[]
= "0.1"
# For font rendering:
= { = "0.1", = ["render"] }
Parsing Text
use ;
let text = parse;
for span in text.spans
JSON Chat Components
use ;
let json = r#"{"text":"Hello","color":"gold","bold":true}"#;
// Returns empty McText on error
let text = parse_json_component;
// Returns Result with error details
let text = try_parse_json_component?;
Rendering (requires render feature)
use ;
let font_system = modern;
let ctx = new;
let mut renderer = new;
ctx.render_str?;
// renderer.buffer contains RGBA pixel data
Feature Flags
| Feature | Description |
|---|---|
serde |
Serialization support for text types |
render |
Font loading, layout engine, and rendering |
Font Versions
Modern and legacy Minecraft font variants are included:
use FontSystem;
let modern = modern;
let legacy = legacy;
License
MIT