static void fontspec_to_win32 (CHOOSEFONT *cf, const char *src, int which) { PangoFontDescription *pfd; PangoFontMap *map; PangoContext *pc; PangoFont *font; pfd = pango_font_description_from_string(src); map = pango_win32_font_map_for_display(); pc = pango_font_map_create_context(map); font = pango_context_load_font(pc, pfd); cf->lpLogFont = pango_win32_font_logfont(font); g_object_unref(font); g_object_unref(pc); pango_font_description_free(pfd); }
void font_instance::InitTheFace() { #ifdef USE_PANGO_WIN32 if ( !theFace ) { LOGFONT *lf=pango_win32_font_logfont(pFont); g_assert(lf != NULL); theFace=pango_win32_font_cache_load(daddy->pangoFontCache,lf); g_free(lf); } XFORM identity = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0}; SetWorldTransform(daddy->hScreenDC, &identity); SetGraphicsMode(daddy->hScreenDC, GM_COMPATIBLE); SelectObject(daddy->hScreenDC,theFace); #else theFace=pango_ft2_font_get_face(pFont); // Deprecated, use pango_fc_font_lock_face() instead if ( theFace ) { FT_Select_Charmap(theFace,ft_encoding_unicode) && FT_Select_Charmap(theFace,ft_encoding_symbol); } #endif }
static void set_font(DiaRenderer *self, DiaFont *font, real height) { WmfRenderer *renderer = WMF_RENDERER (self); W32::LPCTSTR sFace; W32::DWORD dwItalic = 0; W32::DWORD dwWeight = FW_DONTCARE; DiaFontStyle style = dia_font_get_style(font); real font_size = dia_font_get_size (font) * (height / dia_font_get_height (font)); DIAG_NOTE(renderer, "set_font %s %f\n", dia_font_get_family (font), height); if (renderer->hFont) { W32::DeleteObject(renderer->hFont); renderer->hFont = NULL; } if (renderer->pango_context) { g_object_unref (renderer->pango_context); renderer->pango_context = NULL; } if (renderer->use_pango) { #ifdef __PANGOWIN32_H__ /* with the pangowin32 backend there is a better way */ if (!renderer->pango_context) renderer->pango_context = pango_win32_get_context (); PangoFont* pf = pango_context_load_font (renderer->pango_context, dia_font_get_description (font)); if (pf) { W32::LOGFONT* lf = pango_win32_font_logfont (pf); /* .93 : sligthly smaller looks much better */ lf->lfHeight = -SC(height*.93); lf->lfHeight = -SC(font_size); renderer->hFont = (W32::HFONT)W32::CreateFontIndirect (lf); g_free (lf); g_object_unref (pf); } else { gchar *desc = pango_font_description_to_string (dia_font_get_description (font)); dia_context_add_message(renderer->ctx, _("Cannot render unknown font:\n%s"), desc); g_free (desc); } #else g_assert_not_reached(); #endif } else { sFace = dia_font_get_family (font); dwItalic = DIA_FONT_STYLE_GET_SLANT(style) != DIA_FONT_NORMAL; /* although there is a known algorithm avoid it for cleanness */ switch (DIA_FONT_STYLE_GET_WEIGHT(style)) { case DIA_FONT_ULTRALIGHT : dwWeight = FW_ULTRALIGHT; break; case DIA_FONT_LIGHT : dwWeight = FW_LIGHT; break; case DIA_FONT_MEDIUM : dwWeight = FW_MEDIUM; break; case DIA_FONT_DEMIBOLD : dwWeight = FW_DEMIBOLD; break; case DIA_FONT_BOLD : dwWeight = FW_BOLD; break; case DIA_FONT_ULTRABOLD : dwWeight = FW_ULTRABOLD; break; case DIA_FONT_HEAVY : dwWeight = FW_HEAVY; break; default : dwWeight = FW_NORMAL; break; } //Hack to get BYTE out of namespace W32 # ifndef BYTE # define BYTE unsigned char # endif renderer->hFont = (W32::HFONT)W32::CreateFont( - SC (font_size), // logical height of font 0, // logical average character width 0, // angle of escapement 0, // base-line orientation angle dwWeight, // font weight dwItalic, // italic attribute flag 0, // underline attribute flag 0, // strikeout attribute flag DEFAULT_CHARSET, // character set identifier OUT_TT_PRECIS, // output precision CLIP_DEFAULT_PRECIS, // clipping precision PROOF_QUALITY, // output quality DEFAULT_PITCH, // pitch and family sFace); // pointer to typeface name string } }