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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef GR_TEXT_H
22#define GR_TEXT_H
23
25#include <wx/gdicmn.h>
26
27class wxDC;
28
29
30namespace KIGFX
31{
32 class COLOR4D;
33}
34
35namespace KIFONT
36{
37 class METRICS;
38}
39
40class PLOTTER;
41
53int ClampTextPenSize( int aPenSize, int aSize, bool aStrict = false );
54float ClampTextPenSize( float aPenSize, int aSize, bool aStrict = false );
55int ClampTextPenSize( int aPenSize, const VECTOR2I& aSize, bool aStrict = false );
56
61int GetPenSizeForBold( int aTextSize );
62int GetPenSizeForBold( const wxSize& aTextSize );
63
68int GetPenSizeForDemiBold( int aTextSize );
69int GetPenSizeForDemiBold( const wxSize& aTextSize );
70
75int GetPenSizeForNormal( int aTextSize );
76int GetPenSizeForNormal( const wxSize& aTextSize );
77
78inline void InferBold( TEXT_ATTRIBUTES* aAttrs )
79{
80 int penSize( aAttrs->m_StrokeWidth );
81 wxSize textSize( aAttrs->m_Size.x, aAttrs->m_Size.y );
82
83 aAttrs->m_Bold = abs( penSize - GetPenSizeForBold( textSize ) )
84 < abs( penSize - GetPenSizeForNormal( textSize ) );
85}
86
87
91inline int GetKnockoutTextMargin( const VECTOR2I& aSize, int aThickness )
92{
93 return std::max( KiROUND( aThickness / 2.0 ), KiROUND( aSize.y / 9.0 ) );
94}
95
96
100int GRTextWidth( const wxString& aText, KIFONT::FONT* aFont, const VECTOR2I& aSize,
101 int aThickness, bool aBold, bool aItalic, const KIFONT::METRICS& aFontMetrics );
102
121void GRPrintText( wxDC* aDC, const VECTOR2I& aPos, const KIGFX::COLOR4D& aColor,
122 const wxString& aText, const EDA_ANGLE& aOrient, const VECTOR2I& aSize,
123 enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify,
124 int aWidth, bool aItalic, bool aBold, KIFONT::FONT* aFont,
125 const KIFONT::METRICS& aFontMetrics );
126
127
128#endif /* GR_TEXT_H */
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:986
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:94
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Base plotter engine class.
Definition plotter.h:133
int GetPenSizeForBold(int aTextSize)
Definition gr_text.cpp:33
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:113
void InferBold(TEXT_ATTRIBUTES *aAttrs)
Definition gr_text.h:78
int GetPenSizeForDemiBold(int aTextSize)
Definition gr_text.cpp:39
int GetPenSizeForNormal(int aTextSize)
Definition gr_text.cpp:57
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:95
int ClampTextPenSize(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:69
int GetKnockoutTextMargin(const VECTOR2I &aSize, int aThickness)
Return the margin for knocking out text.
Definition gr_text.h:91
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:29
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683