graphitepdf-style 0.2.0

Compatibility style facade types for GraphitePDF.
Documentation

Overview

graphitepdf-style provides compatibility-oriented style types that can be derived from resolved stylesheet data and converted into graphitepdf_layout::LayoutStyle.


Scope

graphitepdf-style contains:

  • the compatibility Style type
  • compatibility layout enums such as FlexDirection, JustifyContent, and AlignItems
  • re-exported font and stylesheet types used by style-facing APIs
  • conversion between resolved stylesheet values and layout-facing style data

Installation

cargo add graphitepdf-style

API Summary

Category Items
Style facade Style, EdgeInsets
Layout-like enums FlexDirection, JustifyContent, AlignItems
Font re-exports FontDescriptor, FontSource, FontStyle, FontVariantWeight, StandardFont
Stylesheet re-exports Stylesheet, StylesheetContainer, StylesheetMap, StyleValue

Example

use graphitepdf_style::{Style, StyleValue, Stylesheet, StylesheetContainer};

fn main() {
    let stylesheet = Stylesheet::new(StyleValue::Object(
        [
            ("fontFamily".to_string(), "Inter".into()),
            ("fontSize".to_string(), 14.0.into()),
            ("paddingTop".to_string(), 12.0.into()),
        ]
        .into_iter()
        .collect(),
    ));

    let style = Style::from_stylesheet(&StylesheetContainer::new(595.0, 842.0), &stylesheet);
    let layout_style = style.to_layout_style();

    assert_eq!(layout_style.font_family.as_deref(), Some("Inter"));
}

Design Principles

  • keep compatibility style behavior explicit
  • reuse the canonical layout style model rather than diverging from it
  • expose font and stylesheet inputs through a simpler facade
  • avoid becoming a second independent style engine

Role In GraphitePDF

This crate is an adapter used by document, the root facade, and compatibility-facing code. The canonical layout crate still owns downstream positioning and rendering behavior.


License

MIT