From 7c3b90eb9834ae605c679be2c240d36715225acc Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 16 Mar 2024 18:33:49 +0100 Subject: locale loading unix --- src/unix/main_unix.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/unix/main_unix.cpp') diff --git a/src/unix/main_unix.cpp b/src/unix/main_unix.cpp index 0c58d02..ef8dd88 100644 --- a/src/unix/main_unix.cpp +++ b/src/unix/main_unix.cpp @@ -8,6 +8,7 @@ #include "array.h" #include "memory_bucket.h" #include "image.h" +#include "fonts.h" #include "config.h" #include #include @@ -15,6 +16,7 @@ #include #include #include +#include #define GL_SILENCE_DEPRECATION #if defined(IMGUI_IMPL_OPENGL_ES2) #include @@ -69,6 +71,22 @@ static void drop_callback(GLFWwindow* window, int count, const char** paths) } } +ts_font_range _ts_get_font_range_to_load() { + wchar_t buffer[50] = {0}; + char* ll = setlocale(LC_ALL, NULL); + mbstowcs (buffer, ll, 50); + + wchar_t* iter = buffer; + while (*iter) { + if (*iter == ' ') *iter = 0; + if (*iter == '.') *iter = 0; + if (*iter == '@') *iter = 0; + iter++; + } + + return ts_locale_to_range(buffer); +} + // Main code int main(int, char**) { @@ -126,8 +144,8 @@ int main(int, char**) // Setup Dear ImGui style ImGui::Spectrum::StyleColorsSpectrum(); - ImGui::Spectrum::LoadFont(18.0f); + ts_load_fonts(18.0f, _ts_get_font_range_to_load()); ts_load_images(); ts_load_config(); -- cgit v1.2.3-70-g09d2