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