f-office 0.2.1

Renders Office Open XML documents the way Microsoft Office does.
Documentation
//! What the tests of this crate share: the Carlito font of the repository's test fonts and the
//! run properties that choose it.

use super::FontDb;

/// The Carlito font file.
pub const CARLITO: &[u8] = include_bytes!(concat!(
    env!(
        "F_OFFICE_UNIT_TEST_FONTS",
        "set F_OFFICE_UNIT_TEST_FONTS to the folder of the test fonts, which holds Carlito-Regular.ttf"
    ),
    "/Carlito-Regular.ttf"
));

/// The font choice of a Carlito run, for run properties that set more than the font.
pub const CARLITO_FONTS: &str = r#"<w:rFonts w:ascii="Carlito" w:hAnsi="Carlito"/>"#;

/// The run properties of a run that sets only the Carlito font.
pub const CARLITO_RUN: &str = r#"<w:rPr><w:rFonts w:ascii="Carlito" w:hAnsi="Carlito"/></w:rPr>"#;

/// A font database that holds Carlito only.
pub fn carlito() -> FontDb {
    let mut fonts = FontDb::new();
    fonts.add_font(CARLITO.to_vec()).unwrap();
    fonts
}

#[test]
fn the_carlito_run_sets_the_carlito_fonts_only() {
    assert_eq!(CARLITO_RUN, format!("<w:rPr>{CARLITO_FONTS}</w:rPr>"));
    assert_eq!(carlito().len(), 1);
}