本文整理汇总了C++中FontPlatformData::fontFace方法的典型用法代码示例。如果您正苦于以下问题:C++ FontPlatformData::fontFace方法的具体用法?C++ FontPlatformData::fontFace怎么用?C++ FontPlatformData::fontFace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FontPlatformData
的用法示例。
在下文中一共展示了FontPlatformData::fontFace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createFontPlatformData
FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
{
bool isLucidaGrande = false;
static AtomicString lucidaStr("Lucida Grande");
if (equalIgnoringCase(family, lucidaStr))
isLucidaGrande = true;
bool useGDI = fontDescription.renderingMode() == AlternateRenderingMode && !isLucidaGrande;
// The logical size constant is 32. We do this for subpixel precision when rendering using Uniscribe.
// This masks rounding errors related to the HFONT metrics being different from the CGFont metrics.
// FIXME: We will eventually want subpixel precision for GDI mode, but the scaled rendering doesn't
// look as nice. That may be solvable though.
#if PLATFORM(CG)
bool canCreateCGFontWithLOGFONT = wkCanCreateCGFontWithLOGFONT();
#else
bool canCreateCGFontWithLOGFONT = true;
#endif
LONG weight = adjustedGDIFontWeight(toGDIFontWeight(fontDescription.weight()), family);
HFONT hfont = createGDIFont(family, weight, fontDescription.italic(),
fontDescription.computedPixelSize() * (useGDI ? 1 : 32), useGDI && canCreateCGFontWithLOGFONT);
if (!hfont)
return 0;
if (isLucidaGrande)
useGDI = false; // Never use GDI for Lucida Grande.
LOGFONT logFont;
GetObject(hfont, sizeof(LOGFONT), &logFont);
bool synthesizeBold = isGDIFontWeightBold(weight) && !isGDIFontWeightBold(logFont.lfWeight);
bool synthesizeItalic = fontDescription.italic() && !logFont.lfItalic;
FontPlatformData* result = new FontPlatformData(hfont, fontDescription.computedPixelSize(), synthesizeBold, synthesizeItalic, useGDI);
#if PLATFORM(CG)
bool fontCreationFailed = !result->cgFont();
#elif PLATFORM(CAIRO)
bool fontCreationFailed = !result->fontFace();
#endif
if (fontCreationFailed) {
// The creation of the CGFontRef failed for some reason. We already asserted in debug builds, but to make
// absolutely sure that we don't use this font, go ahead and return 0 so that we can fall back to the next
// font.
delete result;
DeleteObject(hfont);
return 0;
}
return result;
}