Define base fallback list ♾

This commit is contained in:
Laurenz 2020-01-06 13:06:17 +01:00
parent a93b1ab003
commit c9fd39f37e
2 changed files with 19 additions and 9 deletions

View File

@ -16,7 +16,7 @@
//! format is _PDF_. Alternatively, the layout can be serialized to pass it to //! format is _PDF_. Alternatively, the layout can be serialized to pass it to
//! a suitable renderer. //! a suitable renderer.
// #![allow(unused)] #![allow(unused)]
pub extern crate toddle; pub extern crate toddle;

View File

@ -58,8 +58,15 @@ impl TextStyle {
} }
macro_rules! fallback { macro_rules! fallback {
(($($f:expr),*), $($c:expr => ($($cf:expr),*),)*) => ({ (
let mut fallback = FontFallbackTree::new(vec![$($f.to_string()),*]); list: ($($f:expr),*),
classes: { $($c:expr => ($($cf:expr),*),)* },
base: ($($b:expr),*),
) => ({
let mut fallback = FontFallbackTree::new(
vec![$($f.to_string()),*],
vec![$($b.to_string()),*],
);
$( $(
fallback.set_class_list($c.to_string(), vec![$($cf.to_string()),*]) fallback.set_class_list($c.to_string(), vec![$($cf.to_string()),*])
.expect("TextStyle::default: unexpected error \ .expect("TextStyle::default: unexpected error \
@ -73,12 +80,15 @@ impl Default for TextStyle {
fn default() -> TextStyle { fn default() -> TextStyle {
TextStyle { TextStyle {
fallback: fallback! { fallback: fallback! {
("sans-serif"), list: ("sans-serif"),
"serif" => ("source serif pro", "noto serif", "__base"), classes: {
"sans-serif" => ("source sans pro", "noto sans", "__base"), "serif" => ("source serif pro", "noto serif"),
"monospace" => ("source code pro", "noto sans mono", "__base"), "sans-serif" => ("source sans pro", "noto sans"),
"math" => ("latin modern math", "serif", "__base"), "monospace" => ("source code pro", "noto sans mono"),
"__base" => ("latin modern math", "noto emoji"), "math" => ("latin modern math", "serif"),
},
base: ("source sans pro", "noto sans",
"noto emoji", "latin modern math"),
}, },
variant: FontVariant { variant: FontVariant {
style: FontStyle::Normal, style: FontStyle::Normal,