aboutsummaryrefslogtreecommitdiffstats
path: root/components/gfx/platform/macos
diff options
context:
space:
mode:
authorDzmitry Malyshau <kvark@mozilla.com>2017-11-17 12:03:50 -0500
committerAnthony Ramine <n.oxyde@gmail.com>2017-11-22 00:43:34 +0100
commitba214bcec5f724c93d6725bcdff8fa804881958b (patch)
treee4819197b3e40b86b7726a994f6d8ac68f5bb6db /components/gfx/platform/macos
parentd1e4fdb7faf5b32079e83fa03fe0386bb7c65db3 (diff)
downloadservo-ba214bcec5f724c93d6725bcdff8fa804881958b.tar.gz
servo-ba214bcec5f724c93d6725bcdff8fa804881958b.zip
WR multi-document support
Diffstat (limited to 'components/gfx/platform/macos')
-rw-r--r--components/gfx/platform/macos/font_template.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/components/gfx/platform/macos/font_template.rs b/components/gfx/platform/macos/font_template.rs
index d71dc84254e..c4c14cfd420 100644
--- a/components/gfx/platform/macos/font_template.rs
+++ b/components/gfx/platform/macos/font_template.rs
@@ -17,7 +17,7 @@ use std::fmt;
use std::fs::File;
use std::io::{Read, Error as IoError};
use std::ops::Deref;
-use std::sync::Mutex;
+use std::sync::{Arc, Mutex};
use webrender_api::NativeFontHandle;
/// Platform specific font representation for mac.
@@ -36,7 +36,7 @@ pub struct FontTemplateData {
ctfont: CachedCTFont,
pub identifier: Atom,
- pub font_data: Option<Vec<u8>>
+ pub font_data: Option<Arc<Vec<u8>>>
}
unsafe impl Send for FontTemplateData {}
@@ -47,7 +47,7 @@ impl FontTemplateData {
Ok(FontTemplateData {
ctfont: CachedCTFont(Mutex::new(HashMap::new())),
identifier: identifier.to_owned(),
- font_data: font_data
+ font_data: font_data.map(Arc::new)
})
}
@@ -61,7 +61,7 @@ impl FontTemplateData {
let clamped_pt_size = pt_size.max(0.01);
let ctfont = match self.font_data {
Some(ref bytes) => {
- let fontprov = CGDataProvider::from_buffer(bytes);
+ let fontprov = CGDataProvider::from_buffer(bytes.clone());
let cgfont_result = CGFont::from_data_provider(fontprov);
match cgfont_result {
Ok(cgfont) => {
@@ -103,7 +103,7 @@ impl FontTemplateData {
/// Returns a clone of the bytes in this font if they are in memory. This function never
/// performs disk I/O.
pub fn bytes_if_in_memory(&self) -> Option<Vec<u8>> {
- self.font_data.clone()
+ self.font_data.as_ref().map(|bytes| (**bytes).clone())
}
/// Returns the native font that underlies this font template, if applicable.