Fix stroke text size calculation and bitmap text overbar
Fixes bug 1 from https://gitlab.com/kicad/code/kicad/-/issues/8591. Fixes a bug where no overbar would appear in bitmap text.
This commit is contained in:
parent
0527dc6fe0
commit
2af06a9d60
|
@ -1308,8 +1308,6 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition,
|
|||
wxASSERT_MSG( *chIt != '\n' && *chIt != '\r',
|
||||
wxT( "No support for multiline bitmap text yet" ) );
|
||||
|
||||
bool wasOverbar = overbarDepth == -1;
|
||||
|
||||
if( *chIt == '~' && overbarDepth == -1 )
|
||||
{
|
||||
UTF8::uni_iter lookahead = chIt;
|
||||
|
@ -1333,18 +1331,15 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition,
|
|||
|
||||
if( braceNesting == overbarDepth )
|
||||
{
|
||||
drawBitmapOverbar( overbarLength, overbarHeight );
|
||||
overbarLength = 0;
|
||||
|
||||
overbarDepth = -1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if( wasOverbar && overbarDepth == -1 )
|
||||
{
|
||||
drawBitmapOverbar( overbarLength, overbarHeight );
|
||||
overbarLength = 0;
|
||||
}
|
||||
|
||||
if( overbarDepth >= 0 )
|
||||
if( overbarDepth != -1 )
|
||||
overbarLength += drawBitmapChar( *chIt );
|
||||
else
|
||||
drawBitmapChar( *chIt );
|
||||
|
@ -1353,7 +1348,7 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition,
|
|||
// Handle the case when overbar is active till the end of the drawn text
|
||||
m_currentManager->Translate( 0, commonOffset, 0 );
|
||||
|
||||
if( overbarDepth >= 0 && overbarLength > 0 )
|
||||
if( overbarDepth != -1 && overbarLength > 0 )
|
||||
drawBitmapOverbar( overbarLength, overbarHeight );
|
||||
|
||||
Restore();
|
||||
|
|
|
@ -540,6 +540,7 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, const VECT
|
|||
double maxX = 0.0, curX = 0.0;
|
||||
|
||||
double curScale = 1.0;
|
||||
int overbarDepth = -1;
|
||||
int superSubDepth = -1;
|
||||
int braceNesting = 0;
|
||||
|
||||
|
@ -565,18 +566,31 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, const VECT
|
|||
}
|
||||
else if( (*chIt == '^' || *chIt == '_') && superSubDepth == -1 )
|
||||
{
|
||||
auto lookahead = chIt;
|
||||
UTF8::uni_iter lookahead = chIt;
|
||||
|
||||
if( ++lookahead != end && *lookahead == '{' )
|
||||
{
|
||||
// process superscript
|
||||
// Process superscript
|
||||
chIt = lookahead;
|
||||
superSubDepth = braceNesting;
|
||||
braceNesting++;
|
||||
|
||||
curScale = 0.8;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if( *chIt == '~' && overbarDepth == -1 )
|
||||
{
|
||||
UTF8::uni_iter lookahead = chIt;
|
||||
|
||||
if( ++lookahead != end && *lookahead == '{' )
|
||||
{
|
||||
chIt = lookahead;
|
||||
overbarDepth = braceNesting;
|
||||
braceNesting++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if( *chIt == '{' )
|
||||
{
|
||||
braceNesting++;
|
||||
|
@ -586,6 +600,12 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, const VECT
|
|||
if( braceNesting > 0 )
|
||||
braceNesting--;
|
||||
|
||||
if( braceNesting == overbarDepth )
|
||||
{
|
||||
overbarDepth = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( braceNesting == superSubDepth )
|
||||
{
|
||||
superSubDepth = -1;
|
||||
|
|
Loading…
Reference in New Issue