diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2022-03-20 11:15:12 +1030 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2022-03-22 04:54:05 +1030 |
commit | 136bf8c191486cc75790028f9e14591cc532a948 (patch) | |
tree | 294a7f96cc4b94f99dcaee2daa6ec2ecd007441a /src/win32 | |
parent | ad3bace256bfb6fc694c15965364b7e53181431c (diff) | |
download | cairo-136bf8c191486cc75790028f9e14591cc532a948.tar.gz |
Ensure DWrite toy fonts can not fail if font name not found
Diffstat (limited to 'src/win32')
-rw-r--r-- | src/win32/cairo-dwrite-font.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/win32/cairo-dwrite-font.cpp b/src/win32/cairo-dwrite-font.cpp index afa859fbd..4c9270a59 100644 --- a/src/win32/cairo-dwrite-font.cpp +++ b/src/win32/cairo-dwrite-font.cpp @@ -327,8 +327,17 @@ _cairo_dwrite_font_face_create_for_toy (cairo_toy_font_face_t *toy_face, IDWriteFontFamily *family = DWriteFactory::FindSystemFontFamily(face_name); delete face_name; if (!family) { - *font_face = (cairo_font_face_t*)&_cairo_font_face_nil; - return CAIRO_STATUS_FONT_TYPE_MISMATCH; + /* If the family is not found, use the default that should always exist. */ + face_name_len = MultiByteToWideChar(CP_UTF8, 0, CAIRO_FONT_FAMILY_DEFAULT, -1, NULL, 0); + face_name = new WCHAR[face_name_len]; + MultiByteToWideChar(CP_UTF8, 0, CAIRO_FONT_FAMILY_DEFAULT, -1, face_name, face_name_len); + + family = DWriteFactory::FindSystemFontFamily(face_name); + delete face_name; + if (!family) { + *font_face = (cairo_font_face_t*)&_cairo_font_face_nil; + return CAIRO_STATUS_FONT_TYPE_MISMATCH; + } } DWRITE_FONT_WEIGHT weight; |