Don't assume all glyphs are outline with an outline font.
Underline and overbar may be stroke glyphs. Fixes https://gitlab.com/kicad/code/kicad/-/issues/17478
This commit is contained in:
parent
4ed2a0674a
commit
05cdd44404
|
@ -82,19 +82,19 @@ std::unique_ptr<GLYPH> STROKE_GLYPH::Transform( const VECTOR2D& aGlyphSize, cons
|
||||||
end.x *= aGlyphSize.x;
|
end.x *= aGlyphSize.x;
|
||||||
end.y *= aGlyphSize.y;
|
end.y *= aGlyphSize.y;
|
||||||
|
|
||||||
if( aTilt )
|
if( aTilt != 0.0 )
|
||||||
end.x -= end.y * aTilt;
|
end.x -= end.y * aTilt;
|
||||||
|
|
||||||
glyph->m_boundingBox.SetEnd( end );
|
glyph->m_boundingBox.SetEnd( end );
|
||||||
glyph->m_boundingBox.Offset( aOffset );
|
glyph->m_boundingBox.Offset( aOffset );
|
||||||
|
|
||||||
for( std::vector<VECTOR2D>& pointList : *glyph.get() )
|
for( std::vector<VECTOR2D>& pointList : *glyph )
|
||||||
{
|
{
|
||||||
for( VECTOR2D& point : pointList )
|
for( VECTOR2D& point : pointList )
|
||||||
{
|
{
|
||||||
point *= aGlyphSize;
|
point *= aGlyphSize;
|
||||||
|
|
||||||
if( aTilt )
|
if( aTilt != 0.0 )
|
||||||
point.x -= point.y * aTilt;
|
point.x -= point.y * aTilt;
|
||||||
|
|
||||||
point += aOffset;
|
point += aOffset;
|
||||||
|
@ -111,6 +111,18 @@ std::unique_ptr<GLYPH> STROKE_GLYPH::Transform( const VECTOR2D& aGlyphSize, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void STROKE_GLYPH::Move( const VECTOR2I& aOffset )
|
||||||
|
{
|
||||||
|
m_boundingBox.Offset( aOffset );
|
||||||
|
|
||||||
|
for( std::vector<VECTOR2D>& pointList : *this )
|
||||||
|
{
|
||||||
|
for( VECTOR2D& point : pointList )
|
||||||
|
point += aOffset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOX2D OUTLINE_GLYPH::BoundingBox()
|
BOX2D OUTLINE_GLYPH::BoundingBox()
|
||||||
{
|
{
|
||||||
BOX2I bbox = BBox();
|
BOX2I bbox = BBox();
|
||||||
|
|
|
@ -332,7 +332,12 @@ SCH_FIELD::GetRenderCache( const wxString& forResolvedText, const VECTOR2I& forP
|
||||||
VECTOR2I delta = forPosition - m_renderCachePos;
|
VECTOR2I delta = forPosition - m_renderCachePos;
|
||||||
|
|
||||||
for( std::unique_ptr<KIFONT::GLYPH>& glyph : m_renderCache )
|
for( std::unique_ptr<KIFONT::GLYPH>& glyph : m_renderCache )
|
||||||
static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() )->Move( delta );
|
{
|
||||||
|
if( glyph->IsOutline() )
|
||||||
|
static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() )->Move( delta );
|
||||||
|
else
|
||||||
|
static_cast<KIFONT::STROKE_GLYPH*>( glyph.get() )->Move( delta );
|
||||||
|
}
|
||||||
|
|
||||||
m_renderCachePos = forPosition;
|
m_renderCachePos = forPosition;
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,6 +120,8 @@ public:
|
||||||
double aTilt, const EDA_ANGLE& aAngle, bool aMirror,
|
double aTilt, const EDA_ANGLE& aAngle, bool aMirror,
|
||||||
const VECTOR2I& aOrigin );
|
const VECTOR2I& aOrigin );
|
||||||
|
|
||||||
|
void Move( const VECTOR2I& aOffset );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_penIsDown = false;
|
bool m_penIsDown = false;
|
||||||
BOX2D m_boundingBox;
|
BOX2D m_boundingBox;
|
||||||
|
|
Loading…
Reference in New Issue