Move variables down that are only used when creating LayoutLines and replaced used of push_line bool with checking is layout_lines is empty
This commit is contained in:
parent
ae96bf26d1
commit
5f28feef1f
1 changed files with 10 additions and 13 deletions
23
src/shape.rs
23
src/shape.rs
|
|
@ -875,17 +875,6 @@ impl ShapeLine {
|
||||||
align: Option<Align>,
|
align: Option<Align>,
|
||||||
layout_lines: &mut Vec<LayoutLine>,
|
layout_lines: &mut Vec<LayoutLine>,
|
||||||
) {
|
) {
|
||||||
let align = align.unwrap_or({
|
|
||||||
if self.rtl {
|
|
||||||
Align::Right
|
|
||||||
} else {
|
|
||||||
Align::Left
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// This is used to create a visual line for empty lines (e.g. lines with only a <CR>)
|
|
||||||
let mut push_line = true;
|
|
||||||
|
|
||||||
// For each visual line a list of (span index, and range of words in that span)
|
// For each visual line a list of (span index, and range of words in that span)
|
||||||
// Note that a BiDi visual line could have multiple spans or parts of them
|
// Note that a BiDi visual line could have multiple spans or parts of them
|
||||||
// let mut vl_range_of_spans = Vec::with_capacity(1);
|
// let mut vl_range_of_spans = Vec::with_capacity(1);
|
||||||
|
|
@ -1149,6 +1138,14 @@ impl ShapeLine {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the LayoutLines using the ranges inside visual lines
|
// Create the LayoutLines using the ranges inside visual lines
|
||||||
|
let align = align.unwrap_or({
|
||||||
|
if self.rtl {
|
||||||
|
Align::Right
|
||||||
|
} else {
|
||||||
|
Align::Left
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let start_x = if self.rtl { line_width } else { 0.0 };
|
let start_x = if self.rtl { line_width } else { 0.0 };
|
||||||
|
|
||||||
let number_of_visual_lines = visual_lines.len();
|
let number_of_visual_lines = visual_lines.len();
|
||||||
|
|
@ -1264,10 +1261,10 @@ impl ShapeLine {
|
||||||
max_descent: max_descent * font_size,
|
max_descent: max_descent * font_size,
|
||||||
glyphs,
|
glyphs,
|
||||||
});
|
});
|
||||||
push_line = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if push_line {
|
// This is used to create a visual line for empty lines (e.g. lines with only a <CR>)
|
||||||
|
if layout_lines.is_empty() {
|
||||||
layout_lines.push(LayoutLine {
|
layout_lines.push(LayoutLine {
|
||||||
w: 0.0,
|
w: 0.0,
|
||||||
max_ascent: 0.0,
|
max_ascent: 0.0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue