mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-18 15:09:18 +00:00
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
This commit is contained in:
parent
509b39e9e4
commit
67c703e9e2
@ -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…
Reference in New Issue
Block a user