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 (C) 2018, 2023 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
30
31// Code under test
32#include <vector>
33#include <font/stroke_font.h>
34
38BOOST_AUTO_TEST_SUITE( KicadStrokeFont )
39
40
41
45{
46 using CASE = std::pair<wxString, wxString>;
47
49
50 const std::vector<CASE> cases = {
51 { "v34_STM23G491\t\tController STM32\t(column 3)",
52 "v34_LPC1758\t\t\tController NXP\t\t(column 3)" },
53 { "1\td9c1892a\t\t\tMOLEX\t\t\t1053071202\t\t\t\t\t12\t\tCONNECTOR",
54 "REF\tPART NUMBER\t\t\tMANUFACTURER\tMANUFACTURER PART NUMBER\tQTY\t\tCONNECTOR" },
55 { "5\tC-000208\t\t\tMCMASTER/CARR\t8054T13 BLUE\t\t\t\t3960MM\tCONNECTOR",
56 "REF\tPART NUMBER\t\t\tMANUFACTURER\tMANUFACTURER PART NUMBER\tQTY\t\tCONNECTOR" },
57 { "0\t\t\t\tlinvA\t\t\tL",
58 "3\t\t\t\tlloadA\t\t\tL" },
59 { "6\t\t\t\tVpccA\t\t\tL",
60 "14\t\t\t\t--\t\t\t\tL" },
61 };
62
63 for( const auto& c : cases )
64 {
65 std::vector<std::unique_ptr<KIFONT::GLYPH>> glyphs;
66 BOX2I bbox;
67 wxString text1 = wxString::Format( c.first );
68 wxString text2 = wxString::Format( c.second );
69
70 VECTOR2I output1 = font->GetTextAsGlyphs( &bbox, &glyphs, text1,
71 VECTOR2I( 1000, 1000 ), VECTOR2I( 0, 0 ), ANGLE_0, false,
72 VECTOR2I( 0, 0 ), 0 );
73 VECTOR2I output2 = font->GetTextAsGlyphs( &bbox, &glyphs, text2,
74 VECTOR2I( 1000, 1000 ), VECTOR2I( 0, 0 ), ANGLE_0, false,
75 VECTOR2I( 0, 0 ), 0 );
76
77 BOOST_CHECK_MESSAGE( output1.x == output2.x, "Incorrect tab size for \n\t'" <<
78 text1.ToStdString() << "' and\n\t'" << text2.ToStdString() << "'" );
79 }
80
81 delete font;
82}
83
84
Implement a stroke font drawing.
Definition: stroke_font.h:54
static STROKE_FONT * LoadFont(const wxString &aFontName)
Load a stroke font.
Definition: stroke_font.cpp:65
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:401
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(TabCheck)
Declare the test suite.
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691