From 568a461080e6719098e012e220b235e07eeb6038 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Wed, 12 Jul 2023 08:34:10 +0500 Subject: [PATCH] LTspice import: Fix multiline text alignment. --- .../ltspice/ltspice_sch_parser.cpp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/eeschema/sch_plugins/ltspice/ltspice_sch_parser.cpp b/eeschema/sch_plugins/ltspice/ltspice_sch_parser.cpp index 5661c0df00..6ad1848e2c 100644 --- a/eeschema/sch_plugins/ltspice/ltspice_sch_parser.cpp +++ b/eeschema/sch_plugins/ltspice/ltspice_sch_parser.cpp @@ -752,7 +752,28 @@ void LTSPICE_SCH_PARSER::setTextJustification( EDA_TEXT* default: break; } - // TODO: (V)Center aligns by first line in multiline text + // Center, Left, Right aligns by first line in multiline text + if( wxSplit( aText->GetText(), '\n', '\0' ).size() > 1 ) + { + switch( aJustification ) + { + case LTSPICE_SCHEMATIC::JUSTIFICATION::LEFT: + case LTSPICE_SCHEMATIC::JUSTIFICATION::CENTER: + case LTSPICE_SCHEMATIC::JUSTIFICATION::RIGHT: + aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + aText->Offset( VECTOR2I( 0, -aText->GetTextHeight() / 2 ) ); + break; + + case LTSPICE_SCHEMATIC::JUSTIFICATION::VLEFT: + case LTSPICE_SCHEMATIC::JUSTIFICATION::VCENTER: + case LTSPICE_SCHEMATIC::JUSTIFICATION::VRIGHT: + aText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + aText->Offset( VECTOR2I( -aText->GetTextHeight() / 2, 0 ) ); + break; + + default: break; + } + } }