[cairo-commit] 2 commits - src/win32

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 21 19:13:13 UTC 2022


 src/win32/cairo-dwrite-font.cpp |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

New commits:
commit 4931e44f23059fd7dc1a2ab2c6c5f2eedf651eb5
Merge: 359afa3e8 136bf8c19
Author: Uli Schlachter <psychon at znc.in>
Date:   Mon Mar 21 19:13:11 2022 +0000

    Merge branch 'dwrite-toy-font' into 'master'
    
    Ensure DWrite toy fonts can not fail if font name not found
    
    See merge request cairo/cairo!302

commit 136bf8c191486cc75790028f9e14591cc532a948
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Mar 20 11:15:12 2022 +1030

    Ensure DWrite toy fonts can not fail if font name not found

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;


More information about the cairo-commit mailing list