From eca804c7324af9c1f2fea1943760c33f3d290c5b Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 2 Mar 2023 18:16:57 -0700 Subject: [PATCH] Revert "Make `FontSystem` not self-referencing and update `fontdb` and `rustybuzz`" --- Cargo.toml | 5 +- deny.toml | 5 +- src/cache.rs | 10 +-- src/font/fallback/mod.rs | 44 ++++------- src/font/matches.rs | 14 ++++ src/font/mod.rs | 54 +------------ src/font/system/no_std.rs | 33 ++++---- src/font/system/redox.rs | 36 ++++----- src/font/system/std.rs | 160 ++++++++++++++++++++------------------ src/shape.rs | 35 ++++----- src/swash.rs | 8 +- 11 files changed, 179 insertions(+), 225 deletions(-) create mode 100644 src/font/matches.rs diff --git a/Cargo.toml b/Cargo.toml index 7202f6a..1e82553 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,10 +9,11 @@ documentation = "https://docs.rs/cosmic-text/latest/cosmic_text/" repository = "https://github.com/pop-os/cosmic-text" [dependencies] -fontdb = { version = "0.13.0", default-features = false } +fontdb = { version = "0.10.0", default-features = false } libm = "0.2.6" log = "0.4.17" -rustybuzz = { version = "0.7.0", default-features = false, features = ["libm"] } +ouroboros = "0.15.5" +rustybuzz = { version = "0.6.0", default-features = false, features = ["libm"] } swash = { version = "0.1.6", optional = true } syntect = { version = "5.0.0", optional = true } sys-locale = { version = "0.2.3", optional = true } diff --git a/deny.toml b/deny.toml index 04c6416..fda1256 100644 --- a/deny.toml +++ b/deny.toml @@ -112,7 +112,6 @@ allow = [ "Apache-2.0", "Unicode-DFS-2016", "BSD-2-Clause", - "Zlib", #"Apache-2.0 WITH LLVM-exception", ] # List of explicitly disallowed licenses @@ -164,8 +163,8 @@ exceptions = [ # and the crate will be checked normally, which may produce warnings or errors # depending on the rest of your configuration #license-files = [ -# Each entry is a crate relative path, and the (opaque) hash of its contents -#{ path = "LICENSE", hash = 0xbd0eed23 } + # Each entry is a crate relative path, and the (opaque) hash of its contents + #{ path = "LICENSE", hash = 0xbd0eed23 } #] [licenses.private] diff --git a/src/cache.rs b/src/cache.rs index 0da1f52..ce93b38 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -1,12 +1,10 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -use crate::FontKey; - /// Key for building a glyph cache #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct CacheKey { - /// Font key - pub font_key: FontKey, + /// Font ID + pub font_id: fontdb::ID, /// Glyph ID pub glyph_id: u16, /// `f32` bits of font size @@ -19,7 +17,7 @@ pub struct CacheKey { impl CacheKey { pub fn new( - font_key: FontKey, + font_id: fontdb::ID, glyph_id: u16, font_size: f32, pos: (f32, f32), @@ -28,7 +26,7 @@ impl CacheKey { let (y, y_bin) = SubpixelBin::new(pos.1); ( Self { - font_key, + font_id, glyph_id, font_size_bits: font_size.to_bits(), x_bin, diff --git a/src/font/fallback/mod.rs b/src/font/fallback/mod.rs index 752bd02..7b8fa8c 100644 --- a/src/font/fallback/mod.rs +++ b/src/font/fallback/mod.rs @@ -1,10 +1,11 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 +use alloc::sync::Arc; #[cfg(not(feature = "std"))] use alloc::vec::Vec; use unicode_script::Script; -use crate::{Font, FontKey}; +use crate::Font; use self::platform::*; @@ -25,8 +26,7 @@ mod platform; mod platform; pub struct FontFallbackIter<'a> { - db: &'a fontdb::Database, - font_keys: &'a [FontKey], + fonts: &'a [Arc>], default_families: &'a [&'a str], default_i: usize, scripts: Vec