mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +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.
|
// resources needed by the graphics layer to draw glyphs.
|
||||||
|
|
||||||
pub trait FontHandleMethods {
|
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,()>;
|
-> Result<Self,()>;
|
||||||
|
|
||||||
// an identifier usable by FontContextHandle to recreate this FontHandle.
|
// an identifier usable by FontContextHandle to recreate this FontHandle.
|
||||||
|
@ -216,7 +216,7 @@ pub struct Font {
|
||||||
|
|
||||||
impl<'a> Font {
|
impl<'a> Font {
|
||||||
pub fn new_from_buffer(ctx: &FontContext,
|
pub fn new_from_buffer(ctx: &FontContext,
|
||||||
buffer: ~[u8],
|
buffer: Vec<u8>,
|
||||||
style: &SpecifiedFontStyle,
|
style: &SpecifiedFontStyle,
|
||||||
backend: BackendType)
|
backend: BackendType)
|
||||||
-> Result<Rc<RefCell<Font>>, ()> {
|
-> Result<Rc<RefCell<Font>>, ()> {
|
||||||
|
|
|
@ -47,7 +47,7 @@ impl FontTableMethods for FontTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum FontSource {
|
enum FontSource {
|
||||||
FontSourceMem(~[u8]),
|
FontSourceMem(Vec<u8>),
|
||||||
FontSourceFile(~str)
|
FontSourceFile(~str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ impl Drop for FontHandle {
|
||||||
|
|
||||||
impl FontHandleMethods for FontHandle {
|
impl FontHandleMethods for FontHandle {
|
||||||
fn new_from_buffer(fctx: &FontContextHandle,
|
fn new_from_buffer(fctx: &FontContextHandle,
|
||||||
buf: ~[u8],
|
buf: Vec<u8>,
|
||||||
style: &SpecifiedFontStyle)
|
style: &SpecifiedFontStyle)
|
||||||
-> Result<FontHandle, ()> {
|
-> Result<FontHandle, ()> {
|
||||||
let ft_ctx: FT_Library = fctx.ctx.ctx;
|
let ft_ctx: FT_Library = fctx.ctx.ctx;
|
||||||
|
|
|
@ -47,7 +47,7 @@ impl FontTableMethods for FontTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum FontSource {
|
pub enum FontSource {
|
||||||
FontSourceMem(~[u8]),
|
FontSourceMem(Vec<u8>),
|
||||||
FontSourceFile(~str)
|
FontSourceFile(~str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ impl Drop for FontHandle {
|
||||||
|
|
||||||
impl FontHandleMethods for FontHandle {
|
impl FontHandleMethods for FontHandle {
|
||||||
fn new_from_buffer(fctx: &FontContextHandle,
|
fn new_from_buffer(fctx: &FontContextHandle,
|
||||||
buf: ~[u8],
|
buf: Vec<u8>,
|
||||||
style: &SpecifiedFontStyle)
|
style: &SpecifiedFontStyle)
|
||||||
-> Result<FontHandle, ()> {
|
-> Result<FontHandle, ()> {
|
||||||
let ft_ctx: FT_Library = fctx.ctx.ctx;
|
let ft_ctx: FT_Library = fctx.ctx.ctx;
|
||||||
|
|
|
@ -77,9 +77,9 @@ impl FontHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FontHandleMethods for 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, ()> {
|
-> Result<FontHandle, ()> {
|
||||||
let fontprov = CGDataProvider::from_buffer(buf);
|
let fontprov = CGDataProvider::from_buffer(buf.as_slice());
|
||||||
let cgfont = CGFont::from_data_provider(fontprov);
|
let cgfont = CGFont::from_data_provider(fontprov);
|
||||||
let ctfont = core_text::font::new_from_CGFont(&cgfont, style.pt_size);
|
let ctfont = core_text::font::new_from_CGFont(&cgfont, style.pt_size);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue