diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2021-08-11 07:19:54 +0930 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2022-02-27 15:44:58 +1030 |
commit | 7e644409eab3a495970c6d8dafdab33610e86f87 (patch) | |
tree | f46c4245e1580cf3abdf1fba170c9e54dec00b7a /src/win32 | |
parent | fa76ebec03ebf3252b18e0bb319ca42e00503083 (diff) | |
download | cairo-7e644409eab3a495970c6d8dafdab33610e86f87.tar.gz |
Fix dwrite toy fonts
Diffstat (limited to 'src/win32')
-rw-r--r-- | src/win32/cairo-dwrite-font.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/win32/cairo-dwrite-font.cpp b/src/win32/cairo-dwrite-font.cpp index 42b02792b..dc03c1690 100644 --- a/src/win32/cairo-dwrite-font.cpp +++ b/src/win32/cairo-dwrite-font.cpp @@ -276,17 +276,20 @@ _cairo_dwrite_font_face_create_for_toy (cairo_toy_font_face_t *toy_face, break; } - cairo_dwrite_font_face_t *face = (cairo_dwrite_font_face_t*)malloc(sizeof(cairo_dwrite_font_face_t)); - HRESULT hr = family->GetFirstMatchingFont(weight, DWRITE_FONT_STRETCH_NORMAL, style, &face->font); + // Cannot use C++ style new since cairo deallocates this. + cairo_dwrite_font_face_t *face = (cairo_dwrite_font_face_t*)_cairo_malloc(sizeof(cairo_dwrite_font_face_t)); + IDWriteFont *font; + HRESULT hr = family->GetFirstMatchingFont(weight, DWRITE_FONT_STRETCH_NORMAL, style, &font); if (SUCCEEDED(hr)) { - // Cannot use C++ style new since cairo deallocates this. - *font_face = (cairo_font_face_t*)face; - _cairo_font_face_init (&(*(_cairo_dwrite_font_face**)font_face)->base, &_cairo_dwrite_font_face_backend); - } else { - free(face); + hr = font->CreateFontFace(&face->dwriteface); + if (SUCCEEDED(hr)) { + *font_face = (cairo_font_face_t*)face; + _cairo_font_face_init (&(*(_cairo_dwrite_font_face**)font_face)->base, &_cairo_dwrite_font_face_backend); + return CAIRO_STATUS_SUCCESS; + } } - - return CAIRO_STATUS_SUCCESS; + free(face); + return (cairo_status_t)CAIRO_INT_STATUS_UNSUPPORTED; } static cairo_bool_t |