Skip to content

Commit

Permalink
font sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Jan 9, 2024
1 parent b2e19c4 commit 95b5369
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 5 deletions.
1 change: 1 addition & 0 deletions sources/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ macro(cage_tests folder)
endmacro()

cage_tests("layouts/")
cage_tests("texts/")
cage_tests("widgets/")
cage_tests("")
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "gui.h"
#include "../gui.h"

#include <cage-core/string.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "gui.h"
#include "../gui.h"

#include <cage-core/color.h>

Expand Down
61 changes: 61 additions & 0 deletions sources/gui/texts/fontSizes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "../gui.h"

using namespace cage;

constexpr const char *fontNames[] = {
"cage-tests/gui/DroidSansMono.ttf",
"cage-tests/gui/immortal.ttf",
"cage-tests/gui/roboto.ttf",
"cage-tests/gui/asimov.otf",
"cage/font/ubuntu/regular.ttf",
"cage/font/ubuntu/bold.ttf",
"cage/font/ubuntu/italic.ttf",
"cage/font/ubuntu/monospace.ttf",
};
constexpr String labelTexts[] = {
"Droid Sans Mono",
"Immortal",
"Roboto",
"Asimov",
"Ubuntu Regular",
"Ubuntu Bold",
"Ubuntu Italic",
"Ubuntu Mono",
};
constexpr String multilineText = "lorem ipsum dolor sit amet\npříliš žluťoučký kůň úpěl ďábelské ódy\na quick brown fox jumps over a lazy dog\nhello world, foo, bar, baz\n\n";

const uint32 fontsCount = array_size(fontNames);
static_assert(array_size(fontNames) == array_size(labelTexts));

constexpr Real fontSizes[] = { 9, 11, 14, 18 };

class GuiTestImpl : public GuiTestClass
{
public:
void initialize() override
{
Holder g = newGuiBuilder(engineGuiEntities());
auto _1 = g->panel();
auto _2 = g->scrollbars();
auto _3 = g->alignment();
auto _4 = g->verticalTable(array_size(fontSizes) + 1);
{
g->label().text("");
for (Real size : fontSizes)
g->label().text(Stringizer() + size);
}
for (uint32 fontIndex = 0; fontIndex < fontsCount; fontIndex++)
{
g->label().text(labelTexts[fontIndex]);
for (Real size : fontSizes)
{
GuiTextFormatComponent f;
f.font = HashString(fontNames[fontIndex]);
f.size = size;
g->label().text(multilineText).textFormat(f);
}
}
}
};

MAIN(GuiTestImpl, "fonts sizes")
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "gui.h"
#include "../gui.h"

using namespace cage;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "gui.h"
#include "../gui.h"

// *************************************************************************
// This process may fail due to the text containing malformed utf-8 text.
Expand Down

0 comments on commit 95b5369

Please sign in to comment.