aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2018-01-06 21:52:13 +0100
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2018-01-06 21:52:13 +0100
commit9c9ffe8a68fcbc1ae290a26e79ba753ac465e092 (patch)
treea8f77b4e8e637bb376df34020e54d7a761a2d3c9
parent7a5e81cf7f0e123ad44e68c032bc48f60b1bf529 (diff)
parent5c7722e0a3ec527f1dd19d556c30ec75c9c748db (diff)
downloadnuk.lv2-9c9ffe8a68fcbc1ae290a26e79ba753ac465e092.zip
nuk.lv2-9c9ffe8a68fcbc1ae290a26e79ba753ac465e092.tar.gz
nuk.lv2-9c9ffe8a68fcbc1ae290a26e79ba753ac465e092.tar.bz2
nuk.lv2-9c9ffe8a68fcbc1ae290a26e79ba753ac465e092.tar.xz
Merge commit '5c7722e0a3ec527f1dd19d556c30ec75c9c748db'
-rw-r--r--nk_pugl/nk_pugl.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/nk_pugl/nk_pugl.h b/nk_pugl/nk_pugl.h
index f8b24a2..2734093 100644
--- a/nk_pugl/nk_pugl.h
+++ b/nk_pugl/nk_pugl.h
@@ -37,6 +37,7 @@ extern C {
#if !defined(__APPLE__) && !defined(_WIN32)
# include "GL/glx.h"
# include "GL/glext.h"
+# include <X11/Xresource.h>
#endif
#define NK_ZERO_COMMAND_MEMORY
@@ -400,6 +401,7 @@ _nk_pugl_font_init(nk_pugl_window_t *win)
nk_pugl_config_t *cfg = &win->cfg;
const int font_size = cfg->font.size * win->scale;
+ fprintf(stderr, ":: %f %i\n", win->scale, font_size);
// init nuklear font
struct nk_font *ttf = NULL;
@@ -999,7 +1001,29 @@ nk_pugl_init(nk_pugl_window_t *win)
#else
win->async = (atomic_flag)ATOMIC_FLAG_INIT;
win->disp = XOpenDisplay(0);
- const float dpi1 = XDisplayWidth(win->disp, 0) * 25.4f / XDisplayWidthMM(win->disp, 0);
+ // modern X actually lies here, but proprietary nvidia
+ float dpi1 = XDisplayWidth(win->disp, 0) * 25.4f / XDisplayWidthMM(win->disp, 0);
+
+ // read DPI from users's ~/.Xresources
+ char *resource_string = XResourceManagerString(win->disp);
+ XrmInitialize();
+ if(resource_string)
+ {
+ XrmDatabase db = XrmGetStringDatabase(resource_string);
+ if(db)
+ {
+ char *type = NULL;
+ XrmValue value;
+
+ XrmGetResource(db, "Xft.dpi", "String", &type, &value);
+ if(value.addr)
+ {
+ dpi1 = atof(value.addr);
+ }
+ }
+ }
+
+ fprintf(stderr, ":: %f\n", dpi1);
#endif
win->scale = scale * dpi1 / dpi0;