Fix issue with overbar processing.

Fixes: lp:1852037
* https://bugs.launchpad.net/kicad/+bug/1852037
This commit is contained in:
Jeff Young 2019-11-11 13:04:51 +00:00
parent 9f0c131ba4
commit 55432d9685
1 changed files with 8 additions and 10 deletions

View File

@ -302,9 +302,6 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText, int markupFlags )
for( UTF8::uni_iter chIt = aText.ubegin(), end = aText.uend(); chIt < end; ++chIt ) for( UTF8::uni_iter chIt = aText.ubegin(), end = aText.uend(); chIt < end; ++chIt )
{ {
// Index into bounding boxes table
int dd = *chIt - ' ';
// Handle tabs as locked to the nearest 4th column (counting in spaces) // Handle tabs as locked to the nearest 4th column (counting in spaces)
// The choice of spaces is somewhat arbitrary but sufficient for aligning text // The choice of spaces is somewhat arbitrary but sufficient for aligning text
if( *chIt == '\t' ) if( *chIt == '\t' )
@ -315,9 +312,6 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText, int markupFlags )
// Add the remaining space (between 0 and 3 spaces) // Add the remaining space (between 0 and 3 spaces)
xOffset += addlSpace; xOffset += addlSpace;
// Set the character to ' ' instead of the '?' for tab
dd = 0;
glyphSize = baseGlyphSize; glyphSize = baseGlyphSize;
yOffset = 0; yOffset = 0;
} }
@ -359,7 +353,6 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText, int markupFlags )
else else
{ {
// single ^ starts a superscript // single ^ starts a superscript
dd = *chIt - ' ';
glyphSize = baseGlyphSize * 0.8; glyphSize = baseGlyphSize * 0.8;
yOffset = -baseGlyphSize.y * 0.3; yOffset = -baseGlyphSize.y * 0.3;
} }
@ -376,7 +369,6 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText, int markupFlags )
else else
{ {
// single _ starts a subscript // single _ starts a subscript
dd = *chIt - ' ';
glyphSize = baseGlyphSize * 0.8; glyphSize = baseGlyphSize * 0.8;
yOffset = baseGlyphSize.y * 0.1; yOffset = baseGlyphSize.y * 0.1;
} }
@ -388,8 +380,14 @@ void STROKE_FONT::drawSingleLineText( const UTF8& aText, int markupFlags )
yOffset = 0; yOffset = 0;
} }
// Index into bounding boxes table
int dd = (signed) *chIt - ' ';
if( dd >= (int) m_glyphBoundingBoxes.size() || dd < 0 ) if( dd >= (int) m_glyphBoundingBoxes.size() || dd < 0 )
dd = '?' - ' '; {
int substitute = *chIt == '\t' ? ' ' : '?';
dd = substitute - ' ';
}
GLYPH& glyph = m_glyphs[dd]; GLYPH& glyph = m_glyphs[dd];
BOX2D& bbox = m_glyphBoundingBoxes[dd]; BOX2D& bbox = m_glyphBoundingBoxes[dd];
@ -571,7 +569,7 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, const VECT
} }
// Index in the bounding boxes table // Index in the bounding boxes table
int dd = *it - ' '; int dd = (signed) *it - ' ';
if( dd >= (int) m_glyphBoundingBoxes.size() || dd < 0 ) if( dd >= (int) m_glyphBoundingBoxes.size() || dd < 0 )
dd = '?' - ' '; dd = '?' - ' ';