Default font for eeschema.

This commit is contained in:
Jeff Young 2022-01-07 00:47:23 +00:00
parent eb58d7e44c
commit aef2a3fca4
29 changed files with 338 additions and 66 deletions

View File

@ -115,7 +115,7 @@ void BOARD_ADAPTER::addShapeWithClearance( const PCB_TEXT* aText, CONTAINER_2D_B
GRText( nullptr, aText->GetTextPos(), dummy_color, aText->GetShownText(), aText->GetTextAngle(),
size, aText->GetHorizJustify(), aText->GetVertJustify(), penWidth, aText->IsItalic(),
isBold, aText->GetFont(), addTextSegmToContainer, &callbackData );
isBold, aText->GetDrawFont(), addTextSegmToContainer, &callbackData );
}
@ -243,7 +243,7 @@ void BOARD_ADAPTER::addFootprintShapesWithClearance( const FOOTPRINT* aFootprint
GRText( nullptr, text->GetTextPos(), BLACK, text->GetShownText(), text->GetDrawRotation(),
size, text->GetHorizJustify(), text->GetVertJustify(), penWidth, text->IsItalic(),
isBold, text->GetFont(), addTextSegmToContainer, &callbackData );
isBold, text->GetDrawFont(), addTextSegmToContainer, &callbackData );
}
}

View File

@ -399,6 +399,17 @@ void EDA_TEXT::cacheShownText()
}
KIFONT::FONT* EDA_TEXT::GetDrawFont() const
{
KIFONT::FONT* font = GetFont();
if( !font )
font = KIFONT::FONT::GetFont( wxEmptyString, IsBold(), IsItalic() );
return font;
}
std::vector<std::unique_ptr<KIFONT::GLYPH>>*
EDA_TEXT::GetRenderCache( const wxString& forResolvedText ) const
{
@ -457,12 +468,7 @@ wxString EDA_TEXT::ShortenedShownText() const
int EDA_TEXT::GetInterline() const
{
KIFONT::FONT* font = GetFont();
if( !font )
font = KIFONT::FONT::GetFont( wxEmptyString, m_attributes.m_Bold, m_attributes.m_Italic );
return KiROUND( font->GetInterline( GetTextHeight() ) );
return KiROUND( GetDrawFont()->GetInterline( GetTextHeight() ) );
}
@ -502,7 +508,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
}
// calculate the H and V size
KIFONT::FONT* font = KIFONT::FONT::GetFont();
KIFONT::FONT* font = GetDrawFont();
VECTOR2D fontSize( GetTextSize() );
double penWidth( thickness );
int dx = KiROUND( font->StringBoundaryLimits( text, fontSize, penWidth ).x );
@ -626,6 +632,7 @@ void EDA_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
GetLinePositions( positions, strings.Count() );
// FONT TODO: this is going to use the KiCad font because it doesn't know any better...
for( unsigned ii = 0; ii < strings.Count(); ii++ )
printOneLineOfText( aSettings, aOffset, aColor, aFillMode, strings[ii], positions[ii] );
}
@ -692,7 +699,7 @@ void EDA_TEXT::printOneLineOfText( const RENDER_SETTINGS* aSettings, const VECTO
size.x = -size.x;
GRText( DC, aOffset + aPos, aColor, aText, GetTextAngle(), size, GetHorizJustify(),
GetVertJustify(), penWidth, IsItalic(), IsBold(), GetFont() );
GetVertJustify(), penWidth, IsItalic(), IsBold(), GetDrawFont() );
}
@ -808,8 +815,9 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
std::shared_ptr<SHAPE_COMPOUND> EDA_TEXT::GetEffectiveTextShape( ) const
{
std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
KIFONT::FONT* font = GetDrawFont();
if( GetFont() && GetFont()->IsOutline() )
if( font->IsOutline() )
{
// Make sure the cache is up-to-date before using it
(void) GetRenderCache( m_render_cache_text );
@ -864,14 +872,14 @@ std::shared_ptr<SHAPE_COMPOUND> EDA_TEXT::GetEffectiveTextShape( ) const
{
GRText( nullptr, positions[ii], COLOR4D::BLACK, strings_list.Item( ii ),
GetDrawRotation(), size, GetDrawHorizJustify(), GetDrawVertJustify(),
penWidth, IsItalic(), forceBold, GetFont(), addTextSegmToShape, &prms );
penWidth, IsItalic(), forceBold, font, addTextSegmToShape, &prms );
}
}
else
{
GRText( nullptr, GetDrawPos(), COLOR4D::BLACK, GetShownText(),
GetDrawRotation(), size, GetDrawHorizJustify(), GetDrawVertJustify(),
penWidth, IsItalic(), forceBold, GetFont(), addTextSegmToShape, &prms );
penWidth, IsItalic(), forceBold, font, addTextSegmToShape, &prms );
}
}

View File

@ -28,6 +28,8 @@
#include <panel_eeschema_display_options.h>
#include <widgets/gal_options_panel.h>
#include <widgets/ui_common.h>
#include <widgets/font_choice.h>
PANEL_EESCHEMA_DISPLAY_OPTIONS::PANEL_EESCHEMA_DISPLAY_OPTIONS( wxWindow* aParent,
APP_SETTINGS_BASE* aAppSettings ) :
@ -43,6 +45,11 @@ PANEL_EESCHEMA_DISPLAY_OPTIONS::PANEL_EESCHEMA_DISPLAY_OPTIONS( wxWindow* aParen
void PANEL_EESCHEMA_DISPLAY_OPTIONS::loadEEschemaSettings( EESCHEMA_SETTINGS* cfg )
{
m_defaultFontCtrl->SetStringSelection( cfg->m_Appearance.default_font );
if( m_defaultFontCtrl->GetSelection() < 0 )
m_defaultFontCtrl->SetSelection( 0 );
m_checkShowHiddenPins->SetValue( cfg->m_Appearance.show_hidden_pins );
m_checkShowHiddenFields->SetValue( cfg->m_Appearance.show_hidden_fields );
m_checkShowERCErrors->SetValue( cfg->m_Appearance.show_erc_errors );
@ -80,6 +87,7 @@ bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow()
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>();
cfg->m_Appearance.default_font = m_defaultFontCtrl->GetStringSelection();
cfg->m_Appearance.show_hidden_pins = m_checkShowHiddenPins->GetValue();
cfg->m_Appearance.show_hidden_fields = m_checkShowHiddenFields->GetValue();
cfg->m_Appearance.show_erc_warnings = m_checkShowERCWarnings->GetValue();

View File

@ -5,6 +5,8 @@
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/font_choice.h"
#include "panel_eeschema_display_options_base.h"
///////////////////////////////////////////////////////////////////////////
@ -25,8 +27,24 @@ PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE::PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE( wxWind
wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Appearance") ), wxVERTICAL );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxHORIZONTAL );
m_defaultFontLabel = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Default font:"), wxDefaultPosition, wxDefaultSize, 0 );
m_defaultFontLabel->Wrap( -1 );
bSizer4->Add( m_defaultFontLabel, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
wxString m_defaultFontCtrlChoices[] = { _("KiCad Font") };
int m_defaultFontCtrlNChoices = sizeof( m_defaultFontCtrlChoices ) / sizeof( wxString );
m_defaultFontCtrl = new FONT_CHOICE( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_defaultFontCtrlNChoices, m_defaultFontCtrlChoices, 0 );
m_defaultFontCtrl->SetSelection( 0 );
bSizer4->Add( m_defaultFontCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 );
sbSizer1->Add( bSizer4, 1, wxEXPAND, 5 );
m_checkShowHiddenPins = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("S&how hidden pins"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizer1->Add( m_checkShowHiddenPins, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
sbSizer1->Add( m_checkShowHiddenPins, 0, wxEXPAND|wxALL, 5 );
m_checkShowHiddenFields = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Show hidden fields"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizer1->Add( m_checkShowHiddenFields, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );

View File

@ -86,9 +86,145 @@
<property name="orient">wxVERTICAL</property>
<property name="parent">1</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer4</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Default font:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_defaultFontLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;KiCad Font&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_defaultFontCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">FONT_CHOICE; widgets/font_choice.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property>

View File

@ -10,16 +10,19 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class FONT_CHOICE;
#include "widgets/resettable_panel.h"
#include <wx/sizer.h>
#include <wx/gdicmn.h>
#include <wx/string.h>
#include <wx/checkbox.h>
#include <wx/stattext.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/choice.h>
#include <wx/checkbox.h>
#include <wx/statbox.h>
#include <wx/stattext.h>
#include <wx/spinctrl.h>
#include <wx/gbsizer.h>
#include <wx/panel.h>
@ -35,6 +38,8 @@ class PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE : public RESETTABLE_PANEL
protected:
wxBoxSizer* m_galOptionsSizer;
wxStaticText* m_defaultFontLabel;
FONT_CHOICE* m_defaultFontCtrl;
wxCheckBox* m_checkShowHiddenPins;
wxCheckBox* m_checkShowHiddenFields;
wxCheckBox* m_checkShowERCErrors;

View File

@ -94,6 +94,9 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() :
m_params.emplace_back( new PARAM<bool>( "appearance.print_sheet_reference",
&m_Appearance.print_sheet_reference, true ) );
m_params.emplace_back( new PARAM<wxString>( "appearance.default_font",
&m_Appearance.default_font, "KiCad Font" ) );
m_params.emplace_back( new PARAM<bool>( "appearance.show_hidden_pins",
&m_Appearance.show_hidden_pins, false ) );

View File

@ -42,6 +42,7 @@ public:
bool footprint_preview;
bool navigator_stays_open;
bool print_sheet_reference;
wxString default_font;
bool show_hidden_pins;
bool show_hidden_fields;
bool show_erc_warnings;

View File

@ -111,6 +111,17 @@ int LIB_FIELD::GetPenWidth() const
}
KIFONT::FONT* LIB_FIELD::GetDrawFont() const
{
KIFONT::FONT* font = EDA_TEXT::GetFont();
if( !font )
font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() );
return font;
}
void LIB_FIELD::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
const TRANSFORM& aTransform )
{
@ -121,7 +132,7 @@ void LIB_FIELD::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
wxString text = aData ? *static_cast<wxString*>( aData ) : GetText();
GRText( DC, text_pos, color, text, GetTextAngle(), GetTextSize(), GetHorizJustify(),
GetVertJustify(), penWidth, IsItalic(), IsBold(), GetFont() );
GetVertJustify(), penWidth, IsItalic(), IsBold(), GetDrawFont() );
}

View File

@ -117,6 +117,8 @@ public:
int GetPenWidth() const override;
KIFONT::FONT* GetDrawFont() const override;
/**
* Copy parameters of this field to another field. Pointers are not copied.
*

View File

@ -23,6 +23,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <eeschema_settings.h>
#include <sch_draw_panel.h>
#include <widgets/msgpanel.h>
#include <lib_symbol.h>
@ -115,6 +118,14 @@ bool LIB_ITEM::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
}
const wxString& LIB_ITEM::GetDefaultFont() const
{
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
return cfg->m_Appearance.default_font;
}
void LIB_ITEM::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
const TRANSFORM& aTransform )
{

View File

@ -142,6 +142,8 @@ public:
virtual int GetPenWidth() const = 0;
const wxString& GetDefaultFont() const;
virtual int GetEffectivePenWidth( const RENDER_SETTINGS* aSettings ) const
{
// For historical reasons, a stored value of 0 means "default width" and negative

View File

@ -170,6 +170,12 @@ int LIB_PIN::GetPenWidth() const
}
KIFONT::FONT* LIB_PIN::GetDrawFont() const
{
return KIFONT::FONT::GetFont( GetDefaultFont(), false, false );
}
wxString LIB_PIN::GetShownName() const
{
if( m_name == "~" )
@ -348,10 +354,12 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
if( !aDrawPinName && !aDrawPinNum )
return;
int x, y;
wxDC* DC = aSettings->GetPrintDC();
wxSize PinNameSize( m_nameTextSize, m_nameTextSize );
wxSize PinNumSize( m_numTextSize, m_numTextSize );
int x, y;
wxDC* DC = aSettings->GetPrintDC();
KIFONT::FONT* font = GetDrawFont();
wxSize pinNameSize( m_nameTextSize, m_nameTextSize );
wxSize pinNumSize( m_numTextSize, m_numTextSize );
int namePenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_nameTextSize, false ),
aSettings->GetDefaultPenWidth() );
@ -396,23 +404,23 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
{
x = x1 + aTextInside;
GRText( DC, VECTOR2I( x, y1 ), NameColor, name, EDA_ANGLE::HORIZONTAL,
PinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, namePenWidth,
false, false, nullptr );
pinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, namePenWidth,
false, false, font );
}
else // Orient == PIN_LEFT
{
x = x1 - aTextInside;
GRText( DC, VECTOR2I( x, y1 ), NameColor, name, EDA_ANGLE::HORIZONTAL,
PinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, namePenWidth,
false, false, nullptr );
pinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, namePenWidth,
false, false, font );
}
}
if( aDrawPinNum )
{
GRText( DC, VECTOR2I(( x1 + aPinPos.x) / 2, y1 - num_offset ), NumColor, number,
EDA_ANGLE::HORIZONTAL, PinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, nullptr );
EDA_ANGLE::HORIZONTAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, font );
}
}
else /* Its a vertical line. */
@ -424,16 +432,16 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
if( aDrawPinName )
{
GRText( DC, VECTOR2I( x1, y ), NameColor, name, EDA_ANGLE::VERTICAL, PinNameSize,
GRText( DC, VECTOR2I( x1, y ), NameColor, name, EDA_ANGLE::VERTICAL, pinNameSize,
GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false,
false, nullptr );
false, font );
}
if( aDrawPinNum )
{
GRText( DC, VECTOR2I( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor,
number, EDA_ANGLE::VERTICAL, PinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, nullptr );
number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, font );
}
}
else /* PIN_UP */
@ -442,16 +450,16 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
if( aDrawPinName )
{
GRText( DC, VECTOR2I( x1, y ), NameColor, name, EDA_ANGLE::VERTICAL, PinNameSize,
GRText( DC, VECTOR2I( x1, y ), NameColor, name, EDA_ANGLE::VERTICAL, pinNameSize,
GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false,
false, nullptr );
false, font );
}
if( aDrawPinNum )
{
GRText( DC, VECTOR2I( x1 - num_offset, ( y1 + aPinPos.y) / 2 ), NumColor,
number, EDA_ANGLE::VERTICAL, PinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, nullptr );
number, EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, font );
}
}
}
@ -465,15 +473,15 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
{
x = ( x1 + aPinPos.x) / 2;
GRText( DC, VECTOR2I( x, y1 - name_offset ), NameColor, name, EDA_ANGLE::HORIZONTAL,
PinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM,
namePenWidth, false, false, nullptr );
pinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM,
namePenWidth, false, false, font );
}
if( aDrawPinNum )
{
x = ( x1 + aPinPos.x) / 2;
GRText( DC, VECTOR2I( x, y1 + num_offset ), NumColor, number, EDA_ANGLE::HORIZONTAL,
PinNumSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, numPenWidth,
false, false, nullptr );
pinNumSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, numPenWidth,
false, false, font );
}
}
else /* Its a vertical line. */
@ -482,15 +490,15 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos
{
y = ( y1 + aPinPos.y) / 2;
GRText( DC, VECTOR2I( x1 - name_offset, y ), NameColor, name, EDA_ANGLE::VERTICAL,
PinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM,
namePenWidth, false, false, nullptr );
pinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM,
namePenWidth, false, false, font );
}
if( aDrawPinNum )
{
GRText( DC, VECTOR2I( x1 + num_offset, ( y1 + aPinPos.y) / 2 ), NumColor, number,
EDA_ANGLE::VERTICAL, PinNumSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP,
numPenWidth, false, false, nullptr );
EDA_ANGLE::VERTICAL, pinNumSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP,
numPenWidth, false, false, font );
}
}
}
@ -547,7 +555,7 @@ void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, VECT
}
GRText( DC, txtpos, color, typeName, orient, wxSize( textSize, textSize ), hjustify,
GR_TEXT_V_ALIGN_CENTER, pensize, false, false, nullptr );
GR_TEXT_V_ALIGN_CENTER, pensize, false, false, GetDrawFont() );
}
@ -1069,7 +1077,7 @@ void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITE
const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles, bool aPinOnly ) const
{
KIFONT::FONT* font = KIFONT::FONT::GetFont();
KIFONT::FONT* font = KIFONT::FONT::GetFont( Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>()->m_Appearance.default_font );
EDA_RECT bbox;
VECTOR2I begin;

View File

@ -191,6 +191,8 @@ public:
int GetPenWidth() const override;
KIFONT::FONT* GetDrawFont() const;
/**
* Plot the pin number and pin text info, given the pin line coordinates.
* Same as DrawPinTexts((), but output is the plotter

View File

@ -296,6 +296,17 @@ int LIB_TEXT::GetPenWidth() const
}
KIFONT::FONT* LIB_TEXT::GetDrawFont() const
{
KIFONT::FONT* font = EDA_TEXT::GetFont();
if( !font )
font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() );
return font;
}
void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
const TRANSFORM& aTransform )
{
@ -335,7 +346,7 @@ void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset;
GRText( DC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), GetFont() );
GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), GetDrawFont() );
}

View File

@ -79,6 +79,8 @@ public:
int GetPenWidth() const override;
KIFONT::FONT* GetDrawFont() const override;
const EDA_RECT GetBoundingBox() const override;
void BeginEdit( const VECTOR2I& aStartPoint ) override;

View File

@ -215,6 +215,17 @@ int SCH_FIELD::GetPenWidth() const
}
KIFONT::FONT* SCH_FIELD::GetDrawFont() const
{
KIFONT::FONT* font = EDA_TEXT::GetFont();
if( !font )
font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() );
return font;
}
void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
wxDC* DC = aSettings->GetPrintDC();
@ -254,7 +265,7 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
textpos = GetBoundingBox().Centre() + aOffset;
GRText( DC, textpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), GetFont() );
GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), GetDrawFont() );
}

View File

@ -154,6 +154,8 @@ public:
int GetPenWidth() const override;
KIFONT::FONT* GetDrawFont() const override;
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Move( const VECTOR2I& aMoveVector ) override

View File

@ -22,6 +22,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <eeschema_settings.h>
#include <eda_item.h>
#include <trace_helpers.h>
#include <sch_item.h>
@ -37,9 +40,7 @@
/* Constructor and destructor for SCH_ITEM */
/* They are not inline because this creates problems with gcc at linking time
* in debug mode
*/
/* They are not inline because this creates problems with gcc at linking time in debug mode */
SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) :
EDA_ITEM( aParent, aType )
@ -244,6 +245,14 @@ bool SCH_ITEM::operator < ( const SCH_ITEM& aItem ) const
}
const wxString& SCH_ITEM::GetDefaultFont() const
{
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
return cfg->m_Appearance.default_font;
}
void SCH_ITEM::Plot( PLOTTER* aPlotter ) const
{
wxFAIL_MSG( wxT( "Plot() method not implemented for class " ) + GetClass() );

View File

@ -259,6 +259,8 @@ public:
*/
virtual int GetPenWidth() const { return 0; }
const wxString& GetDefaultFont() const;
/**
* Print a schematic item.
*

View File

@ -441,7 +441,10 @@ void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition,
KIFONT::FONT* font = aAttrs.m_Font;
if( !font )
font = KIFONT::FONT::GetFont( wxEmptyString, aAttrs.m_Bold, aAttrs.m_Italic );
{
font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, aAttrs.m_Bold,
aAttrs.m_Italic );
}
m_gal->SetIsFill( font->IsOutline() );
m_gal->SetIsStroke( font->IsStroke() );
@ -456,7 +459,10 @@ void SCH_PAINTER::boxText( const wxString& aText, const VECTOR2D& aPosition,
KIFONT::FONT* font = aAttrs.m_Font;
if( !font )
font = KIFONT::FONT::GetFont( wxEmptyString, aAttrs.m_Bold, aAttrs.m_Italic );
{
font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, aAttrs.m_Bold,
aAttrs.m_Italic );
}
VECTOR2D extents = font->StringBoundaryLimits( aText, aAttrs.m_Size, aAttrs.m_StrokeWidth );
EDA_RECT box( (VECTOR2I) aPosition, wxSize( extents.x, aAttrs.m_Size.y ) );

View File

@ -403,6 +403,17 @@ int SCH_TEXT::GetPenWidth() const
}
KIFONT::FONT* SCH_TEXT::GetDrawFont() const
{
KIFONT::FONT* font = EDA_TEXT::GetFont();
if( !font )
font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() );
return font;
}
void SCH_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
COLOR4D color = aSettings->GetLayerColor( m_layer );
@ -545,6 +556,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter ) const
int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
COLOR4D color = settings->GetLayerColor( layer );
int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
KIFONT::FONT* font = GetDrawFont();
penWidth = std::max( penWidth, settings->GetMinPenWidth() );
aPlotter->SetCurrentLineWidth( penWidth );
@ -561,7 +573,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter ) const
VECTOR2I textpos = positions[ii] + GetSchematicTextOffset( aPlotter->RenderSettings() );
wxString& txt = strings_list.Item( ii );
aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), GetHorizJustify(),
GetVertJustify(), penWidth, IsItalic(), IsBold() );
GetVertJustify(), penWidth, IsItalic(), IsBold(), false, font );
}
}

View File

@ -173,6 +173,8 @@ public:
int GetPenWidth() const override;
KIFONT::FONT* GetDrawFont() const override;
void Move( const VECTOR2I& aMoveVector ) override
{
EDA_TEXT::Offset( aMoveVector );

View File

@ -336,6 +336,7 @@ public:
*/
virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
virtual KIFONT::FONT* GetDrawFont() const;
virtual EDA_ANGLE GetDrawRotation() const { return GetTextAngle(); }
virtual VECTOR2I GetDrawPos() const { return GetTextPos(); }
virtual GR_TEXT_H_ALIGN_T GetDrawHorizJustify() const { return GetHorizJustify(); };

View File

@ -109,7 +109,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
m_fontLabel->Wrap( -1 );
gbSizer1->Add( m_fontLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxString m_fontCtrlChoices[] = { _("Default Font"), _("KiCad Font") };
wxString m_fontCtrlChoices[] = { _("KiCad Font") };
int m_fontCtrlNChoices = sizeof( m_fontCtrlChoices ) / sizeof( wxString );
m_fontCtrl = new FONT_CHOICE( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fontCtrlNChoices, m_fontCtrlChoices, 0 );
m_fontCtrl->SetSelection( 0 );

View File

@ -777,7 +777,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Default Font&quot; &quot;KiCad Font&quot;</property>
<property name="choices">&quot;KiCad Font&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>

View File

@ -476,7 +476,7 @@ void FP_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerB
size.x = -size.x;
GRText( nullptr, GetTextPos(), BLACK, GetShownText(), GetDrawRotation(), size,
GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold(), GetFont(),
GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold(), GetDrawFont(),
addTextSegmToPoly, &prms );
}

View File

@ -241,10 +241,10 @@ void PCB_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCorner
prms.m_cornerBuffer = &aCornerBuffer;
prms.m_textWidth = GetEffectiveTextPenWidth() + ( 2 * aClearanceValue );
prms.m_error = aError;
COLOR4D color; // not actually used, but needed by GRText
GRText( nullptr, GetTextPos(), color, GetShownText(), GetTextAngle(), size, GetHorizJustify(),
GetVertJustify(), penWidth, IsItalic(), IsBold(), GetFont(), addTextSegmToPoly, &prms );
GRText( nullptr, GetTextPos(), COLOR4D::BLACK, GetShownText(), GetTextAngle(), size,
GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold(), GetDrawFont(),
addTextSegmToPoly, &prms );
}

View File

@ -412,7 +412,7 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aText, const COLOR4
m_plotter->Text( pos, aColor, aText->GetShownText(), aText->GetDrawRotation(), size,
aText->GetHorizJustify(), aText->GetVertJustify(), thickness,
aText->IsItalic(), allow_bold, false, aText->GetFont(), &gbr_metadata );
aText->IsItalic(), allow_bold, false, aText->GetDrawFont(), &gbr_metadata );
}
@ -736,7 +736,8 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItem( const FP_SHAPE* aShape )
void BRDITEMS_PLOTTER::PlotPcbText( const PCB_TEXT* aText )
{
wxString shownText( aText->GetShownText() );
wxString shownText( aText->GetShownText() );
KIFONT::FONT* font = aText->GetDrawFont();
if( shownText.IsEmpty() )
return;
@ -781,16 +782,14 @@ void BRDITEMS_PLOTTER::PlotPcbText( const PCB_TEXT* aText )
wxString& txt = strings_list.Item( ii );
m_plotter->Text( positions[ii], color, txt, aText->GetTextAngle(), size,
aText->GetHorizJustify(), aText->GetVertJustify(), thickness,
aText->IsItalic(), allow_bold, false, aText->GetFont(),
&gbr_metadata );
aText->IsItalic(), allow_bold, false, font, &gbr_metadata );
}
}
else
{
m_plotter->Text( pos, color, shownText, aText->GetTextAngle(), size,
aText->GetHorizJustify(), aText->GetVertJustify(), thickness,
aText->IsItalic(), allow_bold, false, aText->GetFont(),
&gbr_metadata );
aText->IsItalic(), allow_bold, false, font, &gbr_metadata );
}
}