aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlendi <slendi@socopon.com>2024-01-11 00:45:02 +0200
committerSlendi <slendi@socopon.com>2024-01-11 00:45:02 +0200
commit1a6210430d955ee81ee6247e36286fe7335d7395 (patch)
tree3e3d26008e7e6ab5bc2209c071d5b5641593f896
parent3d0f613552715c6629e38360fe86294fa275e90c (diff)
Fix unicode.
Signed-off-by: Slendi <slendi@socopon.com>
-rw-r--r--main.cpp15
-rw-r--r--sample.txt2
2 files changed, 14 insertions, 3 deletions
diff --git a/main.cpp b/main.cpp
index b7909d4..5fc41ae 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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);
diff --git a/sample.txt b/sample.txt
index 53823e6..17468a4 100644
--- a/sample.txt
+++ b/sample.txt
@@ -33,3 +33,5 @@ Line20
Line21
Line22
Line23
+
+Thanks