diff options
author | Slendi <slendi@socopon.com> | 2024-01-11 00:45:02 +0200 |
---|---|---|
committer | Slendi <slendi@socopon.com> | 2024-01-11 00:45:02 +0200 |
commit | 1a6210430d955ee81ee6247e36286fe7335d7395 (patch) | |
tree | 3e3d26008e7e6ab5bc2209c071d5b5641593f896 | |
parent | 3d0f613552715c6629e38360fe86294fa275e90c (diff) |
Fix unicode.
Signed-off-by: Slendi <slendi@socopon.com>
-rw-r--r-- | main.cpp | 15 | ||||
-rw-r--r-- | sample.txt | 2 |
2 files changed, 14 insertions, 3 deletions
@@ -1,3 +1,4 @@ +#include <chrono> #include <fstream> #include <iostream> #include <string> @@ -58,7 +59,15 @@ public: InitWindow(w, h, "Presentation"); SetTargetFPS(30); - m_font = LoadFontEx(m_config.font_path.c_str(), 256, nullptr, 0); + auto time_begin = std::chrono::high_resolution_clock::now(); + m_font = LoadFontEx(m_config.font_path.c_str(), 128, nullptr, 0x2030); + auto time_end = std::chrono::high_resolution_clock::now(); + std::cout << "Loading font took " + << std::chrono::duration_cast<std::chrono::milliseconds>( + time_end - time_begin) + .count() + << "ms" << std::endl; + std::cout.flush(); int display_width = GetMonitorWidth(GetCurrentMonitor()); int display_height = GetMonitorHeight(GetCurrentMonitor()); @@ -126,7 +135,7 @@ public: if (measurement.y > GetScreenHeight() - m_config.padding_y * font_scale * 2) { scale = (GetScreenHeight() - m_config.padding_y * font_scale * 2) / - measurement.y / 2.0f; + measurement.y; } measurement.x *= scale; @@ -136,7 +145,7 @@ public: DrawTextEx(m_font, txt.c_str(), { .x = (GetScreenWidth() - measurement.x) / 2.0f, - .y = (GetScreenHeight() - measurement.y * 2) / 2.0f, + .y = (GetScreenHeight() - measurement.y) / 2.0f, }, m_config.font_size * font_scale * scale, 0, m_config.text_color); @@ -33,3 +33,5 @@ Line20 Line21 Line22 Line23 + +Thanks |