7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 15:01:41 +00:00

Cache based on sub/subscript

Prevents the case where we cache a font in one scale and try to use
another.  This could be contained in scaleFactor but we don't currently
prescale, so hashing on the boolean is probably easier
This commit is contained in:
Seth Hillbrand 2025-02-06 13:23:52 -08:00
parent f45915ba93
commit 1e6e555164

View File

@ -299,6 +299,7 @@ struct GLYPH_CACHE_KEY {
bool fakeItalic;
bool fakeBold;
bool mirror;
bool supersub;
EDA_ANGLE angle;
bool operator==(const GLYPH_CACHE_KEY& rhs ) const
@ -310,6 +311,7 @@ struct GLYPH_CACHE_KEY {
&& fakeItalic == rhs.fakeItalic
&& fakeBold == rhs.fakeBold
&& mirror == rhs.mirror
&& supersub == rhs.supersub
&& angle == rhs.angle;
}
};
@ -323,7 +325,7 @@ namespace std
std::size_t operator()( const GLYPH_CACHE_KEY& k ) const
{
return hash_val( k.face, k.codepoint, k.scale.x, k.scale.y, k.forDrawingSheet,
k.fakeItalic, k.fakeBold, k.mirror, k.angle.AsDegrees() );
k.fakeItalic, k.fakeBold, k.mirror, k.supersub, k.angle.AsDegrees() );
}
};
}
@ -339,11 +341,10 @@ VECTOR2I OUTLINE_FONT::getTextAsGlyphsUnlocked( BOX2I* aBBox,
VECTOR2D glyphSize = aSize;
FT_Face face = m_face;
double scaler = faceSize();
bool supersub = IsSuperscript( aTextStyle ) || IsSubscript( aTextStyle );
if( IsSubscript( aTextStyle ) || IsSuperscript( aTextStyle ) )
{
if( supersub )
scaler = subscriptSize();
}
// set glyph resolution so that FT_Load_Glyph() results are good enough for decomposing
FT_Set_Char_Size( face, 0, scaler, GLYPH_RESOLUTION, 0 );
@ -382,7 +383,7 @@ VECTOR2I OUTLINE_FONT::getTextAsGlyphsUnlocked( BOX2I* aBBox,
if( aGlyphs )
{
GLYPH_CACHE_KEY key = { face, glyphInfo[i].codepoint, scaleFactor, m_forDrawingSheet,
m_fakeItal, m_fakeBold, aMirror, aAngle };
m_fakeItal, m_fakeBold, aMirror, supersub, aAngle };
GLYPH_DATA& glyphData = s_glyphCache[ key ];
if( glyphData.m_Contours.empty() )