← Back to team overview

kicad-developers team mailing list archive

[PATCH] Ruler tool asserts when mirrored text is visible



This resolves https://bugs.launchpad.net/kicad/+bug/1677210.

This is caused because the GAL ruler tool didn't reset its text
mirroring flag before drawing bitmap text. This means if the GAL had
just drawn mirrored text, it would be set, but this is invalid for
OpenGL bitmap fonts (and if it were, would still be incorrect).

I also reset bold/italic, though bitmaps text doesn't seem to care
about that at all.

This fixes the bug. In the longer run, this is still not really ideal,
as every draw-er on the GAL seems to need to reset every single
parametert that it might need. If a parameter is added, all these
"reset loci" need to be vetted for possibly adding or resetting that

Would some kind of stack mechanism make sense here? Unrelated
functions probably should start from a blank slate of some sort. Maybe
a way to avoid unnecessary stack shuffling if you /know/ you don't
need to reset GAL parameters and it's a performance hit to do so


From 8a85b9763dadd448aa1e701821032e39e2a5f6a0 Mon Sep 17 00:00:00 2001
From: John Beard <john.j.beard@xxxxxxxxx>
Date: Wed, 29 Mar 2017 19:35:03 +0800
Subject: [PATCH] Ruler tool: reset text mirror/bold/italic before painting

 common/preview_items/ruler_item.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/preview_items/ruler_item.cpp b/common/preview_items/ruler_item.cpp
index c820f7f87..629fc1d94 100644
--- a/common/preview_items/ruler_item.cpp
+++ b/common/preview_items/ruler_item.cpp
@@ -238,6 +238,9 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
     gal.SetIsStroke( true );
     gal.SetIsFill( false );
     gal.SetStrokeColor( PreviewOverlayDefaultColor() );
+    gal.SetFontBold( false );
+    gal.SetFontItalic( false );
+    gal.SetTextMirrored( false );
     // draw the main line from the origin to cursor
     gal.DrawLine( origin, end );

Follow ups