Skip to content

Commit 7c7f44b

Browse files
committed
Replace NaN vertices with 0,0 to fix text selection (#4)
1 parent 11ac5fc commit 7c7f44b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/painter.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,15 @@ impl Painter {
194194
let mut colors = Vec::with_capacity(mesh.vertices.len());
195195

196196
mesh.vertices.iter().enumerate().for_each(|(_i, v)| {
197-
pos.push(Point::new(v.pos.x, v.pos.y));
197+
// Apparently vertices can be NaN and if they are NaN, nothing is rendered.
198+
// Replacing them with 0 works around this.
199+
let fixed_pos = if v.pos.x.is_nan() || v.pos.y.is_nan() {
200+
Pos2::new(0.0, 0.0)
201+
} else {
202+
v.pos
203+
};
204+
205+
pos.push(Point::new(fixed_pos.x, fixed_pos.y));
198206
texs.push(Point::new(v.uv.x, v.uv.y));
199207
colors.push(Color::from_argb(
200208
v.color.a(),

0 commit comments

Comments
 (0)