Added memory FS and put the default font there so it is easier to load it.

This commit is contained in:
2025-03-28 11:48:16 +01:00
parent 6cf748b05d
commit 63fcb6181f
11 changed files with 341 additions and 96 deletions

View File

@@ -3,11 +3,18 @@ import json
Import('env')
if not hasattr(env, 'Jinja'):
env.Error('RAID requires the Jinja tool.')
src_files = Split("""
application.cpp
fonts.gen.cpp
stb_image.cpp
""")
env.Jinja("fonts.gen.cpp")
env.Jinja("fonts.gen.hpp")
with open('../../dependencies.json', 'r') as f:
dependencies = env.DepsFromJson(json.load(f))

View File

@@ -16,6 +16,7 @@
#include <backends/imgui_impl_opengl3.h>
#include <backends/imgui_impl_sdl3.h>
#include <stb_image.h>
#include "./fonts.gen.hpp"
namespace raid
{
@@ -242,7 +243,7 @@ void Application::configureImgui()
std::vector<FontConfig> Application::getDefaultFonts()
{
return {{
.path = "/data/fonts/NotoSans-Regular.ttf"
.path = DEFAULT_FONT_PATH
}};
}
@@ -295,6 +296,9 @@ bool Application::init()
);
};
mMemoryFS = mFS.emplaceAdapter<mijin::MemoryFileSystemAdapter>();
mMemoryFS->addFile(DEFAULT_FONT_PATH, NOTO_SANS_DATA);
addConfigDir(mijin::getKnownFolder(mijin::KnownFolder::USER_CONFIG_ROOT) / getFolderName());
addDataDir(mijin::getKnownFolder(mijin::KnownFolder::USER_DATA_ROOT) / getFolderName());

View File

@@ -0,0 +1,7 @@
#include "./fonts.gen.hpp"
namespace raid
{
extern const std::array<std::uint8_t, NOTO_SANS_SIZE> NOTO_SANS_DATA = { {{ file_content_hex('#res/fonts/NotoSans-Regular.ttf') }} };
}

View File

@@ -0,0 +1,16 @@
#pragma once
#if !defined(RAID_PRIVATE_RAID_FONTS_GEN_HPP_INCLUDED)
#define RAID_PRIVATE_RAID_FONTS_GEN_HPP_INCLUDED 1
#include <array>
#include <cstdint>
namespace raid
{
inline constexpr std::size_t NOTO_SANS_SIZE = {{ file_size('#res/fonts/NotoSans-Regular.ttf' )}};
extern const std::array<std::uint8_t, NOTO_SANS_SIZE> NOTO_SANS_DATA;
} // namespace raid
#endif // !defined(RAID_PRIVATE_RAID_FONTS_GEN_HPP_INCLUDED)