#include #include #include #include #include using namespace monoformat; constexpr static std::uint16_t const ScreenWidth = 120; constexpr static std::uint16_t const ScreenHeight = 60; int main() { auto fontData = findEmbeddedFont("NokiaSmallPlain_tf"); if (!fontData.size()) { std::cerr << "Error loading font!\n" << std::flush; return 1; } auto fontData2 = findEmbeddedFont("5x7_mf"); if (!fontData2.size()) { std::cerr << "Error loading font!\n" << std::flush; return 1; } std::vector memory; memory.resize((ScreenWidth * ScreenHeight + 7) / 8); MemoryOneBitBuffer screen{memory, ScreenWidth, ScreenHeight}; auto renderer = FontRenderer{fontData}.withIgnoreUnknownChars(true); auto ret = renderer.render("Hallo Welt! ggg äöüß é è ê", {0, renderer.lineHeight() - 1}, screen, true, false); if (!ret) { std::cerr << "Error rendering.\n" << std::flush; return 2; } auto renderer2 = FontRenderer{fontData2}.withIgnoreUnknownChars(true); ret = renderer2.render("Hallo2", {0, renderer2.lineHeight() - 1 + renderer.lineHeight()}, screen, true, false); if (!ret) { std::cerr << "Error rendering.\n" << std::flush; return 2; } std::cerr << "Bbox height: " << ret->boundingBox->size.height << std::endl; std::uint16_t const w = ScreenWidth; std::uint16_t const h = ScreenHeight / 2; std::ostringstream buf; buf << "\xE2\x94\x8C"; for (std::uint16_t i = 0; i < w; ++i) { buf << "\xE2\x94\x80"; } buf << "\xE2\x94\x90\n"; for (std::uint16_t y = 0; y < h; ++y) { buf << "\xE2\x94\x82"; for (std::uint16_t x = 0; x < w; ++x) { bool const pxUpperSet = screen.isPixelSet(x, 2 * y + 0); bool const pxLowerSet = screen.isPixelSet(x, 2 * y + 1); if (pxUpperSet && pxLowerSet) { buf << "\xE2\x96\x88"; } else if (pxUpperSet) { buf << "\xF0\x9F\xAC\x8E"; } else if (pxLowerSet) { buf << "\xE2\x96\x84"; } else { buf << " "; } } buf << "\xE2\x94\x82\n"; } if (ScreenHeight % 1) { buf << "\xE2\x94\x82"; for (std::uint16_t x = 0; x < w; ++x) { bool const pxUpperSet = screen.isPixelSet(x, ScreenHeight - 1); if (pxUpperSet) { buf << "\xF0\x9F\xAC\x8E"; } else { buf << " "; } } buf << "\xE2\x94\x82\n"; } buf << "\xE2\x94\x94"; for (std::uint16_t i = 0; i < w; ++i) { buf << "\xE2\x94\x80"; } buf << "\xE2\x94\x98\n"; std::cout << buf.str(); return 0; }