CADSTAR PCB Archive Importer: Fix imported text height

Apply a scaling factor derived from CADSTAR's default font
This commit is contained in:
Roberto Fernandez Bautista 2020-10-18 18:15:46 +01:00 committed by Jon Evans
parent a514817c57
commit 7839a508b3
3 changed files with 23 additions and 2 deletions

View File

@ -26,6 +26,9 @@
#include <plugins/cadstar/cadstar_archive_parser.h>
const double CADSTAR_ARCHIVE_PARSER::TXT_HEIGHT_RATIO = ( 24.0 - 5.0 ) / 24.0;
void CADSTAR_ARCHIVE_PARSER::FORMAT::Parse( XNODE* aNode )
{
wxASSERT( aNode->GetName() == wxT( "FORMAT" ) );

View File

@ -107,6 +107,18 @@ public:
static const long UNDEFINED_VALUE = -1;
/**
* CADSTAR fonts are drawn on a 24x24 integer matrix, where the each axis goes from 0 to 24.
* The characters can each specify a width of between 12 and 24, but the height is fixed at 24.
*
* The default CADSTAR font uses y=5 as the starting point for capital letters, leaving space
* for the tails of letters such as "g", "p", "y", "q", etc.
*
* The font height in CADSTAR corresponds to the full 24 point height. In KiCad it only
* corresponds to the height above the guide line, meaning the overall text height will be
* larger in KiCad.
*/
static const double TXT_HEIGHT_RATIO;
struct FORMAT
{

View File

@ -1580,7 +1580,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText( const TEXT& aCadstarText,
wxSize unscaledTextSize;
unscaledTextSize.x = getKiCadLength( tc.Width );
unscaledTextSize.y = getKiCadLength( tc.Height );
unscaledTextSize.y = KiROUND( TXT_HEIGHT_RATIO * (double) getKiCadLength( tc.Height ) );
txt->SetTextSize( unscaledTextSize );
switch( aCadstarText.Alignment )
@ -2114,7 +2114,9 @@ void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute( const ATTRIBUTE_LOCATION& aCadsta
FP_TEXT* txt;
if( aCadstarAttributeID == COMPONENT_NAME_ATTRID )
{
txt = &aModule->Reference(); //text should be set outside this function
}
else if( aCadstarAttributeID == PART_NAME_ATTRID )
{
if( aModule->Value().GetText().IsEmpty() )
@ -2166,7 +2168,11 @@ void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute( const ATTRIBUTE_LOCATION& aCadsta
TEXTCODE tc = getTextCode( aCadstarAttrLoc.TextCodeID );
txt->SetTextThickness( getKiCadLength( tc.LineWidth ) );
txt->SetTextSize( { getKiCadLength( tc.Width ), getKiCadLength( tc.Height ) } );
wxSize txtSize;
txtSize.x = getKiCadLength( tc.Width );
txtSize.y = KiROUND( TXT_HEIGHT_RATIO * (double) getKiCadLength( tc.Height ) );
txt->SetTextSize( txtSize );
switch( aCadstarAttrLoc.Alignment )
{