CADSTAR Archive Importer: Fix loading of non-cadstar font text sizes
Non-cadstar fonts use a width of 0.
This commit is contained in:
parent
49bf957c48
commit
80d8974f87
|
@ -2252,7 +2252,14 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( const TEXTCODE_ID& aCadstarT
|
||||||
{
|
{
|
||||||
TEXTCODE textCode = getTextCode( aCadstarTextCodeID );
|
TEXTCODE textCode = getTextCode( aCadstarTextCodeID );
|
||||||
int textHeight = KiROUND( (double) getKiCadLength( textCode.Height ) * TXT_HEIGHT_RATIO );
|
int textHeight = KiROUND( (double) getKiCadLength( textCode.Height ) * TXT_HEIGHT_RATIO );
|
||||||
aKiCadTextItem->SetTextWidth( getKiCadLength( textCode.Width ) );
|
int textWidth = getKiCadLength( textCode.Width );
|
||||||
|
|
||||||
|
// The width is zero for all non-cadstar fonts. Using a width equal to the height seems
|
||||||
|
// to work well for most fonts.
|
||||||
|
if( textWidth == 0 )
|
||||||
|
textWidth = getKiCadLength( textCode.Height );
|
||||||
|
|
||||||
|
aKiCadTextItem->SetTextWidth( textWidth );
|
||||||
aKiCadTextItem->SetTextHeight( textHeight );
|
aKiCadTextItem->SetTextHeight( textHeight );
|
||||||
aKiCadTextItem->SetTextThickness( getKiCadLength( textCode.LineWidth ) );
|
aKiCadTextItem->SetTextThickness( getKiCadLength( textCode.LineWidth ) );
|
||||||
|
|
||||||
|
|
|
@ -2045,6 +2045,12 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText( const TEXT& aCadstarText,
|
||||||
|
|
||||||
wxSize unscaledTextSize;
|
wxSize unscaledTextSize;
|
||||||
unscaledTextSize.x = getKiCadLength( tc.Width );
|
unscaledTextSize.x = getKiCadLength( tc.Width );
|
||||||
|
|
||||||
|
// The width is zero for all non-cadstar fonts. Using a width equal to the height seems
|
||||||
|
// to work well for most fonts.
|
||||||
|
if( unscaledTextSize.x == 0 )
|
||||||
|
unscaledTextSize.x = getKiCadLength( tc.Height );
|
||||||
|
|
||||||
unscaledTextSize.y = KiROUND( TXT_HEIGHT_RATIO * (double) getKiCadLength( tc.Height ) );
|
unscaledTextSize.y = KiROUND( TXT_HEIGHT_RATIO * (double) getKiCadLength( tc.Height ) );
|
||||||
txt->SetTextSize( unscaledTextSize );
|
txt->SetTextSize( unscaledTextSize );
|
||||||
|
|
||||||
|
@ -2109,8 +2115,8 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText( const TEXT& aCadstarText,
|
||||||
if( aScalingFactor != 1.0 )
|
if( aScalingFactor != 1.0 )
|
||||||
{
|
{
|
||||||
wxSize scaledTextSize;
|
wxSize scaledTextSize;
|
||||||
scaledTextSize.x = KiROUND( (double) getKiCadLength( tc.Width ) * aScalingFactor );
|
scaledTextSize.x = KiROUND( (double) unscaledTextSize.x * aScalingFactor );
|
||||||
scaledTextSize.y = KiROUND( (double) getKiCadLength( tc.Height ) * aScalingFactor );
|
scaledTextSize.y = KiROUND( (double) unscaledTextSize.y * aScalingFactor );
|
||||||
txt->SetTextSize( scaledTextSize );
|
txt->SetTextSize( scaledTextSize );
|
||||||
txt->SetTextThickness(
|
txt->SetTextThickness(
|
||||||
KiROUND( (double) getKiCadLength( tc.LineWidth ) * aScalingFactor ) );
|
KiROUND( (double) getKiCadLength( tc.LineWidth ) * aScalingFactor ) );
|
||||||
|
@ -2669,6 +2675,12 @@ void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute( const ATTRIBUTE_LOCATION& aCadsta
|
||||||
|
|
||||||
wxSize txtSize;
|
wxSize txtSize;
|
||||||
txtSize.x = getKiCadLength( tc.Width );
|
txtSize.x = getKiCadLength( tc.Width );
|
||||||
|
|
||||||
|
// The width is zero for all non-cadstar fonts. Using a width equal to the height seems
|
||||||
|
// to work well for most fonts.
|
||||||
|
if( txtSize.x == 0 )
|
||||||
|
txtSize.x = getKiCadLength( tc.Height );
|
||||||
|
|
||||||
txtSize.y = KiROUND( TXT_HEIGHT_RATIO * (double) getKiCadLength( tc.Height ) );
|
txtSize.y = KiROUND( TXT_HEIGHT_RATIO * (double) getKiCadLength( tc.Height ) );
|
||||||
txt->SetTextSize( txtSize );
|
txt->SetTextSize( txtSize );
|
||||||
txt->SetKeepUpright( false ); //Keeping it upright seems to result in incorrect orientation
|
txt->SetKeepUpright( false ); //Keeping it upright seems to result in incorrect orientation
|
||||||
|
|
Loading…
Reference in New Issue