mirror of
https://github.com/servo/servo.git
synced 2025-06-24 09:04:33 +01:00
Persist original character flag data (is space, is cluster, is breakable, etc) in the glyph store when setting glyph-related data.
This commit is contained in:
parent
d460162306
commit
42c6e45d08
2 changed files with 36 additions and 10 deletions
|
@ -38,15 +38,28 @@ enum BreakType {
|
||||||
BreakTypeHyphen
|
BreakTypeHyphen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl BreakType : Eq {
|
||||||
|
pure fn eq(other: &BreakType) -> bool {
|
||||||
|
match (self, *other) {
|
||||||
|
(BreakTypeNone, BreakTypeNone) => true,
|
||||||
|
(BreakTypeNormal, BreakTypeNormal) => true,
|
||||||
|
(BreakTypeHyphen, BreakTypeHyphen) => true,
|
||||||
|
(_,_) => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pure fn ne(other: &BreakType) -> bool {
|
||||||
|
!self.eq(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const BREAK_TYPE_NONE : u8 = 0x0u8;
|
const BREAK_TYPE_NONE : u8 = 0x0u8;
|
||||||
const BREAK_TYPE_NORMAL : u8 = 0x1u8;
|
const BREAK_TYPE_NORMAL : u8 = 0x1u8;
|
||||||
const BREAK_TYPE_HYPHEN : u8 = 0x2u8;
|
const BREAK_TYPE_HYPHEN : u8 = 0x2u8;
|
||||||
|
|
||||||
pure fn break_flag_to_enum(flag: u8) -> BreakType {
|
pure fn break_flag_to_enum(flag: u8) -> BreakType {
|
||||||
if (flag & BREAK_TYPE_NONE) as bool { return BreakTypeNone; }
|
if (flag & BREAK_TYPE_NORMAL) != 0 { return BreakTypeNormal; }
|
||||||
if (flag & BREAK_TYPE_NORMAL) as bool { return BreakTypeNormal; }
|
if (flag & BREAK_TYPE_HYPHEN) != 0 { return BreakTypeHyphen; }
|
||||||
if (flag & BREAK_TYPE_HYPHEN) as bool { return BreakTypeHyphen; }
|
BreakTypeNone
|
||||||
fail ~"Unknown break setting"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn break_enum_to_flag(e: BreakType) -> u8 {
|
pure fn break_enum_to_flag(e: BreakType) -> u8 {
|
||||||
|
@ -244,6 +257,11 @@ impl GlyphEntry {
|
||||||
/*priv*/ pure fn has_flag(flag: u32) -> bool {
|
/*priv*/ pure fn has_flag(flag: u32) -> bool {
|
||||||
(self.value & flag) != 0
|
(self.value & flag) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pure fn adapt_character_flags_of_entry(other: &GlyphEntry) -> GlyphEntry {
|
||||||
|
GlyphEntry { value: self.value | other.value }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stores data for a detailed glyph, in the case that several glyphs
|
// Stores data for a detailed glyph, in the case that several glyphs
|
||||||
|
@ -504,8 +522,10 @@ impl GlyphStore {
|
||||||
is_simple_glyph_id(data.index)
|
is_simple_glyph_id(data.index)
|
||||||
&& is_simple_advance(data.advance)
|
&& is_simple_advance(data.advance)
|
||||||
&& data.offset == au::zero_point()
|
&& data.offset == au::zero_point()
|
||||||
|
&& data.cluster_start // others are stored in detail buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert data.ligature_start; // can't compress ligature continuation glyphs.
|
||||||
assert i < self.entry_buffer.len();
|
assert i < self.entry_buffer.len();
|
||||||
|
|
||||||
let entry = match (data.is_missing, glyph_is_compressible(data)) {
|
let entry = match (data.is_missing, glyph_is_compressible(data)) {
|
||||||
|
@ -516,7 +536,7 @@ impl GlyphStore {
|
||||||
self.detail_store.add_detailed_glyphs_for_entry(i, glyph);
|
self.detail_store.add_detailed_glyphs_for_entry(i, glyph);
|
||||||
ComplexGlyphEntry(data.cluster_start, data.ligature_start, 1)
|
ComplexGlyphEntry(data.cluster_start, data.ligature_start, 1)
|
||||||
}
|
}
|
||||||
};
|
}.adapt_character_flags_of_entry(&self.entry_buffer[i]);
|
||||||
|
|
||||||
//debug!("Adding single glyph[idx=%u]: %?", i, entry);
|
//debug!("Adding single glyph[idx=%u]: %?", i, entry);
|
||||||
|
|
||||||
|
@ -544,7 +564,7 @@ impl GlyphStore {
|
||||||
first_glyph_data.ligature_start,
|
first_glyph_data.ligature_start,
|
||||||
glyph_count)
|
glyph_count)
|
||||||
}
|
}
|
||||||
};
|
}.adapt_character_flags_of_entry(&self.entry_buffer[i]);
|
||||||
|
|
||||||
debug!("Adding multiple glyphs[idx=%u, count=%u]: %?", i, glyph_count, entry);
|
debug!("Adding multiple glyphs[idx=%u, count=%u]: %?", i, glyph_count, entry);
|
||||||
|
|
||||||
|
|
|
@ -358,7 +358,8 @@ pub impl HarfbuzzShaper {
|
||||||
// TODO(Issue #214): cluster ranges need to be computed before
|
// TODO(Issue #214): cluster ranges need to be computed before
|
||||||
// shaping, and then consulted here.
|
// shaping, and then consulted here.
|
||||||
// for now, just pretend that every character is a cluster start.
|
// for now, just pretend that every character is a cluster start.
|
||||||
// (i.e., pretend there are no combining character sequences)
|
// (i.e., pretend there are no combining character sequences).
|
||||||
|
// 1-to-1 mapping of character to glyph also treated as ligature start.
|
||||||
let shape = glyph_data.get_entry_for_glyph(glyph_span.begin(), &mut y_pos);
|
let shape = glyph_data.get_entry_for_glyph(glyph_span.begin(), &mut y_pos);
|
||||||
let data = GlyphData(shape.codepoint, shape.advance, shape.offset, false, true, true);
|
let data = GlyphData(shape.codepoint, shape.advance, shape.offset, false, true, true);
|
||||||
glyphs.add_glyph_for_char_index(char_idx, &data);
|
glyphs.add_glyph_for_char_index(char_idx, &data);
|
||||||
|
@ -366,9 +367,14 @@ pub impl HarfbuzzShaper {
|
||||||
// collect all glyphs to be assigned to the first character.
|
// collect all glyphs to be assigned to the first character.
|
||||||
let datas = DVec();
|
let datas = DVec();
|
||||||
|
|
||||||
while glyph_span.length() > 0 {
|
for glyph_span.eachi |glyph_i| {
|
||||||
let shape = glyph_data.get_entry_for_glyph(glyph_span.begin(), &mut y_pos);
|
let shape = glyph_data.get_entry_for_glyph(glyph_i, &mut y_pos);
|
||||||
datas.push(GlyphData(shape.codepoint, shape.advance, shape.offset, false, true, true));
|
datas.push(GlyphData(shape.codepoint,
|
||||||
|
shape.advance,
|
||||||
|
shape.offset,
|
||||||
|
false, // not missing
|
||||||
|
true, // treat as cluster start
|
||||||
|
glyph_i > glyph_span.begin())); // all but first are ligature continuations
|
||||||
glyph_span.adjust_by(1,-1);
|
glyph_span.adjust_by(1,-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue