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 }
|
harfrust = { version = "0.2.0", default-features = false }
|
||||||
hashbrown = { version = "0.15", optional = true, default-features = false }
|
hashbrown = { version = "0.15", optional = true, default-features = false }
|
||||||
libm = { version = "0.2.8", optional = true }
|
libm = { version = "0.2.8", optional = true }
|
||||||
|
linebender_resource_handle = { version = "0.1.1", default-features = false }
|
||||||
log = "0.4.20"
|
log = "0.4.20"
|
||||||
modit = { version = "0.1.4", optional = true }
|
modit = { version = "0.1.4", optional = true }
|
||||||
rangemap = "1.4.0"
|
rangemap = "1.4.0"
|
||||||
|
|
@ -41,21 +42,18 @@ version = "0.3.13"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["hardcoded-data"]
|
features = ["hardcoded-data"]
|
||||||
|
|
||||||
[dependencies.peniko]
|
|
||||||
version = "0.4.0"
|
|
||||||
optional = true
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std", "swash", "fontconfig"]
|
default = ["std", "swash", "fontconfig"]
|
||||||
fontconfig = ["fontdb/fontconfig", "std"]
|
fontconfig = ["fontdb/fontconfig", "std"]
|
||||||
monospace_fallback = []
|
monospace_fallback = []
|
||||||
no_std = ["hashbrown", "dep:libm", "skrifa/libm", "core_maths"]
|
no_std = ["hashbrown", "dep:libm", "skrifa/libm", "core_maths"]
|
||||||
peniko = ["dep:peniko"]
|
peniko = []
|
||||||
shape-run-cache = []
|
shape-run-cache = []
|
||||||
std = [
|
std = [
|
||||||
"fontdb/memmap",
|
"fontdb/memmap",
|
||||||
"fontdb/std",
|
"fontdb/std",
|
||||||
"harfrust/std",
|
"harfrust/std",
|
||||||
|
"linebender_resource_handle/std",
|
||||||
"skrifa/std",
|
"skrifa/std",
|
||||||
"swash?/std",
|
"swash?/std",
|
||||||
"sys-locale",
|
"sys-locale",
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||||
|
|
||||||
use harfrust::Shaper;
|
use harfrust::Shaper;
|
||||||
|
use linebender_resource_handle::{Blob, FontData};
|
||||||
use skrifa::raw::{ReadError, TableProvider as _};
|
use skrifa::raw::{ReadError, TableProvider as _};
|
||||||
use skrifa::{metrics::Metrics, prelude::*};
|
use skrifa::{metrics::Metrics, prelude::*};
|
||||||
// re-export skrifa
|
// re-export skrifa
|
||||||
pub use skrifa;
|
pub use skrifa;
|
||||||
// re-export peniko::Font;
|
// re-export peniko::Font;
|
||||||
#[cfg(feature = "peniko")]
|
#[cfg(feature = "peniko")]
|
||||||
pub use peniko::Font as PenikoFont;
|
pub use linebender_resource_handle::FontData as PenikoFont;
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
|
|
@ -50,10 +51,7 @@ pub struct Font {
|
||||||
#[cfg(feature = "swash")]
|
#[cfg(feature = "swash")]
|
||||||
swash: (u32, swash::CacheKey),
|
swash: (u32, swash::CacheKey),
|
||||||
harfrust: OwnedFace,
|
harfrust: OwnedFace,
|
||||||
#[cfg(not(feature = "peniko"))]
|
data: FontData,
|
||||||
data: Arc<dyn AsRef<[u8]> + Send + Sync>,
|
|
||||||
#[cfg(feature = "peniko")]
|
|
||||||
data: peniko::Font,
|
|
||||||
id: fontdb::ID,
|
id: fontdb::ID,
|
||||||
monospace_fallback: Option<FontMonospaceFallback>,
|
monospace_fallback: Option<FontMonospaceFallback>,
|
||||||
}
|
}
|
||||||
|
|
@ -88,14 +86,7 @@ impl Font {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn data(&self) -> &[u8] {
|
pub fn data(&self) -> &[u8] {
|
||||||
#[cfg(not(feature = "peniko"))]
|
self.data.data.data()
|
||||||
{
|
|
||||||
(*self.data).as_ref()
|
|
||||||
}
|
|
||||||
#[cfg(feature = "peniko")]
|
|
||||||
{
|
|
||||||
self.data.data.data()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shaper(&self) -> &harfrust::Shaper<'_> {
|
pub fn shaper(&self) -> &harfrust::Shaper<'_> {
|
||||||
|
|
@ -242,10 +233,7 @@ impl Font {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.ok()?,
|
.ok()?,
|
||||||
#[cfg(not(feature = "peniko"))]
|
data: FontData::new(Blob::new(data), info.index),
|
||||||
data,
|
|
||||||
#[cfg(feature = "peniko")]
|
|
||||||
data: peniko::Font::new(peniko::Blob::new(data), info.index),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue