Revert "Make FontSystem not self-referencing and update fontdb and rustybuzz"

This commit is contained in:
Jeremy Soller 2023-03-02 18:16:57 -07:00 committed by GitHub
parent b6398a2d57
commit eca804c732
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 179 additions and 225 deletions

View file

@ -9,9 +9,7 @@ use unicode_script::{Script, UnicodeScript};
use unicode_segmentation::UnicodeSegmentation;
use crate::fallback::FontFallbackIter;
use crate::{
Align, AttrsList, CacheKey, Color, Font, FontKey, FontSystem, LayoutGlyph, LayoutLine, Wrap,
};
use crate::{Align, AttrsList, CacheKey, Color, Font, FontSystem, LayoutGlyph, LayoutLine, Wrap};
fn shape_fallback(
font: &Font,
@ -64,7 +62,7 @@ fn shape_fallback(
y_advance,
x_offset,
y_offset,
font_key: font.key(),
font_id: font.info.id,
glyph_id: info.glyph_id.try_into().expect("failed to cast glyph ID"),
//TODO: color should not be related to shaping
color_opt: attrs.color_opt,
@ -127,21 +125,22 @@ fn shape_run(
let font_matches = font_system.get_font_matches(attrs);
let db = font_system.db();
let default_families = [db.family_name(&attrs.family)];
let default_families = [font_matches.default_family.as_str()];
let mut font_iter = FontFallbackIter::new(
db,
&font_matches,
&font_matches.fonts,
&default_families,
scripts,
font_system.locale(),
font_matches.locale,
);
let font = font_iter.next().expect("no default font found");
let (mut glyphs, mut missing) =
shape_fallback(&font, line, attrs_list, start_run, end_run, span_rtl);
let (mut glyphs, mut missing) = shape_fallback(
font_iter.next().expect("no default font found"),
line,
attrs_list,
start_run,
end_run,
span_rtl,
);
//TODO: improve performance!
while !missing.is_empty() {
@ -150,9 +149,9 @@ fn shape_run(
None => break,
};
log::trace!("Evaluating fallback with font '{}'", font.name());
log::trace!("Evaluating fallback with font '{}'", font.info.family);
let (mut fb_glyphs, fb_missing) =
shape_fallback(&font, line, attrs_list, start_run, end_run, span_rtl);
shape_fallback(font, line, attrs_list, start_run, end_run, span_rtl);
// Insert all matching glyphs
let mut fb_i = 0;
@ -229,7 +228,7 @@ pub struct ShapeGlyph {
pub y_advance: f32,
pub x_offset: f32,
pub y_offset: f32,
pub font_key: FontKey,
pub font_id: fontdb::ID,
pub glyph_id: u16,
pub color_opt: Option<Color>,
pub metadata: usize,
@ -248,7 +247,7 @@ impl ShapeGlyph {
let y_offset = font_size * self.y_offset;
let (cache_key, x_int, y_int) = CacheKey::new(
self.font_key,
self.font_id,
self.glyph_id,
font_size,
(x + x_offset, y - y_offset),