Commit 7678983e authored by Maciej Suminski's avatar Maciej Suminski

Fixed non ASCII characters drawing using GAL.

parent c6d7ee7e
......@@ -142,7 +142,7 @@ BOX2D STROKE_FONT::computeBoundingBox( const GLYPH& aGLYPH, const VECTOR2D& aGLY
}
void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRotationAngle )
void STROKE_FONT::Draw( std::wstring aText, const VECTOR2D& aPosition, double aRotationAngle )
{
// By default overbar is turned off
m_overbar = false;
......@@ -156,7 +156,7 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo
// Split multiline strings into separate ones and draw them line by line
size_t newlinePos = aText.find( '\n' );
if( newlinePos != std::string::npos )
if( newlinePos != std::wstring::npos )
{
VECTOR2D nextlinePosition = VECTOR2D( 0.0, m_glyphSize.y * LINE_HEIGHT_RATIO );
......@@ -233,7 +233,7 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo
m_gal->SetLineWidth( m_gal->GetLineWidth() * 1.3 );
}
for( std::string::const_iterator chIt = aText.begin(); chIt != aText.end(); chIt++ )
for( std::wstring::const_iterator chIt = aText.begin(); chIt != aText.end(); chIt++ )
{
if( *chIt == '~' )
{
......@@ -244,7 +244,7 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo
GLYPH_LIST::iterator glyphIt = m_glyphs.begin();
std::deque<BOX2D>::iterator bbIt = m_glyphBoundingBoxes.begin();
unsigned dd = (unsigned) ((unsigned char) *chIt ) - (unsigned) ' ';
unsigned dd = *chIt - ' ';
if( dd >= m_glyphBoundingBoxes.size() )
dd = '?' - ' ';
......@@ -292,17 +292,17 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo
}
VECTOR2D STROKE_FONT::computeTextSize( const std::string& aText ) const
VECTOR2D STROKE_FONT::computeTextSize( const std::wstring& aText ) const
{
VECTOR2D result = VECTOR2D( 0.0, m_glyphSize.y );
for( std::string::const_iterator chIt = aText.begin(); chIt != aText.end(); chIt++ )
for( std::wstring::const_iterator chIt = aText.begin(); chIt != aText.end(); chIt++ )
{
if( *chIt == '~' )
continue;
std::deque<BOX2D>::const_iterator bbIt = m_glyphBoundingBoxes.begin();
unsigned dd = (unsigned) ((unsigned char)*chIt) - (unsigned) ' ';
unsigned dd = *chIt - ' ';
if( dd >= m_glyphBoundingBoxes.size() )
dd = '?' - ' ';
......
......@@ -191,7 +191,7 @@ void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_TEXT* aItem, GAL* aGal ) const
aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) );
aGal->SetLineWidth( aItem->GetThickness() );
aGal->SetTextAttributes( aItem );
aGal->StrokeText( std::string( aItem->GetText().mb_str() ), position, 0.0 );
aGal->StrokeText( std::wstring( aItem->GetText().wc_str() ), position, 0.0 );
}
......
......@@ -277,7 +277,7 @@ public:
* @param aPosition is the text position in world coordinates.
* @param aRotationAngle is the text rotation angle.
*/
inline virtual void StrokeText( const std::string& aText, const VECTOR2D& aPosition,
inline virtual void StrokeText( const std::wstring& aText, const VECTOR2D& aPosition,
double aRotationAngle )
{
strokeFont.Draw( aText, aPosition, aRotationAngle );
......
......@@ -73,7 +73,7 @@ public:
* @param aPosition is the text position in world coordinates.
* @param aRotationAngle is the text rotation angle.
*/
void Draw( std::string aText, const VECTOR2D& aPosition, double aRotationAngle );
void Draw( std::wstring aText, const VECTOR2D& aPosition, double aRotationAngle );
/**
* @brief Set the scale factor of the font for the glyph size.
......@@ -180,7 +180,7 @@ private:
* @param aText is the text string.
* @return is the text size.
*/
VECTOR2D computeTextSize( const std::string& aText ) const;
VECTOR2D computeTextSize( const std::wstring& aText ) const;
static const double LINE_HEIGHT_RATIO;
};
......
......@@ -280,7 +280,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
if( !net )
return;
std::string netName = std::string( net->GetShortNetname().mb_str() );
std::wstring netName = std::wstring( net->GetShortNetname().wc_str() );
VECTOR2D textPosition = start + line / 2.0; // center of the track
double textOrientation = -atan( line.y / line.x );
double textSize = std::min( static_cast<double>( width ), length / netName.length() );
......@@ -456,7 +456,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
VECTOR2D namesize( tsize, tsize );
m_gal->SetGlyphSize( namesize );
m_gal->SetLineWidth( namesize.x / 12.0 );
m_gal->StrokeText( std::string( aPad->GetShortNetname().mb_str() ),
m_gal->StrokeText( std::wstring( aPad->GetShortNetname().wc_str() ),
textpos, 0.0 );
}
......@@ -474,8 +474,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m_gal->SetGlyphSize( numsize );
m_gal->SetLineWidth( numsize.x / 12.0 );
m_gal->StrokeText( std::string( aPad->GetPadName().mb_str() ),
textpos, 0.0 );
m_gal->StrokeText( std::wstring( aPad->GetPadName().wc_str() ), textpos, 0.0 );
}
m_gal->Restore();
......@@ -720,7 +719,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
m_gal->SetStrokeColor( strokeColor );
m_gal->SetLineWidth( aText->GetThickness() );
m_gal->SetTextAttributes( aText );
m_gal->StrokeText( std::string( aText->GetText().mb_str() ), position, orientation );
m_gal->StrokeText( std::wstring( aText->GetText().wc_str() ), position, orientation );
}
......@@ -736,7 +735,7 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
m_gal->SetStrokeColor( strokeColor );
m_gal->SetLineWidth( aText->GetThickness() );
m_gal->SetTextAttributes( aText );
m_gal->StrokeText( std::string( aText->GetText().mb_str() ), position, orientation );
m_gal->StrokeText( std::wstring( aText->GetText().wc_str() ), position, orientation );
}
......@@ -836,7 +835,7 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
m_gal->SetLineWidth( text.GetThickness() );
m_gal->SetTextAttributes( &text );
m_gal->StrokeText( std::string( text.GetText().mb_str() ), position, orientation );
m_gal->StrokeText( std::wstring( text.GetText().wc_str() ), position, orientation );
}
......
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