diff options
author | Glenn Watson <gw@intuitionlibrary.com> | 2016-02-18 07:57:31 +1000 |
---|---|---|
committer | Glenn Watson <gw@intuitionlibrary.com> | 2016-02-18 10:35:29 +1000 |
commit | c0531c312fdb0783e4d121b4c2d7f15d4f5cdc1f (patch) | |
tree | ced94496eb3f3b4149f1c2d3b0b02422bb3b5471 /components/gfx/platform/macos | |
parent | f7f0eea47035f4316d09db26315bf8ebb72637c9 (diff) | |
download | servo-c0531c312fdb0783e4d121b4c2d7f15d4f5cdc1f.tar.gz servo-c0531c312fdb0783e4d121b4c2d7f15d4f5cdc1f.zip |
Add WebRender integration to Servo.
WebRender is an experimental GPU accelerated rendering backend for Servo.
The WebRender backend can be specified by running Servo with the -w option (otherwise the default rendering backend will be used).
WebRender has many bugs, and missing features - but it is usable to browse most websites - please report any WebRender specific rendering bugs you encounter!
Diffstat (limited to 'components/gfx/platform/macos')
-rw-r--r-- | components/gfx/platform/macos/font_template.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/components/gfx/platform/macos/font_template.rs b/components/gfx/platform/macos/font_template.rs index d6ee6b9f3f0..f15527e6a9f 100644 --- a/components/gfx/platform/macos/font_template.rs +++ b/components/gfx/platform/macos/font_template.rs @@ -9,9 +9,12 @@ use core_text::font::CTFont; use serde::de::{Error, Visitor}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::borrow::ToOwned; +use std::fs::File; +use std::io::Read; use std::ops::Deref; use std::sync::Mutex; use string_cache::Atom; +use url::Url; /// Platform specific font representation for mac. /// The identifier is a PostScript font name. The @@ -62,6 +65,39 @@ impl FontTemplateData { } ctfont.as_ref().map(|ctfont| (*ctfont).clone()) } + + /// Returns a clone of the data in this font. This may be a hugely expensive + /// operation (depending on the platform) which performs synchronous disk I/O + /// and should never be done lightly. + pub fn bytes(&self) -> Vec<u8> { + match self.bytes_if_in_memory() { + Some(font_data) => return font_data, + None => {} + } + + let path = Url::parse(&*self.ctfont() + .expect("No Core Text font available!") + .url() + .expect("No URL for Core Text font!") + .get_string() + .to_string()).expect("Couldn't parse Core Text font URL!") + .to_file_path() + .expect("Core Text font didn't name a path!"); + let mut bytes = Vec::new(); + File::open(path).expect("Couldn't open font file!").read_to_end(&mut bytes).unwrap(); + bytes + } + + /// 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() + } + + /// Returns the native font that underlies this font template, if applicable. + pub fn native_font(&self) -> Option<CGFont> { + self.ctfont().map(|ctfont| ctfont.copy_to_CGFont()) + } } #[derive(Debug)] |