KiCad PCB EDA Suite
Loading...
Searching...
No Matches
legacy_text_format.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 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
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <eda_text.h>
23#include <font/font.h>
24#include <math/util.h>
25
26namespace KICAD_FORMAT
27{
28
29inline int GetLegacyTextThickness( const EDA_TEXT& aText )
30{
31 const int thickness = aText.GetTextThickness();
32
33 if( !aText.IsBold() || thickness <= 1 )
34 return thickness;
35
36 bool strokeFont = true;
37
38 if( const KIFONT::FONT* font = aText.GetFont() )
39 strokeFont = font->IsStroke();
40 else if( !aText.GetUnresolvedFontName().IsEmpty() )
41 strokeFont = KIFONT::FONT::IsStroke( aText.GetUnresolvedFontName() );
42
43 return strokeFont ? KiROUND( thickness * 1.6 ) : thickness;
44}
45
46} // namespace KICAD_FORMAT
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:982
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:94
KIFONT::FONT * GetFont() const
Definition eda_text.h:286
wxString GetUnresolvedFontName() const
Definition eda_text.h:289
bool IsBold() const
Definition eda_text.h:215
virtual int GetTextThickness() const
Definition eda_text.h:159
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:94
virtual bool IsStroke() const
Definition font.h:101
int GetLegacyTextThickness(const EDA_TEXT &aText)