7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-19 23:31:40 +00:00

Fix display of broken fonts

TTF fonts are supposed to obey a specific winding.  But sometimes they
don't, especially with garbage windows font editing programs.  If the
outline with hole winding doesn't have an outline, it is probably an
outline itself

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19010
This commit is contained in:
Seth Hillbrand 2024-10-28 12:33:11 -07:00
parent 905eaa79a9
commit a6b25d1ee1

View File

@ -484,6 +484,8 @@ VECTOR2I OUTLINE_FONT::getTextAsGlyphsUnlocked( BOX2I* aBBox,
for( SHAPE_LINE_CHAIN& hole : holes )
{
bool added_hole = false;
if( hole.PointCount() )
{
for( int ii = 0; ii < glyph->OutlineCount(); ++ii )
@ -491,9 +493,15 @@ VECTOR2I OUTLINE_FONT::getTextAsGlyphsUnlocked( BOX2I* aBBox,
if( glyph->Outline( ii ).PointInside( hole.GetPoint( 0 ) ) )
{
glyph->AddHole( std::move( hole ), ii );
added_hole = true;
break;
}
}
// Some lovely TTF fonts decided that winding didn't matter for outlines that
// don't have holes, so holes that don't fit in any outline are added as outlines
if( !added_hole )
glyph->AddOutline( std::move( hole ) );
}
}