Use chr_idx for ShapeGlyph range in basic shaping
We want byte indices, not code point indices. Fixes a panic when selecting the mixed-language text at the bottom of the rich-text example when the shaping mode is set to "Basic".
This commit is contained in:
parent
db9033ba86
commit
c7a426280b
1 changed files with 26 additions and 24 deletions
14
src/shape.rs
14
src/shape.rs
|
|
@ -448,15 +448,17 @@ fn shape_skip(
|
|||
let ascent = metrics.ascent / f32::from(metrics.units_per_em);
|
||||
let descent = metrics.descent / f32::from(metrics.units_per_em);
|
||||
|
||||
glyphs.extend(line[start_run..end_run].char_indices().enumerate().map(
|
||||
|(i, (chr_idx, codepoint))| {
|
||||
glyphs.extend(
|
||||
line[start_run..end_run]
|
||||
.char_indices()
|
||||
.map(|(chr_idx, codepoint)| {
|
||||
let glyph_id = charmap.map(codepoint);
|
||||
let x_advance = glyph_metrics.advance_width(glyph_id);
|
||||
let attrs = attrs_list.get_span(start_run + chr_idx);
|
||||
|
||||
ShapeGlyph {
|
||||
start: i + start_run,
|
||||
end: i + start_run + 1,
|
||||
start: chr_idx + start_run,
|
||||
end: chr_idx + start_run + codepoint.len_utf8(),
|
||||
x_advance,
|
||||
y_advance: 0.0,
|
||||
x_offset: 0.0,
|
||||
|
|
@ -471,8 +473,8 @@ fn shape_skip(
|
|||
cache_key_flags: attrs.cache_key_flags,
|
||||
metrics_opt: attrs.metrics_opt.map(|x| x.into()),
|
||||
}
|
||||
},
|
||||
));
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/// A shaped glyph
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue