Commit 668bdfa6 authored by Vladimir Ur's avatar Vladimir Ur

Made symbol text capable of overlining. Format for text is slightly changed:...

Made symbol text capable of overlining. Format for text is slightly changed: now text with quotes and/or tildes saved in quoted format: it will cause libraries to fail loading in older versions when ~s or "s are used in text.
parent 5c8894f9
...@@ -39,9 +39,18 @@ bool LIB_TEXT::Save( FILE* ExportFile ) ...@@ -39,9 +39,18 @@ bool LIB_TEXT::Save( FILE* ExportFile )
{ {
wxString text = m_Text; wxString text = m_Text;
if( text.Contains( wxT( "~" ) ) || text.Contains( wxT( "\"" ) ) )
{
// convert double quote to similar-looking two apostrophes
text.Replace( wxT( "\"" ), wxT( "''" ) );
text = wxT( "\"" ) + text + wxT( "\"" );
}
else
{
// Spaces are not allowed in text because it is not double quoted: // Spaces are not allowed in text because it is not double quoted:
// changed to '~' // changed to '~'
text.Replace( wxT( " " ), wxT( "~" ) ); text.Replace( wxT( " " ), wxT( "~" ) );
}
if( fprintf( ExportFile, "T %d %d %d %d %d %d %d %s ", m_Orient, m_Pos.x, m_Pos.y, if( fprintf( ExportFile, "T %d %d %d %d %d %d %d %s ", m_Orient, m_Pos.x, m_Pos.y,
m_Size.x, m_Attributs, m_Unit, m_Convert, TO_UTF8( text ) ) < 0 ) m_Size.x, m_Attributs, m_Unit, m_Convert, TO_UTF8( text ) ) < 0 )
...@@ -79,6 +88,20 @@ bool LIB_TEXT::Load( char* line, wxString& errorMsg ) ...@@ -79,6 +88,20 @@ bool LIB_TEXT::Load( char* line, wxString& errorMsg )
buf[0] = 0; buf[0] = 0;
tmp[0] = 0; // For italic option, Not in old versions tmp[0] = 0; // For italic option, Not in old versions
cnt = sscanf( &line[2], "%d %d %d %d %d %d %d \"%[^\"]\" %s %d %c %c",
&m_Orient, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs,
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
&vjustify );
if( cnt >= 8 ) // if quoted loadng failed, load as not quoted
{
m_Text = FROM_UTF8( buf );
// convert two apostrophes back to double quote
m_Text.Replace( wxT( "''" ), wxT( "\"" ) );
}
else
{
cnt = sscanf( &line[2], "%d %d %d %d %d %d %d %s %s %d %c %c", cnt = sscanf( &line[2], "%d %d %d %d %d %d %d %s %s %d %c %c",
&m_Orient, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs, &m_Orient, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs,
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify, &m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
...@@ -90,6 +113,10 @@ bool LIB_TEXT::Load( char* line, wxString& errorMsg ) ...@@ -90,6 +113,10 @@ bool LIB_TEXT::Load( char* line, wxString& errorMsg )
return false; return false;
} }
/* Convert '~' to spaces (only if text is not quoted). */
m_Text = FROM_UTF8( buf );
m_Text.Replace( wxT( "~" ), wxT( " " ) );
}
m_Size.y = m_Size.x; m_Size.y = m_Size.x;
if( strnicmp( tmp, "Italic", 6 ) == 0 ) if( strnicmp( tmp, "Italic", 6 ) == 0 )
...@@ -129,9 +156,6 @@ bool LIB_TEXT::Load( char* line, wxString& errorMsg ) ...@@ -129,9 +156,6 @@ bool LIB_TEXT::Load( char* line, wxString& errorMsg )
break; break;
} }
/* Convert '~' to spaces. */
m_Text = FROM_UTF8( buf );
m_Text.Replace( wxT( "~" ), wxT( " " ) );
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment