From ccb94fd1a71a047ae4e01be8fc31fe8dc2cef55b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 29 Dec 2021 17:31:40 +0000 Subject: [PATCH] APIs for passing KIFONT::FONT pointers around. Also some clean-up and bug fixes. --- .../3d_canvas/create_3Dgraphic_brd_items.cpp | 8 +- common/CMakeLists.txt | 1 + common/eda_text.cpp | 37 +++-- common/font/font.cpp | 47 ++++++ common/gr_text.cpp | 5 +- common/plotters/DXF_plotter.cpp | 29 ++-- common/plotters/GERBER_plotter.cpp | 29 ++-- common/plotters/PDF_plotter.cpp | 29 ++-- common/plotters/PS_plotter.cpp | 29 ++-- common/plotters/SVG_plotter.cpp | 29 ++-- common/plotters/common_plot_functions.cpp | 2 +- common/plotters/plotter.cpp | 27 ++-- eeschema/lib_field.cpp | 2 +- eeschema/lib_pin.cpp | 22 +-- eeschema/lib_text.cpp | 2 +- eeschema/sch_field.cpp | 2 +- .../cadstar/cadstar_sch_archive_loader.cpp | 35 ++--- .../cadstar/cadstar_sch_archive_loader.h | 2 +- include/eda_angle.h | 13 +- include/eda_text.h | 11 ++ include/font/font.h | 137 ++++++++++++++++++ include/gr_text.h | 2 + include/plotters/plotter.h | 25 ++-- include/plotters/plotter_dxf.h | 25 ++-- include/plotters/plotter_gerber.h | 25 ++-- include/plotters/plotters_pslike.h | 75 +++++----- pcbnew/fp_text.cpp | 2 +- pcbnew/pcb_text.cpp | 2 +- pcbnew/plot_brditems_plotter.cpp | 26 ++-- 29 files changed, 454 insertions(+), 226 deletions(-) create mode 100644 common/font/font.cpp create mode 100644 include/font/font.h diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index c829cc4089..5c7d540aba 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -113,9 +113,9 @@ void BOARD_ADAPTER::addShapeWithClearance( const PCB_TEXT* aText, CONTAINER_2D_B bool isBold = aText->IsBold(); int penWidth = aText->GetEffectiveTextPenWidth(); - GRText( nullptr, aText->GetTextPos(), dummy_color, aText->GetShownText(), - aText->GetTextAngle(), size, aText->GetHorizJustify(), aText->GetVertJustify(), - penWidth, aText->IsItalic(), isBold, addTextSegmToContainer, &callbackData ); + GRText( nullptr, aText->GetTextPos(), dummy_color, aText->GetShownText(), aText->GetTextAngle(), + size, aText->GetHorizJustify(), aText->GetVertJustify(), penWidth, aText->IsItalic(), + isBold, aText->GetFont(), 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, addTextSegmToContainer, &callbackData ); + isBold, text->GetFont(), addTextSegmToContainer, &callbackData ); } } diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 5235caccc4..fff8e82218 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -297,6 +297,7 @@ set( PLUGINS_EAGLE_SRCS ) set( FONT_SRCS + font/font.cpp ) set( COMMON_SRCS diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 8f639cfaac..b8ad90ec4c 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -51,9 +51,9 @@ #include #include #include +#include #include - #include // for wxASSERT #include // wxString, wxArrayString #include // for wxPoint,wxSize @@ -109,7 +109,8 @@ EDA_TEXT::EDA_TEXT( const wxString& text ) : EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText ) : m_text( aText.m_text ), - m_attributes( aText.m_attributes ) + m_attributes( aText.m_attributes ), + m_pos( aText.m_pos ) { cacheShownText(); } @@ -440,11 +441,10 @@ void EDA_TEXT::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void EDA_TEXT::GetLinePositions( std::vector& aPositions, int aLineCount ) const { - wxPoint pos = GetTextPos(); // Position of first line of the - // multiline text according to - // the center of the multiline text block + wxPoint pos = GetTextPos(); // Position of first line of the multiline text according + // to the center of the multiline text block - wxPoint offset; // Offset to next line. + wxPoint offset; // Offset to next line. offset.y = GetInterline(); @@ -465,8 +465,7 @@ void EDA_TEXT::GetLinePositions( std::vector& aPositions, int aLineCoun } } - // Rotate the position of the first line - // around the center of the multiline text block + // Rotate the position of the first line around the center of the multiline text block RotatePoint( &pos, GetTextPos(), GetTextAngle() ); // Rotate the offset lines to increase happened in the right direction @@ -479,6 +478,7 @@ void EDA_TEXT::GetLinePositions( std::vector& aPositions, int aLineCoun } } + void EDA_TEXT::printOneLineOfText( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, const COLOR4D& aColor, OUTLINE_MODE aFillMode, const wxString& aText, const wxPoint &aPos ) @@ -495,7 +495,7 @@ void EDA_TEXT::printOneLineOfText( const RENDER_SETTINGS* aSettings, const wxPoi size.x = -size.x; GRText( DC, aOffset + aPos, aColor, aText, GetTextAngle(), size, GetHorizJustify(), - GetVertJustify(), penWidth, IsItalic(), IsBold() ); + GetVertJustify(), penWidth, IsItalic(), IsBold(), GetFont() ); } @@ -520,6 +520,15 @@ wxString EDA_TEXT::GetTextStyleName() const } +wxString EDA_TEXT::GetFontName() const +{ + if( GetFont() ) + return GetFont()->Name(); + else + return wxEmptyString; +} + + bool EDA_TEXT::IsDefaultFormatting() const { return ( IsVisible() @@ -530,6 +539,7 @@ bool EDA_TEXT::IsDefaultFormatting() const && !IsItalic() && !IsBold() && !IsMultilineAllowed() + && GetFontName().IsEmpty() ); } @@ -627,14 +637,14 @@ std::vector EDA_TEXT::TransformToSegmentList() const wxString txt = strings_list.Item( ii ); GRText( nullptr, positions[ii], color, txt, GetDrawRotation(), size, GetDrawHorizJustify(), GetDrawVertJustify(), penWidth, IsItalic(), forceBold, - addTextSegmToBuffer, &cornerBuffer ); + GetFont(), addTextSegmToBuffer, &cornerBuffer ); } } else { GRText( nullptr, GetDrawPos(), color, GetShownText(), GetDrawRotation(), size, GetDrawHorizJustify(), GetDrawVertJustify(), penWidth, IsItalic(), forceBold, - addTextSegmToBuffer, &cornerBuffer ); + GetFont(), addTextSegmToBuffer, &cornerBuffer ); } return cornerBuffer; @@ -679,6 +689,11 @@ int EDA_TEXT::Compare( const EDA_TEXT* aOther ) const TEST( m_attributes.m_Multiline, aOther->m_attributes.m_Multiline ); TEST( m_attributes.m_KeepUpright, aOther->m_attributes.m_KeepUpright ); + int val = GetFontName().Cmp( aOther->GetFontName() ); + + if( val != 0 ) + return val; + return m_text.Cmp( aOther->m_text ); } diff --git a/common/font/font.cpp b/common/font/font.cpp new file mode 100644 index 0000000000..4479b46326 --- /dev/null +++ b/common/font/font.cpp @@ -0,0 +1,47 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2021 Ola Rinta-Koski + * Copyright (C) 2021 Kicad Developers, see AUTHORS.txt for contributors. + * + * Font abstract base class + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + + +using namespace KIFONT; + +FONT* FONT::s_defaultFont = nullptr; +std::map FONT::s_fontMap; + + +FONT::FONT() +{ +} + + +const wxString& FONT::Name() const +{ + return m_fontName; +} + + diff --git a/common/gr_text.cpp b/common/gr_text.cpp index c5ec292693..e28cdc4240 100644 --- a/common/gr_text.cpp +++ b/common/gr_text.cpp @@ -32,8 +32,8 @@ #include #include #include -#include #include // for KiROUND +#include #include @@ -117,6 +117,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic, * Use a value min(aSize.x, aSize.y) / 5 for a bold text. * @param aItalic is the true to simulate an italic font. * @param aBold use true to use a bold font. Useful only with default width value (aWidth = 0). + * @param aFont is the font to use, or nullptr for the KiCad stroke font * @param aCallback( int x0, int y0, int xf, int yf, void* aData ) is a function called * (if non null) to draw each segment. used to draw 3D texts or for plotting. * NULL for normal drawings @@ -128,7 +129,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic, void GRText( wxDC* aDC, const wxPoint& aPos, const COLOR4D& aColor, const wxString& aText, const EDA_ANGLE& aOrient, const wxSize& aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, - void (* aCallback)( int x0, int y0, int xf, int yf, void* aData ), + KIFONT::FONT* aFont, void (* aCallback)( int x0, int y0, int xf, int yf, void* aData ), void* aCallbackData, PLOTTER* aPlotter ) { bool fill_mode = true; diff --git a/common/plotters/DXF_plotter.cpp b/common/plotters/DXF_plotter.cpp index 2ed12407cf..07102f11c3 100644 --- a/common/plotters/DXF_plotter.cpp +++ b/common/plotters/DXF_plotter.cpp @@ -828,18 +828,19 @@ bool containsNonAsciiChars( const wxString& string ) } -void DXF_PLOTTER::Text( const wxPoint& aPos, - const COLOR4D& aColor, - const wxString& aText, - const EDA_ANGLE& aOrient, - const wxSize& aSize, - enum GR_TEXT_H_ALIGN_T aH_justify, - enum GR_TEXT_V_ALIGN_T aV_justify, - int aWidth, - bool aItalic, - bool aBold, - bool aMultilineAllowed, - void* aData ) +void DXF_PLOTTER::Text( const wxPoint& aPos, + const COLOR4D& aColor, + const wxString& aText, + const EDA_ANGLE& aOrient, + const wxSize& aSize, + enum GR_TEXT_H_ALIGN_T aH_justify, + enum GR_TEXT_V_ALIGN_T aV_justify, + int aWidth, + bool aItalic, + bool aBold, + bool aMultilineAllowed, + KIFONT::FONT* aFont, + void* aData ) { // Fix me: see how to use DXF text mode for multiline texts if( aMultilineAllowed && !aText.Contains( wxT( "\n" ) ) ) @@ -852,8 +853,8 @@ void DXF_PLOTTER::Text( const wxPoint& aPos, // output text as graphics. // Perhaps multiline texts could be handled as DXF text entity // but I do not want spend time about this (JPC) - PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, - aItalic, aBold, aMultilineAllowed, aData ); + PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, + aBold, aMultilineAllowed, aFont, aData ); } else { diff --git a/common/plotters/GERBER_plotter.cpp b/common/plotters/GERBER_plotter.cpp index 9bfa69e554..5192c4373c 100644 --- a/common/plotters/GERBER_plotter.cpp +++ b/common/plotters/GERBER_plotter.cpp @@ -1923,26 +1923,27 @@ void GERBER_PLOTTER::FlashRegularPolygon( const wxPoint& aShapePos, int aDiamete } -void GERBER_PLOTTER::Text( const wxPoint& aPos, - const COLOR4D& aColor, - const wxString& aText, - const EDA_ANGLE& aOrient, - const wxSize& aSize, - enum GR_TEXT_H_ALIGN_T aH_justify, - enum GR_TEXT_V_ALIGN_T aV_justify, - int aWidth, - bool aItalic, - bool aBold, - bool aMultilineAllowed, - void* aData ) +void GERBER_PLOTTER::Text( const wxPoint& aPos, + const COLOR4D& aColor, + const wxString& aText, + const EDA_ANGLE& aOrient, + const wxSize& aSize, + enum GR_TEXT_H_ALIGN_T aH_justify, + enum GR_TEXT_V_ALIGN_T aV_justify, + int aWidth, + bool aItalic, + bool aBold, + bool aMultilineAllowed, + KIFONT::FONT* aFont, + void* aData ) { GBR_METADATA* gbr_metadata = static_cast( aData ); if( gbr_metadata ) formatNetAttribute( &gbr_metadata->m_NetlistMetadata ); - PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, - aBold, aMultilineAllowed, aData ); + PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, + aItalic, aBold, aMultilineAllowed, aFont, aData ); } diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index 65e4830314..7255da1050 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -822,18 +822,19 @@ bool PDF_PLOTTER::EndPlot() } -void PDF_PLOTTER::Text( const wxPoint& aPos, - const COLOR4D& aColor, - const wxString& aText, - const EDA_ANGLE& aOrient, - const wxSize& aSize, - enum GR_TEXT_H_ALIGN_T aH_justify, - enum GR_TEXT_V_ALIGN_T aV_justify, - int aWidth, - bool aItalic, - bool aBold, - bool aMultilineAllowed, - void* aData ) +void PDF_PLOTTER::Text( const wxPoint& aPos, + const COLOR4D& aColor, + const wxString& aText, + const EDA_ANGLE& aOrient, + const wxSize& aSize, + enum GR_TEXT_H_ALIGN_T aH_justify, + enum GR_TEXT_V_ALIGN_T aV_justify, + int aWidth, + bool aItalic, + bool aBold, + bool aMultilineAllowed, + KIFONT::FONT* aFont, + void* aData ) { // PDF files do not like 0 sized texts which create broken files. if( aSize.x == 0 || aSize.y == 0 ) @@ -873,7 +874,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos, fputs( "Q\n", workFile ); // Plot the stroked text (if requested) - PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, - aItalic, aBold, aMultilineAllowed ); + PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, + aBold, aMultilineAllowed, aFont ); } diff --git a/common/plotters/PS_plotter.cpp b/common/plotters/PS_plotter.cpp index ff931a4a6a..99d10f570e 100644 --- a/common/plotters/PS_plotter.cpp +++ b/common/plotters/PS_plotter.cpp @@ -958,18 +958,19 @@ bool PS_PLOTTER::EndPlot() -void PS_PLOTTER::Text( const wxPoint& aPos, - const COLOR4D& aColor, - const wxString& aText, - const EDA_ANGLE& aOrient, - const wxSize& aSize, - enum GR_TEXT_H_ALIGN_T aH_justify, - enum GR_TEXT_V_ALIGN_T aV_justify, - int aWidth, - bool aItalic, - bool aBold, - bool aMultilineAllowed, - void* aData ) +void PS_PLOTTER::Text( const wxPoint& aPos, + const COLOR4D& aColor, + const wxString& aText, + const EDA_ANGLE& aOrient, + const wxSize& aSize, + enum GR_TEXT_H_ALIGN_T aH_justify, + enum GR_TEXT_V_ALIGN_T aV_justify, + int aWidth, + bool aItalic, + bool aBold, + bool aMultilineAllowed, + KIFONT::FONT* aFont, + void* aData ) { SetCurrentLineWidth( aWidth ); SetColor( aColor ); @@ -982,8 +983,8 @@ void PS_PLOTTER::Text( const wxPoint& aPos, fprintf( m_outputFile, "%s %g %g phantomshow\n", ps_test.c_str(), pos_dev.x, pos_dev.y ); } - PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, - aItalic, aBold, aMultilineAllowed ); + PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, + aBold, aMultilineAllowed, aFont, aData ); } diff --git a/common/plotters/SVG_plotter.cpp b/common/plotters/SVG_plotter.cpp index ab4182bb2a..3a26580c3e 100644 --- a/common/plotters/SVG_plotter.cpp +++ b/common/plotters/SVG_plotter.cpp @@ -755,18 +755,19 @@ bool SVG_PLOTTER::EndPlot() } -void SVG_PLOTTER::Text( const wxPoint& aPos, - const COLOR4D& aColor, - const wxString& aText, - const EDA_ANGLE& aOrient, - const wxSize& aSize, - enum GR_TEXT_H_ALIGN_T aH_justify, - enum GR_TEXT_V_ALIGN_T aV_justify, - int aWidth, - bool aItalic, - bool aBold, - bool aMultilineAllowed, - void* aData ) +void SVG_PLOTTER::Text( const wxPoint& aPos, + const COLOR4D& aColor, + const wxString& aText, + const EDA_ANGLE& aOrient, + const wxSize& aSize, + enum GR_TEXT_H_ALIGN_T aH_justify, + enum GR_TEXT_V_ALIGN_T aV_justify, + int aWidth, + bool aItalic, + bool aBold, + bool aMultilineAllowed, + KIFONT::FONT* aFont, + void* aData ) { setFillMode( FILL_T::NO_FILL ); SetColor( aColor ); @@ -823,8 +824,8 @@ void SVG_PLOTTER::Text( const wxPoint& aPos, fprintf( m_outputFile, "%s\n", TO_UTF8( XmlEsc( aText ) ) ); - PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, - aWidth, aItalic, aBold, aMultilineAllowed ); + PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, + aBold, aMultilineAllowed, aFont ); fputs( "", m_outputFile ); } diff --git a/common/plotters/common_plot_functions.cpp b/common/plotters/common_plot_functions.cpp index a730be2570..9430fee509 100644 --- a/common/plotters/common_plot_functions.cpp +++ b/common/plotters/common_plot_functions.cpp @@ -120,7 +120,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL plotter->Text( text->GetTextPos(), plotColor, text->GetShownText(), text->GetTextAngle(), text->GetTextSize(), text->GetHorizJustify(), text->GetVertJustify(), penWidth, text->IsItalic(), text->IsBold(), - text->IsMultilineAllowed() ); + text->IsMultilineAllowed(), text->GetFont() ); } break; diff --git a/common/plotters/plotter.cpp b/common/plotters/plotter.cpp index c3e4e0a75f..c42f529d50 100644 --- a/common/plotters/plotter.cpp +++ b/common/plotters/plotter.cpp @@ -649,22 +649,23 @@ void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill, int a * @param aData is a parameter used by some plotters in SetCurrentLineWidth(), * not directly used here. */ -void PLOTTER::Text( const wxPoint& aPos, - const COLOR4D& aColor, - const wxString& aText, - const EDA_ANGLE& aOrient, - const wxSize& aSize, - enum GR_TEXT_H_ALIGN_T aH_justify, - enum GR_TEXT_V_ALIGN_T aV_justify, - int aPenWidth, - bool aItalic, - bool aBold, - bool aMultilineAllowed, - void* aData ) +void PLOTTER::Text( const wxPoint& aPos, + const COLOR4D& aColor, + const wxString& aText, + const EDA_ANGLE& aOrient, + const wxSize& aSize, + enum GR_TEXT_H_ALIGN_T aH_justify, + enum GR_TEXT_V_ALIGN_T aV_justify, + int aPenWidth, + bool aItalic, + bool aBold, + bool aMultilineAllowed, + KIFONT::FONT* aFont, + void* aData ) { SetColor( aColor ); SetCurrentLineWidth( aPenWidth, aData ); GRText( nullptr, aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aPenWidth, - aItalic, aBold, nullptr, nullptr, this ); + aItalic, aBold, aFont, nullptr, nullptr, this ); } diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index bfc1431892..8a39c3294d 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -121,7 +121,7 @@ void LIB_FIELD::print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, wxString text = aData ? *static_cast( aData ) : GetText(); GRText( DC, text_pos, color, text, GetTextAngle(), GetTextSize(), GetHorizJustify(), - GetVertJustify(), penWidth, IsItalic(), IsBold() ); + GetVertJustify(), penWidth, IsItalic(), IsBold(), GetFont() ); } diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 88502caad7..426e38cfde 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -396,14 +396,14 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos, x = x1 + aTextInside; GRText( DC, wxPoint( x, y1 ), NameColor, name, EDA_ANGLE::HORIZONTAL, PinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, namePenWidth, - false, false ); + false, false, nullptr ); } else // Orient == PIN_LEFT { x = x1 - aTextInside; GRText( DC, wxPoint( x, y1 ), NameColor, name, EDA_ANGLE::HORIZONTAL, PinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, namePenWidth, - false, false ); + false, false, nullptr ); } } @@ -411,7 +411,7 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos, { GRText( DC, wxPoint(( 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 ); + GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, nullptr ); } } else /* Its a vertical line. */ @@ -425,14 +425,14 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos, { GRText( DC, wxPoint( x1, y ), NameColor, name, EDA_ANGLE::VERTICAL, PinNameSize, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false, - false ); + false, nullptr ); } if( aDrawPinNum ) { GRText( DC, wxPoint( 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 ); + GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, nullptr ); } } else /* PIN_UP */ @@ -443,14 +443,14 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos, { GRText( DC, wxPoint( x1, y ), NameColor, name, EDA_ANGLE::VERTICAL, PinNameSize, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, namePenWidth, false, - false ); + false, nullptr ); } if( aDrawPinNum ) { GRText( DC, wxPoint( 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 ); + GR_TEXT_V_ALIGN_BOTTOM, numPenWidth, false, false, nullptr ); } } } @@ -465,14 +465,14 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos, x = ( x1 + aPinPos.x) / 2; GRText( DC, wxPoint( x, y1 - name_offset ), NameColor, name, EDA_ANGLE::HORIZONTAL, PinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, - namePenWidth, false, false ); + namePenWidth, false, false, nullptr ); } if( aDrawPinNum ) { x = ( x1 + aPinPos.x) / 2; GRText( DC, wxPoint( x, y1 + num_offset ), NumColor, number, EDA_ANGLE::HORIZONTAL, PinNumSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, numPenWidth, - false, false ); + false, false, nullptr ); } } else /* Its a vertical line. */ @@ -482,14 +482,14 @@ void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, wxPoint& aPinPos, y = ( y1 + aPinPos.y) / 2; GRText( DC, wxPoint( x1 - name_offset, y ), NameColor, name, EDA_ANGLE::VERTICAL, PinNameSize, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, - namePenWidth, false, false ); + namePenWidth, false, false, nullptr ); } if( aDrawPinNum ) { GRText( DC, wxPoint( 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 ); + numPenWidth, false, false, nullptr ); } } } diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 9a0a2c36f6..68c840e3b1 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -335,7 +335,7 @@ void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const wxPoint& 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() ); + GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), GetFont() ); } diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index e6a510ca75..f9c5a12cad 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -252,7 +252,7 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const wxPoint& 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() ); + GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), GetFont() ); } diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index aee56903d0..1f8380ebe5 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -1813,9 +1813,10 @@ SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCads } -void CADSTAR_SCH_ARCHIVE_LOADER::loadSymbolFieldAttribute( - const ATTRIBUTE_LOCATION& aCadstarAttrLoc, const double& aComponentOrientationDeciDeg, - bool aIsMirrored, SCH_FIELD* aKiCadField ) +void CADSTAR_SCH_ARCHIVE_LOADER::loadSymbolFieldAttribute( const ATTRIBUTE_LOCATION& aCadstarAttrLoc, + double aComponentOrientationDeciDeg, + bool aIsMirrored, + SCH_FIELD* aKiCadField ) { aKiCadField->SetPosition( getKiCadPoint( aCadstarAttrLoc.Position ) ); aKiCadField->SetVisible( true ); @@ -2914,19 +2915,19 @@ void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int for( auto& pin : pins ) { auto setPinOrientation = - [&]( double aAngleRad ) - { - int oDeg = (int) NormalizeAngle180( RAD2DEG( aAngleRad ) ); + [&]( double aAngleRad ) + { + int oDeg = (int) NormalizeAngle180( RAD2DEG( aAngleRad ) ); - if( oDeg >= -45 && oDeg <= 45 ) - pin->SetOrientation( 'R' ); // 0 degrees - else if( oDeg >= 45 && oDeg <= 135 ) - pin->SetOrientation( 'U' ); // 90 degrees - else if( oDeg >= 135 || oDeg <= -135 ) - pin->SetOrientation( 'L' ); // 180 degrees - else - pin->SetOrientation( 'D' ); // -90 degrees - }; + if( oDeg >= -45 && oDeg <= 45 ) + pin->SetOrientation( 'R' ); // 0 degrees + else if( oDeg >= 45 && oDeg <= 135 ) + pin->SetOrientation( 'U' ); // 90 degrees + else if( oDeg >= 135 || oDeg <= -135 ) + pin->SetOrientation( 'L' ); // 180 degrees + else + pin->SetOrientation( 'D' ); // -90 degrees + }; if( uniqueSegments.count( pin->GetPosition() ) ) { @@ -2946,8 +2947,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int } -std::pair CADSTAR_SCH_ARCHIVE_LOADER::getFigureExtentsKiCad( - const FIGURE& aCadstarFigure ) +std::pair +CADSTAR_SCH_ARCHIVE_LOADER::getFigureExtentsKiCad( const FIGURE& aCadstarFigure ) { wxPoint upperLeft( Assignments.Settings.DesignLimit.x, 0 ); wxPoint lowerRight( 0, Assignments.Settings.DesignLimit.y ); diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.h b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.h index f9734dcf04..8355bdf96b 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.h +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.h @@ -153,7 +153,7 @@ private: double& aComponentOrientationDeciDeg ); void loadSymbolFieldAttribute( const ATTRIBUTE_LOCATION& aCadstarAttrLoc, - const double& aComponentOrientationDeciDeg, bool aIsMirrored, + double aComponentOrientationDeciDeg, bool aIsMirrored, SCH_FIELD* aKiCadField ); int getComponentOrientation( double aOrientAngleDeciDeg, double& aReturnedOrientationDeciDeg ); diff --git a/include/eda_angle.h b/include/eda_angle.h index af22b55b06..8311d39288 100644 --- a/include/eda_angle.h +++ b/include/eda_angle.h @@ -211,17 +211,16 @@ public: EDA_ANGLE KeepUpright() const; private: - // value is always stored in 1/10ths of a degree - int m_value; - - double m_radians; //< only used with as-radians constructor - - ANGLE_TYPE m_initial_type; - void normalize( bool n720 = false ); int normalize( int aValue, ANGLE_TYPE aAngleType, bool n720 = false ) const; double normalize( double aValue, ANGLE_TYPE aAngleType, bool n720 = false ) const; +private: + + int m_value; ///< value is always stored in 1/10ths of a degree + double m_radians; ///< only used with as-radians constructor + ANGLE_TYPE m_initial_type; + static constexpr int TENTHS_OF_A_DEGREE_FULL_CIRCLE = 3600; static constexpr int DEGREES_FULL_CIRCLE = 360; static constexpr double RADIANS_FULL_CIRCLE = 2 * M_PI; diff --git a/include/eda_text.h b/include/eda_text.h index 0cb4adccfd..2c3bfc151d 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -176,6 +176,9 @@ public: void SetHorizJustify( GR_TEXT_H_ALIGN_T aType ) { m_attributes.m_Halign = aType; }; void SetVertJustify( GR_TEXT_V_ALIGN_T aType ) { m_attributes.m_Valign = aType; }; + void SetKeepUpright( bool aKeepUpright ) { m_attributes.m_KeepUpright = aKeepUpright; } + bool IsKeepUpright() const { return m_attributes.m_KeepUpright; } + /** * Set the text attributes from another instance. */ @@ -203,6 +206,14 @@ public: bool IsDefaultFormatting() const; + void SetFont( KIFONT::FONT* aFont ) { m_attributes.m_Font = aFont; } + KIFONT::FONT* GetFont() const { return m_attributes.m_Font; } + + wxString GetFontName() const; + + void SetLineSpacing( double aLineSpacing ) { m_attributes.m_LineSpacing = aLineSpacing; } + double GetLineSpacing() const { return m_attributes.m_LineSpacing; } + void SetTextSize( const wxSize& aNewSize ) { m_attributes.m_Size = aNewSize; } wxSize GetTextSize() const { return wxSize( m_attributes.m_Size.x, m_attributes.m_Size.y ); } diff --git a/include/font/font.h b/include/font/font.h new file mode 100644 index 0000000000..68d9a71c69 --- /dev/null +++ b/include/font/font.h @@ -0,0 +1,137 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2021 Ola Rinta-Koski + * Copyright (C) 2021 Kicad Developers, see AUTHORS.txt for contributors. + * + * Font abstract base class + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef FONT_H_ +#define FONT_H_ + +#include +#include +#include +#include + +#include +#include + +namespace KIGFX +{ +class GAL; +} + + +enum TEXT_STYLE +{ + BOLD = 1, + ITALIC = 1 << 1, + SUBSCRIPT = 1 << 2, + SUPERSCRIPT = 1 << 3, + OVERBAR = 1 << 4 +}; + + +using TEXT_STYLE_FLAGS = unsigned int; + + +inline bool IsBold( TEXT_STYLE_FLAGS aFlags ) +{ + return aFlags & TEXT_STYLE::BOLD; +} + + +inline bool IsItalic( TEXT_STYLE_FLAGS aFlags ) +{ + return aFlags & TEXT_STYLE::ITALIC; +} + + +inline bool IsSuperscript( TEXT_STYLE_FLAGS aFlags ) +{ + return aFlags & TEXT_STYLE::SUPERSCRIPT; +} + + +inline bool IsSubscript( TEXT_STYLE_FLAGS aFlags ) +{ + return aFlags & TEXT_STYLE::SUBSCRIPT; +} + + +inline bool IsOverbar( TEXT_STYLE_FLAGS aFlags ) +{ + return aFlags & TEXT_STYLE::OVERBAR; +} + + +std::string TextStyleAsString( TEXT_STYLE_FLAGS aFlags ); + + +namespace KIFONT +{ +/** + * FONT is an abstract base class for both outline and stroke fonts + */ +class FONT +{ +public: + explicit FONT(); + + virtual ~FONT() + { } + + virtual bool IsStroke() const { return false; } + virtual bool IsOutline() const { return false; } + virtual bool IsBold() const { return false; } + virtual bool IsItalic() const { return false; } + + const wxString& Name() const; + inline const char* NameAsToken() const { return Name().utf8_str().data(); } + +protected: + wxString m_fontName; ///< Font name + wxString m_fontFileName; ///< Font file name + +private: + static FONT* s_defaultFont; + static std::map s_fontMap; +}; +} //namespace KIFONT + + +inline std::ostream& operator<<(std::ostream& os, const KIFONT::FONT& aFont) +{ + os << "[Font \"" << aFont.Name() << "\"" << ( aFont.IsStroke() ? " stroke" : "" ) + << ( aFont.IsOutline() ? " outline" : "" ) << ( aFont.IsBold() ? " bold" : "" ) + << ( aFont.IsItalic() ? " italic" : "" ) << "]"; + return os; +} + + +inline std::ostream& operator<<(std::ostream& os, const KIFONT::FONT* aFont) +{ + os << *aFont; + return os; +} + +#endif // FONT_H_ diff --git a/include/gr_text.h b/include/gr_text.h index 76f88264e8..7a80af7cb5 100644 --- a/include/gr_text.h +++ b/include/gr_text.h @@ -101,6 +101,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool italic, b * for a bold text. * @param aItalic true to simulate an italic font. * @param aBold true to use a bold font. + * @param aFont is the font to use, or nullptr for the KiCad stroke font * @param aCallback ( int x0, int y0, int xf, int yf, void* aData ) is a function called * (if non null) to draw each segment. used to draw 3D texts or for plotting. * NULL for normal drawings. @@ -112,6 +113,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool italic, b void GRText( wxDC* aDC, const wxPoint& aPos, const KIGFX::COLOR4D& aColor, const wxString& aText, const EDA_ANGLE& aOrient, const wxSize& aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, + KIFONT::FONT* aFont, void (*aCallback)( int x0, int y0, int xf, int yf, void* aData ) = nullptr, void* aCallbackData = nullptr, PLOTTER* aPlotter = nullptr ); diff --git a/include/plotters/plotter.h b/include/plotters/plotter.h index 862159fd61..3c8a4ed70e 100644 --- a/include/plotters/plotter.h +++ b/include/plotters/plotter.h @@ -399,18 +399,19 @@ public: * For convenience it accept the color to use for specific plotters (GERBER) aData is used * to pass extra parameters. */ - virtual void Text( const wxPoint& aPos, - const COLOR4D& aColor, - const wxString& aText, - const EDA_ANGLE& aOrient, - const wxSize& aSize, - enum GR_TEXT_H_ALIGN_T aH_justify, - enum GR_TEXT_V_ALIGN_T aV_justify, - int aWidth, - bool aItalic, - bool aBold, - bool aMultilineAllowed = false, - void* aData = nullptr ); + virtual void Text( const wxPoint& aPos, + const COLOR4D& aColor, + const wxString& aText, + const EDA_ANGLE& aOrient, + const wxSize& aSize, + enum GR_TEXT_H_ALIGN_T aH_justify, + enum GR_TEXT_V_ALIGN_T aV_justify, + int aWidth, + bool aItalic, + bool aBold, + bool aMultilineAllowed = false, + KIFONT::FONT* aFont = nullptr, + void* aData = nullptr ); /** * Draw a marker (used for the drill map). diff --git a/include/plotters/plotter_dxf.h b/include/plotters/plotter_dxf.h index 489999255a..674819752d 100644 --- a/include/plotters/plotter_dxf.h +++ b/include/plotters/plotter_dxf.h @@ -149,18 +149,19 @@ public: virtual void FlashRegularPolygon( const wxPoint& aShapePos, int aDiameter, int aCornerCount, double aOrient, OUTLINE_MODE aTraceMode, void* aData ) override; - virtual void Text( const wxPoint& aPos, - const COLOR4D& aColor, - const wxString& aText, - const EDA_ANGLE& aOrient, - const wxSize& aSize, - enum GR_TEXT_H_ALIGN_T aH_justify, - enum GR_TEXT_V_ALIGN_T aV_justify, - int aWidth, - bool aItalic, - bool aBold, - bool aMultilineAllowed = false, - void* aData = nullptr ) override; + virtual void Text( const wxPoint& aPos, + const COLOR4D& aColor, + const wxString& aText, + const EDA_ANGLE& aOrient, + const wxSize& aSize, + enum GR_TEXT_H_ALIGN_T aH_justify, + enum GR_TEXT_V_ALIGN_T aV_justify, + int aWidth, + bool aItalic, + bool aBold, + bool aMultilineAllowed = false, + KIFONT::FONT* aFont = nullptr, + void* aData = nullptr ) override; /** diff --git a/include/plotters/plotter_gerber.h b/include/plotters/plotter_gerber.h index 1369181265..6e8b71c67f 100644 --- a/include/plotters/plotter_gerber.h +++ b/include/plotters/plotter_gerber.h @@ -99,18 +99,19 @@ public: virtual void PenTo( const wxPoint& pos, char plume ) override; - virtual void Text( const wxPoint& aPos, - const COLOR4D& aColor, - const wxString& aText, - const EDA_ANGLE& aOrient, - const wxSize& aSize, - enum GR_TEXT_H_ALIGN_T aH_justify, - enum GR_TEXT_V_ALIGN_T aV_justify, - int aWidth, - bool aItalic, - bool aBold, - bool aMultilineAllowed = false, - void* aData = nullptr ) override; + virtual void Text( const wxPoint& aPos, + const COLOR4D& aColor, + const wxString& aText, + const EDA_ANGLE& aOrient, + const wxSize& aSize, + enum GR_TEXT_H_ALIGN_T aH_justify, + enum GR_TEXT_V_ALIGN_T aV_justify, + int aWidth, + bool aItalic, + bool aBold, + bool aMultilineAllowed = false, + KIFONT::FONT* aFont = nullptr, + void* aData = nullptr ) override; /** * Filled circular flashes are stored as apertures diff --git a/include/plotters/plotters_pslike.h b/include/plotters/plotters_pslike.h index 880d4f3d9d..bb48e4341c 100644 --- a/include/plotters/plotters_pslike.h +++ b/include/plotters/plotters_pslike.h @@ -214,18 +214,19 @@ public: double aScaleFactor ) override; virtual void PenTo( const wxPoint& pos, char plume ) override; - virtual void Text( const wxPoint& aPos, - const COLOR4D& aColor, - const wxString& aText, - const EDA_ANGLE& aOrient, - const wxSize& aSize, - enum GR_TEXT_H_ALIGN_T aH_justify, - enum GR_TEXT_V_ALIGN_T aV_justify, - int aWidth, - bool aItalic, - bool aBold, - bool aMultilineAllowed = false, - void* aData = nullptr ) override; + virtual void Text( const wxPoint& aPos, + const COLOR4D& aColor, + const wxString& aText, + const EDA_ANGLE& aOrient, + const wxSize& aSize, + enum GR_TEXT_H_ALIGN_T aH_justify, + enum GR_TEXT_V_ALIGN_T aV_justify, + int aWidth, + bool aItalic, + bool aBold, + bool aMultilineAllowed = false, + KIFONT::FONT* aFont = nullptr, + void* aData = nullptr ) override; protected: virtual void emitSetRGBColor( double r, double g, double b ) override; @@ -331,18 +332,19 @@ public: virtual void PenTo( const wxPoint& pos, char plume ) override; - virtual void Text( const wxPoint& aPos, - const COLOR4D& aColor, - const wxString& aText, - const EDA_ANGLE& aOrient, - const wxSize& aSize, - enum GR_TEXT_H_ALIGN_T aH_justify, - enum GR_TEXT_V_ALIGN_T aV_justify, - int aWidth, - bool aItalic, - bool aBold, - bool aMultilineAllowed = false, - void* aData = nullptr ) override; + virtual void Text( const wxPoint& aPos, + const COLOR4D& aColor, + const wxString& aText, + const EDA_ANGLE& aOrient, + const wxSize& aSize, + enum GR_TEXT_H_ALIGN_T aH_justify, + enum GR_TEXT_V_ALIGN_T aV_justify, + int aWidth, + bool aItalic, + bool aBold, + bool aMultilineAllowed = false, + KIFONT::FONT* aFont = nullptr, + void* aData = nullptr ) override; /** * PDF images are handles as inline, not XObject streams... @@ -494,18 +496,19 @@ public: */ virtual void EndBlock( void* aData ) override; - virtual void Text( const wxPoint& aPos, - const COLOR4D& aColor, - const wxString& aText, - const EDA_ANGLE& aOrient, - const wxSize& aSize, - enum GR_TEXT_H_ALIGN_T aH_justify, - enum GR_TEXT_V_ALIGN_T aV_justify, - int aWidth, - bool aItalic, - bool aBold, - bool aMultilineAllowed = false, - void* aData = nullptr ) override; + virtual void Text( const wxPoint& aPos, + const COLOR4D& aColor, + const wxString& aText, + const EDA_ANGLE& aOrient, + const wxSize& aSize, + enum GR_TEXT_H_ALIGN_T aH_justify, + enum GR_TEXT_V_ALIGN_T aV_justify, + int aWidth, + bool aItalic, + bool aBold, + bool aMultilineAllowed = false, + KIFONT::FONT* aFont = nullptr, + void* aData = nullptr ) override; protected: /** diff --git a/pcbnew/fp_text.cpp b/pcbnew/fp_text.cpp index a6b2e83d9c..a2dd13ba02 100644 --- a/pcbnew/fp_text.cpp +++ b/pcbnew/fp_text.cpp @@ -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(), + GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold(), GetFont(), addTextSegmToPoly, &prms ); } diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index 64044c02ee..a03464812f 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -244,7 +244,7 @@ void PCB_TEXT::TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCorner COLOR4D color; // not actually used, but needed by GRText GRText( nullptr, GetTextPos(), color, GetShownText(), GetTextAngle(), size, GetHorizJustify(), - GetVertJustify(), penWidth, IsItalic(), IsBold(), addTextSegmToPoly, &prms ); + GetVertJustify(), penWidth, IsItalic(), IsBold(), GetFont(), addTextSegmToPoly, &prms ); } diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 2055dac31c..922bd55bfe 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -377,7 +377,7 @@ void BRDITEMS_PLOTTER::PlotBoardGraphicItems() } -void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aTextMod, const COLOR4D& aColor ) +void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aText, const COLOR4D& aColor ) { COLOR4D color = aColor; @@ -387,11 +387,11 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aTextMod, const COL m_plotter->SetColor( color ); // calculate some text parameters : - wxSize size = aTextMod->GetTextSize(); - wxPoint pos = aTextMod->GetTextPos(); - int thickness = aTextMod->GetEffectiveTextPenWidth(); + wxSize size = aText->GetTextSize(); + wxPoint pos = aText->GetTextPos(); + int thickness = aText->GetEffectiveTextPenWidth(); - if( aTextMod->IsMirrored() ) + if( aText->IsMirrored() ) size.x = -size.x; // Text is mirrored // Non bold texts thickness is clamped at 1/6 char size by the low level draw function. @@ -402,18 +402,18 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aTextMod, const COL GBR_METADATA gbr_metadata; - if( IsCopperLayer( aTextMod->GetLayer() ) ) + if( IsCopperLayer( aText->GetLayer() ) ) gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR ); gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP ); - const FOOTPRINT* parent = static_cast ( aTextMod->GetParent() ); + const FOOTPRINT* parent = static_cast ( aText->GetParent() ); gbr_metadata.SetCmpReference( parent->GetReference() ); m_plotter->SetCurrentLineWidth( thickness ); - m_plotter->Text( pos, aColor, aTextMod->GetShownText(), aTextMod->GetDrawRotation(), size, - aTextMod->GetHorizJustify(), aTextMod->GetVertJustify(), thickness, - aTextMod->IsItalic(), allow_bold, false, &gbr_metadata ); + m_plotter->Text( pos, aColor, aText->GetShownText(), aText->GetDrawRotation(), size, + aText->GetHorizJustify(), aText->GetVertJustify(), thickness, + aText->IsItalic(), allow_bold, false, aText->GetFont(), &gbr_metadata ); } @@ -783,14 +783,16 @@ 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, &gbr_metadata ); + aText->IsItalic(), allow_bold, false, aText->GetFont(), + &gbr_metadata ); } } else { m_plotter->Text( pos, color, shownText, aText->GetTextAngle(), size, aText->GetHorizJustify(), aText->GetVertJustify(), thickness, - aText->IsItalic(), allow_bold, false, &gbr_metadata ); + aText->IsItalic(), allow_bold, false, aText->GetFont(), + &gbr_metadata ); } }