CADSTAR PCB Archive Importer: Fix imported text height
Apply a scaling factor derived from CADSTAR's default font
This commit is contained in:
parent
a514817c57
commit
7839a508b3
|
@ -26,6 +26,9 @@
|
||||||
#include <plugins/cadstar/cadstar_archive_parser.h>
|
#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 )
|
void CADSTAR_ARCHIVE_PARSER::FORMAT::Parse( XNODE* aNode )
|
||||||
{
|
{
|
||||||
wxASSERT( aNode->GetName() == wxT( "FORMAT" ) );
|
wxASSERT( aNode->GetName() == wxT( "FORMAT" ) );
|
||||||
|
|
|
@ -107,6 +107,18 @@ public:
|
||||||
|
|
||||||
static const long UNDEFINED_VALUE = -1;
|
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
|
struct FORMAT
|
||||||
{
|
{
|
||||||
|
|
|
@ -1580,7 +1580,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText( const TEXT& aCadstarText,
|
||||||
|
|
||||||
wxSize unscaledTextSize;
|
wxSize unscaledTextSize;
|
||||||
unscaledTextSize.x = getKiCadLength( tc.Width );
|
unscaledTextSize.x = getKiCadLength( tc.Width );
|
||||||
unscaledTextSize.y = getKiCadLength( tc.Height );
|
unscaledTextSize.y = KiROUND( TXT_HEIGHT_RATIO * (double) getKiCadLength( tc.Height ) );
|
||||||
txt->SetTextSize( unscaledTextSize );
|
txt->SetTextSize( unscaledTextSize );
|
||||||
|
|
||||||
switch( aCadstarText.Alignment )
|
switch( aCadstarText.Alignment )
|
||||||
|
@ -2114,7 +2114,9 @@ void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute( const ATTRIBUTE_LOCATION& aCadsta
|
||||||
FP_TEXT* txt;
|
FP_TEXT* txt;
|
||||||
|
|
||||||
if( aCadstarAttributeID == COMPONENT_NAME_ATTRID )
|
if( aCadstarAttributeID == COMPONENT_NAME_ATTRID )
|
||||||
|
{
|
||||||
txt = &aModule->Reference(); //text should be set outside this function
|
txt = &aModule->Reference(); //text should be set outside this function
|
||||||
|
}
|
||||||
else if( aCadstarAttributeID == PART_NAME_ATTRID )
|
else if( aCadstarAttributeID == PART_NAME_ATTRID )
|
||||||
{
|
{
|
||||||
if( aModule->Value().GetText().IsEmpty() )
|
if( aModule->Value().GetText().IsEmpty() )
|
||||||
|
@ -2166,7 +2168,11 @@ void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute( const ATTRIBUTE_LOCATION& aCadsta
|
||||||
TEXTCODE tc = getTextCode( aCadstarAttrLoc.TextCodeID );
|
TEXTCODE tc = getTextCode( aCadstarAttrLoc.TextCodeID );
|
||||||
|
|
||||||
txt->SetTextThickness( getKiCadLength( tc.LineWidth ) );
|
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 )
|
switch( aCadstarAttrLoc.Alignment )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue