Use Vec for Font::new_from_buffer.

This commit is contained in:
Ms2ger 2014-05-05 11:09:36 +02:00
parent 7e2e426212
commit 2a75bbef62
4 changed files with 12 additions and 12 deletions

View file

@ -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() {

View file

@ -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(()); }

View file

@ -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(()); }

View file

@ -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);