aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-06-08 18:58:31 -0700
committerBrian Anderson <banderson@mozilla.com>2012-06-08 18:58:31 -0700
commit61a615fb4d371e83ae007f03de4824eda837ffea (patch)
treea2c599507d5671c89cbcaf947bdccecd9a92e83b
parent5086fde8286efa999ca12344dc9543154b38b5f7 (diff)
downloadservo-61a615fb4d371e83ae007f03de4824eda837ffea.tar.gz
servo-61a615fb4d371e83ae007f03de4824eda837ffea.zip
Put 'use harfbuzz' in text::shaper, not at the crate level
-rwxr-xr-xsrc/servo/servo.rc1
-rw-r--r--src/servo/text/glyph.rs15
-rw-r--r--src/servo/text/shaper.rs17
3 files changed, 19 insertions, 14 deletions
diff --git a/src/servo/servo.rc b/src/servo/servo.rc
index 3427cb56528..b638c60b725 100755
--- a/src/servo/servo.rc
+++ b/src/servo/servo.rc
@@ -10,7 +10,6 @@ use std;
use sdl;
use azure;
use js;
-use harfbuzz;
use stb_image;
mod dom {
diff --git a/src/servo/text/glyph.rs b/src/servo/text/glyph.rs
index 22d0fa85244..b446da09441 100644
--- a/src/servo/text/glyph.rs
+++ b/src/servo/text/glyph.rs
@@ -1,19 +1,12 @@
-import gfx::geom::{au, point, px_to_au};
+import gfx::geom::{au, point};
#[doc="The position of a glyph on the screen."]
class glyph_pos {
let advance: point<au>;
let offset: point<au>;
-
- new(hb_pos: harfbuzz::hb_glyph_position_t) {
- self.advance = {
- x: px_to_au(hb_pos.x_advance as int),
- y: px_to_au(hb_pos.y_advance as int)
- };
- self.offset = {
- x: px_to_au(hb_pos.x_offset as int),
- y: px_to_au(hb_pos.y_offset as int)
- };
+ new(advance: point<au>, offset: point<au>) {
+ self.advance = advance;
+ self.offset = offset;
}
}
diff --git a/src/servo/text/shaper.rs b/src/servo/text/shaper.rs
index 0a4bf8011d9..ae3f8c0629b 100644
--- a/src/servo/text/shaper.rs
+++ b/src/servo/text/shaper.rs
@@ -1,14 +1,19 @@
+use harfbuzz;
+
+export shape_text;
+
import libc::types::common::c99::int32_t;
import libc::{c_uint, c_int, c_void};
import font::font;
import glyph::{glyph, glyph_pos};
import ptr::{null, addr_of, offset};
+import gfx::geom::{point, px_to_au};
import unsafe::reinterpret_cast;
import harfbuzz::{HB_MEMORY_MODE_READONLY,
HB_DIRECTION_LTR};
import harfbuzz::{hb_blob_t, hb_face_t, hb_font_t, hb_buffer_t,
- hb_codepoint_t, hb_bool_t};
+ hb_codepoint_t, hb_bool_t, hb_glyph_position_t};
import harfbuzz::bindgen::{hb_blob_create, hb_blob_destroy,
hb_face_create, hb_face_destroy,
hb_font_create, hb_font_destroy,
@@ -42,7 +47,8 @@ fn shape_text(_font: &font, text: str) -> [glyph] {
var: 0i32
};
- vec::push(glyphs, glyph(ch as uint, glyph_pos(hb_pos)));
+ let pos = hb_glyph_pos_to_servo_glyph_pos(hb_pos);
+ vec::push(glyphs, glyph(ch as uint, pos));
cur_x += 10u;
};
@@ -122,6 +128,13 @@ crust fn glyph_func(_font: *hb_font_t,
ret true as hb_bool_t;
}
+fn hb_glyph_pos_to_servo_glyph_pos(hb_pos: hb_glyph_position_t) -> glyph_pos {
+ glyph_pos(point(px_to_au(hb_pos.x_advance as int),
+ px_to_au(hb_pos.y_advance as int)),
+ point(px_to_au(hb_pos.x_offset as int),
+ px_to_au(hb_pos.y_offset as int)))
+}
+
#[test]
fn test_shape_basic() {
let font = font::create();