layout: Implement text-rendering per SVG 1.1 § 11.7.4.

Like Gecko, we treat `geometricprecision` the same as
`optimizelegibility` for now.
This commit is contained in:
Patrick Walton 2015-01-01 10:55:25 -05:00
parent 112ab49706
commit 53b74ae853
5 changed files with 60 additions and 10 deletions

View file

@ -4,8 +4,8 @@
extern crate harfbuzz;
use font::{Font, FontHandleMethods, FontTableMethods, FontTableTag, IGNORE_LIGATURES_SHAPING_FLAG};
use font::{ShapingOptions};
use font::{DISABLE_KERNING_SHAPING_FLAG, Font, FontHandleMethods, FontTableMethods, FontTableTag};
use font::{IGNORE_LIGATURES_SHAPING_FLAG, ShapingOptions};
use platform::font::FontTable;
use text::glyph::{CharIndex, GlyphStore, GlyphId, GlyphData};
use text::shaping::ShaperMethods;
@ -50,6 +50,8 @@ use std::ptr;
static NO_GLYPH: i32 = -1;
static CONTINUATION_BYTE: i32 = -2;
static KERN: u32 = ((b'k' as u32) << 24) | ((b'e' as u32) << 16) | ((b'r' as u32) << 8) |
(b'n' as u32);
static LIGA: u32 = ((b'l' as u32) << 24) | ((b'i' as u32) << 16) | ((b'g' as u32) << 8) |
(b'a' as u32);
@ -242,6 +244,14 @@ impl ShaperMethods for Shaper {
_end: hb_buffer_get_length(hb_buffer),
})
}
if options.flags.contains(DISABLE_KERNING_SHAPING_FLAG) {
features.push(hb_feature_t {
_tag: KERN,
_value: 0,
_start: 0,
_end: hb_buffer_get_length(hb_buffer),
})
}
hb_shape(self.hb_font, hb_buffer, features.as_mut_ptr(), features.len() as u32);
self.save_glyph_results(text, options, glyphs, hb_buffer);