Browse Source

Fix LIB_TEXT plotting alignment

LIB_TEXT is not all aligned to the center, so place the proper flags
when calling Plot.  This requires handling alignment offsets properly
when rotated as well
7.0
Seth Hillbrand 3 years ago
parent
commit
67c703e9e2
  1. 22
      eeschema/lib_text.cpp

22
eeschema/lib_text.cpp

@ -277,6 +277,26 @@ void LIB_TEXT::Plot( PLOTTER* plotter, bool aBackground, const VECTOR2I& offset,
// convert coordinates from draw Y axis to symbol_editor Y axis
bBox.RevertYAxis();
VECTOR2I txtpos = bBox.Centre();
TEXT_ATTRIBUTES attrs = GetAttributes();
if( attrs.m_Angle == ANGLE_VERTICAL )
{
switch( attrs.m_Halign )
{
case GR_TEXT_H_ALIGN_LEFT: txtpos.y = bBox.GetTop(); break;
case GR_TEXT_H_ALIGN_CENTER: txtpos.y = bBox.GetCenter().y; break;
case GR_TEXT_H_ALIGN_RIGHT: txtpos.y = bBox.GetBottom(); break;
}
}
else
{
switch( attrs.m_Halign )
{
case GR_TEXT_H_ALIGN_LEFT: txtpos.x = bBox.GetLeft(); break;
case GR_TEXT_H_ALIGN_CENTER: txtpos.x = bBox.GetCenter().x; break;
case GR_TEXT_H_ALIGN_RIGHT: txtpos.x = bBox.GetRight(); break;
}
}
// The text orientation may need to be flipped if the transformation matrix causes xy
// axes to be flipped.
@ -307,7 +327,7 @@ void LIB_TEXT::Plot( PLOTTER* plotter, bool aBackground, const VECTOR2I& offset,
font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), IsBold(), IsItalic() );
plotter->Text( pos, color, GetText(), t1 ? ANGLE_HORIZONTAL : ANGLE_VERTICAL, GetTextSize(),
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(),
GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold(),
true, font );
}

Loading…
Cancel
Save