mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
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.
This commit is contained in:
parent
f30faeadd0
commit
f298089f02
1 changed files with 3 additions and 1 deletions
|
@ -16,6 +16,7 @@ use std::borrow::ToOwned;
|
||||||
pub struct FontTemplateData {
|
pub struct FontTemplateData {
|
||||||
pub ctfont: Option<CTFont>,
|
pub ctfont: Option<CTFont>,
|
||||||
pub identifier: String,
|
pub identifier: String,
|
||||||
|
pub font_data: Option<Vec<u8>>
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for FontTemplateData {}
|
unsafe impl Send for FontTemplateData {}
|
||||||
|
@ -24,7 +25,7 @@ unsafe impl Sync for FontTemplateData {}
|
||||||
impl FontTemplateData {
|
impl FontTemplateData {
|
||||||
pub fn new(identifier: &str, font_data: Option<Vec<u8>>) -> FontTemplateData {
|
pub fn new(identifier: &str, font_data: Option<Vec<u8>>) -> FontTemplateData {
|
||||||
let ctfont = match font_data {
|
let ctfont = match font_data {
|
||||||
Some(bytes) => {
|
Some(ref bytes) => {
|
||||||
let fontprov = CGDataProvider::from_buffer(bytes.as_slice());
|
let fontprov = CGDataProvider::from_buffer(bytes.as_slice());
|
||||||
let cgfont_result = CGFont::from_data_provider(fontprov);
|
let cgfont_result = CGFont::from_data_provider(fontprov);
|
||||||
match cgfont_result {
|
match cgfont_result {
|
||||||
|
@ -40,6 +41,7 @@ impl FontTemplateData {
|
||||||
FontTemplateData {
|
FontTemplateData {
|
||||||
ctfont: ctfont,
|
ctfont: ctfont,
|
||||||
identifier: identifier.to_owned(),
|
identifier: identifier.to_owned(),
|
||||||
|
font_data: font_data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue