mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-13 17:53:11 +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
This commit is contained in:
parent
0495828a55
commit
e230d5164d
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -638,12 +638,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 )
|
||||
font = KIFONT::FONT::GetFont( wxEmptyString, IsBold(), IsItalic() );
|
||||
{
|
||||
if( aSettings )
|
||||
font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
|
||||
else
|
||||
font = KIFONT::FONT::GetFont( wxEmptyString, IsBold(), IsItalic() );
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
@ -721,13 +726,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();
|
||||
|
||||
@ -755,12 +760,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
|
||||
@ -786,15 +790,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;
|
||||
@ -859,7 +861,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 );
|
||||
}
|
||||
@ -870,9 +872,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() );
|
||||
}
|
||||
|
||||
|
||||
@ -886,7 +888,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, strings[ii], positions[ii] );
|
||||
@ -898,14 +900,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 )
|
||||
{
|
||||
@ -953,10 +956,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() );
|
||||
@ -1124,7 +1124,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();
|
||||
|
@ -2784,7 +2784,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
|
||||
|
@ -1729,9 +1729,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 ) );
|
||||
|
@ -135,15 +135,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();
|
||||
|
||||
|
@ -621,7 +621,7 @@ void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill, int a
|
||||
}
|
||||
|
||||
|
||||
void PLOTTER::Text( const VECTOR2I& aPos,
|
||||
void PLOTTER::Text( const VECTOR2I& aPos,
|
||||
const COLOR4D& aColor,
|
||||
const wxString& aText,
|
||||
const EDA_ANGLE& aOrient,
|
||||
@ -678,7 +678,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 );
|
||||
}
|
||||
@ -723,7 +723,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 );
|
||||
@ -399,7 +399,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 );
|
||||
|
@ -933,8 +933,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() ) );
|
||||
|
||||
|
@ -319,12 +319,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;
|
||||
}
|
||||
@ -348,10 +348,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() )
|
||||
{
|
||||
@ -491,7 +488,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();
|
||||
@ -1286,11 +1283,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;
|
||||
|
@ -181,6 +181,8 @@ public:
|
||||
*/
|
||||
EDA_ANGLE GetDrawRotation() const override;
|
||||
|
||||
KIFONT::FONT* GetDrawFont( const RENDER_SETTINGS* aSettings ) const override;
|
||||
|
||||
const BOX2I GetBoundingBox() const override;
|
||||
|
||||
/**
|
||||
@ -303,8 +305,6 @@ public:
|
||||
protected:
|
||||
friend class SCH_IO_KICAD_SEXPR_PARSER;
|
||||
|
||||
KIFONT::FONT* getDrawFont() const override;
|
||||
|
||||
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
|
||||
|
||||
/**
|
||||
|
@ -1722,7 +1722,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() );
|
||||
|
@ -568,13 +568,16 @@ 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
|
||||
{
|
||||
static wxString defaultName = KICAD_FONT_NAME;
|
||||
|
||||
EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
|
||||
|
||||
return cfg ? cfg->m_Appearance.default_font : defaultName;
|
||||
if( aSettings )
|
||||
return aSettings->GetDefaultFont();
|
||||
else if( EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) )
|
||||
return cfg->m_Appearance.default_font;
|
||||
else
|
||||
return defaultName;
|
||||
}
|
||||
|
||||
|
||||
|
@ -321,7 +321,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;
|
||||
|
||||
|
@ -567,7 +567,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 )
|
||||
@ -1018,14 +1018,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 );
|
||||
@ -1040,7 +1040,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 )
|
||||
{
|
||||
@ -1063,7 +1063,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 ) )
|
||||
@ -1100,7 +1100,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 )
|
||||
@ -1343,13 +1343,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;
|
||||
@ -1361,8 +1358,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() )
|
||||
{
|
||||
@ -1399,7 +1395,8 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_O
|
||||
}
|
||||
|
||||
// Make sheet pins and hierarchical labels clickable hyperlinks
|
||||
bool linkAlreadyPlotted = false;
|
||||
bool linkAlreadyPlotted = false;
|
||||
BOX2I bodyBBox = GetBodyBoundingBox( settings );
|
||||
|
||||
if( aPlotOpts.m_PDFHierarchicalLinks )
|
||||
{
|
||||
@ -1409,8 +1406,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;
|
||||
}
|
||||
}
|
||||
@ -1419,8 +1415,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;
|
||||
}
|
||||
}
|
||||
@ -1436,9 +1431,9 @@ 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" ),
|
||||
GetEffectiveNetClass()->GetHumanReadableName() ) );
|
||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||
_( "Resolved netclass" ),
|
||||
GetEffectiveNetClass()->GetHumanReadableName() ) );
|
||||
}
|
||||
|
||||
for( const SCH_FIELD& field : GetFields() )
|
||||
@ -1449,14 +1444,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 )
|
||||
@ -1510,9 +1502,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() );
|
||||
@ -2027,7 +2019,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;
|
||||
@ -2162,7 +2154,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();
|
||||
@ -2171,7 +2163,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
|
||||
|
||||
|
@ -308,7 +308,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.
|
||||
@ -400,7 +400,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; }
|
||||
|
||||
@ -609,7 +609,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; }
|
||||
|
||||
|
@ -276,11 +276,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() );
|
||||
}
|
||||
|
||||
|
||||
@ -1168,71 +1167,73 @@ 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 )
|
||||
{
|
||||
// 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
|
||||
// bitmap font becomes immaterial, and there's often more to draw when zoomed out so the
|
||||
// performance gain becomes more significant.
|
||||
static const float BITMAP_FONT_SIZE_THRESHOLD = 3.5;
|
||||
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
|
||||
// bitmap font becomes immaterial, and there's often more to draw when zoomed out so the
|
||||
// performance gain becomes more significant.
|
||||
static const float BITMAP_FONT_SIZE_THRESHOLD = 3.5;
|
||||
|
||||
// Any text non bitmappable?
|
||||
return aTextSize * aGal.GetWorldScale() < BITMAP_FONT_SIZE_THRESHOLD;
|
||||
};
|
||||
// Any text non bitmappable?
|
||||
return aTextSize * aGal.GetWorldScale() < BITMAP_FONT_SIZE_THRESHOLD;
|
||||
};
|
||||
|
||||
const auto drawTextInfo =
|
||||
[&]( const PIN_LAYOUT_CACHE::TEXT_INFO& aTextInfo, const COLOR4D& aColor )
|
||||
{
|
||||
// const double iconSize = std::min( aPin->GetNameTextSize(), schIUScale.mmToIU( 1.5 ) );
|
||||
const bool renderTextAsBitmap = textRendersAsBitmap( *m_gal, aTextInfo.m_TextSize );
|
||||
|
||||
// Which of these gets used depends on the font technology, so set both
|
||||
m_gal->SetStrokeColor( aColor );
|
||||
m_gal->SetFillColor( aColor );
|
||||
|
||||
TEXT_ATTRIBUTES attrs;
|
||||
attrs.m_Font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font );
|
||||
attrs.m_Size = VECTOR2I( aTextInfo.m_TextSize, aTextInfo.m_TextSize );
|
||||
attrs.m_Halign = aTextInfo.m_HAlign;
|
||||
attrs.m_Valign = aTextInfo.m_VAlign;
|
||||
attrs.m_Angle = aTextInfo.m_Angle;
|
||||
attrs.m_StrokeWidth = aTextInfo.m_Thickness;
|
||||
|
||||
if( drawingShadows )
|
||||
{
|
||||
attrs.m_StrokeWidth += KiROUND( shadowWidth );
|
||||
|
||||
if( !attrs.m_Font->IsOutline() )
|
||||
{
|
||||
strokeText( *m_gal, aTextInfo.m_Text, aTextInfo.m_TextPosition, attrs,
|
||||
aPin->GetFontMetrics() );
|
||||
}
|
||||
else
|
||||
// const double iconSize = std::min( aPin->GetNameTextSize(), schIUScale.mmToIU( 1.5 ) );
|
||||
const bool renderTextAsBitmap = textRendersAsBitmap( *m_gal, aTextInfo.m_TextSize );
|
||||
|
||||
// Which of these gets used depends on the font technology, so set both
|
||||
m_gal->SetStrokeColor( aColor );
|
||||
m_gal->SetFillColor( aColor );
|
||||
|
||||
TEXT_ATTRIBUTES attrs;
|
||||
attrs.m_Font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font );
|
||||
attrs.m_Size = VECTOR2I( aTextInfo.m_TextSize, aTextInfo.m_TextSize );
|
||||
attrs.m_Halign = aTextInfo.m_HAlign;
|
||||
attrs.m_Valign = aTextInfo.m_VAlign;
|
||||
attrs.m_Angle = aTextInfo.m_Angle;
|
||||
attrs.m_StrokeWidth = aTextInfo.m_Thickness;
|
||||
|
||||
if( drawingShadows )
|
||||
{
|
||||
attrs.m_StrokeWidth += KiROUND( shadowWidth );
|
||||
|
||||
if( !attrs.m_Font->IsOutline() )
|
||||
{
|
||||
strokeText( *m_gal, aTextInfo.m_Text, aTextInfo.m_TextPosition, attrs,
|
||||
aPin->GetFontMetrics() );
|
||||
}
|
||||
else
|
||||
{
|
||||
boxText( *m_gal, aTextInfo.m_Text, aTextInfo.m_TextPosition, attrs,
|
||||
aPin->GetFontMetrics() );
|
||||
}
|
||||
}
|
||||
else if( nonCached( aPin ) && renderTextAsBitmap )
|
||||
{
|
||||
bitmapText( *m_gal, aTextInfo.m_Text, aTextInfo.m_TextPosition, attrs );
|
||||
const_cast<SCH_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP );
|
||||
}
|
||||
else
|
||||
{
|
||||
strokeText( *m_gal, aTextInfo.m_Text, aTextInfo.m_TextPosition, attrs,
|
||||
aPin->GetFontMetrics() );
|
||||
const_cast<SCH_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP );
|
||||
}
|
||||
};
|
||||
|
||||
const auto getColorForLayer =
|
||||
[&]( int aDrawnLayer )
|
||||
{
|
||||
boxText( *m_gal, aTextInfo.m_Text, aTextInfo.m_TextPosition, attrs,
|
||||
aPin->GetFontMetrics() );
|
||||
}
|
||||
}
|
||||
else if( nonCached( aPin ) && renderTextAsBitmap )
|
||||
{
|
||||
bitmapText( *m_gal, aTextInfo.m_Text, aTextInfo.m_TextPosition, attrs );
|
||||
const_cast<SCH_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP );
|
||||
}
|
||||
else
|
||||
{
|
||||
strokeText( *m_gal, aTextInfo.m_Text, aTextInfo.m_TextPosition, attrs,
|
||||
aPin->GetFontMetrics() );
|
||||
const_cast<SCH_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP );
|
||||
}
|
||||
};
|
||||
if( !aPin->IsVisible() )
|
||||
return getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed );
|
||||
|
||||
const auto getColorForLayer = [&]( int aDrawnLayer )
|
||||
{
|
||||
if( !aPin->IsVisible() )
|
||||
return getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed );
|
||||
|
||||
return getRenderColor( aPin, aDrawnLayer, drawingShadows, aDimmed );
|
||||
};
|
||||
return getRenderColor( aPin, aDrawnLayer, drawingShadows, aDimmed );
|
||||
};
|
||||
|
||||
// Request text layout info and draw it
|
||||
|
||||
@ -1913,7 +1914,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() )
|
||||
{
|
||||
@ -283,12 +283,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;
|
||||
}
|
||||
@ -296,7 +296,7 @@ KIFONT::FONT* SCH_TEXT::getDrawFont() const
|
||||
|
||||
const BOX2I SCH_TEXT::GetBoundingBox() const
|
||||
{
|
||||
BOX2I bbox = GetTextBox();
|
||||
BOX2I bbox = GetTextBox( nullptr );
|
||||
|
||||
if( !GetTextAngle().IsZero() ) // Rotate bbox.
|
||||
{
|
||||
@ -464,11 +464,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;
|
||||
|
||||
@ -510,7 +506,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 );
|
||||
@ -524,7 +520,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;
|
||||
|
||||
@ -168,8 +170,6 @@ public:
|
||||
protected:
|
||||
void swapData( SCH_ITEM* aItem ) override;
|
||||
|
||||
KIFONT::FONT* getDrawFont() const override;
|
||||
|
||||
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
|
||||
|
||||
/**
|
||||
|
@ -258,19 +258,19 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
@ -305,8 +305,8 @@ wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtr
|
||||
else
|
||||
colWidth = abs( size.x ) - ( GetMarginLeft() + GetMarginRight() );
|
||||
|
||||
getDrawFont()->LinebreakText( text, colWidth, GetTextSize(), GetEffectiveTextPenWidth(),
|
||||
IsBold(), IsItalic() );
|
||||
GetDrawFont( aSettings )->LinebreakText( text, colWidth, GetTextSize(), GetEffectiveTextPenWidth(),
|
||||
IsBold(), IsItalic() );
|
||||
|
||||
return text;
|
||||
}
|
||||
@ -387,7 +387,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();
|
||||
|
||||
@ -411,7 +411,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() )
|
||||
@ -428,12 +428,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;
|
||||
@ -140,8 +142,6 @@ public:
|
||||
protected:
|
||||
void swapData( SCH_ITEM* aItem ) override;
|
||||
|
||||
KIFONT::FONT* getDrawFont() const override;
|
||||
|
||||
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
|
||||
|
||||
int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
|
@ -326,7 +326,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.
|
||||
@ -335,7 +335,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).
|
||||
@ -349,7 +349,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.
|
||||
@ -373,6 +374,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();
|
||||
|
||||
@ -423,8 +426,6 @@ public:
|
||||
static wxString GotoPageHref( const wxString& aDestination );
|
||||
|
||||
protected:
|
||||
virtual KIFONT::FONT* getDrawFont() const;
|
||||
|
||||
virtual const KIFONT::METRICS& getFontMetrics() const;
|
||||
|
||||
virtual void cacheShownText();
|
||||
|
@ -133,10 +133,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() )
|
||||
{
|
||||
|
@ -804,7 +804,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 =
|
||||
|
@ -613,17 +613,8 @@ 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() );
|
||||
}
|
||||
|
||||
wxString shownText( text_item->GetShownText( true ) );
|
||||
KIFONT::FONT* font = text_item->GetDrawFont( nullptr );
|
||||
wxString shownText( text_item->GetShownText( true ) );
|
||||
|
||||
if( shownText.IsEmpty() )
|
||||
return;
|
||||
@ -662,7 +653,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++ )
|
||||
{
|
||||
|
@ -2289,13 +2289,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 );
|
||||
@ -2324,7 +2318,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;
|
||||
@ -2381,18 +2375,11 @@ void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
|
||||
return;
|
||||
}
|
||||
|
||||
COLOR4D color = m_pcbSettings.GetColor( aTextBox, 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() );
|
||||
}
|
||||
COLOR4D color = m_pcbSettings.GetColor( aTextBox, aLayer );
|
||||
int thickness = getLineThickness( aTextBox->GetWidth() );
|
||||
LINE_STYLE lineStyle = aTextBox->GetStroke().GetLineStyle();
|
||||
wxString resolvedText( aTextBox->GetShownText( true ) );
|
||||
KIFONT::FONT* font = aTextBox->GetDrawFont( &m_pcbSettings );
|
||||
|
||||
if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // happens only if locked
|
||||
{
|
||||
|
@ -345,7 +345,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() );
|
||||
@ -554,7 +554,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();
|
||||
@ -626,7 +626,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();
|
||||
TEXT_ATTRIBUTES attrs = GetAttributes();
|
||||
wxString shownText = GetShownText( true );
|
||||
|
@ -736,19 +736,8 @@ void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, boo
|
||||
const KIFONT::METRICS& aFontMetrics, bool aStrikeout )
|
||||
{
|
||||
int maxError = m_board->GetDesignSettings().m_MaxError;
|
||||
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() );
|
||||
}
|
||||
|
||||
wxString shownText( aText->GetShownText( true ) );
|
||||
KIFONT::FONT* font = aText->GetDrawFont( m_plotter->RenderSettings() );
|
||||
wxString shownText( aText->GetShownText( true ) );
|
||||
|
||||
if( shownText.IsEmpty() )
|
||||
return;
|
||||
@ -834,7 +823,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