Don't flip alignment of non-side-specific text.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/18235
This commit is contained in:
parent
aaf5c454ff
commit
0040c290ed
|
@ -2085,9 +2085,10 @@ void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
|
const KIFONT::METRICS& metrics = aText->GetFontMetrics();
|
||||||
const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
|
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
|
||||||
bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayTextFill;
|
const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
|
||||||
|
bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayTextFill;
|
||||||
|
|
||||||
KIFONT::FONT* font = aText->GetFont();
|
KIFONT::FONT* font = aText->GetFont();
|
||||||
|
|
||||||
|
@ -2120,8 +2121,18 @@ void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
|
||||||
|
|
||||||
if( m_gal->IsFlippedX() && !( aText->GetLayerSet() & LSET::SideSpecificMask() ).any() )
|
if( m_gal->IsFlippedX() && !( aText->GetLayerSet() & LSET::SideSpecificMask() ).any() )
|
||||||
{
|
{
|
||||||
|
VECTOR2I textPos = aText->GetTextPos();
|
||||||
|
VECTOR2I textWidth = VECTOR2I( aText->GetTextBox().GetWidth(), 0 );
|
||||||
|
RotatePoint( textWidth, textPos, aText->GetDrawRotation() );
|
||||||
|
|
||||||
|
if( attrs.m_Mirrored )
|
||||||
|
textPos -= textWidth;
|
||||||
|
else
|
||||||
|
textPos += textWidth;
|
||||||
|
|
||||||
attrs.m_Mirrored = !attrs.m_Mirrored;
|
attrs.m_Mirrored = !attrs.m_Mirrored;
|
||||||
attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign );
|
strokeText( resolvedText, textPos, attrs, metrics );
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
|
std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
|
||||||
|
@ -2136,7 +2147,7 @@ void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strokeText( resolvedText, aText->GetTextPos(), attrs, aText->GetFontMetrics() );
|
strokeText( resolvedText, aText->GetTextPos(), attrs, metrics );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2243,18 +2254,6 @@ void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( resolvedText.Length() == 0 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
|
|
||||||
attrs.m_StrokeWidth = getLineThickness( aTextBox->GetEffectiveTextPenWidth() );
|
|
||||||
|
|
||||||
if( m_gal->IsFlippedX() && !( aTextBox->GetLayerSet() & LSET::SideSpecificMask() ).any() )
|
|
||||||
{
|
|
||||||
attrs.m_Mirrored = !attrs.m_Mirrored;
|
|
||||||
attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
|
if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
|
||||||
{
|
{
|
||||||
// For now, the textbox is a filled shape.
|
// For now, the textbox is a filled shape.
|
||||||
|
@ -2271,6 +2270,20 @@ void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( resolvedText.Length() == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
const KIFONT::METRICS& metrics = aTextBox->GetFontMetrics();
|
||||||
|
TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
|
||||||
|
attrs.m_StrokeWidth = getLineThickness( aTextBox->GetEffectiveTextPenWidth() );
|
||||||
|
|
||||||
|
if( m_gal->IsFlippedX() && !( aTextBox->GetLayerSet() & LSET::SideSpecificMask() ).any() )
|
||||||
|
{
|
||||||
|
attrs.m_Mirrored = !attrs.m_Mirrored;
|
||||||
|
strokeText( resolvedText, aTextBox->GetDrawPos( true ), attrs, metrics );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
|
std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
|
||||||
|
|
||||||
if( font->IsOutline() )
|
if( font->IsOutline() )
|
||||||
|
@ -2283,7 +2296,7 @@ void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strokeText( resolvedText, aTextBox->GetDrawPos(), attrs, aTextBox->GetFontMetrics() );
|
strokeText( resolvedText, aTextBox->GetDrawPos(), attrs, metrics );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -243,13 +243,19 @@ std::vector<VECTOR2I> PCB_TEXTBOX::GetAnchorAndOppositeCorner() const
|
||||||
|
|
||||||
|
|
||||||
VECTOR2I PCB_TEXTBOX::GetDrawPos() const
|
VECTOR2I PCB_TEXTBOX::GetDrawPos() const
|
||||||
|
{
|
||||||
|
return GetDrawPos( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VECTOR2I PCB_TEXTBOX::GetDrawPos( bool aIsFlipped ) const
|
||||||
{
|
{
|
||||||
std::vector<VECTOR2I> corners = GetAnchorAndOppositeCorner();
|
std::vector<VECTOR2I> corners = GetAnchorAndOppositeCorner();
|
||||||
GR_TEXT_H_ALIGN_T effectiveAlignment = GetHorizJustify();
|
GR_TEXT_H_ALIGN_T effectiveAlignment = GetHorizJustify();
|
||||||
VECTOR2I textAnchor;
|
VECTOR2I textAnchor;
|
||||||
VECTOR2I offset;
|
VECTOR2I offset;
|
||||||
|
|
||||||
if( IsMirrored() )
|
if( IsMirrored() != aIsFlipped )
|
||||||
{
|
{
|
||||||
switch( GetHorizJustify() )
|
switch( GetHorizJustify() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,6 +87,7 @@ public:
|
||||||
int GetMarginBottom() const { return m_marginBottom; }
|
int GetMarginBottom() const { return m_marginBottom; }
|
||||||
|
|
||||||
VECTOR2I GetDrawPos() const override;
|
VECTOR2I GetDrawPos() const override;
|
||||||
|
VECTOR2I GetDrawPos( bool aIsFlipped ) const;
|
||||||
|
|
||||||
void SetTextAngle( const EDA_ANGLE& aAngle ) override;
|
void SetTextAngle( const EDA_ANGLE& aAngle ) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue