mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Remove native.rs. It's no longer needed; just use platform::* directly.
This commit is contained in:
parent
9822f5d96b
commit
b2f5ccfd5f
12 changed files with 104 additions and 176 deletions
|
@ -3,11 +3,11 @@
|
|||
use color::Color;
|
||||
use font_context::FontContext;
|
||||
use geometry::Au;
|
||||
use platform;
|
||||
use platform::font_context::FontContextHandle;
|
||||
use platform::font::{FontHandle, FontTable};
|
||||
use render_context::RenderContext;
|
||||
use text::glyph::{GlyphStore, GlyphIndex};
|
||||
use text::shaper::ShaperMethods;
|
||||
use text::shaper::ShaperMethods;
|
||||
use text::{Shaper, TextRun};
|
||||
use util::range::Range;
|
||||
|
||||
|
@ -16,20 +16,15 @@ use azure::scaled_font::ScaledFont;
|
|||
use azure::azure_hl::{BackendType, ColorPattern};
|
||||
use geom::{Point2D, Rect, Size2D};
|
||||
|
||||
use native;
|
||||
|
||||
// FontHandle encapsulates access to the platform's font API,
|
||||
// e.g. quartz, FreeType. It provides access to metrics and tables
|
||||
// needed by the text shaper as well as access to the underlying font
|
||||
// resources needed by the graphics layer to draw glyphs.
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub type FontHandle = platform::font::QuartzFontHandle;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub type FontHandle = platform::font::FreeTypeFontHandle;
|
||||
|
||||
pub trait FontHandleMethods {
|
||||
fn new_from_buffer(fctx: &FontContextHandle, buf: ~[u8], style: &SpecifiedFontStyle)
|
||||
-> Result<Self,()>;
|
||||
|
||||
// an identifier usable by FontContextHandle to recreate this FontHandle.
|
||||
fn face_identifier(&self) -> ~str;
|
||||
fn family_name(&self) -> ~str;
|
||||
|
@ -37,36 +32,14 @@ pub trait FontHandleMethods {
|
|||
fn is_italic(&self) -> bool;
|
||||
fn boldness(&self) -> CSSFontWeight;
|
||||
|
||||
fn clone_with_style(&self, fctx: &native::FontContextHandle, style: &UsedFontStyle) -> Result<FontHandle, ()>;
|
||||
fn clone_with_style(&self, fctx: &FontContextHandle, style: &UsedFontStyle)
|
||||
-> Result<FontHandle, ()>;
|
||||
fn glyph_index(&self, codepoint: char) -> Option<GlyphIndex>;
|
||||
fn glyph_h_advance(&self, GlyphIndex) -> Option<FractionalPixel>;
|
||||
fn get_metrics(&self) -> FontMetrics;
|
||||
fn get_table_for_tag(&self, FontTableTag) -> Option<FontTable>;
|
||||
}
|
||||
|
||||
// TODO(Issue #163): this is a workaround for static methods and
|
||||
// typedefs not working well together. It should be removed.
|
||||
//
|
||||
// `new` should be part of trait FontHandleMethods.
|
||||
|
||||
pub impl FontHandle {
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn new_from_buffer(fctx: &native::FontContextHandle,
|
||||
buf: ~[u8],
|
||||
style: &SpecifiedFontStyle)
|
||||
-> Result<FontHandle, ()> {
|
||||
platform::font::QuartzFontHandle::new_from_buffer(fctx, buf, style)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn new_from_buffer(fctx: &native::FontContextHandle,
|
||||
buf: ~[u8],
|
||||
style: &SpecifiedFontStyle)
|
||||
-> Result<FontHandle, ()> {
|
||||
platform::font::FreeTypeFontHandle::new_from_buffer(fctx, @buf, style)
|
||||
}
|
||||
}
|
||||
|
||||
// Used to abstract over the shaper's choice of fixed int representation.
|
||||
pub type FractionalPixel = float;
|
||||
|
||||
|
@ -88,12 +61,6 @@ impl FontTableTagConversions for FontTableTag {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub type FontTable = platform::font::QuartzFontTable;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub type FontTable = platform::font::FreeTypeFontTable;
|
||||
|
||||
pub trait FontTableMethods {
|
||||
fn with_buffer(&self, &fn(*u8, uint));
|
||||
}
|
||||
|
@ -246,8 +213,8 @@ pub impl Font {
|
|||
style: &SpecifiedFontStyle,
|
||||
backend: BackendType)
|
||||
-> Result<@mut Font, ()> {
|
||||
let handle = FontHandle::new_from_buffer(&ctx.handle, buffer, style);
|
||||
let handle = if handle.is_ok() {
|
||||
let handle = FontHandleMethods::new_from_buffer(&ctx.handle, buffer, style);
|
||||
let handle: FontHandle = if handle.is_ok() {
|
||||
result::unwrap(handle)
|
||||
} else {
|
||||
return Err(handle.get_err());
|
||||
|
|
|
@ -4,8 +4,8 @@ use font::{Font, FontDescriptor, FontGroup, FontStyle, SelectorPlatformIdentifie
|
|||
use font::{SelectorStubDummy, SpecifiedFontStyle, UsedFontStyle};
|
||||
use font_context;
|
||||
use font_list::FontList;
|
||||
use native::FontHandle;
|
||||
use platform;
|
||||
use platform::font::FontHandle;
|
||||
use platform::font_context::FontContextHandle;
|
||||
use util::cache::Cache;
|
||||
use util::cache::MonoCache;
|
||||
|
||||
|
@ -32,31 +32,11 @@ pub fn dummy_style() -> FontStyle {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
type FontContextHandle = platform::font_context::QuartzFontContextHandle;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
type FontContextHandle = platform::font_context::FreeTypeFontContextHandle;
|
||||
|
||||
pub trait FontContextHandleMethods {
|
||||
fn clone(&self) -> FontContextHandle;
|
||||
fn create_font_from_identifier(&self, ~str, UsedFontStyle) -> Result<FontHandle, ()>;
|
||||
}
|
||||
|
||||
// TODO(Issue #163): this is a workaround for static methods, traits,
|
||||
// and typedefs not working well together. It should be removed.
|
||||
pub impl FontContextHandle {
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn new() -> FontContextHandle {
|
||||
platform::font_context::QuartzFontContextHandle::new()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn new() -> FontContextHandle {
|
||||
platform::font_context::FreeTypeFontContextHandle::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
pub struct FontContext {
|
||||
instance_cache: MonoCache<FontDescriptor, @mut Font>,
|
||||
|
|
|
@ -2,36 +2,17 @@
|
|||
|
||||
use font::{CSSFontWeight, SpecifiedFontStyle};
|
||||
use gfx_font::FontHandleMethods;
|
||||
use gfx_font::FontHandleMethods;
|
||||
use native::FontHandle;
|
||||
use native;
|
||||
use platform;
|
||||
use platform::font::FontHandle;
|
||||
use platform::font_context::FontContextHandle;
|
||||
use platform::font_list::FontListHandle;
|
||||
use util::time::time;
|
||||
|
||||
use core::hashmap::HashMap;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
type FontListHandle = platform::font_list::QuartzFontListHandle;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
type FontListHandle = platform::font_list::FontconfigFontListHandle;
|
||||
|
||||
pub impl FontListHandle {
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn new(fctx: &native::FontContextHandle) -> Result<FontListHandle, ()> {
|
||||
Ok(platform::font_list::QuartzFontListHandle::new(fctx))
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn new(fctx: &native::FontContextHandle) -> Result<FontListHandle, ()> {
|
||||
Ok(platform::font_list::FontconfigFontListHandle::new(fctx))
|
||||
}
|
||||
}
|
||||
|
||||
pub type FontFamilyMap = HashMap<~str, @mut FontFamily>;
|
||||
|
||||
trait FontListHandleMethods {
|
||||
fn get_available_families(&self, fctx: &native::FontContextHandle) -> FontFamilyMap;
|
||||
fn get_available_families(&self, fctx: &FontContextHandle) -> FontFamilyMap;
|
||||
fn load_variations_for_family(&self, family: @mut FontFamily);
|
||||
}
|
||||
|
||||
|
@ -41,8 +22,8 @@ pub struct FontList {
|
|||
}
|
||||
|
||||
pub impl FontList {
|
||||
fn new(fctx: &native::FontContextHandle) -> FontList {
|
||||
let handle = result::unwrap(FontListHandle::new(fctx));
|
||||
fn new(fctx: &FontContextHandle) -> FontList {
|
||||
let handle = FontListHandle::new(fctx);
|
||||
let mut list = FontList {
|
||||
handle: handle,
|
||||
family_map: HashMap::new(),
|
||||
|
@ -51,7 +32,7 @@ pub impl FontList {
|
|||
return list;
|
||||
}
|
||||
|
||||
priv fn refresh(&mut self, _fctx: &native::FontContextHandle) {
|
||||
priv fn refresh(&mut self, _: &FontContextHandle) {
|
||||
// TODO(Issue #186): don't refresh unless something actually
|
||||
// changed. Does OSX have a notification for this event?
|
||||
//
|
||||
|
@ -106,15 +87,15 @@ pub impl FontFamily {
|
|||
}
|
||||
}
|
||||
|
||||
priv fn load_family_variations(@mut self, list: &native::FontListHandle) {
|
||||
priv fn load_family_variations(@mut self, list: &FontListHandle) {
|
||||
let this : &mut FontFamily = self; // FIXME: borrow checker workaround
|
||||
if this.entries.len() > 0 { return; }
|
||||
list.load_variations_for_family(self);
|
||||
assert!(this.entries.len() > 0);
|
||||
}
|
||||
|
||||
fn find_font_for_style(@mut self, list: &native::FontListHandle, style: &SpecifiedFontStyle) -> Option<@FontEntry> {
|
||||
|
||||
fn find_font_for_style(@mut self, list: &FontListHandle, style: &SpecifiedFontStyle)
|
||||
-> Option<@FontEntry> {
|
||||
self.load_family_variations(list);
|
||||
|
||||
// TODO(Issue #189): optimize lookup for
|
||||
|
@ -165,5 +146,8 @@ pub impl FontEntry {
|
|||
self.weight.is_bold()
|
||||
}
|
||||
|
||||
fn is_italic(&self) -> bool { self.italic }
|
||||
fn is_italic(&self) -> bool {
|
||||
self.italic
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
/* This file exists just to make it easier to import platform-specific
|
||||
implementations.
|
||||
|
||||
Note that you still must define each of the files as a module in
|
||||
servo_gfx.rc. This is not ideal and may be changed in the future. */
|
||||
|
||||
pub use font::FontHandle;
|
||||
pub use font_context::FontContextHandle;
|
||||
pub use font_list::FontListHandle;
|
|
@ -8,8 +8,7 @@ use gfx_font::{CSSFontWeight, FontHandleMethods, FontMetrics, FontTable, FontTab
|
|||
use gfx_font::{FontTableTag, FractionalPixel, SpecifiedFontStyle, UsedFontStyle, FontWeight100};
|
||||
use gfx_font::{FontWeight200, FontWeight300, FontWeight400, FontWeight500, FontWeight600};
|
||||
use gfx_font::{FontWeight700, FontWeight800, FontWeight900};
|
||||
use native;
|
||||
use platform::font_context::FreeTypeFontContextHandle;
|
||||
use platform::font_context::{FreeTypeFontContextHandle, FontContextHandle};
|
||||
use text::glyph::GlyphIndex;
|
||||
use text::util::{float_to_fixed, fixed_to_float};
|
||||
|
||||
|
@ -24,6 +23,9 @@ use platform::font::freetype::freetype::{FT_SizeRec, FT_UInt, FT_Size_Metrics};
|
|||
use platform::font::freetype::freetype::{ft_sfnt_os2};
|
||||
use platform::font::freetype::tt_os2::TT_OS2;
|
||||
|
||||
pub use FontHandle = platform::linux::font::FreeTypeFontHandle;
|
||||
pub use FontTable = platform::linux::font::FreeTypeFontTable;
|
||||
|
||||
fn float_to_fixed_ft(f: float) -> i32 {
|
||||
float_to_fixed(6, f)
|
||||
}
|
||||
|
@ -113,9 +115,15 @@ pub impl FreeTypeFontHandle {
|
|||
|
||||
Ok(FreeTypeFontHandle { source: FontSourceFile(file), face: face })
|
||||
}
|
||||
}
|
||||
|
||||
impl FontHandleMethods for FreeTypeFontHandle {
|
||||
pub fn new_from_buffer(fctx: &FreeTypeFontContextHandle,
|
||||
buf: @~[u8], style: &SpecifiedFontStyle) -> Result<FreeTypeFontHandle, ()> {
|
||||
buf: ~[u8],
|
||||
style: &SpecifiedFontStyle)
|
||||
-> Result<FreeTypeFontHandle, ()> {
|
||||
let buf = @buf;
|
||||
|
||||
let ft_ctx: FT_Library = fctx.ctx.ctx;
|
||||
if ft_ctx.is_null() { return Err(()); }
|
||||
|
||||
|
@ -150,9 +158,7 @@ pub impl FreeTypeFontHandle {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FontHandleMethods for FreeTypeFontHandle {
|
||||
// an identifier usable by FontContextHandle to recreate this FontHandle.
|
||||
fn face_identifier(&self) -> ~str {
|
||||
/* FT_Get_Postscript_Name seems like a better choice here, but it
|
||||
|
@ -196,7 +202,7 @@ impl FontHandleMethods for FreeTypeFontHandle {
|
|||
}
|
||||
|
||||
fn clone_with_style(&self,
|
||||
fctx: &native::FontContextHandle,
|
||||
fctx: &FontContextHandle,
|
||||
style: &UsedFontStyle) -> Result<FreeTypeFontHandle, ()> {
|
||||
match self.source {
|
||||
FontSourceMem(buf) => {
|
||||
|
|
|
@ -9,6 +9,8 @@ use platform::font_list::path_from_identifier;
|
|||
use platform::font_context::freetype::freetype::{FTErrorMethods, FT_Library};
|
||||
use platform::font_context::freetype::freetype::bindgen::{FT_Done_FreeType, FT_Init_FreeType};
|
||||
|
||||
pub use FontContextHandle = platform::linux::FreeTypeFontContextHandle;
|
||||
|
||||
struct FreeTypeLibraryHandle {
|
||||
ctx: FT_Library,
|
||||
}
|
||||
|
|
|
@ -6,9 +6,8 @@ extern mod fontconfig;
|
|||
use gfx_font::FontHandleMethods;
|
||||
use gfx_font_context::FontContextHandleMethods;
|
||||
use gfx_font_list::{FontEntry, FontFamily, FontFamilyMap};
|
||||
use native;
|
||||
use platform::font::FreeTypeFontHandle;
|
||||
use platform::font_context::FreeTypeFontContextHandle;
|
||||
use platform::font_context::{FontContextHandle, FreeTypeFontContextHandle};
|
||||
|
||||
use core::hashmap::HashMap;
|
||||
use core::libc::c_int;
|
||||
|
@ -35,7 +34,7 @@ pub struct FontconfigFontListHandle {
|
|||
}
|
||||
|
||||
pub impl FontconfigFontListHandle {
|
||||
pub fn new(fctx: &native::FontContextHandle) -> FontconfigFontListHandle {
|
||||
pub fn new(fctx: &FontContextHandle) -> FontconfigFontListHandle {
|
||||
FontconfigFontListHandle { fctx: fctx.clone() }
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ extern mod core_graphics;
|
|||
extern mod core_text;
|
||||
|
||||
use geometry::Au;
|
||||
use gfx_font::{CSSFontWeight, FontHandleMethods, FontMetrics, FontTable, FontTableMethods};
|
||||
use gfx_font::{CSSFontWeight, FontHandleMethods, FontMetrics, FontTableMethods};
|
||||
use gfx_font::{FontTableTag, FontWeight100, FontWeight200, FontWeight300, FontWeight400};
|
||||
use gfx_font::{FontWeight500, FontWeight600, FontWeight700, FontWeight800, FontWeight900};
|
||||
use gfx_font::{FractionalPixel, SpecifiedFontStyle};
|
||||
|
@ -19,59 +19,39 @@ use platform::macos::font::core_text::font::{CTFont, CTFontMethods, CTFontMethod
|
|||
use platform::macos::font::core_text::font_descriptor::{SymbolicTraitAccessors};
|
||||
use platform::macos::font::core_text::font_descriptor::{TraitAccessors};
|
||||
use platform::macos::font::core_text::font_descriptor::{kCTFontDefaultOrientation};
|
||||
use platform::macos::font_context::QuartzFontContextHandle;
|
||||
use platform::macos::font_context::FontContextHandle;
|
||||
use platform;
|
||||
use text::glyph::GlyphIndex;
|
||||
|
||||
struct QuartzFontTable {
|
||||
pub struct FontTable {
|
||||
data: CFData,
|
||||
}
|
||||
|
||||
|
||||
// Noncopyable.
|
||||
impl Drop for QuartzFontTable { fn finalize(&self) {} }
|
||||
impl Drop for FontTable {
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
pub impl QuartzFontTable {
|
||||
fn wrap(data: CFData) -> QuartzFontTable {
|
||||
QuartzFontTable { data: data }
|
||||
pub impl FontTable {
|
||||
fn wrap(data: CFData) -> FontTable {
|
||||
FontTable { data: data }
|
||||
}
|
||||
}
|
||||
|
||||
impl FontTableMethods for QuartzFontTable {
|
||||
impl FontTableMethods for FontTable {
|
||||
fn with_buffer(&self, blk: &fn(*u8, uint)) {
|
||||
blk(self.data.bytes(), self.data.len());
|
||||
}
|
||||
}
|
||||
|
||||
pub struct QuartzFontHandle {
|
||||
pub struct FontHandle {
|
||||
priv cgfont: Option<CGFont>,
|
||||
ctfont: CTFont,
|
||||
}
|
||||
|
||||
pub impl QuartzFontHandle {
|
||||
fn new_from_buffer(_fctx: &QuartzFontContextHandle, buf: ~[u8],
|
||||
style: &SpecifiedFontStyle) -> Result<QuartzFontHandle, ()> {
|
||||
let fontprov : CGDataProvider = vec::as_imm_buf(buf, |cbuf, len| {
|
||||
platform::macos::font::core_graphics::data_provider::new_from_buffer(cbuf, len)
|
||||
});
|
||||
|
||||
let cgfont = platform::macos::font::core_graphics::font::create_with_data_provider(
|
||||
&fontprov);
|
||||
let ctfont = platform::macos::font::core_text::font::new_from_CGFont(&cgfont,
|
||||
style.pt_size);
|
||||
|
||||
let result = Ok(QuartzFontHandle {
|
||||
cgfont: Some(cgfont),
|
||||
ctfont: ctfont,
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
fn new_from_CTFont(_: &QuartzFontContextHandle,
|
||||
ctfont: CTFont)
|
||||
-> Result<QuartzFontHandle, ()> {
|
||||
Ok(QuartzFontHandle {
|
||||
pub impl FontHandle {
|
||||
fn new_from_CTFont(_: &FontContextHandle, ctfont: CTFont) -> Result<FontHandle, ()> {
|
||||
Ok(FontHandle {
|
||||
mut cgfont: None,
|
||||
ctfont: ctfont,
|
||||
})
|
||||
|
@ -89,7 +69,26 @@ pub impl QuartzFontHandle {
|
|||
}
|
||||
}
|
||||
|
||||
impl FontHandleMethods for QuartzFontHandle {
|
||||
impl FontHandleMethods for FontHandle {
|
||||
fn new_from_buffer(_: &FontContextHandle, buf: ~[u8], style: &SpecifiedFontStyle)
|
||||
-> Result<FontHandle, ()> {
|
||||
let fontprov : CGDataProvider = vec::as_imm_buf(buf, |cbuf, len| {
|
||||
platform::macos::font::core_graphics::data_provider::new_from_buffer(cbuf, len)
|
||||
});
|
||||
|
||||
let cgfont = platform::macos::font::core_graphics::font::create_with_data_provider(
|
||||
&fontprov);
|
||||
let ctfont = platform::macos::font::core_text::font::new_from_CGFont(&cgfont,
|
||||
style.pt_size);
|
||||
|
||||
let result = Ok(FontHandle {
|
||||
cgfont: Some(cgfont),
|
||||
ctfont: ctfont,
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
fn family_name(&self) -> ~str {
|
||||
self.ctfont.family_name()
|
||||
}
|
||||
|
@ -118,11 +117,10 @@ impl FontHandleMethods for QuartzFontHandle {
|
|||
return FontWeight900;
|
||||
}
|
||||
|
||||
fn clone_with_style(&self, fctx: &QuartzFontContextHandle,
|
||||
style: &SpecifiedFontStyle)
|
||||
-> Result<QuartzFontHandle,()> {
|
||||
fn clone_with_style(&self, fctx: &FontContextHandle, style: &SpecifiedFontStyle)
|
||||
-> Result<FontHandle,()> {
|
||||
let new_font = self.ctfont.clone_with_font_size(style.pt_size);
|
||||
return QuartzFontHandle::new_from_CTFont(fctx, new_font);
|
||||
return FontHandle::new_from_CTFont(fctx, new_font);
|
||||
}
|
||||
|
||||
fn glyph_index(&self, codepoint: char) -> Option<GlyphIndex> {
|
||||
|
@ -182,7 +180,7 @@ impl FontHandleMethods for QuartzFontHandle {
|
|||
fn get_table_for_tag(&self, tag: FontTableTag) -> Option<FontTable> {
|
||||
let result: Option<CFData> = self.ctfont.get_font_table(tag);
|
||||
result.chain(|data| {
|
||||
Some(QuartzFontTable::wrap(data))
|
||||
Some(FontTable::wrap(data))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -2,26 +2,28 @@ extern mod core_foundation;
|
|||
extern mod core_graphics;
|
||||
extern mod core_text;
|
||||
|
||||
use gfx_font::{FontHandle, UsedFontStyle};
|
||||
use gfx_font::UsedFontStyle;
|
||||
use gfx_font_context::FontContextHandleMethods;
|
||||
|
||||
use platform::macos::font::QuartzFontHandle;
|
||||
use platform::macos::font::FontHandle;
|
||||
use platform;
|
||||
|
||||
pub struct QuartzFontContextHandle {
|
||||
pub struct FontContextHandle {
|
||||
ctx: ()
|
||||
}
|
||||
|
||||
pub impl QuartzFontContextHandle {
|
||||
pub impl FontContextHandle {
|
||||
// this is a placeholder until NSFontManager or whatever is bound in here.
|
||||
pub fn new() -> QuartzFontContextHandle {
|
||||
QuartzFontContextHandle { ctx: () }
|
||||
pub fn new() -> FontContextHandle {
|
||||
FontContextHandle { ctx: () }
|
||||
}
|
||||
}
|
||||
|
||||
impl FontContextHandleMethods for QuartzFontContextHandle {
|
||||
fn clone(&self) -> QuartzFontContextHandle {
|
||||
QuartzFontContextHandle { ctx: self.ctx }
|
||||
impl FontContextHandleMethods for FontContextHandle {
|
||||
fn clone(&self) -> FontContextHandle {
|
||||
FontContextHandle {
|
||||
ctx: self.ctx
|
||||
}
|
||||
}
|
||||
|
||||
fn create_font_from_identifier(&self,
|
||||
|
@ -32,7 +34,7 @@ impl FontContextHandleMethods for QuartzFontContextHandle {
|
|||
name,
|
||||
style.pt_size);
|
||||
do result::chain(ctfont_result) |ctfont| {
|
||||
QuartzFontHandle::new_from_CTFont(self, ctfont)
|
||||
FontHandle::new_from_CTFont(self, ctfont)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,8 @@ use gfx_font::FontHandleMethods;
|
|||
use gfx_font_context::FontContextHandleMethods;
|
||||
use gfx_font_list::{FontEntry, FontFamily, FontFamilyMap};
|
||||
|
||||
use native;
|
||||
use platform::macos::font::QuartzFontHandle;
|
||||
use platform::macos::font_context::QuartzFontContextHandle;
|
||||
use platform::macos::font::FontHandle;
|
||||
use platform::macos::font_context::FontContextHandle;
|
||||
use platform::macos::font_list::core_foundation::array::CFArray;
|
||||
use platform::macos::font_list::core_foundation::base::CFWrapper;
|
||||
use platform::macos::font_list::core_foundation::string::{CFString, CFStringRef};
|
||||
|
@ -17,13 +16,15 @@ use platform;
|
|||
|
||||
use core::hashmap::HashMap;
|
||||
|
||||
pub struct QuartzFontListHandle {
|
||||
fctx: QuartzFontContextHandle,
|
||||
pub struct FontListHandle {
|
||||
fctx: FontContextHandle,
|
||||
}
|
||||
|
||||
pub impl QuartzFontListHandle {
|
||||
fn new(fctx: &native::FontContextHandle) -> QuartzFontListHandle {
|
||||
QuartzFontListHandle { fctx: fctx.clone() }
|
||||
pub impl FontListHandle {
|
||||
fn new(fctx: &FontContextHandle) -> FontListHandle {
|
||||
FontListHandle {
|
||||
fctx: fctx.clone()
|
||||
}
|
||||
}
|
||||
|
||||
fn get_available_families(&self) -> FontFamilyMap {
|
||||
|
@ -52,7 +53,7 @@ pub impl QuartzFontListHandle {
|
|||
let desc = CFWrapper::wrap_shared(*descref);
|
||||
let font = platform::macos::font_list::core_text::font::new_from_descriptor(&desc,
|
||||
0.0);
|
||||
let handle = result::unwrap(QuartzFontHandle::new_from_CTFont(&self.fctx, font));
|
||||
let handle = result::unwrap(FontHandle::new_from_CTFont(&self.fctx, font));
|
||||
|
||||
debug!("Creating new FontEntry for face: %s", handle.face_name());
|
||||
let entry = @FontEntry::new(family, handle);
|
||||
|
|
|
@ -37,10 +37,7 @@ pub mod font_list;
|
|||
// Misc.
|
||||
pub mod opts;
|
||||
|
||||
// Pub-uses for multiple implementations. Platform selection happens in
|
||||
// font.rs, font_list.rs, font_context.rs
|
||||
pub mod native;
|
||||
|
||||
// Platform-specific implementations.
|
||||
#[path="platform/mod.rs"]
|
||||
pub mod platform;
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ use geom::Point2D;
|
|||
|
||||
use geometry::Au;
|
||||
|
||||
use font::{Font, FontTable, FontTableMethods, FontTableTag};
|
||||
use font::{Font, FontTableMethods, FontTableTag};
|
||||
use platform::font::FontTable;
|
||||
|
||||
use text::glyph::{GlyphStore, GlyphIndex, GlyphData};
|
||||
use text::shaper::ShaperMethods;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue