mirror of
https://github.com/typst/typst
synced 2025-06-16 10:22:51 +08:00
Warn when using variable fonts (#6425)
This commit is contained in:
parent
ada90fdd87
commit
46d57b00b5
@ -196,6 +196,8 @@ bitflags::bitflags! {
|
||||
const SERIF = 1 << 1;
|
||||
/// Font face has a MATH table
|
||||
const MATH = 1 << 2;
|
||||
/// Font face has an fvar table
|
||||
const VARIABLE = 1 << 3;
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,6 +277,7 @@ impl FontInfo {
|
||||
let mut flags = FontFlags::empty();
|
||||
flags.set(FontFlags::MONOSPACE, ttf.is_monospaced());
|
||||
flags.set(FontFlags::MATH, ttf.tables().math.is_some());
|
||||
flags.set(FontFlags::VARIABLE, ttf.is_variable());
|
||||
|
||||
// Determine whether this is a serif or sans-serif font.
|
||||
if let Some(panose) = ttf
|
||||
|
@ -1412,12 +1412,24 @@ pub fn is_default_ignorable(c: char) -> bool {
|
||||
fn check_font_list(engine: &mut Engine, list: &Spanned<FontList>) {
|
||||
let book = engine.world.book();
|
||||
for family in &list.v {
|
||||
if !book.contains_family(family.as_str()) {
|
||||
engine.sink.warn(warning!(
|
||||
match book.select_family(family.as_str()).next() {
|
||||
Some(index) => {
|
||||
if book
|
||||
.info(index)
|
||||
.is_some_and(|x| x.flags.contains(FontFlags::VARIABLE))
|
||||
{
|
||||
engine.sink.warn(warning!(
|
||||
list.span,
|
||||
"variable fonts are not currently supported and may render incorrectly";
|
||||
hint: "try installing a static version of \"{}\" instead", family.as_str()
|
||||
))
|
||||
}
|
||||
}
|
||||
None => engine.sink.warn(warning!(
|
||||
list.span,
|
||||
"unknown font family: {}",
|
||||
family.as_str(),
|
||||
));
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user