mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
auto merge of #5222 : cojennin/servo/mac-font-face, r=metajack
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:
commit
4f32596cc6
1 changed files with 3 additions and 1 deletions
|
@ -16,6 +16,7 @@ use std::borrow::ToOwned;
|
|||
pub struct FontTemplateData {
|
||||
pub ctfont: Option<CTFont>,
|
||||
pub identifier: String,
|
||||
pub font_data: Option<Vec<u8>>
|
||||
}
|
||||
|
||||
unsafe impl Send for FontTemplateData {}
|
||||
|
@ -24,7 +25,7 @@ unsafe impl Sync for FontTemplateData {}
|
|||
impl FontTemplateData {
|
||||
pub fn new(identifier: &str, font_data: Option<Vec<u8>>) -> 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue