mirror of
https://gitlab.com/square-game-liberation-front/F.E.I.S.git
synced 2024-09-23 19:18:28 +02:00
Add support for japanese text
This commit is contained in:
parent
544534d130
commit
8845c71a0a
BIN
assets/fonts/NotoSansJP-Medium.ttf
Normal file
BIN
assets/fonts/NotoSansJP-Medium.ttf
Normal file
Binary file not shown.
19
src/error_messages.cpp
Normal file
19
src/error_messages.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "error_messages.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <tinyfiledialogs.h>
|
||||
|
||||
#include "utf8_strings.hpp"
|
||||
|
||||
void crash_if_missing(const std::filesystem::path& file) {
|
||||
if (not std::filesystem::exists(file)) {
|
||||
tinyfd_messageBox(
|
||||
"Error",
|
||||
("Could not find " + path_to_utf8_encoded_string(file)).c_str(),
|
||||
"ok",
|
||||
"error",
|
||||
1);
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
5
src/error_messages.hpp
Normal file
5
src/error_messages.hpp
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
void crash_if_missing(const std::filesystem::path& file);
|
30
src/main.cpp
30
src/main.cpp
@ -28,6 +28,7 @@
|
||||
#include "chart_state.hpp"
|
||||
#include "config.hpp"
|
||||
#include "editor_state.hpp"
|
||||
#include "error_messages.hpp"
|
||||
#include "file_dialogs.hpp"
|
||||
#include "history_item.hpp"
|
||||
#include "imgui_extras.hpp"
|
||||
@ -61,22 +62,25 @@ int main() {
|
||||
auto& style = ImGui::GetStyle();
|
||||
style.WindowRounding = 5.f;
|
||||
|
||||
auto font_path = assets_folder / "fonts" / "NotoSans-Medium.ttf";
|
||||
if (not std::filesystem::exists(font_path)) {
|
||||
tinyfd_messageBox(
|
||||
"Error",
|
||||
("Could not open " + path_to_utf8_encoded_string(font_path)).c_str(),
|
||||
"ok",
|
||||
"error",
|
||||
1);
|
||||
return -1;
|
||||
}
|
||||
const auto default_font = assets_folder / "fonts" / "NotoSans-Medium.ttf";
|
||||
crash_if_missing(default_font);
|
||||
const auto japanese_font = assets_folder / "fonts" / "NotoSansJP-Medium.ttf";
|
||||
crash_if_missing(japanese_font);
|
||||
ImGuiIO& IO = ImGui::GetIO();
|
||||
IO.Fonts->Clear();
|
||||
IO.Fonts->AddFontFromFileTTF(
|
||||
path_to_utf8_encoded_string(assets_folder / "fonts" / "NotoSans-Medium.ttf")
|
||||
.c_str(),
|
||||
16.f);
|
||||
path_to_utf8_encoded_string(default_font).c_str(),
|
||||
16.f
|
||||
);
|
||||
ImFontConfig font_config;
|
||||
font_config.MergeMode = true;
|
||||
IO.Fonts->AddFontFromFileTTF(
|
||||
path_to_utf8_encoded_string(japanese_font).c_str(),
|
||||
16.0f,
|
||||
&font_config,
|
||||
IO.Fonts->GetGlyphRangesJapanese()
|
||||
);
|
||||
IO.Fonts->Build();
|
||||
ImGui::SFML::UpdateFontTexture();
|
||||
|
||||
IO.ConfigWindowsMoveFromTitleBarOnly = true;
|
||||
|
@ -14,6 +14,7 @@ sources += files(
|
||||
'color.cpp',
|
||||
'config.cpp',
|
||||
'editor_state.cpp',
|
||||
'error_messages.cpp',
|
||||
'file_dialogs.cpp',
|
||||
'guess_tempo.cpp',
|
||||
'history.cpp',
|
||||
|
Loading…
Reference in New Issue
Block a user