Skip to content

Commit 71b97ab

Browse files
author
urbaneks
committed
fixes for r88967 (leak, length, fallback)
git-svn-id: https://svn.r-project.org/R/trunk@88973 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent e2585fb commit 71b97ab

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/library/grDevices/src/cairo/cairoFns.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,9 +1488,9 @@ R_win32_cairo_select_font_face(cairo_t *cr,
14881488
cairo_font_face_t *ff;
14891489

14901490
memset(&lf, 0, sizeof(LOGFONTW));
1491-
if (mbstowcs(lf.lfFaceName, family, 32) == (size_t)-1)
1491+
if (mbstowcs(lf.lfFaceName, family, LF_FACESIZE - 1) == (size_t) -1)
14921492
return;
1493-
lf.lfFaceName[32-1] = L'\0';
1493+
lf.lfFaceName[LF_FACESIZE - 1] = L'\0';
14941494

14951495
if (weight == CAIRO_FONT_WEIGHT_BOLD)
14961496
lf.lfWeight = FW_BOLD;
@@ -1506,6 +1506,9 @@ R_win32_cairo_select_font_face(cairo_t *cr,
15061506
ff = cairo_win32_font_face_create_for_logfontw(&lf);
15071507
if (ff && cairo_font_face_status(ff) == CAIRO_STATUS_SUCCESS)
15081508
cairo_set_font_face(cr, ff);
1509+
else /* fall back to the default handler if not found */
1510+
cairo_select_font_face(cr, family, slant, weight);
1511+
if (ff) cairo_font_face_destroy(ff);
15091512
}
15101513
#endif
15111514

0 commit comments

Comments
 (0)