From 2a75bbef6212e01b61594d782482de0179181101 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 5 May 2014 11:09:36 +0200 Subject: [PATCH] Use Vec for Font::new_from_buffer. --- src/components/gfx/font.rs | 8 ++++---- src/components/gfx/platform/android/font.rs | 6 +++--- src/components/gfx/platform/linux/font.rs | 6 +++--- src/components/gfx/platform/macos/font.rs | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/gfx/font.rs b/src/components/gfx/font.rs index aa389e00664..a77ca3a2a29 100644 --- a/src/components/gfx/font.rs +++ b/src/components/gfx/font.rs @@ -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, style: &SpecifiedFontStyle) -> Result; // 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, + style: &SpecifiedFontStyle, + backend: BackendType) -> Result>, ()> { let handle = FontHandleMethods::new_from_buffer(&ctx.handle, buffer, style); let handle: FontHandle = if handle.is_ok() { diff --git a/src/components/gfx/platform/android/font.rs b/src/components/gfx/platform/android/font.rs index 3601e0e73f0..b8a4f110cc4 100644 --- a/src/components/gfx/platform/android/font.rs +++ b/src/components/gfx/platform/android/font.rs @@ -47,7 +47,7 @@ impl FontTableMethods for FontTable { } enum FontSource { - FontSourceMem(~[u8]), + FontSourceMem(Vec), 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, + style: &SpecifiedFontStyle) -> Result { let ft_ctx: FT_Library = fctx.ctx.ctx; if ft_ctx.is_null() { return Err(()); } diff --git a/src/components/gfx/platform/linux/font.rs b/src/components/gfx/platform/linux/font.rs index 16beabe4a56..94527b3b35d 100644 --- a/src/components/gfx/platform/linux/font.rs +++ b/src/components/gfx/platform/linux/font.rs @@ -47,7 +47,7 @@ impl FontTableMethods for FontTable { } pub enum FontSource { - FontSourceMem(~[u8]), + FontSourceMem(Vec), 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, + style: &SpecifiedFontStyle) -> Result { let ft_ctx: FT_Library = fctx.ctx.ctx; if ft_ctx.is_null() { return Err(()); } diff --git a/src/components/gfx/platform/macos/font.rs b/src/components/gfx/platform/macos/font.rs index 2e3b0246511..5441415b653 100644 --- a/src/components/gfx/platform/macos/font.rs +++ b/src/components/gfx/platform/macos/font.rs @@ -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, style: &SpecifiedFontStyle) -> Result { - 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);