From 37a2ee7d03cda1bbb4aceded237eab60fd6b4291 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 19 Apr 2022 23:33:13 +0100 Subject: [PATCH] Replace tab processing that got lost in move to new font engine. Fixes https://gitlab.com/kicad/code/kicad/issues/11123 --- common/font/stroke_font.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) 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 )