Fix malformed symbol libraries when importing Eagle schematics.

KiCad library symbol text objects cannot contain carriage returns and/or
line feeds which isn't the case with Eagle symbol libraries.  Otherwise,
the library file will be corrupt when it is saved.  Fixing this in the
legacy plugin would break the current file format so just replace them
with underscores.  Ideally these text objects should be broken into
multiple text objects but the current plugin design doesn't support
this.
This commit is contained in:
Wayne Stambaugh 2017-11-03 21:37:18 -04:00
parent dcb75a9b24
commit d5290bdfe0
1 changed files with 11 additions and 1 deletions

View File

@ -1672,7 +1672,17 @@ LIB_TEXT* SCH_EAGLE_PLUGIN::loadSymbolText( std::unique_ptr<LIB_PART>& aPart,
libtext->SetUnit( aGateNumber ); libtext->SetUnit( aGateNumber );
libtext->SetPosition( wxPoint( etext.x.ToSchUnits(), etext.y.ToSchUnits() ) ); libtext->SetPosition( wxPoint( etext.x.ToSchUnits(), etext.y.ToSchUnits() ) );
libtext->SetText( aLibText->GetNodeContent().IsEmpty() ? "~~" : aLibText->GetNodeContent() );
// Eagle supports multiple line text in library symbols. Legacy library symbol text cannot
// contain CRs or LFs.
//
// @todo Split this into multiple text objects and offset the Y position so that it looks
// more like the original Eagle schematic.
wxString text = aLibText->GetNodeContent();
std::replace( text.begin(), text.end(), '\n', '_' );
std::replace( text.begin(), text.end(), '\r', '_' );
libtext->SetText( text.IsEmpty() ? "~~" : text );
loadTextAttributes( libtext.get(), etext ); loadTextAttributes( libtext.get(), etext );
return libtext.release(); return libtext.release();