APIs for passing KIFONT::FONT pointers around.
Also some clean-up and bug fixes.
This commit is contained in:
parent
dd6cd7d184
commit
ccb94fd1a7
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -297,6 +297,7 @@ set( PLUGINS_EAGLE_SRCS
|
|||
)
|
||||
|
||||
set( FONT_SRCS
|
||||
font/font.cpp
|
||||
)
|
||||
|
||||
set( COMMON_SRCS
|
||||
|
|
|
@ -51,9 +51,9 @@
|
|||
#include <i18n_utility.h>
|
||||
#include <geometry/shape_segment.h>
|
||||
#include <geometry/shape_compound.h>
|
||||
#include <font/font.h>
|
||||
#include <geometry/shape_poly_set.h>
|
||||
|
||||
|
||||
#include <wx/debug.h> // for wxASSERT
|
||||
#include <wx/string.h> // wxString, wxArrayString
|
||||
#include <wx/gdicmn.h> // 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,9 +441,8 @@ void EDA_TEXT::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset,
|
|||
|
||||
void EDA_TEXT::GetLinePositions( std::vector<wxPoint>& 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.
|
||||
|
||||
|
@ -465,8 +465,7 @@ void EDA_TEXT::GetLinePositions( std::vector<wxPoint>& 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<wxPoint>& 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<wxPoint> 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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <core/wx_stl_compat.h>
|
||||
#include <font/font.h>
|
||||
|
||||
|
||||
using namespace KIFONT;
|
||||
|
||||
FONT* FONT::s_defaultFont = nullptr;
|
||||
std::map<wxString, FONT*> FONT::s_fontMap;
|
||||
|
||||
|
||||
FONT::FONT()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const wxString& FONT::Name() const
|
||||
{
|
||||
return m_fontName;
|
||||
}
|
||||
|
||||
|
|
@ -32,8 +32,8 @@
|
|||
#include <gr_basic.h>
|
||||
#include <plotters/plotter.h>
|
||||
#include <trigo.h>
|
||||
#include <base_screen.h>
|
||||
#include <math/util.h> // for KiROUND
|
||||
#include <font/font.h>
|
||||
|
||||
#include <basic_gal.h>
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -839,6 +839,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
|
|||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed,
|
||||
KIFONT::FONT* aFont,
|
||||
void* aData )
|
||||
{
|
||||
// Fix me: see how to use DXF text mode for multiline texts
|
||||
|
@ -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
|
||||
{
|
||||
|
|
|
@ -1934,6 +1934,7 @@ void GERBER_PLOTTER::Text( const wxPoint& aPos,
|
|||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed,
|
||||
KIFONT::FONT* aFont,
|
||||
void* aData )
|
||||
{
|
||||
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
|
||||
|
@ -1941,8 +1942,8 @@ void GERBER_PLOTTER::Text( const wxPoint& aPos,
|
|||
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 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -833,6 +833,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
|
|||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed,
|
||||
KIFONT::FONT* aFont,
|
||||
void* aData )
|
||||
{
|
||||
// PDF files do not like 0 sized texts which create broken files.
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -969,6 +969,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
|
|||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed,
|
||||
KIFONT::FONT* aFont,
|
||||
void* aData )
|
||||
{
|
||||
SetCurrentLineWidth( aWidth );
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -766,6 +766,7 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
|
|||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed,
|
||||
KIFONT::FONT* aFont,
|
||||
void* aData )
|
||||
{
|
||||
setFillMode( FILL_T::NO_FILL );
|
||||
|
@ -823,8 +824,8 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
|
|||
fprintf( m_outputFile, "<g class=\"stroked-text\"><desc>%s</desc>\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( "</g>", m_outputFile );
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -660,11 +660,12 @@ void PLOTTER::Text( const wxPoint& aPos,
|
|||
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 );
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ void LIB_FIELD::print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset,
|
|||
wxString text = aData ? *static_cast<wxString*>( aData ) : GetText();
|
||||
|
||||
GRText( DC, text_pos, color, text, GetTextAngle(), GetTextSize(), GetHorizJustify(),
|
||||
GetVertJustify(), penWidth, IsItalic(), IsBold() );
|
||||
GetVertJustify(), penWidth, IsItalic(), IsBold(), GetFont() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
@ -2946,8 +2947,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int
|
|||
}
|
||||
|
||||
|
||||
std::pair<wxPoint, wxSize> CADSTAR_SCH_ARCHIVE_LOADER::getFigureExtentsKiCad(
|
||||
const FIGURE& aCadstarFigure )
|
||||
std::pair<wxPoint, wxSize>
|
||||
CADSTAR_SCH_ARCHIVE_LOADER::getFigureExtentsKiCad( const FIGURE& aCadstarFigure )
|
||||
{
|
||||
wxPoint upperLeft( Assignments.Settings.DesignLimit.x, 0 );
|
||||
wxPoint lowerRight( 0, Assignments.Settings.DesignLimit.y );
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ); }
|
||||
|
|
|
@ -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 <iostream>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <wx/string.h>
|
||||
|
||||
#include <utf8.h>
|
||||
#include <font/text_attributes.h>
|
||||
|
||||
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<wxString, FONT*> 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_
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -410,6 +410,7 @@ public:
|
|||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed = false,
|
||||
KIFONT::FONT* aFont = nullptr,
|
||||
void* aData = nullptr );
|
||||
|
||||
/**
|
||||
|
|
|
@ -160,6 +160,7 @@ public:
|
|||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed = false,
|
||||
KIFONT::FONT* aFont = nullptr,
|
||||
void* aData = nullptr ) override;
|
||||
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ public:
|
|||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed = false,
|
||||
KIFONT::FONT* aFont = nullptr,
|
||||
void* aData = nullptr ) override;
|
||||
|
||||
/**
|
||||
|
|
|
@ -225,6 +225,7 @@ public:
|
|||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed = false,
|
||||
KIFONT::FONT* aFont = nullptr,
|
||||
void* aData = nullptr ) override;
|
||||
|
||||
protected:
|
||||
|
@ -342,6 +343,7 @@ public:
|
|||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed = false,
|
||||
KIFONT::FONT* aFont = nullptr,
|
||||
void* aData = nullptr ) override;
|
||||
|
||||
/**
|
||||
|
@ -505,6 +507,7 @@ public:
|
|||
bool aItalic,
|
||||
bool aBold,
|
||||
bool aMultilineAllowed = false,
|
||||
KIFONT::FONT* aFont = nullptr,
|
||||
void* aData = nullptr ) override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<const FOOTPRINT*> ( aTextMod->GetParent() );
|
||||
const FOOTPRINT* parent = static_cast<const FOOTPRINT*> ( 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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue