Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 mingw64-x-cairo (1.12.14-1) UNRELEASED; urgency=low
 .
   * New upstream release.
Author: Alexandre Pereira Nunes <alex@polesbook.localnet>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

Index: mingw64-x-cairo-1.14.2/src/win32/cairo-win32-font.c
===================================================================
--- mingw64-x-cairo-1.14.2.orig/src/win32/cairo-win32-font.c
+++ mingw64-x-cairo-1.14.2/src/win32/cairo-win32-font.c
@@ -162,7 +162,8 @@ _cairo_win32_scaled_font_init_glyph_path
 static HDC
 _get_global_font_dc (void)
 {
-    static HDC hdc;
+    extern DWORD cairoTlsIndex;
+    HDC hdc = TlsGetValue(cairoTlsIndex);
 
     if (!hdc) {
 	hdc = CreateCompatibleDC (NULL);
@@ -170,7 +171,7 @@ _get_global_font_dc (void)
 	    _cairo_win32_print_gdi_error ("_get_global_font_dc");
 	    return NULL;
 	}
-
+	TlsSetValue(cairoTlsIndex, hdc);
 	if (!SetGraphicsMode (hdc, GM_ADVANCED)) {
 	    _cairo_win32_print_gdi_error ("_get_global_font_dc");
 	    DeleteDC (hdc);
Index: mingw64-x-cairo-1.14.2/src/win32/cairo-win32-system.c
===================================================================
--- mingw64-x-cairo-1.14.2.orig/src/win32/cairo-win32-system.c
+++ mingw64-x-cairo-1.14.2/src/win32/cairo-win32-system.c
@@ -60,6 +60,7 @@
 #endif
 
 #include <windows.h>
+DWORD cairoTlsIndex;
 
 /* declare to avoid "no previous prototype for 'DllMain'" warning */
 BOOL WINAPI
@@ -72,13 +73,19 @@ DllMain (HINSTANCE hinstDLL,
          DWORD     fdwReason,
          LPVOID    lpvReserved)
 {
+    void *ptr;
     switch (fdwReason) {
         case DLL_PROCESS_ATTACH:
             CAIRO_MUTEX_INITIALIZE ();
+            cairoTlsIndex = TlsAlloc();
             break;
 
         case DLL_PROCESS_DETACH:
             CAIRO_MUTEX_FINALIZE ();
+            if ((ptr = TlsGetValue(cairoTlsIndex))) {
+               DeleteDC((HDC)ptr);
+            }
+            TlsFree(cairoTlsIndex);
             break;
     }
 
