Crate badgen

Source
Expand description

Rust SVG badge generator with font path rendering.

+-------+--------+
| LABEL | STATUS |
+-------+--------+

§Basic usage

let badge = badgen::badge(
    &badgen::Style::classic(),
    "status",
    Some("label"),
).unwrap();

println!("{}", badge);

§Performance usage

Note, given this example, you would clear out on every render.

let font = badgen::notosans_font();
let mut font = badgen::font(&font);
let mut scratch = String::with_capacity(4098);
let mut out = String::with_capacity(4098);

badgen::write_badge_with_font(
    &mut out,
    &badgen::Style::classic(),
    "world",
    Some("hello"),
    &mut font,
    &mut scratch,
)
.unwrap();

println!("{}", out);

Structs§

CachedFont
A wrapper around a font that caches a finite number of glyph paths.
FontGlyph
A rendered glyph.
Gradient
A two color gradient value.
Opacity
Wrapper around a string opacity value.
Point
An x and y coordinate.
Style
A badge style.
TrueTypeFont
A True Type Font with a font height and path precision.

Enums§

Color
Possible colors for use in a badge.

Traits§

Font
A Font trait specific to badge generation.

Functions§

badge
Generate an SVG badge given a style, status and optional label.
font
Prepares a cached True Type Font for use in generating badges with integer SVG paths.
font_licenses
Licenses for fonts included in binary.
font_with_precision
Prepares a cached True Type Font for use in generating badges with a given precision.
notosans_font
Parsed NotoSans font.
write_badge
Writes an SVG badge to a fmt::Write given a style, status and optional label.
write_badge_with_font
Writes an SVG badge to a fmt::Write given a style, status, optional label, font and scratch space.