Skip to content

Commit d0b4690

Browse files
committed
Take DPI into account to compute font/grid size
Fixes #3257. (cherry picked from commit e010aad)
1 parent 5dfb7dd commit d0b4690

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

utils/lstopo/lstopo-cairo.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright © 2009 CNRS
33
* Copyright © 2009-2017 Inria. All rights reserved.
4-
* Copyright © 2009-2010, 2014 Université Bordeaux
4+
* Copyright © 2009-2010, 2014, 2017 Université Bordeaux
55
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
66
* See COPYING in top-level directory.
77
*/
@@ -184,6 +184,7 @@ x11_init(void *_disp)
184184
int scr;
185185
Screen *screen;
186186
int screen_width, screen_height;
187+
unsigned int dpi_x, dpi_y, dpi;
187188

188189
/* create the toplevel window */
189190
if (!(dpy = XOpenDisplay(NULL))) {
@@ -195,6 +196,15 @@ x11_init(void *_disp)
195196
disp->scr = scr = DefaultScreen(dpy);
196197
screen = ScreenOfDisplay(dpy, scr);
197198

199+
/* 25.4mm per inch */
200+
dpi_x = ((double) DisplayWidth(dpy, scr) * 25.4) / DisplayWidthMM(dpy, scr);
201+
dpi_y = ((double) DisplayHeight(dpy, scr) * 25.4) / DisplayHeightMM(dpy, scr);
202+
dpi = (dpi_x + dpi_y) / 2;
203+
204+
/* Original values for fontsize/gridsize were tuned for 96dpi */
205+
coutput->loutput.fontsize = (coutput->loutput.fontsize * dpi) / 96;
206+
coutput->loutput.gridsize = (coutput->loutput.gridsize * dpi) / 96;
207+
198208
/* recurse once for preparing sizes and positions using the root window surface */
199209
root = RootWindow(dpy, scr);
200210
disp->top = root;

0 commit comments

Comments
 (0)