mirror of
https://gitlab.com/square-game-liberation-front/F.E.I.S.git
synced 2024-09-24 03:28: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 "chart_state.hpp"
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "editor_state.hpp"
|
#include "editor_state.hpp"
|
||||||
|
#include "error_messages.hpp"
|
||||||
#include "file_dialogs.hpp"
|
#include "file_dialogs.hpp"
|
||||||
#include "history_item.hpp"
|
#include "history_item.hpp"
|
||||||
#include "imgui_extras.hpp"
|
#include "imgui_extras.hpp"
|
||||||
@ -61,22 +62,25 @@ int main() {
|
|||||||
auto& style = ImGui::GetStyle();
|
auto& style = ImGui::GetStyle();
|
||||||
style.WindowRounding = 5.f;
|
style.WindowRounding = 5.f;
|
||||||
|
|
||||||
auto font_path = assets_folder / "fonts" / "NotoSans-Medium.ttf";
|
const auto default_font = assets_folder / "fonts" / "NotoSans-Medium.ttf";
|
||||||
if (not std::filesystem::exists(font_path)) {
|
crash_if_missing(default_font);
|
||||||
tinyfd_messageBox(
|
const auto japanese_font = assets_folder / "fonts" / "NotoSansJP-Medium.ttf";
|
||||||
"Error",
|
crash_if_missing(japanese_font);
|
||||||
("Could not open " + path_to_utf8_encoded_string(font_path)).c_str(),
|
|
||||||
"ok",
|
|
||||||
"error",
|
|
||||||
1);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ImGuiIO& IO = ImGui::GetIO();
|
ImGuiIO& IO = ImGui::GetIO();
|
||||||
IO.Fonts->Clear();
|
IO.Fonts->Clear();
|
||||||
IO.Fonts->AddFontFromFileTTF(
|
IO.Fonts->AddFontFromFileTTF(
|
||||||
path_to_utf8_encoded_string(assets_folder / "fonts" / "NotoSans-Medium.ttf")
|
path_to_utf8_encoded_string(default_font).c_str(),
|
||||||
.c_str(),
|
16.f
|
||||||
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();
|
ImGui::SFML::UpdateFontTexture();
|
||||||
|
|
||||||
IO.ConfigWindowsMoveFromTitleBarOnly = true;
|
IO.ConfigWindowsMoveFromTitleBarOnly = true;
|
||||||
|
@ -14,6 +14,7 @@ sources += files(
|
|||||||
'color.cpp',
|
'color.cpp',
|
||||||
'config.cpp',
|
'config.cpp',
|
||||||
'editor_state.cpp',
|
'editor_state.cpp',
|
||||||
|
'error_messages.cpp',
|
||||||
'file_dialogs.cpp',
|
'file_dialogs.cpp',
|
||||||
'guess_tempo.cpp',
|
'guess_tempo.cpp',
|
||||||
'history.cpp',
|
'history.cpp',
|
||||||
|
Loading…
Reference in New Issue
Block a user