Introduce NativeFont

This commit is contained in:
Brian Anderson 2012-06-21 17:42:43 -07:00
parent 7d56150947
commit 3ffbaaaa47
4 changed files with 79 additions and 0 deletions

View file

@ -62,10 +62,21 @@ mod platform {
}
mod text {
export glyph;
export text_run;
export font;
export shaper;
mod glyph;
mod text_run;
mod font;
mod shaper;
mod native_font {
#[cfg(target_os = "macos")]
mod quartz_native_font;
#[cfg(target_os = "linux")]
mod ft_native_font;
}
}
mod util {

View file

@ -0,0 +1,36 @@
#[doc = "
NativeFont 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.
"];
export NativeFont, create_test_native_font;
#[cfg(target_os = "macos")]
type NativeFont/& = quartz_native_font::NativeFont;
#[cfg(target_os = "linux")]
type NativeFont/& = ft_native_font::NativeFont;
fn create_test_native_font() -> NativeFont {
fail;
}
#[test]
#[ignore]
fn should_get_glyph_indexes() {
let font = create_test_native_font();
let idx = font.glyph_index('w');
assert idx == some(40u);
}
#[test]
#[ignore]
fn should_get_glyph_h_advance() {
let font = create_test_native_font();
let adv = font.glyph_h_advance(40u);
assert adv == 15;
}

View file

@ -0,0 +1,16 @@
import glyph::GlyphIndex;
class NativeFont/& {
let bogus: int;
new() { self.bogus = 0; }
fn glyph_index(_codepoint: char) -> option<GlyphIndex> {
fail;
}
// FIXME: What unit is this returning? Let's have a custom type
fn glyph_h_advance(_glyph: GlyphIndex) -> int {
fail;
}
}

View file

@ -0,0 +1,16 @@
import glyph::GlyphIndex;
class NativeFont/& {
let bogus: int;
new() { self.bogus = 0; }
fn glyph_index(_codepoint: char) -> option<GlyphIndex> {
fail;
}
// FIXME: What unit is this returning? Let's have a custom type
fn glyph_h_advance(_glyph: GlyphIndex) -> int {
fail;
}
}