Replace tab processing that got lost in move to new font engine.
Fixes https://gitlab.com/kicad/code/kicad/issues/11123
This commit is contained in:
parent
97071e330e
commit
37a2ee7d03
|
@ -212,6 +212,9 @@ VECTOR2I STROKE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr
|
||||||
{
|
{
|
||||||
constexpr double SPACE_WIDTH = 0.6;
|
constexpr double SPACE_WIDTH = 0.6;
|
||||||
constexpr double INTER_CHAR = 0.2;
|
constexpr double INTER_CHAR = 0.2;
|
||||||
|
constexpr double TAB_WIDTH = 4 * 0.82; // Not quite as wide as 5.1/6.0 tab formatting, but
|
||||||
|
// a better match for Scintilla, and closer to the
|
||||||
|
// nominal SPACE_WIDTH + INTER_CHAR
|
||||||
constexpr double SUPER_SUB_SIZE_MULTIPLIER = 0.7;
|
constexpr double SUPER_SUB_SIZE_MULTIPLIER = 0.7;
|
||||||
constexpr double SUPER_HEIGHT_OFFSET = 0.5;
|
constexpr double SUPER_HEIGHT_OFFSET = 0.5;
|
||||||
constexpr double SUB_HEIGHT_OFFSET = 0.3;
|
constexpr double SUB_HEIGHT_OFFSET = 0.3;
|
||||||
|
@ -232,28 +235,31 @@ VECTOR2I STROKE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr
|
||||||
|
|
||||||
for( wxUniChar c : aText )
|
for( wxUniChar c : aText )
|
||||||
{
|
{
|
||||||
// dd is the index into bounding boxes table
|
// Handle tabs as locked to the nearest 4th column (in space-widths).
|
||||||
int dd = (signed) c - ' ';
|
if( c == '\t' )
|
||||||
|
|
||||||
if( dd >= (int) m_glyphBoundingBoxes->size() || dd < 0 )
|
|
||||||
{
|
{
|
||||||
// Filtering non existing glyphes and non printable chars
|
int tabWidth = KiROUND( glyphSize.x * TAB_WIDTH );
|
||||||
if( c == '\t' )
|
int currentIntrusion = ( cursor.x - aOrigin.x ) % tabWidth;
|
||||||
c = ' ';
|
|
||||||
else
|
|
||||||
c = '?';
|
|
||||||
|
|
||||||
// Fix the index:
|
cursor.x += tabWidth - currentIntrusion;
|
||||||
dd = (signed) c - ' ';
|
|
||||||
}
|
}
|
||||||
|
else if( c == ' ' )
|
||||||
if( dd <= 0 ) // dd < 0 should not happen
|
|
||||||
{
|
{
|
||||||
// 'space' character - draw nothing, advance cursor position
|
// 'space' character - draw nothing, advance cursor position
|
||||||
cursor.x += KiROUND( glyphSize.x * SPACE_WIDTH );
|
cursor.x += KiROUND( glyphSize.x * SPACE_WIDTH );
|
||||||
}
|
}
|
||||||
else
|
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<STROKE_GLYPH*>( m_glyphs->at( dd ).get() );
|
STROKE_GLYPH* source = static_cast<STROKE_GLYPH*>( m_glyphs->at( dd ).get() );
|
||||||
|
|
||||||
if( aGlyphs )
|
if( aGlyphs )
|
||||||
|
|
Loading…
Reference in New Issue