#svg #badge #svg-graphics #renderer #font #shield #graphics #rust

shields

A high-performance badge rendering engine written in Rust, supporting SVG output and font parsing

1 unstable release

Uses new Rust 2024

new 0.1.0 May 16, 2025

#1531 in Web programming

MIT license

255KB
559 lines

shields

A high-performance badge rendering engine written in Rust, supporting SVG output and font parsing. This project is designed for developers and services that require fast, customizable, and reliable badge generation, similar to shields.io, but with a focus on performance and extensibility.

Features

  • โšก High Performance: Built with Rust for maximum speed and efficiency.
  • ๐Ÿ–ผ๏ธ SVG Output: Generates crisp, standards-compliant SVG badges.
  • ๐Ÿ”ค Font Parsing: Supports custom font rendering using TTF parsing.
  • ๐Ÿง  LRU Caching: Efficient in-memory caching for repeated badge requests.
  • ๐Ÿ› ๏ธ Extensible API: Easy to integrate and extend for various use cases.
  • ๐Ÿงช Comprehensive Testing: Includes tests for rendering accuracy and performance.

Installation

Prerequisites

  • Rust (edition 2024 or later)
  • Cargo package manager (comes with Rust)

Build

Clone the repository and build the project:

git clone https://github.com/Jannchie/shields.git
cd shields
cargo build --release

Run

To run the badge rendering engine:

cargo run --release

Usage Example

Here is a basic example of how to use the shields library in your Rust project:

use shields::BadgeRenderer;

fn main() {
    let renderer = BadgeRenderer::new();
    let svg = renderer.render("build", "passing", "#4c1");
    std::fs::write("badge.svg", svg).unwrap();
}

This will generate a badge.svg file with a "build: passing" badge.

Contributing

Contributions are welcome! To get started:

  1. Fork the repository on GitHub.
  2. Create a new branch for your feature or bugfix.
  3. Commit your changes with clear messages.
  4. Open a pull request describing your changes.
  5. For issues, please use the GitHub Issues page.

Before submitting a PR, ensure all tests pass:

cargo test

License

This project is licensed under the MIT License. See the LICENSE file for details.

Community & Contact

Dependencies

~2.2โ€“3.5MB
~65K SLoC