michael@0: diff --git a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp michael@0: --- a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp michael@0: +++ b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp michael@0: @@ -37,16 +37,17 @@ michael@0: #include "cairoint.h" michael@0: michael@0: #include "cairo-win32-private.h" michael@0: #include "cairo-surface-private.h" michael@0: #include "cairo-clip-private.h" michael@0: michael@0: #include "cairo-d2d-private.h" michael@0: #include "cairo-dwrite-private.h" michael@0: +#include "cairo-truetype-subset-private.h" michael@0: #include michael@0: michael@0: typedef HRESULT (WINAPI*D2D1CreateFactoryFunc)( michael@0: D2D1_FACTORY_TYPE factoryType, michael@0: REFIID iid, michael@0: CONST D2D1_FACTORY_OPTIONS *pFactoryOptions, michael@0: void **factory michael@0: ); michael@0: @@ -1036,17 +1037,17 @@ cairo_int_status_t michael@0: { michael@0: cairo_dwrite_scaled_font_t *dwritesf = static_cast(scaled_font); michael@0: cairo_dwrite_font_face_t *face = reinterpret_cast(dwritesf->base.font_face); michael@0: michael@0: const void *data; michael@0: UINT32 size; michael@0: void *tableContext; michael@0: BOOL exists; michael@0: - face->dwriteface->TryGetFontTable(tag, michael@0: + face->dwriteface->TryGetFontTable(be32_to_cpu (tag), michael@0: &data, michael@0: &size, michael@0: &tableContext, michael@0: &exists); michael@0: michael@0: if (!exists) { michael@0: return CAIRO_INT_STATUS_UNSUPPORTED; michael@0: } michael@0: @@ -1476,16 +1477,59 @@ DWriteFactory::CreateRenderingParams() michael@0: Instance()->CreateCustomRenderingParams(gamma, contrast, clearTypeLevel, michael@0: pixelGeometry, renderingMode, michael@0: &mCustomClearTypeRenderingParams); michael@0: Instance()->CreateCustomRenderingParams(gamma, contrast, clearTypeLevel, michael@0: pixelGeometry, DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC, michael@0: &mForceGDIClassicRenderingParams); michael@0: } michael@0: michael@0: +static cairo_bool_t michael@0: +_name_tables_match (cairo_scaled_font_t *font1, michael@0: + cairo_scaled_font_t *font2) michael@0: +{ michael@0: + unsigned long size1; michael@0: + unsigned long size2; michael@0: + cairo_int_status_t status1; michael@0: + cairo_int_status_t status2; michael@0: + unsigned char *buffer1; michael@0: + unsigned char *buffer2; michael@0: + cairo_bool_t result = false; michael@0: + michael@0: + if (!font1->backend->load_truetype_table || michael@0: + !font2->backend->load_truetype_table) michael@0: + return false; michael@0: + michael@0: + status1 = font1->backend->load_truetype_table (font1, michael@0: + TT_TAG_name, 0, NULL, &size1); michael@0: + status2 = font2->backend->load_truetype_table (font2, michael@0: + TT_TAG_name, 0, NULL, &size2); michael@0: + if (status1 || status2) michael@0: + return false; michael@0: + if (size1 != size2) michael@0: + return false; michael@0: + michael@0: + buffer1 = (unsigned char*)malloc (size1); michael@0: + buffer2 = (unsigned char*)malloc (size2); michael@0: + michael@0: + if (buffer1 && buffer2) { michael@0: + status1 = font1->backend->load_truetype_table (font1, michael@0: + TT_TAG_name, 0, buffer1, &size1); michael@0: + status2 = font2->backend->load_truetype_table (font2, michael@0: + TT_TAG_name, 0, buffer2, &size2); michael@0: + if (!status1 && !status2) { michael@0: + result = memcmp (buffer1, buffer2, size1) == 0; michael@0: + } michael@0: + } michael@0: + michael@0: + free (buffer1); michael@0: + free (buffer2); michael@0: + return result; michael@0: +} michael@0: + michael@0: // Helper for _cairo_win32_printing_surface_show_glyphs to create a win32 equivalent michael@0: // of a dwrite scaled_font so that we can print using ExtTextOut instead of drawing michael@0: // paths or blitting glyph bitmaps. michael@0: cairo_int_status_t michael@0: _cairo_dwrite_scaled_font_create_win32_scaled_font (cairo_scaled_font_t *scaled_font, michael@0: cairo_scaled_font_t **new_font) michael@0: { michael@0: if (cairo_scaled_font_get_type (scaled_font) != CAIRO_FONT_TYPE_DWRITE) { michael@0: @@ -1528,19 +1572,18 @@ cairo_int_status_t michael@0: &ctm, michael@0: &options); michael@0: cairo_font_face_destroy (win32_face); michael@0: michael@0: if (!font) { michael@0: return CAIRO_INT_STATUS_UNSUPPORTED; michael@0: } michael@0: michael@0: - if (_cairo_win32_scaled_font_is_type1 (font) || _cairo_win32_scaled_font_is_bitmap (font)) { michael@0: - // If we somehow got a Type1 or bitmap font, it can't be the same physical font michael@0: - // as directwrite was using, so glyph IDs will not match; best we can do is to michael@0: - // throw it away and fall back on rendering paths or blitting bitmaps instead. michael@0: + if (!_name_tables_match (font, scaled_font)) { michael@0: + // If the font name tables aren't equal, then GDI may have failed to michael@0: + // find the right font and substituted a different font. michael@0: cairo_scaled_font_destroy (font); michael@0: return CAIRO_INT_STATUS_UNSUPPORTED; michael@0: } michael@0: michael@0: *new_font = font; michael@0: return CAIRO_INT_STATUS_SUCCESS; michael@0: } michael@0: diff --git a/gfx/cairo/cairo/src/cairo-truetype-subset-private.h b/gfx/cairo/cairo/src/cairo-truetype-subset-private.h michael@0: --- a/gfx/cairo/cairo/src/cairo-truetype-subset-private.h michael@0: +++ b/gfx/cairo/cairo/src/cairo-truetype-subset-private.h michael@0: @@ -34,16 +34,18 @@ michael@0: * Adrian Johnson michael@0: */ michael@0: michael@0: #ifndef CAIRO_TRUETYPE_SUBSET_PRIVATE_H michael@0: #define CAIRO_TRUETYPE_SUBSET_PRIVATE_H michael@0: michael@0: #include "cairoint.h" michael@0: michael@0: +CAIRO_BEGIN_DECLS michael@0: + michael@0: #if CAIRO_HAS_FONT_SUBSET michael@0: michael@0: /* The structs defined here should strictly follow the TrueType michael@0: * specification and not be padded. We use only 16-bit integer michael@0: * in their definition to guarantee that. The fields of type michael@0: * "FIXED" in the TT spec are broken into two *_1 and *_2 16-bit michael@0: * parts, and 64-bit members are broken into four. michael@0: * michael@0: @@ -191,9 +193,11 @@ typedef struct _tt_composite_glyph { michael@0: typedef struct _tt_glyph_data { michael@0: int16_t num_contours; michael@0: int8_t data[8]; michael@0: tt_composite_glyph_t glyph; michael@0: } tt_glyph_data_t; michael@0: michael@0: #endif /* CAIRO_HAS_FONT_SUBSET */ michael@0: michael@0: +CAIRO_END_DECLS michael@0: + michael@0: #endif /* CAIRO_TRUETYPE_SUBSET_PRIVATE_H */