From 96f39fea9921292d5aa67f478bd3d8e947f127be Mon Sep 17 00:00:00 2001 From: Emulator000 Date: Sat, 26 Sep 2020 21:56:20 +0200 Subject: Bugfix in textfield Y position calculation --- src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 7c215ee..e6200c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -554,7 +554,14 @@ impl Form { // Calcolate the text offset let x = 2.0; // Suppose this fixed offset as we should have known the border here - let y = 0.5 * (rect[3] - rect[1]) - 0.4 * font_size as f32; // Formula picked up from Poppler + + // Formula picked up from Poppler + let dy = rect[1] - rect[3]; + let y = if dy > 0.0 { + 0.5 * dy - 0.4 * font_size as f32 + } else { + 0.5 * font_size as f32 + }; // Set the text bounds, first are fixed at "1 0 0 1" and then the calculated x,y content.operations.append(&mut vec![Operation::new( -- cgit v1.2.3