mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Use atoms for font template structures.
This commit is contained in:
parent
d7cf58d6f1
commit
f8eeef0eb4
5 changed files with 27 additions and 26 deletions
|
@ -7,7 +7,7 @@ use core_graphics::font::CGFont;
|
|||
use core_text::font::CTFont;
|
||||
use core_text;
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
use string_cache::Atom;
|
||||
|
||||
/// Platform specific font representation for mac.
|
||||
/// The identifier is a PostScript font name. The
|
||||
|
@ -15,7 +15,7 @@ use std::borrow::ToOwned;
|
|||
/// paint functions that create CGFont references.
|
||||
pub struct FontTemplateData {
|
||||
pub ctfont: Option<CTFont>,
|
||||
pub identifier: String,
|
||||
pub identifier: Atom,
|
||||
pub font_data: Option<Vec<u8>>
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ unsafe impl Send for FontTemplateData {}
|
|||
unsafe impl Sync for FontTemplateData {}
|
||||
|
||||
impl FontTemplateData {
|
||||
pub fn new(identifier: &str, font_data: Option<Vec<u8>>) -> FontTemplateData {
|
||||
pub fn new(identifier: Atom, font_data: Option<Vec<u8>>) -> FontTemplateData {
|
||||
let ctfont = match font_data {
|
||||
Some(ref bytes) => {
|
||||
let fontprov = CGDataProvider::from_buffer(bytes);
|
||||
|
@ -34,7 +34,7 @@ impl FontTemplateData {
|
|||
}
|
||||
},
|
||||
None => {
|
||||
Some(core_text::font::new_from_name(identifier, 0.0).unwrap())
|
||||
Some(core_text::font::new_from_name(identifier.as_slice(), 0.0).unwrap())
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue