mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Use Vec for Font::new_from_buffer.
This commit is contained in:
parent
7e2e426212
commit
2a75bbef62
4 changed files with 12 additions and 12 deletions
|
@ -33,7 +33,7 @@ use text::{Shaper, TextRun};
|
|||
// resources needed by the graphics layer to draw glyphs.
|
||||
|
||||
pub trait FontHandleMethods {
|
||||
fn new_from_buffer(fctx: &FontContextHandle, buf: ~[u8], style: &SpecifiedFontStyle)
|
||||
fn new_from_buffer(fctx: &FontContextHandle, buf: Vec<u8>, style: &SpecifiedFontStyle)
|
||||
-> Result<Self,()>;
|
||||
|
||||
// an identifier usable by FontContextHandle to recreate this FontHandle.
|
||||
|
@ -216,9 +216,9 @@ pub struct Font {
|
|||
|
||||
impl<'a> Font {
|
||||
pub fn new_from_buffer(ctx: &FontContext,
|
||||
buffer: ~[u8],
|
||||
style: &SpecifiedFontStyle,
|
||||
backend: BackendType)
|
||||
buffer: Vec<u8>,
|
||||
style: &SpecifiedFontStyle,
|
||||
backend: BackendType)
|
||||
-> Result<Rc<RefCell<Font>>, ()> {
|
||||
let handle = FontHandleMethods::new_from_buffer(&ctx.handle, buffer, style);
|
||||
let handle: FontHandle = if handle.is_ok() {
|
||||
|
|
|
@ -47,7 +47,7 @@ impl FontTableMethods for FontTable {
|
|||
}
|
||||
|
||||
enum FontSource {
|
||||
FontSourceMem(~[u8]),
|
||||
FontSourceMem(Vec<u8>),
|
||||
FontSourceFile(~str)
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,8 @@ impl Drop for FontHandle {
|
|||
|
||||
impl FontHandleMethods for FontHandle {
|
||||
fn new_from_buffer(fctx: &FontContextHandle,
|
||||
buf: ~[u8],
|
||||
style: &SpecifiedFontStyle)
|
||||
buf: Vec<u8>,
|
||||
style: &SpecifiedFontStyle)
|
||||
-> Result<FontHandle, ()> {
|
||||
let ft_ctx: FT_Library = fctx.ctx.ctx;
|
||||
if ft_ctx.is_null() { return Err(()); }
|
||||
|
|
|
@ -47,7 +47,7 @@ impl FontTableMethods for FontTable {
|
|||
}
|
||||
|
||||
pub enum FontSource {
|
||||
FontSourceMem(~[u8]),
|
||||
FontSourceMem(Vec<u8>),
|
||||
FontSourceFile(~str)
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,8 @@ impl Drop for FontHandle {
|
|||
|
||||
impl FontHandleMethods for FontHandle {
|
||||
fn new_from_buffer(fctx: &FontContextHandle,
|
||||
buf: ~[u8],
|
||||
style: &SpecifiedFontStyle)
|
||||
buf: Vec<u8>,
|
||||
style: &SpecifiedFontStyle)
|
||||
-> Result<FontHandle, ()> {
|
||||
let ft_ctx: FT_Library = fctx.ctx.ctx;
|
||||
if ft_ctx.is_null() { return Err(()); }
|
||||
|
|
|
@ -77,9 +77,9 @@ impl FontHandle {
|
|||
}
|
||||
|
||||
impl FontHandleMethods for FontHandle {
|
||||
fn new_from_buffer(_: &FontContextHandle, buf: ~[u8], style: &SpecifiedFontStyle)
|
||||
fn new_from_buffer(_: &FontContextHandle, buf: Vec<u8>, style: &SpecifiedFontStyle)
|
||||
-> Result<FontHandle, ()> {
|
||||
let fontprov = CGDataProvider::from_buffer(buf);
|
||||
let fontprov = CGDataProvider::from_buffer(buf.as_slice());
|
||||
let cgfont = CGFont::from_data_provider(fontprov);
|
||||
let ctfont = core_text::font::new_from_CGFont(&cgfont, style.pt_size);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue