From d5290bdfe00678f6d0f24c6dbe23ff3d2d062cc6 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 3 Nov 2017 21:37:18 -0400 Subject: [PATCH] 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. --- eeschema/sch_eagle_plugin.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 6142aeaf9b..fae394b471 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -1672,7 +1672,17 @@ LIB_TEXT* SCH_EAGLE_PLUGIN::loadSymbolText( std::unique_ptr& aPart, libtext->SetUnit( aGateNumber ); 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 ); return libtext.release();