Make attribute spans use ranges and update docs
This commit is contained in:
parent
16f0eb9efe
commit
e4c8d4ba6b
8 changed files with 147 additions and 123 deletions
10
src/shape.rs
10
src/shape.rs
|
|
@ -94,7 +94,7 @@ fn shape_fallback(
|
|||
// Set color
|
||||
//TODO: these attributes should not be related to shaping
|
||||
for glyph in glyphs.iter_mut() {
|
||||
let attrs = attrs_list.get_span(glyph.start, glyph.end);
|
||||
let attrs = attrs_list.get_span(glyph.start..glyph.end);
|
||||
glyph.color_opt = attrs.color_opt;
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ fn shape_run<'a>(
|
|||
&line[start_run..end_run],
|
||||
);
|
||||
|
||||
let attrs = attrs_list.get_span(start_run, end_run);
|
||||
let attrs = attrs_list.get_span(start_run..end_run);
|
||||
|
||||
let font_matches = font_system.get_font_matches(attrs);
|
||||
|
||||
|
|
@ -234,6 +234,7 @@ fn shape_run<'a>(
|
|||
glyphs
|
||||
}
|
||||
|
||||
/// A shaped glyph
|
||||
pub struct ShapeGlyph {
|
||||
pub start: usize,
|
||||
pub end: usize,
|
||||
|
|
@ -272,6 +273,7 @@ impl ShapeGlyph {
|
|||
}
|
||||
}
|
||||
|
||||
/// A shaped word (for word wrapping)
|
||||
pub struct ShapeWord {
|
||||
pub blank: bool,
|
||||
pub glyphs: Vec<ShapeGlyph>,
|
||||
|
|
@ -302,7 +304,7 @@ impl ShapeWord {
|
|||
for (egc_i, egc) in word.grapheme_indices(true) {
|
||||
let start_egc = start_word + egc_i;
|
||||
let end_egc = start_egc + egc.len();
|
||||
let attrs_egc = attrs_list.get_span(start_egc, end_egc);
|
||||
let attrs_egc = attrs_list.get_span(start_egc..end_egc);
|
||||
if ! attrs.compatible(&attrs_egc) {
|
||||
//TODO: more efficient
|
||||
glyphs.append(&mut shape_run(
|
||||
|
|
@ -334,6 +336,7 @@ impl ShapeWord {
|
|||
}
|
||||
}
|
||||
|
||||
/// A shaped span (for bidirectional processing)
|
||||
pub struct ShapeSpan {
|
||||
pub rtl: bool,
|
||||
pub words: Vec<ShapeWord>,
|
||||
|
|
@ -413,6 +416,7 @@ impl ShapeSpan {
|
|||
}
|
||||
}
|
||||
|
||||
/// A shaped line (or paragraph)
|
||||
pub struct ShapeLine {
|
||||
pub rtl: bool,
|
||||
pub spans: Vec<ShapeSpan>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue