KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_kicad_stroke_font.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
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU 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
24
26
27// Code under test
28#include <vector>
29#include <font/stroke_font.h>
30
34BOOST_AUTO_TEST_SUITE( KicadStrokeFont )
35
36
37
41{
42 using CASE = std::pair<wxString, wxString>;
43
45
46 const std::vector<CASE> cases = {
47 { "v34_STM23G491\t\tController STM32\t(column 3)",
48 "v34_LPC1758\t\t\tController NXP\t\t(column 3)" },
49 { "1\td9c1892a\t\t\tMOLEX\t\t\t1053071202\t\t\t\t\t12\t\tCONNECTOR",
50 "REF\tPART NUMBER\t\t\tMANUFACTURER\tMANUFACTURER PART NUMBER\tQTY\t\tCONNECTOR" },
51 { "5\tC-000208\t\t\tMCMASTER/CARR\t8054T13 BLUE\t\t\t\t3960MM\tCONNECTOR",
52 "REF\tPART NUMBER\t\t\tMANUFACTURER\tMANUFACTURER PART NUMBER\tQTY\t\tCONNECTOR" },
53 { "0\t\t\t\tlinvA\t\t\tL",
54 "3\t\t\t\tlloadA\t\t\tL" },
55 { "6\t\t\t\tVpccA\t\t\tL",
56 "14\t\t\t\t--\t\t\t\tL" },
57 };
58
59 for( const auto& c : cases )
60 {
61 std::vector<std::unique_ptr<KIFONT::GLYPH>> glyphs;
62 BOX2I bbox;
63 wxString text1 = wxString::Format( c.first );
64 wxString text2 = wxString::Format( c.second );
65
66 VECTOR2I output1 = font->GetTextAsGlyphs( &bbox, &glyphs, text1,
67 VECTOR2I( 1000, 1000 ), VECTOR2I( 0, 0 ), ANGLE_0, false,
68 VECTOR2I( 0, 0 ), 0 );
69 VECTOR2I output2 = font->GetTextAsGlyphs( &bbox, &glyphs, text2,
70 VECTOR2I( 1000, 1000 ), VECTOR2I( 0, 0 ), ANGLE_0, false,
71 VECTOR2I( 0, 0 ), 0 );
72
73 BOOST_CHECK_MESSAGE( output1.x == output2.x, "Incorrect tab size for \n\t'" <<
74 text1.ToStdString() << "' and\n\t'" << text2.ToStdString() << "'" );
75 }
76
77 delete font;
78}
79
80
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
Implement a stroke font drawing.
Definition stroke_font.h:50
static STROKE_FONT * LoadFont(const wxString &aFontName)
Load a stroke font.
VECTOR2I GetTextAsGlyphs(BOX2I *aBoundingBox, std::vector< std::unique_ptr< GLYPH > > *aGlyphs, const wxString &aText, const VECTOR2I &aSize, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle, bool aMirror, const VECTOR2I &aOrigin, TEXT_STYLE_FLAGS aTextStyle) const override
Convert text string to an array of GLYPHs.
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:411
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683