Cherry-pick TEXT_ATTRIBUTES and EDA_ANGLE from rockola/kicad-strokefont

This commit is contained in:
Jeff Young
2021-12-28 22:15:20 +00:00
parent a0c4f05c17
commit 86cb57f4a7
91 changed files with 1896 additions and 1576 deletions
+18 -33
View File
@@ -758,10 +758,10 @@ bool SVG_PLOTTER::EndPlot()
void SVG_PLOTTER::Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
double aOrient,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
@@ -777,31 +777,16 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
switch( aH_justify )
{
case GR_TEXT_HJUSTIFY_CENTER:
hjust = "middle";
break;
case GR_TEXT_HJUSTIFY_RIGHT:
hjust = "end";
break;
case GR_TEXT_HJUSTIFY_LEFT:
hjust = "start";
break;
case GR_TEXT_H_ALIGN_CENTER: hjust = "middle"; break;
case GR_TEXT_H_ALIGN_RIGHT: hjust = "end"; break;
case GR_TEXT_H_ALIGN_LEFT: hjust = "start"; break;
}
switch( aV_justify )
{
case GR_TEXT_VJUSTIFY_CENTER:
text_pos.y += aSize.y / 2;
break;
case GR_TEXT_VJUSTIFY_TOP:
text_pos.y += aSize.y;
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
break;
case GR_TEXT_V_ALIGN_CENTER: text_pos.y += aSize.y / 2; break;
case GR_TEXT_V_ALIGN_TOP: text_pos.y += aSize.y; break;
case GR_TEXT_V_ALIGN_BOTTOM: break;
}
wxSize text_size;
@@ -814,14 +799,14 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
DPOINT text_pos_dev = userToDeviceCoordinates( text_pos );
DPOINT sz_dev = userToDeviceSize( text_size );
if( aOrient != 0 ) {
if( aOrient != EDA_ANGLE::ANGLE_0 )
{
fprintf( m_outputFile,
"<g transform=\"rotate(%f %f %f)\">\n",
- aOrient * 0.1, anchor_pos_dev.x, anchor_pos_dev.y );
- aOrient.AsDegrees(), anchor_pos_dev.x, anchor_pos_dev.y );
}
fprintf( m_outputFile,
"<text x=\"%f\" y=\"%f\"\n", text_pos_dev.x, text_pos_dev.y );
fprintf( m_outputFile, "<text x=\"%f\" y=\"%f\"\n", text_pos_dev.x, text_pos_dev.y );
/// If the text is mirrored, we should also mirror the hidden text to match
if( aSize.x < 0 )
@@ -830,16 +815,16 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
fprintf( m_outputFile,
"textLength=\"%f\" font-size=\"%f\" lengthAdjust=\"spacingAndGlyphs\"\n"
"text-anchor=\"%s\" opacity=\"0\">%s</text>\n",
sz_dev.x, sz_dev.y,
hjust, TO_UTF8( XmlEsc( aText ) ) );
sz_dev.x, sz_dev.y, hjust, TO_UTF8( XmlEsc( aText ) ) );
if( aOrient != 0 )
if( aOrient != EDA_ANGLE::ANGLE_0 )
fputs( "</g>\n", m_outputFile );
fprintf( m_outputFile,
"<g class=\"stroked-text\"><desc>%s</desc>\n",
fprintf( m_outputFile, "<g class=\"stroked-text\"><desc>%s</desc>\n",
TO_UTF8( XmlEsc( aText ) ) );
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
aWidth, aItalic, aBold, aMultilineAllowed );
fputs( "</g>", m_outputFile );
}