Files
hcie-rust-v3.05/hcie-text
Your Name 513efcdcff
mandatory-regression-gate / deterministic-tests (push) Has been cancelled
mandatory-regression-gate / protected-performance-path (push) Has been cancelled
Refactor dependencies and improve test runner diagnostics
- Updated `Cargo.toml` files across multiple crates to replace local `egui` and `eframe` dependencies with workspace references, ensuring consistent platform support.
- Enhanced `run_all_tests.bat` and `run_all_tests.sh` scripts to capture and report names of failed and skipped crates, improving test diagnostics.
- Fixed duplicate keys in `hcie-text/Cargo.toml` and ensured proper feature activation for Linux builds in affected crates.
- Added a new repair plan document outlining steps to address failing crates and improve overall test execution reliability.
2026-07-23 16:34:05 +03:00
..
2026-07-09 02:59:53 +03:00
2026-07-09 02:59:53 +03:00
2026-07-09 02:59:53 +03:00

hcie-text

A specialized Rust library for high-quality text rendering and layer generation, designed for integration into image editing software.

Project Summary

hcie-text provides the core logic for converting text strings into rasterized pixel data and Layer objects. It leverages the fontdue crate for efficient and accurate glyph rendering, allowing users to load custom fonts, specify text styles, and output RGBA buffers ready for canvas composition.

Usage Guide

Basic Workflow

  1. Initialize: Create a TextRenderer instance.
  2. Load Fonts: Load one or more .ttf or .otf fonts using load_font(name, data).
  3. Render: Use rasterize_text to get a raw RGBA pixel buffer and the dimensions of the rendered text.
  4. Layer Creation: Use create_text_layer to generate a Layer object compatible with the hcie-protocol.

Key API

  • TextRenderer::new(): Initializes the renderer.
  • load_font(&mut self, name: &str, data: &[u8]): Registers a font by name.
  • rasterize_text(&mut self, text: &str, font_name: &str, size: f32, color: [u8; 4]): Returns (Vec<u8>, width, height).
  • create_text_layer(&mut self, text: &str, font: &str, size: f32, color: [u8; 4]): Creates a Layer with LayerType::Text.

AI Agent Instructions

When working on this library or integrating it:

  • Font Management: Always verify that a font is loaded via has_font() or ensure load_font() was called before attempting to rasterize.
  • Coordinates: The library uses a PositiveYDown coordinate system, consistent with standard image buffers.
  • Layering: When creating layers, ensure the dimensions match the intended canvas or are handled by the compositor.
  • Protocol Alignment: Ensure all Layer outputs strictly follow the hcie-protocol definitions.

Development and Testing

Prerequisites

  • Rust toolchain (latest stable)

Commands

Build the library:

cargo build

Run tests:

cargo test

Run the test GUI example:

cargo run --example text_test

(Note: The example requires system fonts to be available at standard Linux paths like /usr/share/fonts)