Be a little more stringent with Xft parsing

This commit is contained in:
Kovid Goyal 2017-05-20 00:26:26 +05:30
parent 357a415386
commit 1d1138ca31
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -78,9 +78,10 @@ def x11_dpi_native():
raise RuntimeError('Could not connect to the X server') raise RuntimeError('Could not connect to the X server')
try: try:
db = XResourceManagerString(display).decode('utf-8') db = XResourceManagerString(display).decode('utf-8')
q = 'Xft.dpi:\t'
for line in db.splitlines(): for line in db.splitlines():
if line.startswith('Xft.dpi:'): if line.startswith(q):
return float(line.split()[1]) return float(line[len(q):])
finally: finally:
XCloseDisplay(display) XCloseDisplay(display)
raise RuntimeError('Failed to get dpi resource') raise RuntimeError('Failed to get dpi resource')