aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/gfx
diff options
context:
space:
mode:
authorMukilan Thiyagarajan <mukilan@igalia.com>2024-04-22 15:08:21 +0530
committerGitHub <noreply@github.com>2024-04-22 09:38:21 +0000
commit821893b2eecfc72918ab8154c3cb61cd45d53857 (patch)
tree035596a6a3af9a3138b0a58974d9745ffa702a26 /components/shared/gfx
parent25b182c372427e798954b814b0f1a0875ab43f98 (diff)
downloadservo-821893b2eecfc72918ab8154c3cb61cd45d53857.tar.gz
servo-821893b2eecfc72918ab8154c3cb61cd45d53857.zip
fonts: Rework platform font initialization (#32127)
This change reworks the way that platform fonts are created and descriptor data is on `FontTemplate` is initialized. The main change here is that platform fonts for local font faces are always initialized using the font data loaded into memory from disk. This means that there is now only a single path for creating platform fonts. In addition, the font list is now responsible for getting the `FontTemplateDescriptor` for local `FontTemplate`s. Before the font had to be loaded into memory to get the weight, style, and width used for the descriptor. This is what fonts lists are for though, so for every platform we have that information before needing to load the font. In the future, hopefully this will allow discarding fonts before needing to load them into memory. Web fonts still get the descriptor from the platform handle, but hopefully that can be done with skrifa in the future. Thsese two fixes together allow properly loading indexed font variations on Linux machines. Before only the first variation could be instantiated. Fixes https://github.com/servo/servo/issues/13317. Fixes https://github.com/servo/servo/issues/24554. Co-authored-by: Martin Robinson <mrobinson@igalia.com> ---- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13317 and #24554 - [x] There are tests for these changes --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/shared/gfx')
-rw-r--r--components/shared/gfx/lib.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/components/shared/gfx/lib.rs b/components/shared/gfx/lib.rs
index 5045a677c86..aaf57b5dfb1 100644
--- a/components/shared/gfx/lib.rs
+++ b/components/shared/gfx/lib.rs
@@ -9,6 +9,7 @@
pub mod print_tree;
use std::sync::atomic::{AtomicU64, Ordering};
+use std::sync::Arc;
use malloc_size_of_derive::MallocSizeOf;
use range::{int_range_index, RangeIndex};
@@ -119,12 +120,8 @@ pub fn node_id_from_scroll_id(id: usize) -> Option<usize> {
None
}
-pub enum FontData {
- Raw(Vec<u8>),
- Native(NativeFontHandle),
-}
-
pub trait WebrenderApi {
fn add_font_instance(&self, font_key: FontKey, size: f32) -> FontInstanceKey;
- fn add_font(&self, data: FontData) -> FontKey;
+ fn add_font(&self, data: Arc<Vec<u8>>, index: u32) -> FontKey;
+ fn add_system_font(&self, handle: NativeFontHandle) -> FontKey;
}