diff --git a/common/font/stroke_font.cpp b/common/font/stroke_font.cpp index 82a7e83546..e8ad68e4ef 100644 --- a/common/font/stroke_font.cpp +++ b/common/font/stroke_font.cpp @@ -212,6 +212,9 @@ VECTOR2I STROKE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector= (int) m_glyphBoundingBoxes->size() || dd < 0 ) + // Handle tabs as locked to the nearest 4th column (in space-widths). + if( c == '\t' ) { - // Filtering non existing glyphes and non printable chars - if( c == '\t' ) - c = ' '; - else - c = '?'; + int tabWidth = KiROUND( glyphSize.x * TAB_WIDTH ); + int currentIntrusion = ( cursor.x - aOrigin.x ) % tabWidth; - // Fix the index: - dd = (signed) c - ' '; + cursor.x += tabWidth - currentIntrusion; } - - if( dd <= 0 ) // dd < 0 should not happen + else if( c == ' ' ) { // 'space' character - draw nothing, advance cursor position cursor.x += KiROUND( glyphSize.x * SPACE_WIDTH ); } else { + // dd is the index into bounding boxes table + int dd = (signed) c - ' '; + + // Filtering non existing glyphs and non printable chars + if( dd < 0 || dd >= (int) m_glyphBoundingBoxes->size() ) + { + c = '?'; + dd = (signed) c - ' '; + } + STROKE_GLYPH* source = static_cast( m_glyphs->at( dd ).get() ); if( aGlyphs )