Added more options to font loading.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <fmt/format.h>
|
||||
#include <imgui.h>
|
||||
#include <mijin/async/coroutine.hpp>
|
||||
#include <mijin/util/bitflags.hpp>
|
||||
#include <mijin/virtual_filesystem/stacked.hpp>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
@@ -34,6 +35,19 @@ struct Message
|
||||
const char* text;
|
||||
};
|
||||
|
||||
struct FontFlags : mijin::BitFlags<FontFlags>
|
||||
{
|
||||
bool pixelSnapH : 1 = false;
|
||||
};
|
||||
|
||||
struct FontConfig
|
||||
{
|
||||
fs::path path;
|
||||
std::vector<std::pair<ImWchar, ImWchar>> glyphRanges;
|
||||
float size = 20.f;
|
||||
FontFlags flags;
|
||||
};
|
||||
|
||||
class Application
|
||||
{
|
||||
private:
|
||||
@@ -90,7 +104,13 @@ public:
|
||||
int run(int argc, char* argv[]);
|
||||
|
||||
[[nodiscard]]
|
||||
bool loadFont(const fs::path& path);
|
||||
bool loadFonts(std::span<const FontConfig> fonts);
|
||||
|
||||
[[nodiscard]]
|
||||
bool loadFont(const FontConfig& font)
|
||||
{
|
||||
return loadFonts({&font, 1});
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ImTextureID getOrLoadTexture(fs::path path);
|
||||
@@ -100,6 +120,7 @@ protected:
|
||||
virtual std::string getFolderName() = 0;
|
||||
virtual std::string getWindowTitle() = 0;
|
||||
virtual void configureImgui();
|
||||
virtual std::vector<FontConfig> getDefaultFonts();
|
||||
virtual void handleMessage(const Message& message);
|
||||
virtual void handleSDLEvent(const SDL_Event& event);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user