From c65228e15ff83e5fd331e260fdb8f334c109e3d3 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 29 Aug 2022 11:52:40 +0100 Subject: [PATCH] Fix plotting offset issue for non-symbol fields. --- eeschema/sch_field.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index cab34c7a40..ea07ca8034 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -929,7 +929,10 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground ) const return; // Calculate the text orientation, according to the symbol orientation/mirror - EDA_ANGLE orient = GetTextAngle(); + EDA_ANGLE orient = GetTextAngle(); + VECTOR2I textpos = GetTextPos(); + GR_TEXT_H_ALIGN_T hjustify = GetHorizJustify(); + GR_TEXT_V_ALIGN_T vjustify = GetVertJustify(); if( m_parent && m_parent->Type() == SCH_SYMBOL_T ) { @@ -942,21 +945,22 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground ) const else orient = ANGLE_HORIZONTAL; } - } - /* - * Calculate the text justification, according to the symbol orientation/mirror. - * This is a bit complicated due to cumulative calculations: - * - numerous cases (mirrored or not, rotation) - * - the plotter's Text function will also recalculate H and V justifications according to - * the text orientation. - * - When a symbol is mirrored, the text is not mirrored and justifications are complicated - * to calculate so the easier way is to use no justifications (centered text) and use - * GetBoundingBox to know the text coordinate considered as centered - */ - GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_CENTER; - GR_TEXT_V_ALIGN_T vjustify = GR_TEXT_V_ALIGN_CENTER; - VECTOR2I textpos = GetBoundingBox().Centre(); + /* + * Calculate the text justification, according to the symbol orientation/mirror. This is + * a bit complicated due to cumulative calculations: + * - numerous cases (mirrored or not, rotation) + * - the plotter's Text() function will also recalculate H and V justifications according + * to the text orientation + * - when a symbol is mirrored the text is not, and justifications become a nightmare + * + * So the easier way is to use no justifications (centered text) and use GetBoundingBox to + * know the text coordinate considered as centered. + */ + hjustify = GR_TEXT_H_ALIGN_CENTER; + vjustify = GR_TEXT_V_ALIGN_CENTER; + textpos = GetBoundingBox().Centre(); + } aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify, penWidth, IsItalic(), IsBold(), false, GetDrawFont() );