pub struct FontScheme {
pub major_latin: String,
pub minor_latin: String,
}Expand description
A theme’s font scheme (<a:fontScheme>, CT_FontScheme): a heading (“major”) and body
(“minor”) typeface, behind Word’s “Theme Fonts” and built-in heading styles.
Only the Latin typeface of each is modeled (<a:latin typeface="..">). CT_FontCollection also
requires an East Asian and complex-script typeface (ea/cs, each minOccurs="1") and allows
a further list of per-script fallback typefaces (font, e.g. script="Jpan") — the writer
always emits ea/cs with an empty typeface="" (schema-valid, and exactly what a Latin-only
real Word theme does) and omits the per-script fallback list entirely (its own minOccurs="0",
so this is valid too); Word simply falls back to its own built-in per-script defaults. Reading a
real theme that does declare ea/cs/per-script fonts silently ignores them, same scope limit
as writing.
Fields§
§major_latin: String§minor_latin: StringImplementations§
Source§impl FontScheme
impl FontScheme
Sourcepub fn new(
major_latin: impl Into<String>,
minor_latin: impl Into<String>,
) -> FontScheme
pub fn new( major_latin: impl Into<String>, minor_latin: impl Into<String>, ) -> FontScheme
Creates a font scheme with the given heading (“major”) and body (“minor”) Latin typefaces.
Examples found in repository?
14fn main() -> office_toolkit::Result<()> {
15 let default_theme_document = Document::new()
16 .with_theme(Theme::office_default())
17 .with_paragraph(Paragraph::with_text("Office's built-in default theme."))
18 .with_paragraph(Paragraph::with_text(
19 "Cambria for headings, Calibri for body text, the classic Office palette.",
20 ));
21 let default_path = output_path("docx_theme_default.docx");
22 default_theme_document.save_to_file(&default_path)?;
23 println!("Wrote {}", default_path.display());
24
25 // A custom, branded theme: a dark navy/orange palette and a different
26 // heading/body font pairing.
27 let custom_colors = ColorScheme::new(
28 "1B1B1B", "FFFFFF", "0A2540", "F5F5F5", "0A2540", "E8622C", "2E86AB", "6FB98F", "F4A259",
29 "8E4585", "1155CC", "6B3FA0",
30 );
31 let custom_fonts = FontScheme::new("Georgia", "Verdana");
32 let custom_theme_document = Document::new()
33 .with_theme(Theme::new("Custom Brand", custom_colors, custom_fonts))
34 .with_paragraph(Paragraph::with_text("A custom, branded theme."))
35 .with_paragraph(Paragraph::with_text(
36 "Georgia for headings, Verdana for body text, a navy/orange palette.",
37 ));
38 let custom_path = output_path("docx_theme_custom.docx");
39 custom_theme_document.save_to_file(&custom_path)?;
40 println!("Wrote {}", custom_path.display());
41
42 Ok(())
43}Sourcepub fn office_default() -> FontScheme
pub fn office_default() -> FontScheme
Office’s own built-in default fonts: Cambria for headings, Calibri for body text.
Trait Implementations§
Source§impl Clone for FontScheme
impl Clone for FontScheme
Source§fn clone(&self) -> FontScheme
fn clone(&self) -> FontScheme
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FontScheme
impl Debug for FontScheme
impl Eq for FontScheme
Source§impl PartialEq for FontScheme
impl PartialEq for FontScheme
impl StructuralPartialEq for FontScheme
Auto Trait Implementations§
impl Freeze for FontScheme
impl RefUnwindSafe for FontScheme
impl Send for FontScheme
impl Sync for FontScheme
impl Unpin for FontScheme
impl UnsafeUnpin for FontScheme
impl UnwindSafe for FontScheme
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.