diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 1e7a140e74..6acc5e44ce 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -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(); diff --git a/common/gal/stroke_font.cpp b/common/gal/stroke_font.cpp index 5b010ecd35..3496687d0e 100644 --- a/common/gal/stroke_font.cpp +++ b/common/gal/stroke_font.cpp @@ -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;