Hi Seth, Jeff, I see you have touched this code recently. I've noticed that tabs are handled differently for bbox calculation resulting in slightly oversized bbox.
When rendering tabs we count them as whatever width is needed to align to multiple of 4 and +1 additional space but when calculating bbox it is align to 4 spaces + '?' width, which is a bit wider. I attached a patch that fixes this particular issue to count tab as align to 4 spaces + 1 space. But I think this is confusing in general, why do we still render another space after aligning width to multiple of 4? Here is a picture of left-justified text in pcbnew. First line is "a<tab>b", second "<4 spaces>b", third "<5 spaces>b". [image: image.png] Regards, Andrew
From 264b656fdbfedbe2631840f7c67bb320e557c7d8 Mon Sep 17 00:00:00 2001 From: qu1ck <anlutse...@gmail.com> Date: Mon, 11 Nov 2019 17:25:24 -0800 Subject: [PATCH] Make stroke font bbox calculation consistent with rendering When rendering tabs we count them as 4 + 1 space but when calculating bbox it is 4 spaces + '?' width, which is a bit wider. --- common/gal/stroke_font.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/gal/stroke_font.cpp b/common/gal/stroke_font.cpp index 81ffe6f93..94913c605 100644 --- a/common/gal/stroke_font.cpp +++ b/common/gal/stroke_font.cpp @@ -572,7 +572,10 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, const VECT int dd = (signed) *it - ' '; if( dd >= (int) m_glyphBoundingBoxes.size() || dd < 0 ) - dd = '?' - ' '; + { + int substitute = *it == '\t' ? ' ' : '?'; + dd = substitute - ' '; + } const BOX2D& box = m_glyphBoundingBoxes[dd]; curX += box.GetEnd().x * curScale; -- 2.24.0.rc1.363.gb1bccd3e3d-goog
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : kicad-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp