static cairo_font_face_t * pango_cairo_win32_font_get_font_face (PangoCairoFont *font) { PangoCairoWin32Font *cwfont = PANGO_CAIRO_WIN32_FONT (font); PangoWin32Font *win32font = PANGO_WIN32_FONT (cwfont); if (cwfont->font_face == NULL) { LOGFONTW logfontw; /* Count here on the fact that all the struct fields are the * same for LOGFONTW and LOGFONTA except lfFaceName which is the * last field */ memcpy (&logfontw, &win32font->logfont, sizeof (LOGFONTA)); if (!MultiByteToWideChar (CP_ACP, MB_ERR_INVALID_CHARS, win32font->logfont.lfFaceName, -1, logfontw.lfFaceName, G_N_ELEMENTS (logfontw.lfFaceName))) logfontw.lfFaceName[0] = 0; /* Hopefully this will select some font */ cwfont->font_face = cairo_win32_font_face_create_for_logfontw (&logfontw); /* Failure of the above should only occur for out of memory, * we can't proceed at that point */ if (!cwfont->font_face) g_error ("Unable to create Win32 cairo font face.\nThis means out of memory or a cairo/fontconfig/FreeType bug"); } return cwfont->font_face; }
cairo_font_face_t* ScaledFontWin::GetCairoFontFace() { if (mLogFont.lfFaceName[0] == 0) { return nullptr; } return cairo_win32_font_face_create_for_logfontw(&mLogFont); }
void Context::setFont( const cinder::Font &font ) { #if defined( CINDER_COCOA ) cairo_font_face_t *cairoFont = cairo_quartz_font_face_create_for_cgfont( font.getCgFontRef() ); #elif defined( CINDER_MSW ) cairo_font_face_t *cairoFont = cairo_win32_font_face_create_for_logfontw( &font.getLogfont() ); #endif cairo_set_font_face( mCairo, cairoFont ); cairo_font_face_destroy( cairoFont ); }