Clarify off by one issue
This commit is contained in:
parent
c247bbdad2
commit
a1f767505e
1 changed files with 7 additions and 7 deletions
|
|
@ -116,17 +116,17 @@ where
|
||||||
self.line.wrap_simple()
|
self.line.wrap_simple()
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut max_x = 0;
|
let mut width = 0;
|
||||||
let mut line_y = 0;
|
let mut height = 0;
|
||||||
|
|
||||||
for layout_line in layout_lines {
|
for layout_line in layout_lines {
|
||||||
for glyph in layout_line.glyphs.iter() {
|
for glyph in layout_line.glyphs.iter() {
|
||||||
max_x = cmp::max(max_x, (glyph.x + glyph.w) as i32);
|
width = cmp::max(width, (glyph.x + glyph.w) as i32 + 1);
|
||||||
}
|
}
|
||||||
line_y += self.metrics.line_height;
|
height += self.metrics.line_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
let size = Size::new(max_x as f32, line_y as f32);
|
let size = Size::new(width as f32, height as f32);
|
||||||
|
|
||||||
log::debug!("layout {:?} in {:?}", size, instant.elapsed());
|
log::debug!("layout {:?} in {:?}", size, instant.elapsed());
|
||||||
|
|
||||||
|
|
@ -174,7 +174,7 @@ where
|
||||||
let mut layout_lines = Vec::new();
|
let mut layout_lines = Vec::new();
|
||||||
shape.layout(
|
shape.layout(
|
||||||
self.metrics.font_size,
|
self.metrics.font_size,
|
||||||
layout.bounds().width as i32 + 1 /*TODO: why this off by one error*/,
|
layout.bounds().width as i32,
|
||||||
&mut layout_lines,
|
&mut layout_lines,
|
||||||
0,
|
0,
|
||||||
self.line.wrap_simple()
|
self.line.wrap_simple()
|
||||||
|
|
@ -219,7 +219,7 @@ where
|
||||||
line_y += self.metrics.line_height;
|
line_y += self.metrics.line_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
log::debug!("draw {:?} in {:?}", layout.bounds(), instant.elapsed());
|
log::trace!("draw {:?} in {:?}", layout.bounds(), instant.elapsed());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue