Skip to content

Commit

Permalink
Merge pull request #159 from forkgull/warn-on-error
Browse files Browse the repository at this point in the history
Upgrade missing glyphs during shaping to a warning
  • Loading branch information
jackpot51 authored Jul 24, 2023
2 parents 9d2f7a4 + e65bcbc commit 78b24e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ std = [
]
vi = ["syntect"]
wasm-web = ["sys-locale?/js"]
warn_on_missing_glyphs = []

[workspace]
members = [
Expand Down
11 changes: 8 additions & 3 deletions src/font/fallback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ mod platform;
#[path = "windows.rs"]
mod platform;

#[cfg(not(feature = "warn_on_missing_glyphs"))]
use log::debug as missing_warn;
#[cfg(feature = "warn_on_missing_glyphs")]
use log::warn as missing_warn;

pub struct FontFallbackIter<'a> {
font_system: &'a mut FontSystem,
font_ids: &'a [fontdb::ID],
Expand Down Expand Up @@ -60,14 +65,14 @@ impl<'a> FontFallbackIter<'a> {

pub fn check_missing(&mut self, word: &str) {
if self.end {
log::debug!(
missing_warn!(
"Failed to find any fallback for {:?} locale '{}': '{}'",
self.scripts,
self.font_system.locale(),
word
);
} else if self.other_i > 0 {
log::debug!(
missing_warn!(
"Failed to find preset fallback for {:?} locale '{}', used '{}': '{}'",
self.scripts,
self.font_system.locale(),
Expand All @@ -76,7 +81,7 @@ impl<'a> FontFallbackIter<'a> {
);
} else if !self.scripts.is_empty() && self.common_i > 0 {
let family = common_fallback()[self.common_i - 1];
log::debug!(
missing_warn!(
"Failed to find script fallback for {:?} locale '{}', used '{}': '{}'",
self.scripts,
self.font_system.locale(),
Expand Down

0 comments on commit 78b24e0

Please sign in to comment.