diff options
author | inmarket <andrewh@inmarket.com.au> | 2015-11-22 18:42:11 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2015-11-22 18:42:11 +1000 |
commit | 0ec1a5e4da8815f6d7c31cf7941b76f3d9fd5e28 (patch) | |
tree | 9ccca9970133bf90d8f8979a7d250f6ce10c7e7d /tools/mcufontencoder/src/bdf_import.hh | |
parent | 3ae120406e1244d728276b2bcc74d03d1ccb230d (diff) | |
download | uGFX-0ec1a5e4da8815f6d7c31cf7941b76f3d9fd5e28.tar.gz uGFX-0ec1a5e4da8815f6d7c31cf7941b76f3d9fd5e28.tar.bz2 uGFX-0ec1a5e4da8815f6d7c31cf7941b76f3d9fd5e28.zip |
Add the mcufont encoder to the tools (including a win32 build) with binaries
Diffstat (limited to 'tools/mcufontencoder/src/bdf_import.hh')
-rw-r--r-- | tools/mcufontencoder/src/bdf_import.hh | 80 |
1 files changed, 80 insertions, 0 deletions
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<DataFile> LoadBDF(std::istream &file); + +} + +#ifdef CXXTEST_RUNNING +#include <cxxtest/TestSuite.h> + +using namespace mcufont; + +class BDFTests: public CxxTest::TestSuite +{ +public: + void testLoadBDF() + { + std::istringstream s(testfile); + std::unique_ptr<DataFile> 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 |