mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Honour renderSettings' default font.
This still leaves a few things out in the cold, such as hit-testing and polygon generation. But at least it allows us to plot with a default font. Fixes https://gitlab.com/kicad/code/kicad/-/issues/19031 (cherry picked from commit e230d5164dc80f67fab1377890a3c3d5915cfd42)
This commit is contained in:
parent
593537c52e
commit
f10d11d36c
@ -178,7 +178,7 @@ HANDLER_RESULT<types::Box2> API_HANDLER_COMMON::handleGetTextExtents(
|
||||
|
||||
types::Box2 response;
|
||||
|
||||
BOX2I bbox = text.GetTextBox();
|
||||
BOX2I bbox = text.GetTextBox( nullptr );
|
||||
EDA_ANGLE angle = text.GetTextAngle();
|
||||
|
||||
if( !angle.IsZero() )
|
||||
|
@ -701,7 +701,7 @@ void DS_DATA_ITEM_TEXT::SetConstrainedTextSize()
|
||||
dummy.SetVertJustify( m_Vjustify );
|
||||
dummy.SetTextAngle( EDA_ANGLE( m_Orient, DEGREES_T ) );
|
||||
|
||||
BOX2I rect = dummy.GetTextBox();
|
||||
BOX2I rect = dummy.GetTextBox( nullptr );
|
||||
VECTOR2D size;
|
||||
size.x = KiROUND( (int) rect.GetWidth() / FSCALE );
|
||||
size.y = KiROUND( (int) rect.GetHeight() / FSCALE );
|
||||
|
@ -221,7 +221,7 @@ const BOX2I DS_DRAW_ITEM_TEXT::GetApproxBBox()
|
||||
|
||||
const BOX2I DS_DRAW_ITEM_TEXT::GetBoundingBox() const
|
||||
{
|
||||
return EDA_TEXT::GetTextBox();
|
||||
return EDA_TEXT::GetTextBox( nullptr );
|
||||
}
|
||||
|
||||
|
||||
|
@ -631,12 +631,17 @@ void EDA_TEXT::cacheShownText()
|
||||
}
|
||||
|
||||
|
||||
KIFONT::FONT* EDA_TEXT::getDrawFont() const
|
||||
KIFONT::FONT* EDA_TEXT::GetDrawFont( const RENDER_SETTINGS* aSettings ) const
|
||||
{
|
||||
KIFONT::FONT* font = GetFont();
|
||||
|
||||
if( !font )
|
||||
{
|
||||
if( aSettings )
|
||||
font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
|
||||
else
|
||||
font = KIFONT::FONT::GetFont( wxEmptyString, IsBold(), IsItalic() );
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
@ -714,13 +719,13 @@ void EDA_TEXT::AddRenderCacheGlyph( const SHAPE_POLY_SET& aPoly )
|
||||
}
|
||||
|
||||
|
||||
int EDA_TEXT::GetInterline() const
|
||||
int EDA_TEXT::GetInterline( const RENDER_SETTINGS* aSettings ) const
|
||||
{
|
||||
return KiROUND( getDrawFont()->GetInterline( GetTextHeight(), getFontMetrics() ) );
|
||||
return KiROUND( GetDrawFont( aSettings )->GetInterline( GetTextHeight(), getFontMetrics() ) );
|
||||
}
|
||||
|
||||
|
||||
BOX2I EDA_TEXT::GetTextBox( int aLine ) const
|
||||
BOX2I EDA_TEXT::GetTextBox( const RENDER_SETTINGS* aSettings, int aLine ) const
|
||||
{
|
||||
VECTOR2I drawPos = GetDrawPos();
|
||||
|
||||
@ -748,12 +753,11 @@ BOX2I EDA_TEXT::GetTextBox( int aLine ) const
|
||||
}
|
||||
|
||||
// calculate the H and V size
|
||||
KIFONT::FONT* font = getDrawFont();
|
||||
KIFONT::FONT* font = GetDrawFont( aSettings );
|
||||
VECTOR2D fontSize( GetTextSize() );
|
||||
bool bold = IsBold();
|
||||
bool italic = IsItalic();
|
||||
VECTOR2I extents = font->StringBoundaryLimits( text, fontSize, thickness, bold, italic,
|
||||
getFontMetrics() );
|
||||
VECTOR2I extents = font->StringBoundaryLimits( text, fontSize, thickness, bold, italic, getFontMetrics() );
|
||||
int overbarOffset = 0;
|
||||
|
||||
// Creates bounding box (rectangle) for horizontal, left and top justified text. The
|
||||
@ -779,15 +783,13 @@ BOX2I EDA_TEXT::GetTextBox( int aLine ) const
|
||||
for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
|
||||
{
|
||||
text = strings.Item( ii );
|
||||
extents = font->StringBoundaryLimits( text, fontSize, thickness, bold, italic,
|
||||
getFontMetrics() );
|
||||
extents = font->StringBoundaryLimits( text, fontSize, thickness, bold, italic, getFontMetrics() );
|
||||
textsize.x = std::max( textsize.x, extents.x );
|
||||
}
|
||||
|
||||
// interline spacing is only *between* lines, so total height is the height of the first
|
||||
// line plus the interline distance (with interline spacing) for all subsequent lines
|
||||
textsize.y += KiROUND( ( strings.GetCount() - 1 )
|
||||
* font->GetInterline( fontSize.y, getFontMetrics() ) );
|
||||
textsize.y += KiROUND( ( strings.GetCount() - 1 ) * font->GetInterline( fontSize.y, getFontMetrics() ) );
|
||||
}
|
||||
|
||||
textsize.y += overbarOffset;
|
||||
@ -852,7 +854,7 @@ BOX2I EDA_TEXT::GetTextBox( int aLine ) const
|
||||
|
||||
bool EDA_TEXT::TextHitTest( const VECTOR2I& aPoint, int aAccuracy ) const
|
||||
{
|
||||
const BOX2I rect = GetTextBox().GetInflated( aAccuracy );
|
||||
const BOX2I rect = GetTextBox( nullptr ).GetInflated( aAccuracy );
|
||||
const VECTOR2I location = GetRotated( aPoint, GetDrawPos(), -GetDrawRotation() );
|
||||
return rect.Contains( location );
|
||||
}
|
||||
@ -863,9 +865,9 @@ bool EDA_TEXT::TextHitTest( const BOX2I& aRect, bool aContains, int aAccuracy )
|
||||
const BOX2I rect = aRect.GetInflated( aAccuracy );
|
||||
|
||||
if( aContains )
|
||||
return rect.Contains( GetTextBox() );
|
||||
return rect.Contains( GetTextBox( nullptr ) );
|
||||
|
||||
return rect.Intersects( GetTextBox(), GetDrawRotation() );
|
||||
return rect.Intersects( GetTextBox( nullptr ), GetDrawRotation() );
|
||||
}
|
||||
|
||||
|
||||
@ -880,7 +882,7 @@ void EDA_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
||||
|
||||
positions.reserve( strings.Count() );
|
||||
|
||||
GetLinePositions( positions, (int) strings.Count() );
|
||||
GetLinePositions( aSettings, positions, (int) strings.Count() );
|
||||
|
||||
for( unsigned ii = 0; ii < strings.Count(); ii++ )
|
||||
printOneLineOfText( aSettings, aOffset, aColor, aFillMode, strings[ii], positions[ii] );
|
||||
@ -893,14 +895,15 @@ void EDA_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
||||
}
|
||||
|
||||
|
||||
void EDA_TEXT::GetLinePositions( std::vector<VECTOR2I>& aPositions, int aLineCount ) const
|
||||
void EDA_TEXT::GetLinePositions( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPositions,
|
||||
int aLineCount ) const
|
||||
{
|
||||
VECTOR2I pos = GetDrawPos(); // Position of first line of the multiline text according
|
||||
// to the center of the multiline text block
|
||||
|
||||
VECTOR2I offset; // Offset to next line.
|
||||
|
||||
offset.y = GetInterline();
|
||||
offset.y = GetInterline( aSettings );
|
||||
|
||||
if( aLineCount > 1 )
|
||||
{
|
||||
@ -952,10 +955,7 @@ void EDA_TEXT::printOneLineOfText( const RENDER_SETTINGS* aSettings, const VECTO
|
||||
if( IsMirrored() )
|
||||
size.x = -size.x;
|
||||
|
||||
KIFONT::FONT* font = GetFont();
|
||||
|
||||
if( !font )
|
||||
font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
|
||||
KIFONT::FONT* font = GetDrawFont( aSettings );
|
||||
|
||||
GRPrintText( DC, aOffset + aPos, aColor, aText, GetDrawRotation(), size, GetHorizJustify(),
|
||||
GetVertJustify(), penWidth, IsItalic(), IsBold(), font, getFontMetrics() );
|
||||
@ -1123,7 +1123,7 @@ std::shared_ptr<SHAPE_COMPOUND> EDA_TEXT::GetEffectiveTextShape( bool aTriangula
|
||||
{
|
||||
std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
|
||||
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
|
||||
KIFONT::FONT* font = getDrawFont();
|
||||
KIFONT::FONT* font = GetDrawFont( nullptr );
|
||||
int penWidth = GetEffectiveTextPenWidth();
|
||||
wxString shownText( GetShownText( true ) );
|
||||
VECTOR2I drawPos = GetDrawPos();
|
||||
|
@ -2785,7 +2785,7 @@ void CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment( EDA_TEXT* aKiCadTextIte
|
||||
{
|
||||
if( !aKiCadTextItem->GetText().IsEmpty() )
|
||||
{
|
||||
VECTOR2I positionOffset( 0, aKiCadTextItem->GetInterline() );
|
||||
VECTOR2I positionOffset( 0, aKiCadTextItem->GetInterline( nullptr ) );
|
||||
RotatePoint( positionOffset, aKiCadTextItem->GetTextAngle() );
|
||||
|
||||
//Count num of additional lines
|
||||
|
@ -1658,9 +1658,8 @@ void PDF_PLOTTER::Text( const VECTOR2I& aPos,
|
||||
|
||||
wxStringTokenizer str_tok( aText, " ", wxTOKEN_RET_DELIMS );
|
||||
|
||||
// If aFont is not specilied (== nullptr), use the default kicad stroke font
|
||||
if( !aFont )
|
||||
aFont = KIFONT::FONT::GetFont();
|
||||
aFont = KIFONT::FONT::GetFont( m_renderSettings->GetDefaultFont() );
|
||||
|
||||
VECTOR2I full_box( aFont->StringBoundaryLimits( aText, t_size, aWidth, aBold, aItalic,
|
||||
aFontMetrics ) );
|
||||
|
@ -136,15 +136,9 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL
|
||||
case WSG_TEXT_T:
|
||||
{
|
||||
DS_DRAW_ITEM_TEXT* text = (DS_DRAW_ITEM_TEXT*) item;
|
||||
KIFONT::FONT* font = text->GetFont();
|
||||
KIFONT::FONT* font = text->GetDrawFont( settings );
|
||||
COLOR4D color = plotColor;
|
||||
|
||||
if( !font )
|
||||
{
|
||||
font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), text->IsBold(),
|
||||
text->IsItalic() );
|
||||
}
|
||||
|
||||
if( plotter->GetColorMode() && text->GetTextColor() != COLOR4D::UNSPECIFIED )
|
||||
color = text->GetTextColor();
|
||||
|
||||
@ -154,8 +148,8 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL
|
||||
text->GetTextAngle(), text->GetTextSize(), text->GetHorizJustify(),
|
||||
text->GetVertJustify(), penWidth, text->IsItalic(), text->IsBold(),
|
||||
text->IsMultilineAllowed(), font, text->GetFontMetrics() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WSG_POLY_T:
|
||||
{
|
||||
|
@ -745,7 +745,7 @@ void PLOTTER::Text( const VECTOR2I& aPos,
|
||||
}
|
||||
|
||||
if( !aFont )
|
||||
aFont = KIFONT::FONT::GetFont();
|
||||
aFont = KIFONT::FONT::GetFont( m_renderSettings->GetDefaultFont() );
|
||||
|
||||
aFont->Draw( &callback_gal, aText, aPos, attributes, aFontMetrics );
|
||||
}
|
||||
@ -790,7 +790,7 @@ void PLOTTER::PlotText( const VECTOR2I& aPos,
|
||||
} );
|
||||
|
||||
if( !aFont )
|
||||
aFont = KIFONT::FONT::GetFont();
|
||||
aFont = KIFONT::FONT::GetFont( m_renderSettings->GetDefaultFont() );
|
||||
|
||||
aFont->Draw( &callback_gal, aText, aPos, attributes, aFontMetrics );
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
|
||||
{
|
||||
SCH_TEXTBOX* textboxItem = static_cast<SCH_TEXTBOX*>( child );
|
||||
|
||||
if( unresolved( textboxItem->GetShownText( &sheet, true ) ) )
|
||||
if( unresolved( textboxItem->GetShownText( nullptr, &sheet, true ) ) )
|
||||
{
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
ercItem->SetItems( symbol );
|
||||
@ -398,7 +398,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
|
||||
}
|
||||
else if( SCH_TEXTBOX* textBox = dynamic_cast<SCH_TEXTBOX*>( item ) )
|
||||
{
|
||||
if( textBox->GetShownText( &sheet, true ).Matches( wxS( "*${*}*" ) ) )
|
||||
if( textBox->GetShownText( nullptr, &sheet, true ).Matches( wxS( "*${*}*" ) ) )
|
||||
{
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
ercItem->SetItems( textBox );
|
||||
|
@ -945,8 +945,7 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
|
||||
if( value == DEFAULT_FONT_NAME )
|
||||
field.SetFont( nullptr );
|
||||
else if( value == KICAD_FONT_NAME )
|
||||
field.SetFont( KIFONT::FONT::GetFont( wxEmptyString, field.IsBold(),
|
||||
field.IsItalic() ) );
|
||||
field.SetFont( KIFONT::FONT::GetFont( wxEmptyString, field.IsBold(), field.IsItalic() ) );
|
||||
else
|
||||
field.SetFont( KIFONT::FONT::GetFont( aValue, field.IsBold(), field.IsItalic() ) );
|
||||
|
||||
|
@ -348,12 +348,12 @@ int SCH_FIELD::GetPenWidth() const
|
||||
}
|
||||
|
||||
|
||||
KIFONT::FONT* SCH_FIELD::getDrawFont() const
|
||||
KIFONT::FONT* SCH_FIELD::GetDrawFont( const RENDER_SETTINGS* aSettings ) const
|
||||
{
|
||||
KIFONT::FONT* font = EDA_TEXT::GetFont();
|
||||
|
||||
if( !font )
|
||||
font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() );
|
||||
font = KIFONT::FONT::GetFont( GetDefaultFont( aSettings ), IsBold(), IsItalic() );
|
||||
|
||||
return font;
|
||||
}
|
||||
@ -377,10 +377,7 @@ std::vector<std::unique_ptr<KIFONT::GLYPH>>*
|
||||
SCH_FIELD::GetRenderCache( const wxString& forResolvedText, const VECTOR2I& forPosition,
|
||||
TEXT_ATTRIBUTES& aAttrs ) const
|
||||
{
|
||||
KIFONT::FONT* font = GetFont();
|
||||
|
||||
if( !font )
|
||||
font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() );
|
||||
KIFONT::FONT* font = GetDrawFont( nullptr );
|
||||
|
||||
if( font->IsOutline() )
|
||||
{
|
||||
@ -692,7 +689,7 @@ EDA_ANGLE SCH_FIELD::GetDrawRotation() const
|
||||
|
||||
const BOX2I SCH_FIELD::GetBoundingBox() const
|
||||
{
|
||||
BOX2I bbox = GetTextBox();
|
||||
BOX2I bbox = GetTextBox( nullptr );
|
||||
|
||||
// Calculate the bounding box position relative to the parent:
|
||||
VECTOR2I origin = GetParentPosition();
|
||||
@ -1540,11 +1537,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS&
|
||||
color = nc->GetSchematicColor();
|
||||
}
|
||||
|
||||
KIFONT::FONT* font = GetFont();
|
||||
|
||||
if( !font )
|
||||
font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() );
|
||||
|
||||
KIFONT::FONT* font = GetDrawFont( renderSettings );
|
||||
TEXT_ATTRIBUTES attrs = GetAttributes();
|
||||
attrs.m_StrokeWidth = penWidth;
|
||||
attrs.m_Halign = hjustify;
|
||||
|
@ -195,6 +195,8 @@ public:
|
||||
*/
|
||||
EDA_ANGLE GetDrawRotation() const override;
|
||||
|
||||
KIFONT::FONT* GetDrawFont( const RENDER_SETTINGS* aSettings ) const override;
|
||||
|
||||
const BOX2I GetBoundingBox() const override;
|
||||
|
||||
/**
|
||||
@ -329,8 +331,6 @@ public:
|
||||
#endif
|
||||
|
||||
protected:
|
||||
KIFONT::FONT* getDrawFont() const override;
|
||||
|
||||
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
|
||||
|
||||
/**
|
||||
|
@ -1733,7 +1733,7 @@ const LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSymdef( const SYMDEF_ID& aSymd
|
||||
|
||||
for( size_t ii = 0; ii < strings.size(); ++ii )
|
||||
{
|
||||
BOX2I bbox = libtext->GetTextBox( ii );
|
||||
BOX2I bbox = libtext->GetTextBox( nullptr, ii );
|
||||
VECTOR2I linePos = { bbox.GetLeft(), -bbox.GetBottom() };
|
||||
|
||||
RotatePoint( linePos, libtext->GetTextPos(), -libtext->GetTextAngle() );
|
||||
|
@ -22,6 +22,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "font/kicad_font_name.h"
|
||||
#include <pgm_base.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <eeschema_settings.h>
|
||||
@ -475,12 +476,18 @@ int SCH_ITEM::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
|
||||
}
|
||||
|
||||
|
||||
const wxString& SCH_ITEM::GetDefaultFont() const
|
||||
const wxString& SCH_ITEM::GetDefaultFont( const RENDER_SETTINGS* aSettings ) const
|
||||
{
|
||||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||
EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
|
||||
static wxString defaultName = KICAD_FONT_NAME;
|
||||
|
||||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||
|
||||
if( aSettings )
|
||||
return aSettings->GetDefaultFont();
|
||||
else if( EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) )
|
||||
return cfg->m_Appearance.default_font;
|
||||
else
|
||||
return defaultName;
|
||||
}
|
||||
|
||||
|
||||
|
@ -302,7 +302,7 @@ public:
|
||||
|
||||
int GetEffectivePenWidth( const SCH_RENDER_SETTINGS* aSettings ) const;
|
||||
|
||||
const wxString& GetDefaultFont() const;
|
||||
const wxString& GetDefaultFont( const RENDER_SETTINGS* aSettings ) const;
|
||||
|
||||
const KIFONT::METRICS& GetFontMetrics() const;
|
||||
|
||||
|
@ -560,7 +560,7 @@ double SCH_LABEL_BASE::Similarity( const SCH_ITEM& aOther ) const
|
||||
void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo )
|
||||
{
|
||||
int margin = GetTextOffset() * 2;
|
||||
int labelLen = GetBodyBoundingBox().GetSizeMax();
|
||||
int labelLen = GetBodyBoundingBox( nullptr ).GetSizeMax();
|
||||
int accumulated = GetTextHeight() / 2;
|
||||
|
||||
if( Type() == SCH_GLOBAL_LABEL_T )
|
||||
@ -960,14 +960,14 @@ int SCH_LABEL_BASE::GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings ) con
|
||||
}
|
||||
|
||||
|
||||
const BOX2I SCH_LABEL_BASE::GetBodyBoundingBox() const
|
||||
const BOX2I SCH_LABEL_BASE::GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const
|
||||
{
|
||||
// build the bounding box of the label only, without taking into account its fields
|
||||
|
||||
BOX2I box;
|
||||
std::vector<VECTOR2I> pts;
|
||||
|
||||
CreateGraphicShape( nullptr, pts, GetTextPos() );
|
||||
CreateGraphicShape( aSettings, pts, GetTextPos() );
|
||||
|
||||
for( const VECTOR2I& pt : pts )
|
||||
box.Merge( pt );
|
||||
@ -982,7 +982,7 @@ const BOX2I SCH_LABEL_BASE::GetBoundingBox() const
|
||||
{
|
||||
// build the bounding box of the entire label, including its fields
|
||||
|
||||
BOX2I box = GetBodyBoundingBox();
|
||||
BOX2I box = GetBodyBoundingBox( nullptr );
|
||||
|
||||
for( const SCH_FIELD& field : m_fields )
|
||||
{
|
||||
@ -1005,7 +1005,7 @@ const BOX2I SCH_LABEL_BASE::GetBoundingBox() const
|
||||
|
||||
bool SCH_LABEL_BASE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
||||
{
|
||||
BOX2I bbox = GetBodyBoundingBox();
|
||||
BOX2I bbox = GetBodyBoundingBox( nullptr );
|
||||
bbox.Inflate( aAccuracy );
|
||||
|
||||
if( bbox.Contains( aPosition ) )
|
||||
@ -1042,7 +1042,7 @@ bool SCH_LABEL_BASE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy
|
||||
}
|
||||
else
|
||||
{
|
||||
if( rect.Intersects( GetBodyBoundingBox() ) )
|
||||
if( rect.Intersects( GetBodyBoundingBox( nullptr ) ) )
|
||||
return true;
|
||||
|
||||
for( const SCH_FIELD& field : m_fields )
|
||||
@ -1285,13 +1285,10 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_O
|
||||
penWidth = std::max( penWidth, settings->GetMinPenWidth() );
|
||||
aPlotter->SetCurrentLineWidth( penWidth );
|
||||
|
||||
KIFONT::FONT* font = GetFont();
|
||||
KIFONT::FONT* font = GetDrawFont( settings );
|
||||
|
||||
if( !font )
|
||||
font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), IsBold(), IsItalic() );
|
||||
|
||||
VECTOR2I textpos = GetTextPos() + GetSchematicTextOffset( aPlotter->RenderSettings() );
|
||||
CreateGraphicShape( aPlotter->RenderSettings(), s_poly, GetTextPos() );
|
||||
VECTOR2I textpos = GetTextPos() + GetSchematicTextOffset( settings );
|
||||
CreateGraphicShape( settings, s_poly, GetTextPos() );
|
||||
|
||||
TEXT_ATTRIBUTES attrs = GetAttributes();
|
||||
attrs.m_StrokeWidth = penWidth;
|
||||
@ -1303,8 +1300,7 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_O
|
||||
}
|
||||
else
|
||||
{
|
||||
aPlotter->PlotText( textpos, color, GetShownText( sheet, true ), attrs, font,
|
||||
GetFontMetrics() );
|
||||
aPlotter->PlotText( textpos, color, GetShownText( sheet, true ), attrs, font, GetFontMetrics() );
|
||||
|
||||
if( aPlotter->GetColorMode() )
|
||||
{
|
||||
@ -1342,6 +1338,7 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_O
|
||||
|
||||
// Make sheet pins and hierarchical labels clickable hyperlinks
|
||||
bool linkAlreadyPlotted = false;
|
||||
BOX2I bodyBBox = GetBodyBoundingBox( settings );
|
||||
|
||||
if( aPlotOpts.m_PDFHierarchicalLinks )
|
||||
{
|
||||
@ -1351,8 +1348,7 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_O
|
||||
{
|
||||
SCH_SHEET_PATH path = *sheet;
|
||||
path.pop_back();
|
||||
aPlotter->HyperlinkBox( GetBodyBoundingBox(),
|
||||
EDA_TEXT::GotoPageHref( path.GetPageNumber() ) );
|
||||
aPlotter->HyperlinkBox( bodyBBox, EDA_TEXT::GotoPageHref( path.GetPageNumber() ) );
|
||||
linkAlreadyPlotted = true;
|
||||
}
|
||||
}
|
||||
@ -1361,8 +1357,7 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_O
|
||||
SCH_SHEET_PATH path = *sheet;
|
||||
SCH_SHEET* parent = static_cast<SCH_SHEET*>( m_parent );
|
||||
path.push_back( parent );
|
||||
aPlotter->HyperlinkBox( GetBodyBoundingBox(),
|
||||
EDA_TEXT::GotoPageHref( path.GetPageNumber() ) );
|
||||
aPlotter->HyperlinkBox( bodyBBox, EDA_TEXT::GotoPageHref( path.GetPageNumber() ) );
|
||||
linkAlreadyPlotted = true;
|
||||
}
|
||||
}
|
||||
@ -1378,8 +1373,8 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_O
|
||||
_( "Net" ),
|
||||
connection->Name() ) );
|
||||
|
||||
properties.emplace_back(
|
||||
wxString::Format( wxT( "!%s = %s" ), _( "Resolved netclass" ),
|
||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||
_( "Resolved netclass" ),
|
||||
GetEffectiveNetClass()->GetHumanReadableName() ) );
|
||||
}
|
||||
|
||||
@ -1391,14 +1386,11 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_O
|
||||
}
|
||||
|
||||
if( !properties.empty() )
|
||||
aPlotter->HyperlinkMenu( GetBodyBoundingBox(), properties );
|
||||
aPlotter->HyperlinkMenu( bodyBBox, properties );
|
||||
}
|
||||
|
||||
if( Type() == SCH_HIER_LABEL_T )
|
||||
{
|
||||
aPlotter->Bookmark( GetBodyBoundingBox(), GetShownText( false ),
|
||||
_( "Hierarchical Labels" ) );
|
||||
}
|
||||
aPlotter->Bookmark( bodyBBox, GetShownText( false ), _( "Hierarchical Labels" ) );
|
||||
}
|
||||
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
@ -1498,9 +1490,9 @@ bool SCH_LABEL::Deserialize( const google::protobuf::Any &aContainer )
|
||||
}
|
||||
|
||||
|
||||
const BOX2I SCH_LABEL::GetBodyBoundingBox() const
|
||||
const BOX2I SCH_LABEL::GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const
|
||||
{
|
||||
BOX2I rect = GetTextBox();
|
||||
BOX2I rect = GetTextBox( aSettings );
|
||||
|
||||
rect.Offset( 0, -GetTextOffset() );
|
||||
rect.Inflate( GetEffectiveTextPenWidth() );
|
||||
@ -1987,7 +1979,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings
|
||||
int margin = GetLabelBoxExpansion( aRenderSettings );
|
||||
int halfSize = ( GetTextHeight() / 2 ) + margin;
|
||||
int linewidth = GetPenWidth();
|
||||
int symb_len = GetTextBox().GetWidth() + 2 * margin;
|
||||
int symb_len = GetTextBox( aRenderSettings ).GetWidth() + 2 * margin;
|
||||
|
||||
int x = symb_len + linewidth + 3;
|
||||
int y = halfSize + linewidth + 3;
|
||||
@ -2122,7 +2114,7 @@ void SCH_HIERLABEL::CreateGraphicShape( const RENDER_SETTINGS* aSettings,
|
||||
}
|
||||
|
||||
|
||||
const BOX2I SCH_HIERLABEL::GetBodyBoundingBox() const
|
||||
const BOX2I SCH_HIERLABEL::GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const
|
||||
{
|
||||
int penWidth = GetEffectiveTextPenWidth();
|
||||
int margin = GetTextOffset();
|
||||
@ -2131,7 +2123,7 @@ const BOX2I SCH_HIERLABEL::GetBodyBoundingBox() const
|
||||
int y = GetTextPos().y;
|
||||
|
||||
int height = GetTextHeight() + penWidth + margin;
|
||||
int length = GetTextBox().GetWidth();
|
||||
int length = GetTextBox( aSettings ).GetWidth();
|
||||
|
||||
length += height; // add height for triangular shapes
|
||||
|
||||
|
@ -316,7 +316,7 @@ public:
|
||||
/**
|
||||
* Return the bounding box of the label only, without taking in account its fields.
|
||||
*/
|
||||
virtual const BOX2I GetBodyBoundingBox() const;
|
||||
virtual const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const;
|
||||
|
||||
/**
|
||||
* Return the bounding box of the label including its fields.
|
||||
@ -412,7 +412,7 @@ public:
|
||||
return wxT( "SCH_LABEL" );
|
||||
}
|
||||
|
||||
const BOX2I GetBodyBoundingBox() const override;
|
||||
const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
|
||||
|
||||
bool IsConnectable() const override { return true; }
|
||||
|
||||
@ -612,7 +612,7 @@ public:
|
||||
void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
|
||||
const VECTOR2I& aPos, LABEL_FLAG_SHAPE aShape ) const;
|
||||
|
||||
const BOX2I GetBodyBoundingBox() const override;
|
||||
const BOX2I GetBodyBoundingBox( const RENDER_SETTINGS* aSettings ) const override;
|
||||
|
||||
bool IsConnectable() const override { return true; }
|
||||
|
||||
|
@ -272,11 +272,10 @@ bool SCH_PAINTER::isUnitAndConversionShown( const SCH_ITEM* aItem ) const
|
||||
|
||||
KIFONT::FONT* SCH_PAINTER::getFont( const EDA_TEXT* aItem ) const
|
||||
{
|
||||
if( KIFONT::FONT* font = aItem->GetFont() )
|
||||
if( KIFONT::FONT* font = aItem->GetDrawFont( &m_schSettings ) )
|
||||
return font;
|
||||
|
||||
return KIFONT::FONT::GetFont( m_schSettings.GetDefaultFont(), aItem->IsBold(),
|
||||
aItem->IsItalic() );
|
||||
return KIFONT::FONT::GetFont( m_schSettings.GetDefaultFont(), aItem->IsBold(), aItem->IsItalic() );
|
||||
}
|
||||
|
||||
|
||||
@ -1084,7 +1083,8 @@ void SCH_PAINTER::draw( const SCH_PIN* aPin, int aLayer, bool aDimmed )
|
||||
m_schSettings.m_ShowPinsElectricalType,
|
||||
m_schSettings.m_ShowPinAltIcons );
|
||||
|
||||
const auto textRendersAsBitmap = [&]( KIGFX::GAL& aGal, int aTextSize )
|
||||
const auto textRendersAsBitmap =
|
||||
[&]( KIGFX::GAL& aGal, int aTextSize )
|
||||
{
|
||||
// Rendering text is expensive (particularly when using outline fonts). At small effective
|
||||
// sizes (ie: zoomed out) the visual differences between outline and/or stroke fonts and the
|
||||
@ -1142,7 +1142,8 @@ void SCH_PAINTER::draw( const SCH_PIN* aPin, int aLayer, bool aDimmed )
|
||||
}
|
||||
};
|
||||
|
||||
const auto getColorForLayer = [&]( int aDrawnLayer )
|
||||
const auto getColorForLayer =
|
||||
[&]( int aDrawnLayer )
|
||||
{
|
||||
if( !aPin->IsVisible() )
|
||||
return getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed );
|
||||
@ -1775,7 +1776,7 @@ void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer, bool aDimmed )
|
||||
// SCH_FIELD text.
|
||||
if( font->IsOutline() && aText->Type() == SCH_TEXT_T )
|
||||
{
|
||||
BOX2I firstLineBBox = aText->GetTextBox( 0 );
|
||||
BOX2I firstLineBBox = aText->GetTextBox( nullptr, 0 );
|
||||
int sizeDiff = firstLineBBox.GetHeight() - aText->GetTextSize().y;
|
||||
int adjust = KiROUND( sizeDiff * 0.4 );
|
||||
VECTOR2I adjust_offset( 0, - adjust );
|
||||
|
@ -82,7 +82,7 @@ void SCH_TEXT::NormalizeJustification( bool inverse )
|
||||
return;
|
||||
|
||||
VECTOR2I delta( 0, 0 );
|
||||
BOX2I bbox = GetTextBox();
|
||||
BOX2I bbox = GetTextBox( nullptr );
|
||||
|
||||
if( GetTextAngle().IsHorizontal() )
|
||||
{
|
||||
@ -285,12 +285,12 @@ int SCH_TEXT::GetPenWidth() const
|
||||
}
|
||||
|
||||
|
||||
KIFONT::FONT* SCH_TEXT::getDrawFont() const
|
||||
KIFONT::FONT* SCH_TEXT::GetDrawFont( const RENDER_SETTINGS* aSettings ) const
|
||||
{
|
||||
KIFONT::FONT* font = EDA_TEXT::GetFont();
|
||||
|
||||
if( !font )
|
||||
font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() );
|
||||
font = KIFONT::FONT::GetFont( GetDefaultFont( aSettings ), IsBold(), IsItalic() );
|
||||
|
||||
return font;
|
||||
}
|
||||
@ -384,7 +384,7 @@ void SCH_TEXT::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBody
|
||||
|
||||
const BOX2I SCH_TEXT::GetBoundingBox() const
|
||||
{
|
||||
BOX2I bbox = GetTextBox();
|
||||
BOX2I bbox = GetTextBox( nullptr );
|
||||
|
||||
if( !GetTextAngle().IsZero() ) // Rotate bbox.
|
||||
{
|
||||
@ -556,11 +556,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& a
|
||||
penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
|
||||
aPlotter->SetCurrentLineWidth( penWidth );
|
||||
|
||||
KIFONT::FONT* font = GetFont();
|
||||
|
||||
if( !font )
|
||||
font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() );
|
||||
|
||||
KIFONT::FONT* font = GetDrawFont( renderSettings );
|
||||
TEXT_ATTRIBUTES attrs = GetAttributes();
|
||||
attrs.m_StrokeWidth = penWidth;
|
||||
|
||||
@ -602,7 +598,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& a
|
||||
// SCH_FIELD text.
|
||||
if( font->IsOutline() )
|
||||
{
|
||||
BOX2I firstLineBBox = GetTextBox( 0 );
|
||||
BOX2I firstLineBBox = GetTextBox( renderSettings, 0 );
|
||||
int sizeDiff = firstLineBBox.GetHeight() - GetTextSize().y;
|
||||
int adjust = KiROUND( sizeDiff * 0.4 );
|
||||
VECTOR2I adjust_offset( 0, - adjust );
|
||||
@ -616,7 +612,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& a
|
||||
wxStringSplit( GetShownText( sheet, true ), strings_list, '\n' );
|
||||
positions.reserve( strings_list.Count() );
|
||||
|
||||
GetLinePositions( positions, (int) strings_list.Count() );
|
||||
GetLinePositions( renderSettings, positions, (int) strings_list.Count() );
|
||||
|
||||
attrs.m_Multiline = false;
|
||||
|
||||
|
@ -59,6 +59,8 @@ public:
|
||||
return _( "Text" );
|
||||
}
|
||||
|
||||
KIFONT::FONT* GetDrawFont( const RENDER_SETTINGS* aSettings ) const override;
|
||||
|
||||
virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
|
||||
int aDepth = 0 ) const;
|
||||
|
||||
@ -174,8 +176,6 @@ public:
|
||||
static HTML_MESSAGE_BOX* ShowSyntaxHelp( wxWindow* aParentWindow );
|
||||
|
||||
protected:
|
||||
KIFONT::FONT* getDrawFont() const override;
|
||||
|
||||
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
|
||||
|
||||
/**
|
||||
|
@ -258,12 +258,12 @@ bool SCH_TEXTBOX::operator<( const SCH_ITEM& aItem ) const
|
||||
}
|
||||
|
||||
|
||||
KIFONT::FONT* SCH_TEXTBOX::getDrawFont() const
|
||||
KIFONT::FONT* SCH_TEXTBOX::GetDrawFont( const RENDER_SETTINGS* aSettings ) const
|
||||
{
|
||||
KIFONT::FONT* font = EDA_TEXT::GetFont();
|
||||
|
||||
if( !font )
|
||||
font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() );
|
||||
font = KIFONT::FONT::GetFont( GetDefaultFont( aSettings ), IsBold(), IsItalic() );
|
||||
|
||||
return font;
|
||||
}
|
||||
@ -345,8 +345,8 @@ void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aB
|
||||
}
|
||||
|
||||
|
||||
wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
|
||||
int aDepth ) const
|
||||
wxString SCH_TEXTBOX::GetShownText( const RENDER_SETTINGS* aSettings, const SCH_SHEET_PATH* aPath,
|
||||
bool aAllowExtraText, int aDepth ) const
|
||||
{
|
||||
SCH_SHEET* sheet = nullptr;
|
||||
|
||||
@ -381,8 +381,8 @@ wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtr
|
||||
else
|
||||
colWidth = abs( size.x ) - ( GetMarginLeft() + GetMarginRight() );
|
||||
|
||||
getDrawFont()->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(),
|
||||
IsItalic() );
|
||||
GetDrawFont( aSettings )->LinebreakText( text, colWidth, GetTextSize(), GetEffectiveTextPenWidth(),
|
||||
IsBold(), IsItalic() );
|
||||
|
||||
return text;
|
||||
}
|
||||
@ -463,7 +463,7 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS
|
||||
COLOR4D color = GetStroke().GetColor();
|
||||
COLOR4D bg = renderSettings->GetBackgroundColor();
|
||||
|
||||
KIFONT::FONT* font = getDrawFont();
|
||||
KIFONT::FONT* font = GetDrawFont( renderSettings );
|
||||
|
||||
color = GetTextColor();
|
||||
|
||||
@ -487,7 +487,7 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS
|
||||
std::vector<VECTOR2I> positions;
|
||||
wxArrayString strings_list;
|
||||
|
||||
wxStringSplit( GetShownText( sheet, true ), strings_list, '\n' );
|
||||
wxStringSplit( GetShownText( renderSettings, sheet, true ), strings_list, '\n' );
|
||||
positions.reserve( strings_list.Count() );
|
||||
|
||||
if( renderSettings->m_Transform != TRANSFORM() || aOffset != VECTOR2I() )
|
||||
@ -504,12 +504,12 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS
|
||||
temp.SetEnd( renderSettings->TransformCoordinate( m_end ) + aOffset );
|
||||
|
||||
attrs = temp.GetAttributes();
|
||||
temp.GetLinePositions( positions, (int) strings_list.Count() );
|
||||
temp.GetLinePositions( renderSettings, positions, (int) strings_list.Count() );
|
||||
}
|
||||
else
|
||||
{
|
||||
attrs = GetAttributes();
|
||||
GetLinePositions( positions, (int) strings_list.Count() );
|
||||
GetLinePositions( renderSettings, positions, (int) strings_list.Count() );
|
||||
}
|
||||
|
||||
attrs.m_StrokeWidth = penWidth;
|
||||
|
@ -70,8 +70,10 @@ public:
|
||||
|
||||
VECTOR2I GetDrawPos() const override;
|
||||
|
||||
virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
|
||||
int aDepth = 0 ) const;
|
||||
KIFONT::FONT* GetDrawFont( const RENDER_SETTINGS* aSettings ) const override;
|
||||
|
||||
virtual wxString GetShownText( const RENDER_SETTINGS* aSettings, const SCH_SHEET_PATH* aPath,
|
||||
bool aAllowExtraText, int aDepth = 0 ) const;
|
||||
|
||||
wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
|
||||
{
|
||||
@ -80,7 +82,7 @@ public:
|
||||
if( SCHEMATIC* schematic = Schematic() )
|
||||
sheetPath = &schematic->CurrentSheet();
|
||||
|
||||
return GetShownText( sheetPath, aAllowExtraText, aDepth );
|
||||
return GetShownText( nullptr, sheetPath, aAllowExtraText, aDepth );
|
||||
}
|
||||
|
||||
bool IsHypertext() const override;
|
||||
@ -143,8 +145,6 @@ public:
|
||||
bool operator==( const SCH_ITEM& aOther ) const override;
|
||||
|
||||
protected:
|
||||
KIFONT::FONT* getDrawFont() const override;
|
||||
|
||||
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
|
||||
|
||||
int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
|
@ -318,7 +318,7 @@ public:
|
||||
* this rectangle is calculated for 0 orient text.
|
||||
* If orientation is not 0 the rect must be rotated to match the physical area
|
||||
*/
|
||||
BOX2I GetTextBox( int aLine = -1 ) const;
|
||||
BOX2I GetTextBox( const RENDER_SETTINGS* aSettings, int aLine = -1 ) const;
|
||||
|
||||
/**
|
||||
* Return the distance between two lines of text.
|
||||
@ -327,7 +327,7 @@ public:
|
||||
* interline distance plus room for characters like j, {, and [. It also used for single
|
||||
* line text, to calculate the text bounding box.
|
||||
*/
|
||||
int GetInterline() const;
|
||||
int GetInterline( const RENDER_SETTINGS* aSettings ) const;
|
||||
|
||||
/**
|
||||
* @return a wxString with the style name( Normal, Italic, Bold, Bold+Italic).
|
||||
@ -341,7 +341,8 @@ public:
|
||||
* @param aPositions is the list to populate by the VECTOR2I positions.
|
||||
* @param aLineCount is the number of lines (not recalculated here for efficiency reasons.
|
||||
*/
|
||||
void GetLinePositions( std::vector<VECTOR2I>& aPositions, int aLineCount ) const;
|
||||
void GetLinePositions( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPositions,
|
||||
int aLineCount ) const;
|
||||
|
||||
/**
|
||||
* Return the levenstein distance between two texts.
|
||||
@ -365,6 +366,8 @@ public:
|
||||
virtual EDA_ANGLE GetDrawRotation() const { return GetTextAngle(); }
|
||||
virtual VECTOR2I GetDrawPos() const { return GetTextPos(); }
|
||||
|
||||
virtual KIFONT::FONT* GetDrawFont( const RENDER_SETTINGS* aSettings ) const;
|
||||
|
||||
virtual void ClearRenderCache();
|
||||
virtual void ClearBoundingBoxCache();
|
||||
|
||||
@ -415,8 +418,6 @@ public:
|
||||
static wxString GotoPageHref( const wxString& aDestination );
|
||||
|
||||
protected:
|
||||
virtual KIFONT::FONT* getDrawFont() const;
|
||||
|
||||
virtual const KIFONT::METRICS& getFontMetrics() const;
|
||||
|
||||
virtual void cacheShownText();
|
||||
|
@ -144,10 +144,7 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run()
|
||||
if( constraint.GetSeverity() == RPT_SEVERITY_IGNORE )
|
||||
return true;
|
||||
|
||||
KIFONT::FONT* font = text->GetFont();
|
||||
|
||||
if( !font )
|
||||
font = KIFONT::FONT::GetFont( wxEmptyString, text->IsBold(), text->IsItalic() );
|
||||
KIFONT::FONT* font = text->GetDrawFont( nullptr );
|
||||
|
||||
if( font->IsOutline() )
|
||||
{
|
||||
|
@ -805,7 +805,7 @@ void GENCAD_EXPORTER::createComponentsSection()
|
||||
layer.c_str(),
|
||||
TO_UTF8( escapeString( textItem->GetText() ) ) );
|
||||
|
||||
BOX2I textBox = textItem->GetTextBox();
|
||||
BOX2I textBox = textItem->GetTextBox( nullptr );
|
||||
|
||||
fprintf( m_file, " 0 0 %g %g\n",
|
||||
textBox.GetWidth() / SCALE_FACTOR,
|
||||
|
@ -730,7 +730,7 @@ const BOX2I PCB_DIMENSION_BASE::GetBoundingBox() const
|
||||
BOX2I bBox;
|
||||
int xmin, xmax, ymin, ymax;
|
||||
|
||||
bBox = GetTextBox();
|
||||
bBox = GetTextBox( nullptr );
|
||||
xmin = bBox.GetX();
|
||||
xmax = bBox.GetRight();
|
||||
ymin = bBox.GetY();
|
||||
@ -947,7 +947,7 @@ void PCB_DIM_ALIGNED::updateGeometry()
|
||||
|
||||
// Now that we have the text updated, we can determine how to draw the crossbar.
|
||||
// First we need to create an appropriate bounding polygon to collide with
|
||||
BOX2I textBox = GetTextBox().Inflate( GetTextWidth() / 2, - GetEffectiveTextPenWidth() );
|
||||
BOX2I textBox = GetTextBox( nullptr ).Inflate( GetTextWidth() / 2, - GetEffectiveTextPenWidth() );
|
||||
|
||||
SHAPE_POLY_SET polyBox;
|
||||
polyBox.NewOutline();
|
||||
@ -1183,7 +1183,7 @@ void PCB_DIM_ORTHOGONAL::updateGeometry()
|
||||
|
||||
// Now that we have the text updated, we can determine how to draw the crossbar.
|
||||
// First we need to create an appropriate bounding polygon to collide with
|
||||
BOX2I textBox = GetTextBox().Inflate( GetTextWidth() / 2, GetEffectiveTextPenWidth() );
|
||||
BOX2I textBox = GetTextBox( nullptr ).Inflate( GetTextWidth() / 2, GetEffectiveTextPenWidth() );
|
||||
|
||||
SHAPE_POLY_SET polyBox;
|
||||
polyBox.NewOutline();
|
||||
@ -1400,7 +1400,7 @@ void PCB_DIM_LEADER::updateGeometry()
|
||||
|
||||
// Now that we have the text updated, we can determine how to draw the second line
|
||||
// First we need to create an appropriate bounding polygon to collide with
|
||||
BOX2I textBox = GetTextBox().Inflate( GetTextWidth() / 2, GetEffectiveTextPenWidth() * 2 );
|
||||
BOX2I textBox = GetTextBox( nullptr ).Inflate( GetTextWidth() / 2, GetEffectiveTextPenWidth() * 2 );
|
||||
|
||||
SHAPE_POLY_SET polyBox;
|
||||
polyBox.NewOutline();
|
||||
@ -1623,7 +1623,7 @@ void PCB_DIM_RADIAL::updateGeometry()
|
||||
|
||||
// Now that we have the text updated, we can determine how to draw the second line
|
||||
// First we need to create an appropriate bounding polygon to collide with
|
||||
BOX2I textBox = GetTextBox().Inflate( GetTextWidth() / 2, GetEffectiveTextPenWidth() );
|
||||
BOX2I textBox = GetTextBox( nullptr ).Inflate( GetTextWidth() / 2, GetEffectiveTextPenWidth() );
|
||||
|
||||
SHAPE_POLY_SET polyBox;
|
||||
polyBox.NewOutline();
|
||||
|
@ -1734,7 +1734,7 @@ void ALTIUM_PCB::HelperParseDimensions6Radial(const ADIMENSION6 &aElem)
|
||||
dimension->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
|
||||
dimension->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
|
||||
int yAdjust = dimension->GetTextBox().GetCenter().y - dimension->GetTextPos().y;
|
||||
int yAdjust = dimension->GetTextBox( nullptr ).GetCenter().y - dimension->GetTextPos().y;
|
||||
dimension->SetTextPos( dimension->GetTextPos() + VECTOR2I( 0, yAdjust + aElem.textgap ) );
|
||||
dimension->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
|
||||
|
||||
|
@ -617,7 +617,7 @@ void PCB_IO_IPC2581::addText( wxXmlNode* aContentNode, EDA_TEXT* aText,
|
||||
const KIFONT::METRICS& aFontMetrics )
|
||||
{
|
||||
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
|
||||
KIFONT::FONT* font = aText->GetFont();
|
||||
KIFONT::FONT* font = aText->GetDrawFont( nullptr );
|
||||
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
|
||||
|
||||
attrs.m_StrokeWidth = aText->GetEffectiveTextPenWidth();
|
||||
@ -626,9 +626,6 @@ void PCB_IO_IPC2581::addText( wxXmlNode* aContentNode, EDA_TEXT* aText,
|
||||
|
||||
wxXmlNode* text_node = appendNode( aContentNode, "UserSpecial" );
|
||||
|
||||
if( !font )
|
||||
font = KIFONT::FONT::GetFont();
|
||||
|
||||
std::list<VECTOR2I> pts;
|
||||
|
||||
auto push_pts =
|
||||
|
@ -617,17 +617,7 @@ void FEATURES_MANAGER::InitFeatureList( PCB_LAYER_ID aLayer, std::vector<BOARD_I
|
||||
isKnockout = static_cast<PCB_TEXTBOX*>( item )->IsKnockout();
|
||||
|
||||
const KIFONT::METRICS& fontMetrics = item->GetFontMetrics();
|
||||
|
||||
KIFONT::FONT* font = text_item->GetFont();
|
||||
|
||||
if( !font )
|
||||
{
|
||||
wxString defaultFontName; // empty string is the KiCad stroke font
|
||||
|
||||
font = KIFONT::FONT::GetFont( defaultFontName, text_item->IsBold(),
|
||||
text_item->IsItalic() );
|
||||
}
|
||||
|
||||
KIFONT::FONT* font = text_item->GetDrawFont( nullptr );
|
||||
wxString shownText( text_item->GetShownText( true ) );
|
||||
|
||||
if( shownText.IsEmpty() )
|
||||
@ -667,7 +657,7 @@ void FEATURES_MANAGER::InitFeatureList( PCB_LAYER_ID aLayer, std::vector<BOARD_I
|
||||
wxStringSplit( shownText, strings_list, '\n' );
|
||||
positions.reserve( strings_list.Count() );
|
||||
|
||||
text_item->GetLinePositions( positions, strings_list.Count() );
|
||||
text_item->GetLinePositions( nullptr, positions, strings_list.Count() );
|
||||
|
||||
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
|
||||
{
|
||||
|
@ -2248,13 +2248,7 @@ void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
|
||||
const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
|
||||
bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayTextFill;
|
||||
|
||||
KIFONT::FONT* font = aText->GetFont();
|
||||
|
||||
if( !font )
|
||||
{
|
||||
font = KIFONT::FONT::GetFont( m_pcbSettings.GetDefaultFont(), aText->IsBold(),
|
||||
aText->IsItalic() );
|
||||
}
|
||||
KIFONT::FONT* font = aText->GetDrawFont( &m_pcbSettings );
|
||||
|
||||
m_gal->SetStrokeColor( color );
|
||||
m_gal->SetFillColor( color );
|
||||
@ -2283,7 +2277,7 @@ void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
|
||||
// So we need to recalculate the text position to keep it at the same position
|
||||
// on the canvas
|
||||
VECTOR2I textPos = aText->GetTextPos();
|
||||
VECTOR2I textWidth = VECTOR2I( aText->GetTextBox().GetWidth(), 0 );
|
||||
VECTOR2I textWidth = VECTOR2I( aText->GetTextBox( &m_pcbSettings ).GetWidth(), 0 );
|
||||
|
||||
if( aText->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
|
||||
textWidth.x = -textWidth.x;
|
||||
@ -2344,14 +2338,7 @@ void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
|
||||
int thickness = getLineThickness( aTextBox->GetWidth() );
|
||||
LINE_STYLE lineStyle = aTextBox->GetStroke().GetLineStyle();
|
||||
wxString resolvedText( aTextBox->GetShownText( true ) );
|
||||
|
||||
KIFONT::FONT* font = aTextBox->GetFont();
|
||||
|
||||
if( !font )
|
||||
{
|
||||
font = KIFONT::FONT::GetFont( m_pcbSettings.GetDefaultFont(), aTextBox->IsBold(),
|
||||
aTextBox->IsItalic() );
|
||||
}
|
||||
KIFONT::FONT* font = aTextBox->GetDrawFont( &m_pcbSettings );
|
||||
|
||||
if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // happens only if locked
|
||||
{
|
||||
|
@ -342,7 +342,7 @@ void PCB_TEXT::KeepUpright()
|
||||
const BOX2I PCB_TEXT::GetBoundingBox() const
|
||||
{
|
||||
EDA_ANGLE angle = GetDrawRotation();
|
||||
BOX2I rect = GetTextBox();
|
||||
BOX2I rect = GetTextBox( nullptr );
|
||||
|
||||
if( IsKnockout() )
|
||||
rect.Inflate( getKnockoutMargin() );
|
||||
@ -551,7 +551,7 @@ void PCB_TEXT::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, int aClearance,
|
||||
ERROR_LOC aErrorLoc ) const
|
||||
{
|
||||
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
|
||||
KIFONT::FONT* font = getDrawFont();
|
||||
KIFONT::FONT* font = GetDrawFont( nullptr );
|
||||
int penWidth = GetEffectiveTextPenWidth();
|
||||
TEXT_ATTRIBUTES attrs = GetAttributes();
|
||||
wxString shownText = GetShownText( true );
|
||||
|
@ -443,7 +443,7 @@ wxString PCB_TEXTBOX::GetShownText( bool aAllowExtraText, int aDepth ) const
|
||||
text = ExpandTextVars( text, &resolver );
|
||||
}
|
||||
|
||||
KIFONT::FONT* font = getDrawFont();
|
||||
KIFONT::FONT* font = GetDrawFont( nullptr );
|
||||
EDA_ANGLE drawAngle = GetDrawRotation();
|
||||
std::vector<VECTOR2I> corners = GetCornersInSequence( drawAngle );
|
||||
int colWidth = ( corners[1] - corners[0] ).EuclideanNorm();
|
||||
@ -621,7 +621,7 @@ void PCB_TEXTBOX::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, int aClearanc
|
||||
ERROR_LOC aErrorLoc ) const
|
||||
{
|
||||
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
|
||||
KIFONT::FONT* font = getDrawFont();
|
||||
KIFONT::FONT* font = GetDrawFont( nullptr );
|
||||
int penWidth = GetEffectiveTextPenWidth();
|
||||
|
||||
// Note: this function is mainly used in 3D viewer.
|
||||
|
@ -691,18 +691,7 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
|
||||
void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout,
|
||||
const KIFONT::METRICS& aFontMetrics, bool aStrikeout )
|
||||
{
|
||||
KIFONT::FONT* font = aText->GetFont();
|
||||
|
||||
if( !font )
|
||||
{
|
||||
wxString defaultFontName; // empty string is the KiCad stroke font
|
||||
|
||||
if( m_plotter->RenderSettings() )
|
||||
defaultFontName = m_plotter->RenderSettings()->GetDefaultFont();
|
||||
|
||||
font = KIFONT::FONT::GetFont( defaultFontName, aText->IsBold(), aText->IsItalic() );
|
||||
}
|
||||
|
||||
KIFONT::FONT* font = aText->GetDrawFont( m_plotter->RenderSettings() );
|
||||
wxString shownText( aText->GetShownText( true ) );
|
||||
|
||||
if( shownText.IsEmpty() )
|
||||
@ -787,7 +776,7 @@ void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, boo
|
||||
wxStringSplit( shownText, strings_list, '\n' );
|
||||
positions.reserve( strings_list.Count() );
|
||||
|
||||
aText->GetLinePositions( positions, (int) strings_list.Count() );
|
||||
aText->GetLinePositions( m_plotter->RenderSettings(), positions, (int) strings_list.Count() );
|
||||
|
||||
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user