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
commit5c7722e0a3ec527f1dd19d556c30ec75c9c748db (patch)
tree37266a81e1229db5dd8ef3e481de24ed7b369767
parent79a501a1678f3a2a81a8ff1dfc3fb8ecfdf0cfe0 (diff)
downloadnuk.lv2-5c7722e0a3ec527f1dd19d556c30ec75c9c748db.zip
nuk.lv2-5c7722e0a3ec527f1dd19d556c30ec75c9c748db.tar.gz
nuk.lv2-5c7722e0a3ec527f1dd19d556c30ec75c9c748db.tar.bz2
nuk.lv2-5c7722e0a3ec527f1dd19d556c30ec75c9c748db.tar.xz
Squashed 'nk_pugl/' changes from 643f07a..e8cbe22
e8cbe22 honor Xft.dpi in ~/.Xresources. git-subtree-dir: nk_pugl git-subtree-split: e8cbe22972126cc0d0e90ab7790ccf47f615183d
-rw-r--r--nk_pugl.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/nk_pugl.h b/nk_pugl.h
index f8b24a2..2734093 100644
--- a/nk_pugl.h
+++ b/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;