KiCad PCB EDA Suite
Loading...
Searching...
No Matches
text_attributes.cpp
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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21#include <font/outline_font.h>
22
23
25 m_Font( aFont ),
29 m_LineSpacing( 1.0 ),
30 m_StrokeWidth( 0 ),
31 m_Italic( false ),
32 m_Bold( false ),
33 m_Underlined( false ),
34 m_Hover( false ),
36 m_Mirrored( false ),
37 m_Multiline( true ),
38 m_KeepUpright( false ),
40{
41}
42
43
45{
46 wxString fontName;
47
48 if( m_Font )
49 fontName = m_Font->GetName();
50
51 wxString rhsFontName;
52
53 if( aRhs.m_Font )
54 rhsFontName = aRhs.m_Font->GetName();
55
56 int retv = fontName.Cmp( rhsFontName );
57
58 if( retv )
59 return retv;
60
61 if( m_Size.x != aRhs.m_Size.x )
62 return m_Size.x - aRhs.m_Size.x;
63
64 if( m_Size.y != aRhs.m_Size.y )
65 return m_Size.y - aRhs.m_Size.y;
66
67 if( m_StrokeWidth != aRhs.m_StrokeWidth )
68 return m_StrokeWidth - aRhs.m_StrokeWidth;
69
70 if( m_Angle.AsDegrees() != aRhs.m_Angle.AsDegrees() )
71 return m_Angle.AsDegrees() < aRhs.m_Angle.AsDegrees() ? -1 : 1;
72
73 if( m_LineSpacing != aRhs.m_LineSpacing )
74 return m_LineSpacing < aRhs.m_LineSpacing ? -1 : 1;
75
76 if( m_Halign != aRhs.m_Halign )
77 return m_Halign - aRhs.m_Halign;
78
79 if( m_Valign != aRhs.m_Valign )
80 return m_Valign - aRhs.m_Valign;
81
82 if( m_Italic != aRhs.m_Italic )
83 return m_Italic - aRhs.m_Italic;
84
85 if( m_Bold != aRhs.m_Bold )
86 return m_Bold - aRhs.m_Bold;
87
88 if( m_Underlined != aRhs.m_Underlined )
89 return m_Underlined - aRhs.m_Underlined;
90
91 retv = m_Color.Compare( aRhs.m_Color );
92
93 if( retv )
94 return retv;
95
96 if( m_Mirrored != aRhs.m_Mirrored )
97 return m_Mirrored - aRhs.m_Mirrored;
98
99 if( m_Multiline != aRhs.m_Multiline )
100 return m_Multiline - aRhs.m_Multiline;
101
102 return m_KeepUpright - aRhs.m_KeepUpright;
103}
104
105
106std::ostream& operator<<( std::ostream& aStream, const TEXT_ATTRIBUTES& aAttributes )
107{
108 aStream << "Font: \"";
109
110 if ( aAttributes.m_Font )
111 aStream << *aAttributes.m_Font;
112 else
113 aStream << "UNDEFINED";
114
115 aStream << "\"\n";
116 aStream << "Horizontal Alignment: " << aAttributes.m_Halign << std::endl
117 << "Vertical Alignment: " << aAttributes.m_Valign << std::endl
118 << "Angle: " << aAttributes.m_Angle << std::endl
119 << "Line Spacing: " << aAttributes.m_LineSpacing << std::endl
120 << "Stroke Width: " << aAttributes.m_StrokeWidth << std::endl
121 << "Italic: " << aAttributes.m_Italic << std::endl
122 << "Bold: " << aAttributes.m_Bold << std::endl
123 << "Underline: " << aAttributes.m_Underlined << std::endl
124 << "Color: " << aAttributes.m_Color << std::endl
125 << "Mirrored " << aAttributes.m_Mirrored << std::endl
126 << "Multilined: " << aAttributes.m_Multiline << std::endl
127 << "Size: " << aAttributes.m_Size << std::endl
128 << "Keep Upright: " << aAttributes.m_KeepUpright << std::endl;
129
130 return aStream;
131}
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
double AsDegrees() const
Definition eda_angle.h:116
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:131
const wxString & GetName() const
Definition font.h:149
KIGFX::COLOR4D m_Color
TEXT_ATTRIBUTES(KIFONT::FONT *aFont=nullptr)
int Compare(const TEXT_ATTRIBUTES &aRhs) const
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
KIFONT::FONT * m_Font
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:411
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:33
std::ostream & operator<<(std::ostream &aStream, const TEXT_ATTRIBUTES &aAttributes)
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_CENTER