Pcbnew: fix a crash when a non ascii char (i.e. a char having a code > 127) is found in a text (see Bug #1246340).
Could be only a temporary fix (tested only with French non ascii chars).
This commit is contained in:
parent
e49a3275e2
commit
cfb3c942d7
|
@ -244,8 +244,13 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo
|
||||||
GLYPH_LIST::iterator glyphIt = m_glyphs.begin();
|
GLYPH_LIST::iterator glyphIt = m_glyphs.begin();
|
||||||
std::deque<BOX2D>::iterator bbIt = m_glyphBoundingBoxes.begin();
|
std::deque<BOX2D>::iterator bbIt = m_glyphBoundingBoxes.begin();
|
||||||
|
|
||||||
advance( glyphIt, (int) ( *chIt ) - (int) ' ' );
|
unsigned dd = (unsigned) ((unsigned char) *chIt ) - (unsigned) ' ';
|
||||||
advance( bbIt, (int) ( *chIt ) - (int) ' ' );
|
|
||||||
|
if( dd >= m_glyphBoundingBoxes.size() )
|
||||||
|
dd = '?' - ' ';
|
||||||
|
|
||||||
|
advance( glyphIt, dd );
|
||||||
|
advance( bbIt, dd );
|
||||||
|
|
||||||
GLYPH glyph = *glyphIt;
|
GLYPH glyph = *glyphIt;
|
||||||
|
|
||||||
|
@ -297,7 +302,13 @@ VECTOR2D STROKE_FONT::computeTextSize( const std::string& aText ) const
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::deque<BOX2D>::const_iterator bbIt = m_glyphBoundingBoxes.begin();
|
std::deque<BOX2D>::const_iterator bbIt = m_glyphBoundingBoxes.begin();
|
||||||
advance( bbIt, (int) ( *chIt ) - (int) ' ' );
|
unsigned dd = (unsigned) ((unsigned char)*chIt) - (unsigned) ' ';
|
||||||
|
|
||||||
|
if( dd >= m_glyphBoundingBoxes.size() )
|
||||||
|
dd = '?' - ' ';
|
||||||
|
|
||||||
|
advance( bbIt, dd );
|
||||||
|
|
||||||
result.x += m_scaleFactor * m_glyphSize.x * bbIt->GetEnd().x;
|
result.x += m_scaleFactor * m_glyphSize.x * bbIt->GetEnd().x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue