From f298089f0216f50b64d1197b36075f606566e609 Mon Sep 17 00:00:00 2001 From: Connor Jennings Date: Sun, 15 Mar 2015 14:02:27 -0400 Subject: [PATCH] Retain buffer for CGDataProviderCreateWithData. Fixes #5084. CGDataProviderCreateWithData just wraps the underlying buffer. The underlying buffer needs to be kept around until the data provider is freed. Adding the buffer to the FontTemplateData struct ensures it sticks around. --- components/gfx/platform/macos/font_template.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/gfx/platform/macos/font_template.rs b/components/gfx/platform/macos/font_template.rs index c6eb84d9746..02865733990 100644 --- a/components/gfx/platform/macos/font_template.rs +++ b/components/gfx/platform/macos/font_template.rs @@ -16,6 +16,7 @@ use std::borrow::ToOwned; pub struct FontTemplateData { pub ctfont: Option, pub identifier: String, + pub font_data: Option> } unsafe impl Send for FontTemplateData {} @@ -24,7 +25,7 @@ unsafe impl Sync for FontTemplateData {} impl FontTemplateData { pub fn new(identifier: &str, font_data: Option>) -> FontTemplateData { let ctfont = match font_data { - Some(bytes) => { + Some(ref bytes) => { let fontprov = CGDataProvider::from_buffer(bytes.as_slice()); let cgfont_result = CGFont::from_data_provider(fontprov); match cgfont_result { @@ -40,6 +41,7 @@ impl FontTemplateData { FontTemplateData { ctfont: ctfont, identifier: identifier.to_owned(), + font_data: font_data } } }