Altium PCB import: read and apply TrueType font names to text.

This commit is contained in:
Alex Shvartzkop 2023-07-04 13:29:42 +03:00
parent 536744d37a
commit e892405738
4 changed files with 24 additions and 3 deletions

View File

@ -170,6 +170,21 @@ public:
} }
} }
int ReadBytes( char* aOut, size_t aSize )
{
if( aSize > GetRemainingBytes() )
{
m_error = true;
return 0;
}
else
{
memcpy( aOut, m_pos, aSize );
m_pos += aSize;
return aSize;
}
}
int32_t ReadKicadUnit() int32_t ReadKicadUnit()
{ {
return ConvertToKicadUnit( Read<int32_t>() ); return ConvertToKicadUnit( Read<int32_t>() );

View File

@ -904,7 +904,11 @@ ATEXT6::ATEXT6( ALTIUM_PARSER& aReader, std::map<uint32_t, wxString>& aStringTab
aReader.Skip( 2 ); aReader.Skip( 2 );
isBold = aReader.Read<uint8_t>() != 0; isBold = aReader.Read<uint8_t>() != 0;
isItalic = aReader.Read<uint8_t>() != 0; isItalic = aReader.Read<uint8_t>() != 0;
aReader.Skip( 64 ); // font_name
char fontData[64] = { 0 };
aReader.ReadBytes( fontData, sizeof( fontData ) );
fontname = wxString( fontData, wxMBConvUTF16LE(), sizeof( fontData ) );
isInverted = aReader.Read<uint8_t>() != 0; isInverted = aReader.Read<uint8_t>() != 0;
aReader.Skip( 4 ); aReader.Skip( 4 );
uint32_t stringIndex = aReader.Read<uint32_t>(); uint32_t stringIndex = aReader.Read<uint32_t>();

View File

@ -687,6 +687,7 @@ struct ATEXT6
bool isDesignator; bool isDesignator;
ALTIUM_TEXT_TYPE fonttype; ALTIUM_TEXT_TYPE fonttype;
wxString fontname;
wxString text; wxString text;

View File

@ -3132,8 +3132,9 @@ void ALTIUM_PCB::ConvertTexts6ToEdaTextSettings( const ATEXT6& aElem, EDA_TEXT*
{ {
if( aElem.fonttype == ALTIUM_TEXT_TYPE::TRUETYPE ) if( aElem.fonttype == ALTIUM_TEXT_TYPE::TRUETYPE )
{ {
// TODO: why is this required? Somehow, truetype size is calculated differently // TODO: why is this required? Somehow, truetype size is calculated differently (tuned to Arial)
aEdaText->SetTextSize( VECTOR2I( aElem.height / 2, aElem.height / 2 ) ); aEdaText->SetTextSize( VECTOR2I( aElem.height * 0.63, aElem.height * 0.63 ) );
aEdaText->SetFont( KIFONT::FONT::GetFont( aElem.fontname, aElem.isBold, aElem.isItalic ) );
} }
else else
{ {