[pango/pango1-dwrite] pangowin32-private.h: Add declarations needed for GDI+



commit a7076b2dab3d20d10e8b6335932c8d7b1f610b82
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Jul 12 10:42:26 2022 +0800

    pangowin32-private.h: Add declarations needed for GDI+
    
    We can't just include the GDI+ headers since the headers shipped with the
    Windows SDK does not support usage in plain C, so we need to define the
    structures, enums, typedefs and the function prototypes as needed, for checking
    whether a font support hinting.
    
    DirectWrite also supports such checks in a simpler fashion, but is only
    supported for Windows 8.1 or later.

 pango/pangowin32-private.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
---
diff --git a/pango/pangowin32-private.h b/pango/pangowin32-private.h
index 52d7e8f41..9bbc3b22c 100644
--- a/pango/pangowin32-private.h
+++ b/pango/pangowin32-private.h
@@ -59,6 +59,73 @@
 
 G_BEGIN_DECLS
 
+/*
+ * Sadly, we can't just include the GDI+ headers from the Windows SDKs since they are for C++
+ * So, these are the structures, enums, typedef's and function prototypes
+ * required for using GDI+ in C, used to implement checking for whether the font supports
+ * hinting, especially for Windows 7 and 8, where DirectWrite does not support checking for
+ * such things.  We still need to link to gdiplus.lib to use these APIs.
+ */
+
+struct _GdiplusStartupInput
+{
+    UINT32 GdiplusVersion;
+    gpointer DebugEventCallback;
+    BOOL SuppressBackgroundThread;
+    BOOL SuppressExternalCodecs;
+};
+
+enum _Status
+{
+    Ok                          = 0,
+    GenericError                = 1,
+    InvalidParameter            = 2,
+    OutOfMemory                 = 3,
+    ObjectBusy                  = 4,
+    InsufficientBuffer          = 5,
+    NotImplemented              = 6,
+    Win32Error                  = 7,
+    WrongState                  = 8,
+    Aborted                     = 9,
+    FileNotFound                = 10,
+    ValueOverflow               = 11,
+    AccessDenied                = 12,
+    UnknownImageFormat          = 13,
+    FontFamilyNotFound          = 14,
+    FontStyleNotFound           = 15,
+    NotTrueTypeFont             = 16,
+    UnsupportedGdiplusVersion   = 17,
+    GdiplusNotInitialized       = 18,
+    PropertyNotFound            = 19,
+    PropertyNotSupported        = 20,
+    ProfileNotFound             = 21
+};
+
+enum _TextRenderingHint
+{
+    TextRenderingHintSystemDefault = 0,            // Glyph with system default rendering hint
+    TextRenderingHintSingleBitPerPixelGridFit,     // Glyph bitmap with hinting
+    TextRenderingHintSingleBitPerPixel,            // Glyph bitmap without hinting
+    TextRenderingHintAntiAliasGridFit,             // Glyph anti-alias bitmap with hinting
+    TextRenderingHintAntiAlias,                    // Glyph anti-alias bitmap without hinting
+    TextRenderingHintClearTypeGridFit              // Glyph CT bitmap with hinting
+};
+
+typedef enum _Status Status;
+typedef enum _Status GpStatus;
+typedef enum _TextRenderingHint TextRenderingHint;
+typedef struct _GdiplusStartupInput GdiplusStartupInput;
+typedef struct _GpGraphics GpGraphics;
+
+extern GpStatus WINAPI
+GdiplusStartup(ULONG_PTR *token,
+               const GdiplusStartupInput *input,
+               gpointer                   output);
+extern void WINAPI GdiplusShutdown(ULONG_PTR token);
+extern GpStatus WINAPI GdipCreateFromHDC (HDC hdc, GpGraphics **graphics);
+extern GpStatus WINAPI GdipGetTextRenderingHint(GpGraphics *graphics, TextRenderingHint *mode);
+extern GpStatus WINAPI GdipDeleteGraphics(GpGraphics *graphics);
+
 #define PANGO_TYPE_WIN32_FONT_MAP             (_pango_win32_font_map_get_type ())
 #define PANGO_WIN32_FONT_MAP(object)          (G_TYPE_CHECK_INSTANCE_CAST ((object), 
PANGO_TYPE_WIN32_FONT_MAP, PangoWin32FontMap))
 #define PANGO_WIN32_IS_FONT_MAP(object)       (G_TYPE_CHECK_INSTANCE_TYPE ((object), 
PANGO_TYPE_WIN32_FONT_MAP))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]