Use linebender_resource_handle instead of peniko (#424)
Signed-off-by: Nico Burns <nico@nicoburns.com>
This commit is contained in:
parent
355b7febb1
commit
e04bfd098f
2 changed files with 8 additions and 22 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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<dyn AsRef<[u8]> + Send + Sync>,
|
||||
#[cfg(feature = "peniko")]
|
||||
data: peniko::Font,
|
||||
data: FontData,
|
||||
id: fontdb::ID,
|
||||
monospace_fallback: Option<FontMonospaceFallback>,
|
||||
}
|
||||
|
|
@ -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),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue