From e04bfd098f58958b09f0cf5e14a67f87e49dbaec Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Sun, 21 Sep 2025 13:45:37 +0100 Subject: [PATCH] Use linebender_resource_handle instead of peniko (#424) Signed-off-by: Nico Burns --- Cargo.toml | 8 +++----- src/font/mod.rs | 22 +++++----------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a0e01b7..eb0f387 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ fontdb = { version = "0.23", default-features = false } harfrust = { version = "0.2.0", default-features = false } hashbrown = { version = "0.15", optional = true, default-features = false } libm = { version = "0.2.8", optional = true } +linebender_resource_handle = { version = "0.1.1", default-features = false } log = "0.4.20" modit = { version = "0.1.4", optional = true } rangemap = "1.4.0" @@ -41,21 +42,18 @@ version = "0.3.13" default-features = false features = ["hardcoded-data"] -[dependencies.peniko] -version = "0.4.0" -optional = true - [features] default = ["std", "swash", "fontconfig"] fontconfig = ["fontdb/fontconfig", "std"] monospace_fallback = [] no_std = ["hashbrown", "dep:libm", "skrifa/libm", "core_maths"] -peniko = ["dep:peniko"] +peniko = [] shape-run-cache = [] std = [ "fontdb/memmap", "fontdb/std", "harfrust/std", + "linebender_resource_handle/std", "skrifa/std", "swash?/std", "sys-locale", diff --git a/src/font/mod.rs b/src/font/mod.rs index 3b7d53b..869833e 100644 --- a/src/font/mod.rs +++ b/src/font/mod.rs @@ -1,13 +1,14 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 use harfrust::Shaper; +use linebender_resource_handle::{Blob, FontData}; use skrifa::raw::{ReadError, TableProvider as _}; use skrifa::{metrics::Metrics, prelude::*}; // re-export skrifa pub use skrifa; // re-export peniko::Font; #[cfg(feature = "peniko")] -pub use peniko::Font as PenikoFont; +pub use linebender_resource_handle::FontData as PenikoFont; use core::fmt; @@ -50,10 +51,7 @@ pub struct Font { #[cfg(feature = "swash")] swash: (u32, swash::CacheKey), harfrust: OwnedFace, - #[cfg(not(feature = "peniko"))] - data: Arc + Send + Sync>, - #[cfg(feature = "peniko")] - data: peniko::Font, + data: FontData, id: fontdb::ID, monospace_fallback: Option, } @@ -88,14 +86,7 @@ impl Font { } pub fn data(&self) -> &[u8] { - #[cfg(not(feature = "peniko"))] - { - (*self.data).as_ref() - } - #[cfg(feature = "peniko")] - { - self.data.data.data() - } + self.data.data.data() } pub fn shaper(&self) -> &harfrust::Shaper<'_> { @@ -242,10 +233,7 @@ impl Font { }, ) .ok()?, - #[cfg(not(feature = "peniko"))] - data, - #[cfg(feature = "peniko")] - data: peniko::Font::new(peniko::Blob::new(data), info.index), + data: FontData::new(Blob::new(data), info.index), }) } }