Add load system fonts experiment flag
This commit is contained in:
@@ -44,6 +44,10 @@ class ExperimentFlags {
|
||||
|
||||
// Use the new platform specific file dialog wrappers.
|
||||
bool kNewFileDialogWrapper = true;
|
||||
|
||||
// Platform specific loading of fonts from the system. Currently
|
||||
// only supports macOS.
|
||||
bool kLoadSystemFonts = true;
|
||||
};
|
||||
|
||||
ExperimentFlags() = default;
|
||||
|
||||
@@ -93,6 +93,9 @@
|
||||
ImGui::Text(text); \
|
||||
ImGui::Separator();
|
||||
|
||||
#define TABLE_BORDERS_RESIZABLE \
|
||||
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable
|
||||
|
||||
#define CLEAR_AND_RETURN_STATUS(status) \
|
||||
if (!status.ok()) { \
|
||||
auto temp = status; \
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "app/core/platform/font_loader.h"
|
||||
#include "app/editor/master_editor.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/style.h"
|
||||
@@ -212,7 +213,7 @@ absl::Status Controller::CreateRenderer() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Controller::CreateGuiContext() const {
|
||||
absl::Status Controller::CreateGuiContext() {
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
|
||||
@@ -228,6 +229,25 @@ absl::Status Controller::CreateGuiContext() const {
|
||||
ImGui_ImplSDL2_InitForSDLRenderer(window_.get(), renderer_.get());
|
||||
ImGui_ImplSDLRenderer2_Init(renderer_.get());
|
||||
|
||||
if (flags()->kLoadSystemFonts) {
|
||||
LoadSystemFonts();
|
||||
} else {
|
||||
LoadFontFamilies();
|
||||
}
|
||||
|
||||
// Set the default style
|
||||
gui::ColorsYaze();
|
||||
|
||||
// Build a new ImGui frame
|
||||
ImGui_ImplSDLRenderer2_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame(window_.get());
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Controller::LoadFontFamilies() const {
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
|
||||
// Define constants
|
||||
static const char *KARLA_REGULAR = "assets/font/Karla-Regular.ttf";
|
||||
static const char *ROBOTO_MEDIUM = "assets/font/Roboto-Medium.ttf";
|
||||
@@ -277,13 +297,6 @@ absl::Status Controller::CreateGuiContext() const {
|
||||
io.Fonts->GetGlyphRangesJapanese());
|
||||
}
|
||||
|
||||
// Set the default style
|
||||
gui::ColorsYaze();
|
||||
|
||||
// Build a new ImGui frame
|
||||
ImGui_ImplSDLRenderer2_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame(window_.get());
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ class Controller : public ExperimentFlags {
|
||||
|
||||
absl::Status CreateWindow();
|
||||
absl::Status CreateRenderer();
|
||||
absl::Status CreateGuiContext() const;
|
||||
absl::Status CreateGuiContext();
|
||||
absl::Status LoadFontFamilies() const;
|
||||
void CloseWindow() { active_ = false; }
|
||||
|
||||
friend int ::main(int argc, char **argv);
|
||||
|
||||
Reference in New Issue
Block a user