Fallback to monospaced font if Monospace family is not found
This commit is contained in:
parent
bfb5eefbfa
commit
e1e9fb5215
1 changed files with 14 additions and 0 deletions
|
|
@ -112,6 +112,7 @@ impl<'a> Iterator for FontFallbackIter<'a> {
|
|||
fn next(&mut self) -> Option<Self::Item> {
|
||||
while self.default_i < self.default_families.len() {
|
||||
self.default_i += 1;
|
||||
let mut monospace_fallback = None;
|
||||
for id in self.font_ids.iter() {
|
||||
let default_family = self
|
||||
.font_system
|
||||
|
|
@ -122,6 +123,19 @@ impl<'a> Iterator for FontFallbackIter<'a> {
|
|||
return Some(font);
|
||||
}
|
||||
}
|
||||
// Set a monospace fallback if Monospace family is not found
|
||||
if self.default_families[self.default_i - 1] == &Family::Monospace
|
||||
&& self.font_system.db().face(*id).map(|f| f.monospaced) == Some(true)
|
||||
&& monospace_fallback.is_none()
|
||||
{
|
||||
monospace_fallback = Some(id);
|
||||
}
|
||||
}
|
||||
// If default family is Monospace allback to first monospaced font
|
||||
if let Some(id) = monospace_fallback {
|
||||
if let Some(font) = self.font_system.get_font(*id) {
|
||||
return Some(font);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue