зеркало из https://github.com/mozilla/gecko-dev.git
servo: Introduce NativeFont
Source-Repo: https://github.com/servo/servo Source-Revision: 3ffbaaaa47d64e8e28310fe0cc9b1a943c6f9c69
This commit is contained in:
Родитель
350e638fad
Коммит
4d3b2ea91a
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче