1 diff --git a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
2 --- a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
3 +++ b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
7 #include "cairo-win32-private.h"
8 #include "cairo-surface-private.h"
9 #include "cairo-clip-private.h"
11 #include "cairo-d2d-private.h"
12 #include "cairo-dwrite-private.h"
13 +#include "cairo-truetype-subset-private.h"
16 typedef HRESULT (WINAPI*D2D1CreateFactoryFunc)(
17 D2D1_FACTORY_TYPE factoryType,
19 CONST D2D1_FACTORY_OPTIONS *pFactoryOptions,
22 @@ -1036,17 +1037,17 @@ cairo_int_status_t
24 cairo_dwrite_scaled_font_t *dwritesf = static_cast<cairo_dwrite_scaled_font_t*>(scaled_font);
25 cairo_dwrite_font_face_t *face = reinterpret_cast<cairo_dwrite_font_face_t*>(dwritesf->base.font_face);
31 - face->dwriteface->TryGetFontTable(tag,
32 + face->dwriteface->TryGetFontTable(be32_to_cpu (tag),
39 return CAIRO_INT_STATUS_UNSUPPORTED;
41 @@ -1476,16 +1477,59 @@ DWriteFactory::CreateRenderingParams()
42 Instance()->CreateCustomRenderingParams(gamma, contrast, clearTypeLevel,
43 pixelGeometry, renderingMode,
44 &mCustomClearTypeRenderingParams);
45 Instance()->CreateCustomRenderingParams(gamma, contrast, clearTypeLevel,
46 pixelGeometry, DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC,
47 &mForceGDIClassicRenderingParams);
51 +_name_tables_match (cairo_scaled_font_t *font1,
52 + cairo_scaled_font_t *font2)
54 + unsigned long size1;
55 + unsigned long size2;
56 + cairo_int_status_t status1;
57 + cairo_int_status_t status2;
58 + unsigned char *buffer1;
59 + unsigned char *buffer2;
60 + cairo_bool_t result = false;
62 + if (!font1->backend->load_truetype_table ||
63 + !font2->backend->load_truetype_table)
66 + status1 = font1->backend->load_truetype_table (font1,
67 + TT_TAG_name, 0, NULL, &size1);
68 + status2 = font2->backend->load_truetype_table (font2,
69 + TT_TAG_name, 0, NULL, &size2);
70 + if (status1 || status2)
75 + buffer1 = (unsigned char*)malloc (size1);
76 + buffer2 = (unsigned char*)malloc (size2);
78 + if (buffer1 && buffer2) {
79 + status1 = font1->backend->load_truetype_table (font1,
80 + TT_TAG_name, 0, buffer1, &size1);
81 + status2 = font2->backend->load_truetype_table (font2,
82 + TT_TAG_name, 0, buffer2, &size2);
83 + if (!status1 && !status2) {
84 + result = memcmp (buffer1, buffer2, size1) == 0;
93 // Helper for _cairo_win32_printing_surface_show_glyphs to create a win32 equivalent
94 // of a dwrite scaled_font so that we can print using ExtTextOut instead of drawing
95 // paths or blitting glyph bitmaps.
97 _cairo_dwrite_scaled_font_create_win32_scaled_font (cairo_scaled_font_t *scaled_font,
98 cairo_scaled_font_t **new_font)
100 if (cairo_scaled_font_get_type (scaled_font) != CAIRO_FONT_TYPE_DWRITE) {
101 @@ -1528,19 +1572,18 @@ cairo_int_status_t
104 cairo_font_face_destroy (win32_face);
107 return CAIRO_INT_STATUS_UNSUPPORTED;
110 - if (_cairo_win32_scaled_font_is_type1 (font) || _cairo_win32_scaled_font_is_bitmap (font)) {
111 - // If we somehow got a Type1 or bitmap font, it can't be the same physical font
112 - // as directwrite was using, so glyph IDs will not match; best we can do is to
113 - // throw it away and fall back on rendering paths or blitting bitmaps instead.
114 + if (!_name_tables_match (font, scaled_font)) {
115 + // If the font name tables aren't equal, then GDI may have failed to
116 + // find the right font and substituted a different font.
117 cairo_scaled_font_destroy (font);
118 return CAIRO_INT_STATUS_UNSUPPORTED;
122 return CAIRO_INT_STATUS_SUCCESS;
124 diff --git a/gfx/cairo/cairo/src/cairo-truetype-subset-private.h b/gfx/cairo/cairo/src/cairo-truetype-subset-private.h
125 --- a/gfx/cairo/cairo/src/cairo-truetype-subset-private.h
126 +++ b/gfx/cairo/cairo/src/cairo-truetype-subset-private.h
128 * Adrian Johnson <ajohnson@redneon.com>
131 #ifndef CAIRO_TRUETYPE_SUBSET_PRIVATE_H
132 #define CAIRO_TRUETYPE_SUBSET_PRIVATE_H
134 #include "cairoint.h"
138 #if CAIRO_HAS_FONT_SUBSET
140 /* The structs defined here should strictly follow the TrueType
141 * specification and not be padded. We use only 16-bit integer
142 * in their definition to guarantee that. The fields of type
143 * "FIXED" in the TT spec are broken into two *_1 and *_2 16-bit
144 * parts, and 64-bit members are broken into four.
146 @@ -191,9 +193,11 @@ typedef struct _tt_composite_glyph {
147 typedef struct _tt_glyph_data {
148 int16_t num_contours;
150 tt_composite_glyph_t glyph;
153 #endif /* CAIRO_HAS_FONT_SUBSET */
157 #endif /* CAIRO_TRUETYPE_SUBSET_PRIVATE_H */