From 0ec1a5e4da8815f6d7c31cf7941b76f3d9fd5e28 Mon Sep 17 00:00:00 2001 From: inmarket Date: Sun, 22 Nov 2015 18:42:11 +1000 Subject: Add the mcufont encoder to the tools (including a win32 build) with binaries --- tools/mcufontencoder/src/bdf_import.hh | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 tools/mcufontencoder/src/bdf_import.hh (limited to 'tools/mcufontencoder/src/bdf_import.hh') diff --git a/tools/mcufontencoder/src/bdf_import.hh b/tools/mcufontencoder/src/bdf_import.hh new file mode 100644 index 00000000..d94103e5 --- /dev/null +++ b/tools/mcufontencoder/src/bdf_import.hh @@ -0,0 +1,80 @@ +// Function for importing .BDF fonts as data files. + +#pragma once +#include "datafile.hh" + +namespace mcufont +{ + +std::unique_ptr LoadBDF(std::istream &file); + +} + +#ifdef CXXTEST_RUNNING +#include + +using namespace mcufont; + +class BDFTests: public CxxTest::TestSuite +{ +public: + void testLoadBDF() + { + std::istringstream s(testfile); + std::unique_ptr f = LoadBDF(s); + + TS_ASSERT_EQUALS(f->GetFontInfo().name, "-Misc-Fixed-Medium-R-Normal--14-130-75-75-C-70-ISO8859-15"); + TS_ASSERT_EQUALS(f->GetFontInfo().max_width, 6); + TS_ASSERT_EQUALS(f->GetFontInfo().max_height, 11); + TS_ASSERT_EQUALS(f->GetGlyphCount(), 1); + TS_ASSERT_EQUALS(f->GetGlyphEntry(0).chars.size(), 2); + } + +private: + static constexpr const char *testfile = + "STARTFONT 2.1\n" + "FONT -Misc-Fixed-Medium-R-Normal--14-130-75-75-C-70-ISO8859-15\n" + "FONTBOUNDINGBOX 7 14 0 -2\n" + "STARTCHAR defaultchar\n" + "ENCODING 0\n" + "DWIDTH 7 0\n" + "BBX 7 14 0 -2\n" + "BITMAP\n" + "00\n" + "B4\n" + "84\n" + "00\n" + "84\n" + "84\n" + "00\n" + "84\n" + "84\n" + "00\n" + "84\n" + "B4\n" + "00\n" + "00\n" + "ENDCHAR\n" + "STARTCHAR copychar\n" + "ENCODING 2\n" + "DWIDTH 7 0\n" + "BBX 7 14 0 -2\n" + "BITMAP\n" + "00\n" + "B4\n" + "84\n" + "00\n" + "84\n" + "84\n" + "00\n" + "84\n" + "84\n" + "00\n" + "84\n" + "B4\n" + "00\n" + "00\n" + "ENDCHAR\n"; + +}; +#endif -- cgit v1.2.3