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
28#include <eda_item.h>
30
31namespace KIGFX
32{
33 class COLOR4D;
34}
35
36namespace KIFONT
37{
38 class METRICS;
39}
40
41class PLOTTER;
42
54int Clamp_Text_PenSize( int aPenSize, int aSize, bool aStrict = false );
55float Clamp_Text_PenSize( float aPenSize, int aSize, bool aStrict = false );
56int Clamp_Text_PenSize( int aPenSize, const VECTOR2I& aSize, bool aStrict = false );
57
62int GetPenSizeForBold( int aTextSize );
63int GetPenSizeForBold( const wxSize& aTextSize );
64
69int GetPenSizeForDemiBold( int aTextSize );
70int GetPenSizeForDemiBold( const wxSize& aTextSize );
71
76int GetPenSizeForNormal( int aTextSize );
77int GetPenSizeForNormal( const wxSize& aTextSize );
78
79inline void InferBold( TEXT_ATTRIBUTES* aAttrs )
80{
81 int penSize( aAttrs->m_StrokeWidth );
82 wxSize textSize( aAttrs->m_Size.x, aAttrs->m_Size.y );
83
84 aAttrs->m_Bold = abs( penSize - GetPenSizeForBold( textSize ) )
85 < abs( penSize - GetPenSizeForNormal( textSize ) );
86}
87
88
92inline int GetKnockoutTextMargin( const VECTOR2I& aSize, int aThickness )
93{
94 return std::max( KiROUND( aThickness / 2 ), KiROUND( aSize.y / 9.0 ) );
95}
96
97
101int GRTextWidth( const wxString& aText, KIFONT::FONT* aFont, const VECTOR2I& aSize,
102 int aThickness, bool aBold, bool aItalic, const KIFONT::METRICS& aFontMetrics );
103
122void GRPrintText( wxDC* aDC, const VECTOR2I& aPos, const KIGFX::COLOR4D& aColor,
123 const wxString& aText, const EDA_ANGLE& aOrient, const VECTOR2I& aSize,
124 enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify,
125 int aWidth, bool aItalic, bool aBold, KIFONT::FONT* aFont,
126 const KIFONT::METRICS& aFontMetrics );
127
128
129#endif /* GR_TEXT_H */
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:104
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:79
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:92
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
GR_TEXT_H_ALIGN_T
GR_TEXT_V_ALIGN_T
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:118