We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Vispy Windows XP Compatibility
When trying to run a Vispy Application in windows xp project will not start due to fault "Attribute Error: function 'SetProcessDPIAware' not found".  First instance traced back to "vispy\ext\gdi32plus.py line 165"  this line was commented out and program ran again and produced the same fault but pointed at "vispy\util\dpi_win32.py line 13" this line was also commented out and the program finally loaded.  Exhaustive testing is not yet complete but program is basically functional.

It appears the "SetProcessDPIAware" API is not supported in windows XP and only partially supported in windows vista and later, see....  https://msdn.microsoft.com/en-us/library/dn469266(v=vs.85).aspx and .... https://msdn.microsoft.com/en-us/library/dn302122(v=vs.85).aspx.

Further testing needs to be done to see whether Vispy is obtaining proper DPI settings.  
reference: http://www.experts-exchange.com/Programming/Languages/Scripting/Python/Q_21794611.html


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `vispy/ext/gdi32plus.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # -----------------------------------------------------------------------------
3 # Copyright (c) 2014, Vispy Development Team. All Rights Reserved.
4 # Distributed under the (new) BSD License. See LICENSE.txt for more info.
5 # -----------------------------------------------------------------------------
6 
7 # Adapted from Pyglet
8 
9 import atexit
10 from functools import partial
11 import struct
12 
13 from ctypes import (windll, Structure, POINTER, byref, WINFUNCTYPE,
14                     c_uint, c_float, c_int, c_ulong, c_uint64,
15                     c_void_p, c_uint32, c_wchar, c_wchar_p)
16 from ctypes.wintypes import (LONG, BYTE, HFONT, HGDIOBJ, BOOL, UINT, INT,
17                              DWORD, LPARAM)
18 
19 try:
20     import _winreg as winreg
21 except ImportError:
22     import winreg  # noqa, analysis:ignore
23 
24 _64_bit = (8 * struct.calcsize("P")) == 64
25 
26 LF_FACESIZE = 32
27 FW_BOLD = 700
28 FW_NORMAL = 400
29 ANTIALIASED_QUALITY = 4
30 FontStyleBold = 1
31 FontStyleItalic = 2
32 UnitPixel = 2
33 UnitPoint = 3
34 DEFAULT_CHARSET = 1
35 ANSI_CHARSET = 0
36 TRUETYPE_FONTTYPE = 4
37 GM_ADVANCED = 2
38 CSIDL_FONTS = 0x0014
39 
40 PixelFormat24bppRGB = 137224
41 PixelFormat32bppRGB = 139273
42 PixelFormat32bppARGB = 2498570
43 
44 DriverStringOptionsCmapLookup = 1
45 DriverStringOptionsRealizedAdvance = 4
46 TextRenderingHintAntiAlias = 4
47 TextRenderingHintAntiAliasGridFit = 3
48 ImageLockModeRead = 1
49 StringFormatFlagsMeasureTrailingSpaces = 0x00000800
50 StringFormatFlagsNoClip = 0x00004000
51 StringFormatFlagsNoFitBlackBox = 0x00000004
52 
53 INT_PTR = c_int
54 REAL = c_float
55 TCHAR = c_wchar
56 UINT32 = c_uint32
57 HDC = c_void_p
58 PSTR = c_uint64 if _64_bit else c_uint
59 
60 HORZSIZE = 4
61 VERTSIZE = 6
62 
63 HORZRES = 8
64 VERTRES = 10
65 
66 
67 # gdi32
68 
69 class POINT(Structure):
70     _fields_ = [('x', LONG), ('y', LONG)]
71 
72 
73 class RECT(Structure):
74     _fields_ = [('left', LONG), ('top', LONG),
75                 ('right', LONG), ('bottom', LONG)]
76 
77 
78 class PANOSE(Structure):
79     _fields_ = [
80         ('bFamilyType', BYTE), ('bSerifStyle', BYTE), ('bWeight', BYTE),
81         ('bProportion', BYTE), ('bContrast', BYTE), ('bStrokeVariation', BYTE),
82         ('bArmStyle', BYTE), ('bLetterform', BYTE), ('bMidline', BYTE),
83         ('bXHeight', BYTE)]
84 
85 
86 class TEXTMETRIC(Structure):
87     _fields_ = [
88         ('tmHeight', LONG), ('tmAscent', LONG), ('tmDescent', LONG),
89         ('tmInternalLeading', LONG), ('tmExternalLeading', LONG),
90         ('tmAveCharWidth', LONG), ('tmMaxCharWidth', LONG),
91         ('tmWeight', LONG), ('tmOverhang', LONG),
92         ('tmDigitizedAspectX', LONG), ('tmDigitizedAspectY', LONG),
93         ('tmFirstChar', TCHAR), ('tmLastChar', TCHAR),
94         ('tmDefaultChar', TCHAR), ('tmBreakChar', TCHAR),
95         ('tmItalic', BYTE), ('tmUnderlined', BYTE),
96         ('tmStruckOut', BYTE), ('tmPitchAndFamily', BYTE),
97         ('tmCharSet', BYTE)]
98 
99 
100 class OUTLINETEXTMETRIC(Structure):
101     _fields_ = [
102         ('otmSize', UINT), ('otmTextMetrics', TEXTMETRIC),
103         ('otmMysteryBytes', BYTE), ('otmPanoseNumber', PANOSE),
104         ('otmMysteryByte', BYTE),
105         ('otmfsSelection', UINT), ('otmfsType', UINT),
106         ('otmsCharSlopeRise', INT), ('otmsCharSlopeRun', INT),
107         ('otmItalicAngle', INT), ('otmEMSquare', UINT), ('otmAscent', INT),
108         ('otmDescent', INT), ('otmLineGap', UINT), ('otmsCapEmHeight', UINT),
109         ('otmsXHeight', UINT), ('otmrcFontBox', RECT), ('otmMacAscent', INT),
110         ('otmMacDescent', INT), ('otmMacLineGap', UINT),
111         ('otmusMinimumPPEM', UINT), ('otmptSubscriptSize', POINT),
112         ('otmptSubscriptOffset', POINT), ('otmptSuperscriptSize', POINT),
113         ('otmptSuperscriptOffset', POINT), ('otmsStrikeoutSize', UINT),
114         ('otmsStrikeoutPosition', INT), ('otmsUnderscoreSize', INT),
115         ('otmsUnderscorePosition', INT), ('otmpFamilyName', PSTR),
116         ('otmpFaceName', PSTR), ('otmpStyleName', PSTR),
117         ('otmpFullName', PSTR), ('junk', (BYTE) * 1024)]  # room for strs
118 
119 
120 class LOGFONT(Structure):
121     _fields_ = [
122         ('lfHeight', LONG), ('lfWidth', LONG), ('lfEscapement', LONG),
123         ('lfOrientation', LONG), ('lfWeight', LONG), ('lfItalic', BYTE),
124         ('lfUnderline', BYTE), ('lfStrikeOut', BYTE), ('lfCharSet', BYTE),
125         ('lfOutPrecision', BYTE), ('lfClipPrecision', BYTE),
126         ('lfQuality', BYTE), ('lfPitchAndFamily', BYTE),
127         ('lfFaceName', (TCHAR * LF_FACESIZE))]
128 
129 
130 gdi32 = windll.gdi32
131 
132 gdi32.CreateFontIndirectW.restype = HFONT
133 gdi32.CreateFontIndirectW.argtypes = [POINTER(LOGFONT)]
134 
135 gdi32.SelectObject.restype = HGDIOBJ
136 gdi32.SelectObject.argtypes = [HDC, HGDIOBJ]
137 
138 gdi32.SetGraphicsMode.restype = INT
139 gdi32.SetGraphicsMode.argtypes = [HDC, INT]
140 
141 gdi32.GetTextMetricsW.restype = BOOL
142 gdi32.GetTextMetricsW.argtypes = [HDC, POINTER(TEXTMETRIC)]
143 
144 FONTENUMPROC = WINFUNCTYPE(INT, POINTER(LOGFONT), POINTER(TEXTMETRIC),
145                            DWORD, c_void_p)
146 gdi32.EnumFontFamiliesExW.restype = INT
147 gdi32.EnumFontFamiliesExW.argtypes = [HDC, POINTER(LOGFONT),
148                                       FONTENUMPROC, LPARAM, DWORD]
149 
150 gdi32.GetOutlineTextMetricsW.restype = UINT
151 gdi32.GetOutlineTextMetricsW.argtypes = [HDC, UINT,
152                                          POINTER(OUTLINETEXTMETRIC)]
153 
154 
155 gdi32.GetDeviceCaps.argtypes = [HDC, INT]
156 gdi32.GetDeviceCaps.restype = INT
157 
158 user32 = windll.user32
159 
160 user32.GetDC.restype = HDC  # HDC
161 user32.GetDC.argtypes = [UINT32]  # HWND
162 
163 user32.ReleaseDC.argtypes = [c_void_p, HDC]
164 
165 user32.SetProcessDPIAware.argtypes = []
166 
167 
168 # gdiplus
169 
170 class GdiplusStartupInput(Structure):
171     _fields_ = [
172         ('GdiplusVersion', UINT32), ('DebugEventCallback', c_void_p),
173         ('SuppressBackgroundThread', BOOL), ('SuppressExternalCodecs', BOOL)]
174 
175 
176 class GdiplusStartupOutput(Structure):
177     _fields = [('NotificationHookProc', c_void_p),
178                ('NotificationUnhookProc', c_void_p)]
179 
180 gdiplus = windll.gdiplus
181 
182 gdiplus.GdipCreateFontFamilyFromName.restype = c_int
183 gdiplus.GdipCreateFontFamilyFromName.argtypes = [c_wchar_p, c_void_p, c_void_p]
184 
185 gdiplus.GdipNewPrivateFontCollection.restype = c_int
186 gdiplus.GdipNewPrivateFontCollection.argtypes = [c_void_p]
187 
188 gdiplus.GdipPrivateAddFontFile.restype = c_int
189 gdiplus.GdipPrivateAddFontFile.argtypes = [c_void_p, c_wchar_p]
190 
191 gdiplus.GdipGetFamilyName.restype = c_int
192 gdiplus.GdipGetFamilyName.argtypes = [c_void_p, c_wchar_p, c_int]
193 
194 
195 def gdiplus_init():
196     token = c_ulong()
197     startup_in = GdiplusStartupInput()
198     startup_in.GdiplusVersion = 1
199     startup_out = GdiplusStartupOutput()
200     gdiplus.GdiplusStartup(byref(token), byref(startup_in), byref(startup_out))
201     atexit.register(partial(gdiplus.GdiplusShutdown, token))
202 
203 gdiplus_init()
204
```

Path: `vispy/util/dpi/_win32.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # -----------------------------------------------------------------------------
3 # Copyright (c) 2014, Vispy Development Team. All Rights Reserved.
4 # Distributed under the (new) BSD License. See LICENSE.txt for more info.
5 # -----------------------------------------------------------------------------
6 
7 from ...ext.gdi32plus import (gdi32, user32, HORZSIZE, VERTSIZE,
8                               HORZRES, VERTRES)
9 
10 
11 def get_dpi():
12     """Get screen DPI from the OS"""
13     user32.SetProcessDPIAware()
14     dc = user32.GetDC(0)
15     h_size = gdi32.GetDeviceCaps(dc, HORZSIZE)
16     v_size = gdi32.GetDeviceCaps(dc, VERTSIZE)
17     h_res = gdi32.GetDeviceCaps(dc, HORZRES)
18     v_res = gdi32.GetDeviceCaps(dc, VERTRES)
19     user32.ReleaseDC(None, dc)
20     return (h_res/float(h_size) + v_res/float(v_size)) * 0.5 * 25.4
21
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/vispy/ext/gdi32plus.py b/vispy/ext/gdi32plus.py
--- a/vispy/ext/gdi32plus.py
+++ b/vispy/ext/gdi32plus.py
@@ -162,7 +162,10 @@
 
 user32.ReleaseDC.argtypes = [c_void_p, HDC]
 
-user32.SetProcessDPIAware.argtypes = []
+try:
+    user32.SetProcessDPIAware.argtypes = []
+except AttributeError:
+    pass  # not present on XP
 
 
 # gdiplus
diff --git a/vispy/util/dpi/_win32.py b/vispy/util/dpi/_win32.py
--- a/vispy/util/dpi/_win32.py
+++ b/vispy/util/dpi/_win32.py
@@ -10,7 +10,10 @@
 
 def get_dpi():
     """Get screen DPI from the OS"""
-    user32.SetProcessDPIAware()
+    try:
+        user32.SetProcessDPIAware()
+    except AttributeError:
+        pass  # not present on XP
     dc = user32.GetDC(0)
     h_size = gdi32.GetDeviceCaps(dc, HORZSIZE)
     v_size = gdi32.GetDeviceCaps(dc, VERTSIZE)

{"golden_diff": "diff --git a/vispy/ext/gdi32plus.py b/vispy/ext/gdi32plus.py\n--- a/vispy/ext/gdi32plus.py\n+++ b/vispy/ext/gdi32plus.py\n@@ -162,7 +162,10 @@\n \n user32.ReleaseDC.argtypes = [c_void_p, HDC]\n \n-user32.SetProcessDPIAware.argtypes = []\n+try:\n+    user32.SetProcessDPIAware.argtypes = []\n+except AttributeError:\n+    pass  # not present on XP\n \n \n # gdiplus\ndiff --git a/vispy/util/dpi/_win32.py b/vispy/util/dpi/_win32.py\n--- a/vispy/util/dpi/_win32.py\n+++ b/vispy/util/dpi/_win32.py\n@@ -10,7 +10,10 @@\n \n def get_dpi():\n     \"\"\"Get screen DPI from the OS\"\"\"\n-    user32.SetProcessDPIAware()\n+    try:\n+        user32.SetProcessDPIAware()\n+    except AttributeError:\n+        pass  # not present on XP\n     dc = user32.GetDC(0)\n     h_size = gdi32.GetDeviceCaps(dc, HORZSIZE)\n     v_size = gdi32.GetDeviceCaps(dc, VERTSIZE)\n", "issue": "Vispy Windows XP Compatibility\nWhen trying to run a Vispy Application in windows xp project will not start due to fault \"Attribute Error: function 'SetProcessDPIAware' not found\".  First instance traced back to \"vispy\\ext\\gdi32plus.py line 165\"  this line was commented out and program ran again and produced the same fault but pointed at \"vispy\\util\\dpi_win32.py line 13\" this line was also commented out and the program finally loaded.  Exhaustive testing is not yet complete but program is basically functional.\n\nIt appears the \"SetProcessDPIAware\" API is not supported in windows XP and only partially supported in windows vista and later, see....  https://msdn.microsoft.com/en-us/library/dn469266(v=vs.85).aspx and .... https://msdn.microsoft.com/en-us/library/dn302122(v=vs.85).aspx.\n\nFurther testing needs to be done to see whether Vispy is obtaining proper DPI settings.  \nreference: http://www.experts-exchange.com/Programming/Languages/Scripting/Python/Q_21794611.html\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# -----------------------------------------------------------------------------\n# Copyright (c) 2014, Vispy Development Team. All Rights Reserved.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n# -----------------------------------------------------------------------------\n\n# Adapted from Pyglet\n\nimport atexit\nfrom functools import partial\nimport struct\n\nfrom ctypes import (windll, Structure, POINTER, byref, WINFUNCTYPE,\n                    c_uint, c_float, c_int, c_ulong, c_uint64,\n                    c_void_p, c_uint32, c_wchar, c_wchar_p)\nfrom ctypes.wintypes import (LONG, BYTE, HFONT, HGDIOBJ, BOOL, UINT, INT,\n                             DWORD, LPARAM)\n\ntry:\n    import _winreg as winreg\nexcept ImportError:\n    import winreg  # noqa, analysis:ignore\n\n_64_bit = (8 * struct.calcsize(\"P\")) == 64\n\nLF_FACESIZE = 32\nFW_BOLD = 700\nFW_NORMAL = 400\nANTIALIASED_QUALITY = 4\nFontStyleBold = 1\nFontStyleItalic = 2\nUnitPixel = 2\nUnitPoint = 3\nDEFAULT_CHARSET = 1\nANSI_CHARSET = 0\nTRUETYPE_FONTTYPE = 4\nGM_ADVANCED = 2\nCSIDL_FONTS = 0x0014\n\nPixelFormat24bppRGB = 137224\nPixelFormat32bppRGB = 139273\nPixelFormat32bppARGB = 2498570\n\nDriverStringOptionsCmapLookup = 1\nDriverStringOptionsRealizedAdvance = 4\nTextRenderingHintAntiAlias = 4\nTextRenderingHintAntiAliasGridFit = 3\nImageLockModeRead = 1\nStringFormatFlagsMeasureTrailingSpaces = 0x00000800\nStringFormatFlagsNoClip = 0x00004000\nStringFormatFlagsNoFitBlackBox = 0x00000004\n\nINT_PTR = c_int\nREAL = c_float\nTCHAR = c_wchar\nUINT32 = c_uint32\nHDC = c_void_p\nPSTR = c_uint64 if _64_bit else c_uint\n\nHORZSIZE = 4\nVERTSIZE = 6\n\nHORZRES = 8\nVERTRES = 10\n\n\n# gdi32\n\nclass POINT(Structure):\n    _fields_ = [('x', LONG), ('y', LONG)]\n\n\nclass RECT(Structure):\n    _fields_ = [('left', LONG), ('top', LONG),\n                ('right', LONG), ('bottom', LONG)]\n\n\nclass PANOSE(Structure):\n    _fields_ = [\n        ('bFamilyType', BYTE), ('bSerifStyle', BYTE), ('bWeight', BYTE),\n        ('bProportion', BYTE), ('bContrast', BYTE), ('bStrokeVariation', BYTE),\n        ('bArmStyle', BYTE), ('bLetterform', BYTE), ('bMidline', BYTE),\n        ('bXHeight', BYTE)]\n\n\nclass TEXTMETRIC(Structure):\n    _fields_ = [\n        ('tmHeight', LONG), ('tmAscent', LONG), ('tmDescent', LONG),\n        ('tmInternalLeading', LONG), ('tmExternalLeading', LONG),\n        ('tmAveCharWidth', LONG), ('tmMaxCharWidth', LONG),\n        ('tmWeight', LONG), ('tmOverhang', LONG),\n        ('tmDigitizedAspectX', LONG), ('tmDigitizedAspectY', LONG),\n        ('tmFirstChar', TCHAR), ('tmLastChar', TCHAR),\n        ('tmDefaultChar', TCHAR), ('tmBreakChar', TCHAR),\n        ('tmItalic', BYTE), ('tmUnderlined', BYTE),\n        ('tmStruckOut', BYTE), ('tmPitchAndFamily', BYTE),\n        ('tmCharSet', BYTE)]\n\n\nclass OUTLINETEXTMETRIC(Structure):\n    _fields_ = [\n        ('otmSize', UINT), ('otmTextMetrics', TEXTMETRIC),\n        ('otmMysteryBytes', BYTE), ('otmPanoseNumber', PANOSE),\n        ('otmMysteryByte', BYTE),\n        ('otmfsSelection', UINT), ('otmfsType', UINT),\n        ('otmsCharSlopeRise', INT), ('otmsCharSlopeRun', INT),\n        ('otmItalicAngle', INT), ('otmEMSquare', UINT), ('otmAscent', INT),\n        ('otmDescent', INT), ('otmLineGap', UINT), ('otmsCapEmHeight', UINT),\n        ('otmsXHeight', UINT), ('otmrcFontBox', RECT), ('otmMacAscent', INT),\n        ('otmMacDescent', INT), ('otmMacLineGap', UINT),\n        ('otmusMinimumPPEM', UINT), ('otmptSubscriptSize', POINT),\n        ('otmptSubscriptOffset', POINT), ('otmptSuperscriptSize', POINT),\n        ('otmptSuperscriptOffset', POINT), ('otmsStrikeoutSize', UINT),\n        ('otmsStrikeoutPosition', INT), ('otmsUnderscoreSize', INT),\n        ('otmsUnderscorePosition', INT), ('otmpFamilyName', PSTR),\n        ('otmpFaceName', PSTR), ('otmpStyleName', PSTR),\n        ('otmpFullName', PSTR), ('junk', (BYTE) * 1024)]  # room for strs\n\n\nclass LOGFONT(Structure):\n    _fields_ = [\n        ('lfHeight', LONG), ('lfWidth', LONG), ('lfEscapement', LONG),\n        ('lfOrientation', LONG), ('lfWeight', LONG), ('lfItalic', BYTE),\n        ('lfUnderline', BYTE), ('lfStrikeOut', BYTE), ('lfCharSet', BYTE),\n        ('lfOutPrecision', BYTE), ('lfClipPrecision', BYTE),\n        ('lfQuality', BYTE), ('lfPitchAndFamily', BYTE),\n        ('lfFaceName', (TCHAR * LF_FACESIZE))]\n\n\ngdi32 = windll.gdi32\n\ngdi32.CreateFontIndirectW.restype = HFONT\ngdi32.CreateFontIndirectW.argtypes = [POINTER(LOGFONT)]\n\ngdi32.SelectObject.restype = HGDIOBJ\ngdi32.SelectObject.argtypes = [HDC, HGDIOBJ]\n\ngdi32.SetGraphicsMode.restype = INT\ngdi32.SetGraphicsMode.argtypes = [HDC, INT]\n\ngdi32.GetTextMetricsW.restype = BOOL\ngdi32.GetTextMetricsW.argtypes = [HDC, POINTER(TEXTMETRIC)]\n\nFONTENUMPROC = WINFUNCTYPE(INT, POINTER(LOGFONT), POINTER(TEXTMETRIC),\n                           DWORD, c_void_p)\ngdi32.EnumFontFamiliesExW.restype = INT\ngdi32.EnumFontFamiliesExW.argtypes = [HDC, POINTER(LOGFONT),\n                                      FONTENUMPROC, LPARAM, DWORD]\n\ngdi32.GetOutlineTextMetricsW.restype = UINT\ngdi32.GetOutlineTextMetricsW.argtypes = [HDC, UINT,\n                                         POINTER(OUTLINETEXTMETRIC)]\n\n\ngdi32.GetDeviceCaps.argtypes = [HDC, INT]\ngdi32.GetDeviceCaps.restype = INT\n\nuser32 = windll.user32\n\nuser32.GetDC.restype = HDC  # HDC\nuser32.GetDC.argtypes = [UINT32]  # HWND\n\nuser32.ReleaseDC.argtypes = [c_void_p, HDC]\n\nuser32.SetProcessDPIAware.argtypes = []\n\n\n# gdiplus\n\nclass GdiplusStartupInput(Structure):\n    _fields_ = [\n        ('GdiplusVersion', UINT32), ('DebugEventCallback', c_void_p),\n        ('SuppressBackgroundThread', BOOL), ('SuppressExternalCodecs', BOOL)]\n\n\nclass GdiplusStartupOutput(Structure):\n    _fields = [('NotificationHookProc', c_void_p),\n               ('NotificationUnhookProc', c_void_p)]\n\ngdiplus = windll.gdiplus\n\ngdiplus.GdipCreateFontFamilyFromName.restype = c_int\ngdiplus.GdipCreateFontFamilyFromName.argtypes = [c_wchar_p, c_void_p, c_void_p]\n\ngdiplus.GdipNewPrivateFontCollection.restype = c_int\ngdiplus.GdipNewPrivateFontCollection.argtypes = [c_void_p]\n\ngdiplus.GdipPrivateAddFontFile.restype = c_int\ngdiplus.GdipPrivateAddFontFile.argtypes = [c_void_p, c_wchar_p]\n\ngdiplus.GdipGetFamilyName.restype = c_int\ngdiplus.GdipGetFamilyName.argtypes = [c_void_p, c_wchar_p, c_int]\n\n\ndef gdiplus_init():\n    token = c_ulong()\n    startup_in = GdiplusStartupInput()\n    startup_in.GdiplusVersion = 1\n    startup_out = GdiplusStartupOutput()\n    gdiplus.GdiplusStartup(byref(token), byref(startup_in), byref(startup_out))\n    atexit.register(partial(gdiplus.GdiplusShutdown, token))\n\ngdiplus_init()\n", "path": "vispy/ext/gdi32plus.py"}, {"content": "# -*- coding: utf-8 -*-\n# -----------------------------------------------------------------------------\n# Copyright (c) 2014, Vispy Development Team. All Rights Reserved.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n# -----------------------------------------------------------------------------\n\nfrom ...ext.gdi32plus import (gdi32, user32, HORZSIZE, VERTSIZE,\n                              HORZRES, VERTRES)\n\n\ndef get_dpi():\n    \"\"\"Get screen DPI from the OS\"\"\"\n    user32.SetProcessDPIAware()\n    dc = user32.GetDC(0)\n    h_size = gdi32.GetDeviceCaps(dc, HORZSIZE)\n    v_size = gdi32.GetDeviceCaps(dc, VERTSIZE)\n    h_res = gdi32.GetDeviceCaps(dc, HORZRES)\n    v_res = gdi32.GetDeviceCaps(dc, VERTRES)\n    user32.ReleaseDC(None, dc)\n    return (h_res/float(h_size) + v_res/float(v_size)) * 0.5 * 25.4\n", "path": "vispy/util/dpi/_win32.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# -----------------------------------------------------------------------------\n# Copyright (c) 2014, Vispy Development Team. All Rights Reserved.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n# -----------------------------------------------------------------------------\n\n# Adapted from Pyglet\n\nimport atexit\nfrom functools import partial\nimport struct\n\nfrom ctypes import (windll, Structure, POINTER, byref, WINFUNCTYPE,\n                    c_uint, c_float, c_int, c_ulong, c_uint64,\n                    c_void_p, c_uint32, c_wchar, c_wchar_p)\nfrom ctypes.wintypes import (LONG, BYTE, HFONT, HGDIOBJ, BOOL, UINT, INT,\n                             DWORD, LPARAM)\n\ntry:\n    import _winreg as winreg\nexcept ImportError:\n    import winreg  # noqa, analysis:ignore\n\n_64_bit = (8 * struct.calcsize(\"P\")) == 64\n\nLF_FACESIZE = 32\nFW_BOLD = 700\nFW_NORMAL = 400\nANTIALIASED_QUALITY = 4\nFontStyleBold = 1\nFontStyleItalic = 2\nUnitPixel = 2\nUnitPoint = 3\nDEFAULT_CHARSET = 1\nANSI_CHARSET = 0\nTRUETYPE_FONTTYPE = 4\nGM_ADVANCED = 2\nCSIDL_FONTS = 0x0014\n\nPixelFormat24bppRGB = 137224\nPixelFormat32bppRGB = 139273\nPixelFormat32bppARGB = 2498570\n\nDriverStringOptionsCmapLookup = 1\nDriverStringOptionsRealizedAdvance = 4\nTextRenderingHintAntiAlias = 4\nTextRenderingHintAntiAliasGridFit = 3\nImageLockModeRead = 1\nStringFormatFlagsMeasureTrailingSpaces = 0x00000800\nStringFormatFlagsNoClip = 0x00004000\nStringFormatFlagsNoFitBlackBox = 0x00000004\n\nINT_PTR = c_int\nREAL = c_float\nTCHAR = c_wchar\nUINT32 = c_uint32\nHDC = c_void_p\nPSTR = c_uint64 if _64_bit else c_uint\n\nHORZSIZE = 4\nVERTSIZE = 6\n\nHORZRES = 8\nVERTRES = 10\n\n\n# gdi32\n\nclass POINT(Structure):\n    _fields_ = [('x', LONG), ('y', LONG)]\n\n\nclass RECT(Structure):\n    _fields_ = [('left', LONG), ('top', LONG),\n                ('right', LONG), ('bottom', LONG)]\n\n\nclass PANOSE(Structure):\n    _fields_ = [\n        ('bFamilyType', BYTE), ('bSerifStyle', BYTE), ('bWeight', BYTE),\n        ('bProportion', BYTE), ('bContrast', BYTE), ('bStrokeVariation', BYTE),\n        ('bArmStyle', BYTE), ('bLetterform', BYTE), ('bMidline', BYTE),\n        ('bXHeight', BYTE)]\n\n\nclass TEXTMETRIC(Structure):\n    _fields_ = [\n        ('tmHeight', LONG), ('tmAscent', LONG), ('tmDescent', LONG),\n        ('tmInternalLeading', LONG), ('tmExternalLeading', LONG),\n        ('tmAveCharWidth', LONG), ('tmMaxCharWidth', LONG),\n        ('tmWeight', LONG), ('tmOverhang', LONG),\n        ('tmDigitizedAspectX', LONG), ('tmDigitizedAspectY', LONG),\n        ('tmFirstChar', TCHAR), ('tmLastChar', TCHAR),\n        ('tmDefaultChar', TCHAR), ('tmBreakChar', TCHAR),\n        ('tmItalic', BYTE), ('tmUnderlined', BYTE),\n        ('tmStruckOut', BYTE), ('tmPitchAndFamily', BYTE),\n        ('tmCharSet', BYTE)]\n\n\nclass OUTLINETEXTMETRIC(Structure):\n    _fields_ = [\n        ('otmSize', UINT), ('otmTextMetrics', TEXTMETRIC),\n        ('otmMysteryBytes', BYTE), ('otmPanoseNumber', PANOSE),\n        ('otmMysteryByte', BYTE),\n        ('otmfsSelection', UINT), ('otmfsType', UINT),\n        ('otmsCharSlopeRise', INT), ('otmsCharSlopeRun', INT),\n        ('otmItalicAngle', INT), ('otmEMSquare', UINT), ('otmAscent', INT),\n        ('otmDescent', INT), ('otmLineGap', UINT), ('otmsCapEmHeight', UINT),\n        ('otmsXHeight', UINT), ('otmrcFontBox', RECT), ('otmMacAscent', INT),\n        ('otmMacDescent', INT), ('otmMacLineGap', UINT),\n        ('otmusMinimumPPEM', UINT), ('otmptSubscriptSize', POINT),\n        ('otmptSubscriptOffset', POINT), ('otmptSuperscriptSize', POINT),\n        ('otmptSuperscriptOffset', POINT), ('otmsStrikeoutSize', UINT),\n        ('otmsStrikeoutPosition', INT), ('otmsUnderscoreSize', INT),\n        ('otmsUnderscorePosition', INT), ('otmpFamilyName', PSTR),\n        ('otmpFaceName', PSTR), ('otmpStyleName', PSTR),\n        ('otmpFullName', PSTR), ('junk', (BYTE) * 1024)]  # room for strs\n\n\nclass LOGFONT(Structure):\n    _fields_ = [\n        ('lfHeight', LONG), ('lfWidth', LONG), ('lfEscapement', LONG),\n        ('lfOrientation', LONG), ('lfWeight', LONG), ('lfItalic', BYTE),\n        ('lfUnderline', BYTE), ('lfStrikeOut', BYTE), ('lfCharSet', BYTE),\n        ('lfOutPrecision', BYTE), ('lfClipPrecision', BYTE),\n        ('lfQuality', BYTE), ('lfPitchAndFamily', BYTE),\n        ('lfFaceName', (TCHAR * LF_FACESIZE))]\n\n\ngdi32 = windll.gdi32\n\ngdi32.CreateFontIndirectW.restype = HFONT\ngdi32.CreateFontIndirectW.argtypes = [POINTER(LOGFONT)]\n\ngdi32.SelectObject.restype = HGDIOBJ\ngdi32.SelectObject.argtypes = [HDC, HGDIOBJ]\n\ngdi32.SetGraphicsMode.restype = INT\ngdi32.SetGraphicsMode.argtypes = [HDC, INT]\n\ngdi32.GetTextMetricsW.restype = BOOL\ngdi32.GetTextMetricsW.argtypes = [HDC, POINTER(TEXTMETRIC)]\n\nFONTENUMPROC = WINFUNCTYPE(INT, POINTER(LOGFONT), POINTER(TEXTMETRIC),\n                           DWORD, c_void_p)\ngdi32.EnumFontFamiliesExW.restype = INT\ngdi32.EnumFontFamiliesExW.argtypes = [HDC, POINTER(LOGFONT),\n                                      FONTENUMPROC, LPARAM, DWORD]\n\ngdi32.GetOutlineTextMetricsW.restype = UINT\ngdi32.GetOutlineTextMetricsW.argtypes = [HDC, UINT,\n                                         POINTER(OUTLINETEXTMETRIC)]\n\n\ngdi32.GetDeviceCaps.argtypes = [HDC, INT]\ngdi32.GetDeviceCaps.restype = INT\n\nuser32 = windll.user32\n\nuser32.GetDC.restype = HDC  # HDC\nuser32.GetDC.argtypes = [UINT32]  # HWND\n\nuser32.ReleaseDC.argtypes = [c_void_p, HDC]\n\ntry:\n    user32.SetProcessDPIAware.argtypes = []\nexcept AttributeError:\n    pass  # not present on XP\n\n\n# gdiplus\n\nclass GdiplusStartupInput(Structure):\n    _fields_ = [\n        ('GdiplusVersion', UINT32), ('DebugEventCallback', c_void_p),\n        ('SuppressBackgroundThread', BOOL), ('SuppressExternalCodecs', BOOL)]\n\n\nclass GdiplusStartupOutput(Structure):\n    _fields = [('NotificationHookProc', c_void_p),\n               ('NotificationUnhookProc', c_void_p)]\n\ngdiplus = windll.gdiplus\n\ngdiplus.GdipCreateFontFamilyFromName.restype = c_int\ngdiplus.GdipCreateFontFamilyFromName.argtypes = [c_wchar_p, c_void_p, c_void_p]\n\ngdiplus.GdipNewPrivateFontCollection.restype = c_int\ngdiplus.GdipNewPrivateFontCollection.argtypes = [c_void_p]\n\ngdiplus.GdipPrivateAddFontFile.restype = c_int\ngdiplus.GdipPrivateAddFontFile.argtypes = [c_void_p, c_wchar_p]\n\ngdiplus.GdipGetFamilyName.restype = c_int\ngdiplus.GdipGetFamilyName.argtypes = [c_void_p, c_wchar_p, c_int]\n\n\ndef gdiplus_init():\n    token = c_ulong()\n    startup_in = GdiplusStartupInput()\n    startup_in.GdiplusVersion = 1\n    startup_out = GdiplusStartupOutput()\n    gdiplus.GdiplusStartup(byref(token), byref(startup_in), byref(startup_out))\n    atexit.register(partial(gdiplus.GdiplusShutdown, token))\n\ngdiplus_init()\n", "path": "vispy/ext/gdi32plus.py"}, {"content": "# -*- coding: utf-8 -*-\n# -----------------------------------------------------------------------------\n# Copyright (c) 2014, Vispy Development Team. All Rights Reserved.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n# -----------------------------------------------------------------------------\n\nfrom ...ext.gdi32plus import (gdi32, user32, HORZSIZE, VERTSIZE,\n                              HORZRES, VERTRES)\n\n\ndef get_dpi():\n    \"\"\"Get screen DPI from the OS\"\"\"\n    try:\n        user32.SetProcessDPIAware()\n    except AttributeError:\n        pass  # not present on XP\n    dc = user32.GetDC(0)\n    h_size = gdi32.GetDeviceCaps(dc, HORZSIZE)\n    v_size = gdi32.GetDeviceCaps(dc, VERTSIZE)\n    h_res = gdi32.GetDeviceCaps(dc, HORZRES)\n    v_res = gdi32.GetDeviceCaps(dc, VERTRES)\n    user32.ReleaseDC(None, dc)\n    return (h_res/float(h_size) + v_res/float(v_size)) * 0.5 * 25.4\n", "path": "vispy/util/dpi/_win32.py"}]}