fonts: retry fallback with no presentation if we hit last resort

The introduction of the Emoji vs Text VS processing means that we might
in some cases not find a glyph with the requested presentation.

In that case, we'd rather show the emoji presentation glyph than none at
all, so we'll retry fallback processing with unspecified presentation.

refs: #997
This commit is contained in:
Wez Furlong committed 2021-08-17 22:00:27 -07:00
1 parent 4eb17dd9f4
commit 4fc8dfb374
2 files changed
+18

No files matched your search

+1
View File
@@ -109,6 +109,7 @@ impl LoadedFont {
presentation,
);
no_glyphs.retain(|&c| c != '\u{FE0F}' && c != '\u{FE0E}');
filter_out_synthetic(&mut no_glyphs);
if !no_glyphs.is_empty() {
+17
View File
@@ -186,6 +186,7 @@ impl HarfbuzzShaper {
let cell_width;
let shaped_any;
let initial_font_idx = font_idx;
loop {
match self.load_fallback(font_idx).context("load_fallback")? {
@@ -225,6 +226,22 @@ impl HarfbuzzShaper {
for c in s.chars() {
no_glyphs.push(c);
}
if presentation.is_some() {
// We hit the last resort and we have an explicit presentation.
// This is a little awkward; we want to record the missing
// glyphs so that we can resolve them async, but we also
// want to try the current set of fonts without forcing
// the presentation match as we might find the results
// that way.
// Let's restart the shape but pretend that no specific
// presentation was used.
// We'll probably match the emoji presentation for something,
// but might potentially discover the text presentation for
// that glyph in a fallback font and swap it out a little
// later after a flash of showing the emoji one.
return self.do_shape(initial_font_idx, s, font_size, dpi, no_glyphs, None);
}
}
let hb_infos = buf.glyph_infos();