Skip to content

Commit

Permalink
Add font backend fontdue
Browse files Browse the repository at this point in the history
  • Loading branch information
declantsien committed Feb 28, 2024
1 parent 0bae0b6 commit adf6aea
Show file tree
Hide file tree
Showing 8 changed files with 409 additions and 5 deletions.
1 change: 1 addition & 0 deletions webrender/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ serialize_program = ["serde", "webrender_build/serialize_program"]
dynamic_freetype = ["glyph_rasterizer/dynamic_freetype"]
static_freetype = ["glyph_rasterizer/static_freetype"]
font_backend_swash = ["glyph_rasterizer/backend_swash", "api/font_backend_swash"]
font_backend_fontdue = ["glyph_rasterizer/backend_fontdue", "api/font_backend_fontdue"]
font_backend_native = ["glyph_rasterizer/backend_native"]
leak_checks = []
gecko = ["firefox-on-glean", "glyph_rasterizer/gecko"]
Expand Down
4 changes: 2 additions & 2 deletions webrender/src/resource_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2094,14 +2094,14 @@ impl ResourceCache {
index: 0,
}
}
#[cfg(all(not(feature = "font_backend_swash"), not(target_os = "macos")))]
#[cfg(all(not(feature = "font_backend_swash"), not(feature = "font_backend_fontdue"), not(target_os = "macos")))]
FontTemplate::Native(native) => {
PlainFontTemplate {
data: native.path.to_string_lossy().to_string(),
index: native.index,
}
}
#[cfg(all(not(feature = "font_backend_swash"), target_os = "macos"))]
#[cfg(all(not(feature = "font_backend_swash"), not(feature = "font_backend_fontdue"), target_os = "macos"))]
FontTemplate::Native(native) => {
PlainFontTemplate {
data: native.name,
Expand Down
1 change: 1 addition & 0 deletions webrender_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ serialize = []
deserialize = []
display_list_stats = []
font_backend_swash = []
font_backend_fontdue = []

[dependencies]
app_units = "0.7.3"
Expand Down
6 changes: 3 additions & 3 deletions webrender_api/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use peek_poke::PeekPoke;
use std::cmp::Ordering;
use std::hash::{Hash, Hasher};
#[cfg(all(not(feature = "font_backend_swash"), not(target_os = "macos")))]
#[cfg(all(not(feature = "font_backend_swash"), not(feature = "font_backend_fontdue"), not(target_os = "macos")))]
use std::path::PathBuf;
use std::sync::Arc;
// local imports
Expand Down Expand Up @@ -57,14 +57,14 @@ impl FontSize {
#[derive(Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct NativeFontHandle(pub u32);

#[cfg(all(not(feature = "font_backend_swash"), not(target_os = "macos")))]
#[cfg(all(not(feature = "font_backend_swash"), not(feature = "font_backend_fontdue"), not(target_os = "macos")))]
#[derive(Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct NativeFontHandle {
pub path: PathBuf,
pub index: u32,
}

#[cfg(all(not(feature = "font_backend_swash"), target_os = "macos"))]
#[cfg(all(not(feature = "font_backend_swash"), not(feature = "font_backend_fontdue"), target_os = "macos"))]
#[derive(Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct NativeFontHandle {
pub name: String,
Expand Down
7 changes: 7 additions & 0 deletions wr_glyph_rasterizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ capture = ["api/serialize", "serde", "smallvec/serde"]
replay = ["api/deserialize", "serde", "smallvec/serde"]
gecko = ["firefox-on-glean", "glean"]
backend_swash = ["swash", "zeno", "font-index", "api/font_backend_swash"]
backend_fontdue = ["fontdue", "ttf-parser", "resvg", "usvg", "tiny-skia", "tiny-skia-path", "parking_lot"]
backend_native = [
"freetype", "libc",
"dwrote",
Expand All @@ -33,6 +34,12 @@ fxhash = "0.2.1"
glean = { version = "57.0.0", optional = true }
firefox-on-glean = { version = "0.1.0", optional = true }
serde = { optional = true, version = "1.0", features = ["serde_derive"] }
fontdue = { version = "0.7", features = ["parallel"], optional = true }
ttf-parser = { version = "0.19", optional = true }
resvg = { version = "0.29", optional = true }
usvg = { version = "0.29", optional = true }
tiny-skia = { version = "0.8", optional = true }
tiny-skia-path = { version = "0.8", optional = true }
parking_lot = { version = "0.12", optional = true }
swash = { version = "0.1", optional = true }
zeno = { version = "0.2.2", optional = true }
Expand Down
Loading

0 comments on commit adf6aea

Please sign in to comment.