diff --git a/components/gfx/platform/macos/font.rs b/components/gfx/platform/macos/font.rs index b8474aa6da9..6ef613572d5 100644 --- a/components/gfx/platform/macos/font.rs +++ b/components/gfx/platform/macos/font.rs @@ -57,9 +57,9 @@ pub struct FontHandle { impl FontHandleMethods for FontHandle { fn new_from_template(_fctx: &FontContextHandle, - template: Arc, - pt_size: Option) - -> Result { + template: Arc, + pt_size: Option) + -> Result { let size = match pt_size { Some(s) => s.to_f64_px(), None => 0.0 diff --git a/components/gfx/platform/macos/font_template.rs b/components/gfx/platform/macos/font_template.rs index e84691971ac..7e8229babe1 100644 --- a/components/gfx/platform/macos/font_template.rs +++ b/components/gfx/platform/macos/font_template.rs @@ -38,22 +38,8 @@ unsafe impl Sync for FontTemplateData {} impl FontTemplateData { pub fn new(identifier: Atom, font_data: Option>) -> FontTemplateData { - let ctfont = match font_data { - Some(ref bytes) => { - let fontprov = CGDataProvider::from_buffer(bytes); - let cgfont_result = CGFont::from_data_provider(fontprov); - match cgfont_result { - Ok(cgfont) => Some(core_text::font::new_from_CGFont(&cgfont, 0.0)), - Err(_) => None - } - }, - None => { - Some(core_text::font::new_from_name(identifier.as_slice(), 0.0).unwrap()) - } - }; - FontTemplateData { - ctfont: CachedCTFont(Mutex::new(ctfont)), + ctfont: CachedCTFont(Mutex::new(None)), identifier: identifier.to_owned(), font_data: font_data } @@ -63,7 +49,17 @@ impl FontTemplateData { pub fn ctfont(&self) -> Option { let mut ctfont = self.ctfont.lock().unwrap(); if ctfont.is_none() { - *ctfont = core_text::font::new_from_name(self.identifier.as_slice(), 0.0).ok() + *ctfont = match self.font_data { + Some(ref bytes) => { + let fontprov = CGDataProvider::from_buffer(bytes); + let cgfont_result = CGFont::from_data_provider(fontprov); + match cgfont_result { + Ok(cgfont) => Some(core_text::font::new_from_CGFont(&cgfont, 0.0)), + Err(_) => None + } + } + None => core_text::font::new_from_name(self.identifier.as_slice(), 0.0).ok(), + } } ctfont.as_ref().map(|ctfont| (*ctfont).clone()) } diff --git a/tests/ref/basic.list b/tests/ref/basic.list index fa4ccd4c687..1318c9d6f4d 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -219,6 +219,7 @@ flaky_cpu == linebreak_simple_a.html linebreak_simple_b.html == nth_last_of_type_pseudo_a.html nth_last_of_type_pseudo_b.html == nth_of_type_pseudo_a.html nth_of_type_pseudo_b.html == object_element_a.html object_element_b.html +!= octicons_a.html octicons_ref.html == ol_japanese_iroha_a.html ol_japanese_iroha_ref.html != ol_japanese_iroha_bullet_styles.html ol_japanese_iroha_ref.html == ol_simple_a.html ol_simple_ref.html diff --git a/tests/ref/fonts/octicons/LICENSE.txt b/tests/ref/fonts/octicons/LICENSE.txt new file mode 100644 index 00000000000..69aa0d54269 --- /dev/null +++ b/tests/ref/fonts/octicons/LICENSE.txt @@ -0,0 +1,9 @@ +(c) 2012-2015 GitHub + +When using the GitHub logos, be sure to follow the GitHub logo guidelines (https://github.com/logos) + +Font License: SIL OFL 1.1 (http://scripts.sil.org/OFL) +Applies to all font files + +Code License: MIT (http://choosealicense.com/licenses/mit/) +Applies to all other files diff --git a/tests/ref/fonts/octicons/octicons.ttf b/tests/ref/fonts/octicons/octicons.ttf new file mode 100644 index 00000000000..9e091053052 Binary files /dev/null and b/tests/ref/fonts/octicons/octicons.ttf differ diff --git a/tests/ref/octicons_a.html b/tests/ref/octicons_a.html new file mode 100644 index 00000000000..eb3a4a97b82 --- /dev/null +++ b/tests/ref/octicons_a.html @@ -0,0 +1,15 @@ + + + + + +

+ diff --git a/tests/ref/octicons_ref.html b/tests/ref/octicons_ref.html new file mode 100644 index 00000000000..926297b1da4 --- /dev/null +++ b/tests/ref/octicons_ref.html @@ -0,0 +1,12 @@ + + + + + +

+ +