add: Rect font rendering

This commit is contained in:
Simon Hardt
2022-03-05 23:06:10 +01:00
parent 0fe1509c6c
commit e1e410561c
5 changed files with 151 additions and 6 deletions

View File

@@ -82,14 +82,88 @@ int main()
pos.y += font->getHeight(text, 250) / 2;
pos.y -= font->getMaxYOffset(text, 250) + font->getHeight(text, 250);
target.DrawText(text, pos, *font, 250);
// target.DrawTextGlyphBounds(text, pos, *font, 250);
// target.DrawLine({0, (int32_t)pos.y},
// {(int32_t)display->getSize().width, pos.y});
target.DrawTextGlyphBounds(text, pos, *font, 250);
target.DrawLine({0, (int32_t)pos.y},
{(int32_t)display->getSize().width, pos.y});
auto rect = frame::Rect{0,
0,
(int)display->getSize().width,
(int)display->getSize().height};
target.DrawText(rect, text, *font, 250);
display->Display(target.getImage());
std::this_thread::sleep_for(2s);
std::this_thread::sleep_for(10s);
target.Clear();
target.DrawText(rect, text, *font, 250, frame::AlignHorizontal::CENTER);
display->Display(target.getImage());
std::this_thread::sleep_for(2s);
target.Clear();
target.DrawText(rect, text, *font, 250, frame::AlignHorizontal::RIGHT);
display->Display(target.getImage());
std::this_thread::sleep_for(2s);
target.Clear();
target.DrawText(rect,
text,
*font,
250,
frame::AlignHorizontal::LEFT,
frame::AlignVertical::CENTER);
display->Display(target.getImage());
std::this_thread::sleep_for(2s);
target.Clear();
target.DrawText(rect,
text,
*font,
250,
frame::AlignHorizontal::CENTER,
frame::AlignVertical::CENTER);
display->Display(target.getImage());
std::this_thread::sleep_for(2s);
target.Clear();
target.DrawText(rect,
text,
*font,
250,
frame::AlignHorizontal::RIGHT,
frame::AlignVertical::CENTER);
display->Display(target.getImage());
std::this_thread::sleep_for(2s);
target.Clear();
target.DrawText(rect,
text,
*font,
250,
frame::AlignHorizontal::LEFT,
frame::AlignVertical::BOTTOM);
display->Display(target.getImage());
std::this_thread::sleep_for(2s);
target.Clear();
target.DrawText(rect,
text,
*font,
250,
frame::AlignHorizontal::CENTER,
frame::AlignVertical::BOTTOM);
display->Display(target.getImage());
std::this_thread::sleep_for(2s);
target.Clear();
target.DrawText(rect,
text,
*font,
250,
frame::AlignHorizontal::RIGHT,
frame::AlignVertical::BOTTOM);
display->Display(target.getImage());
std::this_thread::sleep_for(2s);
display->Clear(frame::display::Color::WHITE);
}