aboutsummaryrefslogtreecommitdiffstats
path: root/components/gfx/text
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-04-16 19:50:50 +0200
committerGitHub <noreply@github.com>2024-04-16 17:50:50 +0000
commit6b2fa91357ea289d03e206018389c43ffd836047 (patch)
tree164367ab35aa156bd944f58a1e6e9f9fa9a967b0 /components/gfx/text
parent689c14471430bb331ff0d46d5be7e16b81a1de54 (diff)
downloadservo-6b2fa91357ea289d03e206018389c43ffd836047.tar.gz
servo-6b2fa91357ea289d03e206018389c43ffd836047.zip
gfx: Remove `FontTemplateData` (#32034)
Now that `FontTemplateData` is more or less the same on all platforms, it can be removed. This is a preparatory change for a full refactor of the font system on Servo. The major changes here are: - Remove `FontTemplateData` and move its members into `FontTemplate` - Make `FontTemplate` have full interior mutability instead of only the `FontTemplateData` member. This is preparation for having these data types `Send` and `Sync` with locking. - Remove the strong/weak reference concept for font data. In practice, all font data references were strong, so this was never fully complete. Instead of using this approach, the new font system will use a central font data cache with references associated to layouts. - The `CTFont` cache is now a global cache, so `CTFont`s can be shared between threads. The cache is cleared when clearing font caches. A benefit of this change (apart from `CTFont` sharing) is that font data loading is platform-independent now.
Diffstat (limited to 'components/gfx/text')
-rw-r--r--components/gfx/text/text_run.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/components/gfx/text/text_run.rs b/components/gfx/text/text_run.rs
index a411c7125db..56f66d6cd1f 100644
--- a/components/gfx/text/text_run.rs
+++ b/components/gfx/text/text_run.rs
@@ -17,7 +17,7 @@ use webrender_api::FontInstanceKey;
use xi_unicode::LineBreakLeafIter;
use crate::font::{Font, FontHandleMethods, FontMetrics, RunMetrics, ShapingFlags, ShapingOptions};
-use crate::platform::font_template::FontTemplateData;
+use crate::font_template::FontTemplateRefMethods;
use crate::text::glyph::{ByteIndex, GlyphStore};
thread_local! {
@@ -30,7 +30,8 @@ thread_local! {
pub struct TextRun {
/// The UTF-8 string represented by this text run.
pub text: Arc<String>,
- pub font_template: Arc<FontTemplateData>,
+ /// This ensures the data stays alive as long as this TextRun is using this font.
+ font_data: Arc<Vec<u8>>,
pub pt_size: Au,
pub font_metrics: FontMetrics,
pub font_key: FontInstanceKey,
@@ -193,7 +194,7 @@ impl<'a> TextRun {
TextRun {
text: Arc::new(text),
font_metrics: font.metrics.clone(),
- font_template: font.handle.template(),
+ font_data: font.handle.template().data(),
font_key: font.font_key,
pt_size: font.descriptor.pt_size,
glyphs: Arc::new(glyphs),