More fun with font fallback
After 41b6c4a5ad, I was able to
experience a panic on a linux system.
This commit gives us one last fallback to plain ? glyphs.
This commit is contained in:
1 parent
1978eba0a1
commit
8d6274887f
1 file changed
+15
-1
@@ -58,12 +58,26 @@ fn make_question_string(s: &str) -> String {
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
let len = s.graphemes(true).count();
|
||||
let mut result = String::new();
|
||||
let c = if !is_question_string(s) {
|
||||
std::char::REPLACEMENT_CHARACTER
|
||||
} else {
|
||||
'?'
|
||||
};
|
||||
for _ in 0..len {
|
||||
result.push(std::char::REPLACEMENT_CHARACTER);
|
||||
result.push(c);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn is_question_string(s: &str) -> bool {
|
||||
for c in s.chars() {
|
||||
if c != std::char::REPLACEMENT_CHARACTER {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
impl HarfbuzzShaper {
|
||||
pub fn new(handles: &[FontDataHandle]) -> anyhow::Result<Self> {
|
||||
let lib = ftwrap::Library::new()?;
|
||||
|
||||
Reference in new issue
Block a user