KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gr_text.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2009-2014 Jerry Jacobs
5 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef GR_TEXT_H
26#define GR_TEXT_H
27
29#include <wx/gdicmn.h>
30
31class wxDC;
32
33
34namespace KIGFX
35{
36 class COLOR4D;
37}
38
39namespace KIFONT
40{
41 class METRICS;
42}
43
44class PLOTTER;
45
57int Clamp_Text_PenSize( int aPenSize, int aSize, bool aStrict = false );
58float Clamp_Text_PenSize( float aPenSize, int aSize, bool aStrict = false );
59int Clamp_Text_PenSize( int aPenSize, const VECTOR2I& aSize, bool aStrict = false );
60
65int GetPenSizeForBold( int aTextSize );
66int GetPenSizeForBold( const wxSize& aTextSize );
67
72int GetPenSizeForDemiBold( int aTextSize );
73int GetPenSizeForDemiBold( const wxSize& aTextSize );
74
79int GetPenSizeForNormal( int aTextSize );
80int GetPenSizeForNormal( const wxSize& aTextSize );
81
82inline void InferBold( TEXT_ATTRIBUTES* aAttrs )
83{
84 int penSize( aAttrs->m_StrokeWidth );
85 wxSize textSize( aAttrs->m_Size.x, aAttrs->m_Size.y );
86
87 aAttrs->m_Bold = abs( penSize - GetPenSizeForBold( textSize ) )
88 < abs( penSize - GetPenSizeForNormal( textSize ) );
89}
90
91
95inline int GetKnockoutTextMargin( const VECTOR2I& aSize, int aThickness )
96{
97 return std::max( KiROUND( aThickness / 2 ), KiROUND( aSize.y / 9.0 ) );
98}
99
100
104int GRTextWidth( const wxString& aText, KIFONT::FONT* aFont, const VECTOR2I& aSize,
105 int aThickness, bool aBold, bool aItalic, const KIFONT::METRICS& aFontMetrics );
106
125void GRPrintText( wxDC* aDC, const VECTOR2I& aPos, const KIGFX::COLOR4D& aColor,
126 const wxString& aText, const EDA_ANGLE& aOrient, const VECTOR2I& aSize,
127 enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify,
128 int aWidth, bool aItalic, bool aBold, KIFONT::FONT* aFont,
129 const KIFONT::METRICS& aFontMetrics );
130
131
132#endif /* GR_TEXT_H */
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Base plotter engine class.
Definition: plotter.h:105
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aStrict=false)
Pen width should not allow characters to become cluttered up in their own fatness.
Definition: gr_text.cpp:87
int GetPenSizeForBold(int aTextSize)
Definition: gr_text.cpp:40
void GRPrintText(wxDC *aDC, const VECTOR2I &aPos, const KIGFX::COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &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, const KIFONT::METRICS &aFontMetrics)
Print a graphic text through wxDC.
Definition: gr_text.cpp:142
void InferBold(TEXT_ATTRIBUTES *aAttrs)
Definition: gr_text.h:82
int GetPenSizeForDemiBold(int aTextSize)
Definition: gr_text.cpp:46
int GetPenSizeForNormal(int aTextSize)
Definition: gr_text.cpp:64
int GRTextWidth(const wxString &aText, KIFONT::FONT *aFont, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic, const KIFONT::METRICS &aFontMetrics)
Definition: gr_text.cpp:113
int GetKnockoutTextMargin(const VECTOR2I &aSize, int aThickness)
Returns the margin for knocking out text.
Definition: gr_text.h:95
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
GR_TEXT_H_ALIGN_T
GR_TEXT_V_ALIGN_T