summaryrefslogtreecommitdiff
path: root/src/win32
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2022-06-16 21:44:04 +0930
committerAdrian Johnson <ajohnson@redneon.com>2022-06-17 20:42:43 +0930
commitf0ba2165a6a23bdbc9d6e93da4231c2cac77a2c2 (patch)
treec609b1624b65098467ca6f66e94c947fdc828923 /src/win32
parentb5d2395a5fd9f357839df8c5e6d4dae1ac302e13 (diff)
downloadcairo-f0ba2165a6a23bdbc9d6e93da4231c2cac77a2c2.tar.gz
Add color palette option
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/cairo-dwrite-font.cpp13
-rw-r--r--src/win32/cairo-dwrite-private.hpp1
2 files changed, 12 insertions, 2 deletions
diff --git a/src/win32/cairo-dwrite-font.cpp b/src/win32/cairo-dwrite-font.cpp
index edac72c5f..c58827555 100644
--- a/src/win32/cairo-dwrite-font.cpp
+++ b/src/win32/cairo-dwrite-font.cpp
@@ -924,6 +924,15 @@ _cairo_dwrite_scaled_font_init_glyph_color_surface(cairo_dwrite_scaled_font_t *s
DWRITE_GLYPH_IMAGE_FORMATS_TIFF |
DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8;
+ RefPtr<IDWriteFontFace2> fontFace2;
+ UINT32 palette_count = 0;
+ if (SUCCEEDED(dwrite_font_face->dwriteface->QueryInterface(&fontFace2)))
+ palette_count = fontFace2->GetColorPaletteCount();
+
+ UINT32 palette_index = CAIRO_COLOR_PALETTE_DEFAULT;
+ if (scaled_font->base.options.palette_index < palette_count)
+ palette_index = scaled_font->base.options.palette_index;
+
hr = DWriteFactory::Instance4()->TranslateColorGlyphRun(
origin,
&run,
@@ -931,7 +940,7 @@ _cairo_dwrite_scaled_font_init_glyph_color_surface(cairo_dwrite_scaled_font_t *s
supported_formats,
DWRITE_MEASURING_MODE_NATURAL,
&matrix,
- 0,
+ palette_index,
&run_enumerator);
if (hr == DWRITE_E_NOCOLOR) {
@@ -1028,7 +1037,7 @@ _cairo_dwrite_scaled_font_init_glyph_color_surface(cairo_dwrite_scaled_font_t *s
&color_run->glyphRun,
foreground_color_brush,
nullptr,
- 0,
+ palette_index,
DWRITE_MEASURING_MODE_NATURAL);
uses_foreground_color = TRUE;
break;
diff --git a/src/win32/cairo-dwrite-private.hpp b/src/win32/cairo-dwrite-private.hpp
index 34f86e8f1..92b096857 100644
--- a/src/win32/cairo-dwrite-private.hpp
+++ b/src/win32/cairo-dwrite-private.hpp
@@ -37,6 +37,7 @@
#include "cairoint.h"
#include "cairo-win32-refptr.hpp"
#include <dwrite.h>
+#include <dwrite_2.h>
#include <d2d1.h>
/* If either of the dwrite_3.h or d2d1_3.h headers required for color fonts