diff --git a/src/servo/gfx/renderer.rs b/src/servo/gfx/renderer.rs index 892b40607ba..f0ee72ee244 100644 --- a/src/servo/gfx/renderer.rs +++ b/src/servo/gfx/renderer.rs @@ -192,7 +192,7 @@ fn draw_text(draw_target: AzDrawTargetRef, item: dl::display_item, text_run: Tex let mut origin = Point2D(bounds.origin.x, bounds.origin.y.add(bounds.size.height)); let azglyphs = text_run.glyphs.map { |glyph| let azglyph: AzGlyph = { - mIndex: glyph.codepoint as uint32_t, + mIndex: glyph.index as uint32_t, mPosition: { x: au_to_px(origin.x.add(glyph.pos.offset.x)) as AzFloat, y: au_to_px(origin.y.add(glyph.pos.offset.y)) as AzFloat diff --git a/src/servo/text/font.rs b/src/servo/text/font.rs index 2d079ccad69..2147b4a0272 100644 --- a/src/servo/text/font.rs +++ b/src/servo/text/font.rs @@ -1,5 +1,6 @@ export Font, create_test_font, test_font_bin; +import glyph::GlyphIndex; import vec_to_ptr = vec::unsafe::to_ptr; import libc::{ c_int, c_double, c_ulong }; import ptr::{ null, addr_of }; @@ -48,7 +49,7 @@ class Font/& { &self.fontbuf } - fn glyph_idx(codepoint: char) -> option { + fn glyph_idx(codepoint: char) -> option { #debug("getting glyph for codepoint %u", codepoint as uint); let codepoint_str = str::from_char(codepoint); @@ -70,7 +71,7 @@ class Font/& { // This might not be true, but at least we'll know if it isn't assert num_glyphs == 1 as c_int; - let glyph_index = unsafe { *glyphs }.index as uint; + let glyph_index = unsafe { *glyphs }.index as GlyphIndex; #debug("glyph index is %?", glyph_index); cairo_glyph_free(glyphs); some(glyph_index) @@ -80,7 +81,7 @@ class Font/& { } } - fn glyph_h_advance(glyph: uint) -> int { + fn glyph_h_advance(glyph: GlyphIndex) -> int { #debug("getting h advance for glyph %?", glyph); diff --git a/src/servo/text/glyph.rs b/src/servo/text/glyph.rs index 8768ae00eb9..f50907d030a 100644 --- a/src/servo/text/glyph.rs +++ b/src/servo/text/glyph.rs @@ -1,6 +1,11 @@ +export GlyphIndex, GlyphPos, Glyph; + import gfx::geometry::au; import geom::point::Point2D; +#[doc = "The index of a particular glyph within a font"] +type GlyphIndex = uint; + #[doc="The position of a glyph on the screen."] class GlyphPos { let advance: Point2D; @@ -13,11 +18,11 @@ class GlyphPos { #[doc="A single glyph."] class Glyph { - let codepoint: uint; + let index: GlyphIndex; let pos: GlyphPos; - new(codepoint: uint, pos: GlyphPos) { - self.codepoint = codepoint; + new(index: GlyphIndex, pos: GlyphPos) { + self.index = index; self.pos = copy pos; } } diff --git a/src/servo/text/shaper.rs b/src/servo/text/shaper.rs index 2303644e648..9a7a3e51c0d 100644 --- a/src/servo/text/shaper.rs +++ b/src/servo/text/shaper.rs @@ -141,12 +141,12 @@ fn hb_glyph_pos_to_servo_glyph_pos(hb_pos: &hb_glyph_position_t) -> GlyphPos { px_to_au(hb_pos.y_offset as int))) } -fn should_get_glyph_codepoints() { +fn should_get_glyph_indexes() { #[test]; let font = font::create_test_font(); let glyphs = shape_text(&font, "firecracker"); - let idxs = glyphs.map { |glyph| glyph.codepoint }; + let idxs = glyphs.map { |glyph| glyph.index }; assert idxs == [32u, 8u, 13u, 14u, 10u, 13u, 201u, 10u, 37u, 14u, 13u]; }