summaryrefslogtreecommitdiff
path: root/src/unix
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2024-03-16 18:33:49 +0100
committerAldrik Ramaekers <aldrikboy@gmail.com>2024-03-16 18:33:49 +0100
commit7c3b90eb9834ae605c679be2c240d36715225acc (patch)
tree1114d70e857174daf0f8e9b8edd08dbe4e2037fe /src/unix
parent253c967318e6a75c6c4947b01f12ee3797db1b40 (diff)
locale loading unix
Diffstat (limited to 'src/unix')
-rw-r--r--src/unix/main_unix.cpp20
1 files changed, 19 insertions, 1 deletions
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 <stdio.h>
#include <stdlib.h>
@@ -15,6 +16,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
+#include <locale.h>
#define GL_SILENCE_DEPRECATION
#if defined(IMGUI_IMPL_OPENGL_ES2)
#include <GLES2/gl2.h>
@@ -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();