src/font.c

changeset 128
c36170c76a2b
parent 106
895f92cff6b8
--- a/src/font.c	Thu May 29 11:20:49 2025 +0200
+++ b/src/font.c	Thu May 29 11:34:34 2025 +0200
@@ -31,6 +31,7 @@
 #include "ascension/ui/font.h"
 
 #include <assert.h>
+#include <math.h>
 #include <cx/array_list.h>
 
 void asc_font(enum AscFontStyle style, int size) {
@@ -80,6 +81,11 @@
 }
 
 TTF_Font *asc_font_load(AscFont font) {
+    // apply the UI scaling factor first to get the actual font size
+    if (asc_context.ui_scale != 1.f) {
+        font.size = (int) roundf((float) font.size * asc_context.ui_scale);
+    }
+
     CxIterator iter = cxListIterator(asc_font_cache);
     cx_foreach(struct asc_font_cache_entry*, cache, iter) {
         if (cache->font.style == font.style && cache->font.size == font.size) {

mercurial