本文整理汇总了C++中FontDescription::firstFamily方法的典型用法代码示例。如果您正苦于以下问题:C++ FontDescription::firstFamily方法的具体用法?C++ FontDescription::firstFamily怎么用?C++ FontDescription::firstFamily使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FontDescription
的用法示例。
在下文中一共展示了FontDescription::firstFamily方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createFontForDocument
void FontBuilder::createFontForDocument(PassRefPtr<FontSelector> fontSelector, RenderStyle* documentStyle)
{
FontDescription fontDescription = FontDescription();
fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle->locale()));
if (Settings* settings = m_document->settings()) {
fontDescription.setUsePrinterFont(m_document->printing());
const AtomicString& standardFont = settings->standardFontFamily(fontDescription.script());
if (!standardFont.isEmpty()) {
fontDescription.setGenericFamily(FontDescription::StandardFamily);
fontDescription.firstFamily().setFamily(standardFont);
fontDescription.firstFamily().appendFamily(0);
}
fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
int size = FontSize::fontSizeForKeyword(m_document, CSSValueMedium, false);
fontDescription.setSpecifiedSize(size);
fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescription, documentStyle->effectiveZoom(), size));
} else {
fontDescription.setUsePrinterFont(m_document->printing());
}
FontOrientation fontOrientation;
NonCJKGlyphOrientation glyphOrientation;
getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation);
fontDescription.setOrientation(fontOrientation);
fontDescription.setNonCJKGlyphOrientation(glyphOrientation);
documentStyle->setFontDescription(fontDescription);
documentStyle->font().update(fontSelector);
}
示例2: setFontFamilyInitial
void FontBuilder::setFontFamilyInitial(float effectiveZoom)
{
FontDescriptionChangeScope scope(this);
FontDescription initialDesc = FontDescription();
// We need to adjust the size to account for the generic family change from monospace to non-monospace.
if (scope.fontDescription().keywordSize() && scope.fontDescription().useFixedDefaultSize())
setSize(scope.fontDescription(), effectiveZoom, FontSize::fontSizeForKeyword(m_document, CSSValueXxSmall + scope.fontDescription().keywordSize() - 1, false));
scope.fontDescription().setGenericFamily(initialDesc.genericFamily());
if (!initialDesc.firstFamily().familyIsEmpty())
scope.fontDescription().setFamily(initialDesc.firstFamily());
}
示例3: setFontFamilyToStandard
inline static void setFontFamilyToStandard(FontDescription& fontDescription, const Document* document)
{
if (!document || !document->settings())
return;
fontDescription.setGenericFamily(FontDescription::StandardFamily);
const AtomicString& standardFontFamily = document->settings()->genericFontFamilySettings().standard();
if (standardFontFamily.isEmpty())
return;
fontDescription.firstFamily().setFamily(standardFontFamily);
// FIXME: Why is this needed here?
fontDescription.firstFamily().appendFamily(nullptr);
}
示例4: systemFont
void RenderThemeChromiumWin::systemFont(int propId, FontDescription& fontDescription) const
{
// This logic owes much to RenderThemeSafari.cpp.
FontDescription* cachedDesc = 0;
AtomicString faceName;
float fontSize = 0;
switch (propId) {
case CSSValueSmallCaption:
cachedDesc = &smallSystemFont;
if (!smallSystemFont.isAbsoluteSize()) {
NONCLIENTMETRICS metrics;
getNonClientMetrics(&metrics);
faceName = AtomicString(metrics.lfSmCaptionFont.lfFaceName, wcslen(metrics.lfSmCaptionFont.lfFaceName));
fontSize = systemFontSize(metrics.lfSmCaptionFont);
}
break;
case CSSValueMenu:
cachedDesc = &menuFont;
if (!menuFont.isAbsoluteSize()) {
NONCLIENTMETRICS metrics;
getNonClientMetrics(&metrics);
faceName = AtomicString(metrics.lfMenuFont.lfFaceName, wcslen(metrics.lfMenuFont.lfFaceName));
fontSize = systemFontSize(metrics.lfMenuFont);
}
break;
case CSSValueStatusBar:
cachedDesc = &labelFont;
if (!labelFont.isAbsoluteSize()) {
NONCLIENTMETRICS metrics;
getNonClientMetrics(&metrics);
faceName = metrics.lfStatusFont.lfFaceName;
fontSize = systemFontSize(metrics.lfStatusFont);
}
break;
case CSSValueWebkitMiniControl:
case CSSValueWebkitSmallControl:
case CSSValueWebkitControl:
faceName = defaultGUIFont();
// Why 2 points smaller? Because that's what Gecko does.
fontSize = defaultFontSize - pointsToPixels(2);
break;
default:
faceName = defaultGUIFont();
fontSize = defaultFontSize;
break;
}
if (!cachedDesc)
cachedDesc = &fontDescription;
if (fontSize) {
cachedDesc->firstFamily().setFamily(faceName);
cachedDesc->setIsAbsoluteSize(true);
cachedDesc->setGenericFamily(FontDescription::NoFamily);
cachedDesc->setSpecifiedSize(fontSize);
cachedDesc->setWeight(FontWeightNormal);
cachedDesc->setItalic(false);
}
fontDescription = *cachedDesc;
}
示例5: systemFont
// static
void RenderThemeChromiumFontProvider::systemFont(CSSValueID valueID, FontDescription& fontDescription)
{
float fontSize = s_defaultFontSize;
switch (valueID) {
case CSSValueWebkitMiniControl:
case CSSValueWebkitSmallControl:
case CSSValueWebkitControl:
// Why 2 points smaller? Because that's what Gecko does. Note that we
// are assuming a 96dpi screen, which is the default that we use on
// Windows.
static const float pointsPerInch = 72.0f;
static const float pixelsPerInch = 96.0f;
fontSize -= (2.0f / pointsPerInch) * pixelsPerInch;
break;
default:
break;
}
fontDescription.firstFamily().setFamily(defaultGUIFont());
fontDescription.setSpecifiedSize(fontSize);
fontDescription.setIsAbsoluteSize(true);
fontDescription.setGenericFamily(FontDescription::NoFamily);
fontDescription.setWeight(FontWeightNormal);
fontDescription.setStyle(FontStyleNormal);
}
示例6: systemFont
void RenderThemeGtk::systemFont(int, FontDescription& fontDescription) const
{
GtkSettings* settings = gtk_settings_get_default();
if (!settings)
return;
// This will be a font selection string like "Sans 10" so we cannot use it as the family name.
GOwnPtr<gchar> fontName;
g_object_get(settings, "gtk-font-name", &fontName.outPtr(), NULL);
PangoFontDescription* pangoDescription = pango_font_description_from_string(fontName.get());
if (!pangoDescription)
return;
fontDescription.firstFamily().setFamily(pango_font_description_get_family(pangoDescription));
int size = pango_font_description_get_size(pangoDescription) / PANGO_SCALE;
// If the size of the font is in points, we need to convert it to pixels.
if (!pango_font_description_get_size_is_absolute(pangoDescription))
size = size * (getScreenDPI() / 72.0);
fontDescription.setSpecifiedSize(size);
fontDescription.setIsAbsoluteSize(true);
fontDescription.setGenericFamily(FontDescription::NoFamily);
fontDescription.setWeight(FontWeightNormal);
fontDescription.setItalic(false);
pango_font_description_free(pangoDescription);
}
示例7: font
HRESULT STDMETHODCALLTYPE DOMElement::font(WebFontDescription* webFontDescription)
{
if (!webFontDescription) {
ASSERT_NOT_REACHED();
return E_POINTER;
}
ASSERT(m_element);
WebCore::RenderElement* renderer = m_element->renderer();
if (!renderer)
return E_FAIL;
FontDescription fontDescription = renderer->style().fontCascade().fontDescription();
AtomicString family = fontDescription.firstFamily();
// FIXME: This leaks. Delete this whole function to get rid of the leak.
UChar* familyCharactersBuffer = new UChar[family.length()];
StringView(family.string()).getCharactersWithUpconvert(familyCharactersBuffer);
webFontDescription->family = familyCharactersBuffer;
webFontDescription->familyLength = family.length();
webFontDescription->size = fontDescription.computedSize();
webFontDescription->bold = fontDescription.weight() >= WebCore::FontWeight600;
webFontDescription->italic = fontDescription.italic();
return S_OK;
}
示例8: systemFont
void RenderThemeSafari::systemFont(int propId, FontDescription& fontDescription) const
{
static FontDescription systemFont;
static FontDescription smallSystemFont;
static FontDescription menuFont;
static FontDescription labelFont;
static FontDescription miniControlFont;
static FontDescription smallControlFont;
static FontDescription controlFont;
FontDescription* cachedDesc;
float fontSize = 0;
switch (propId) {
case CSSValueSmallCaption:
cachedDesc = &smallSystemFont;
if (!smallSystemFont.isAbsoluteSize())
fontSize = systemFontSizeForControlSize(NSSmallControlSize);
break;
case CSSValueMenu:
cachedDesc = &menuFont;
if (!menuFont.isAbsoluteSize())
fontSize = systemFontSizeForControlSize(NSRegularControlSize);
break;
case CSSValueStatusBar:
cachedDesc = &labelFont;
if (!labelFont.isAbsoluteSize())
fontSize = 10.0f;
break;
case CSSValueWebkitMiniControl:
cachedDesc = &miniControlFont;
if (!miniControlFont.isAbsoluteSize())
fontSize = systemFontSizeForControlSize(NSMiniControlSize);
break;
case CSSValueWebkitSmallControl:
cachedDesc = &smallControlFont;
if (!smallControlFont.isAbsoluteSize())
fontSize = systemFontSizeForControlSize(NSSmallControlSize);
break;
case CSSValueWebkitControl:
cachedDesc = &controlFont;
if (!controlFont.isAbsoluteSize())
fontSize = systemFontSizeForControlSize(NSRegularControlSize);
break;
default:
cachedDesc = &systemFont;
if (!systemFont.isAbsoluteSize())
fontSize = 13.0f;
}
if (fontSize) {
cachedDesc->setIsAbsoluteSize(true);
cachedDesc->setGenericFamily(FontDescription::NoFamily);
cachedDesc->firstFamily().setFamily("Lucida Grande");
cachedDesc->setSpecifiedSize(fontSize);
cachedDesc->setWeight(FontWeightNormal);
cachedDesc->setItalic(false);
}
fontDescription = *cachedDesc;
}
示例9: fillFontDescription
static void fillFontDescription(FontDescription& fontDescription, LOGFONT& logFont, float fontSize)
{
fontDescription.setIsAbsoluteSize(true);
fontDescription.setGenericFamily(FontDescription::NoFamily);
fontDescription.firstFamily().setFamily(String(logFont.lfFaceName));
fontDescription.setSpecifiedSize(fontSize);
fontDescription.setWeight(logFont.lfWeight >= 700 ? FontWeightBold : FontWeightNormal); // FIXME: Use real weight.
fontDescription.setItalic(logFont.lfItalic);
}
示例10: setFontFromControlSize
void RenderThemeSafari::setFontFromControlSize(CSSStyleSelector* selector, RenderStyle* style, NSControlSize controlSize) const
{
FontDescription fontDescription;
fontDescription.setIsAbsoluteSize(true);
fontDescription.setGenericFamily(FontDescription::SerifFamily);
float fontSize = systemFontSizeForControlSize(controlSize);
fontDescription.firstFamily().setFamily("Lucida Grande");
fontDescription.setComputedSize(fontSize);
fontDescription.setSpecifiedSize(fontSize);
// Reset line height
style->setLineHeight(RenderStyle::initialLineHeight());
if (style->setFontDescription(fontDescription))
style->font().update(selector->fontSelector());
}
示例11: url
TEST(DragImageTest, TrimWhitespace) {
KURL url(ParsedURLString, "http://www.example.com/");
String testLabel = " Example Example Example \n ";
String expectedLabel = "Example Example Example";
float deviceScaleFactor = 1.0f;
FontDescription fontDescription;
fontDescription.firstFamily().setFamily("Arial");
fontDescription.setSpecifiedSize(16);
fontDescription.setIsAbsoluteSize(true);
fontDescription.setGenericFamily(FontDescription::NoFamily);
fontDescription.setWeight(FontWeightNormal);
fontDescription.setStyle(FontStyleNormal);
std::unique_ptr<DragImage> testImage =
DragImage::create(url, testLabel, fontDescription, deviceScaleFactor);
std::unique_ptr<DragImage> expectedImage =
DragImage::create(url, expectedLabel, fontDescription, deviceScaleFactor);
EXPECT_EQ(testImage->size().width(), expectedImage->size().width());
}
示例12: font
HRESULT STDMETHODCALLTYPE DOMElement::font(WebFontDescription* webFontDescription)
{
if (!webFontDescription) {
ASSERT_NOT_REACHED();
return E_POINTER;
}
ASSERT(m_element);
WebCore::RenderElement* renderer = m_element->renderer();
if (!renderer)
return E_FAIL;
FontDescription fontDescription = renderer->style().font().fontDescription();
AtomicString family = fontDescription.firstFamily();
webFontDescription->family = family.characters();
webFontDescription->familyLength = family.length();
webFontDescription->size = fontDescription.computedSize();
webFontDescription->bold = fontDescription.weight() >= WebCore::FontWeight600;
webFontDescription->italic = fontDescription.italic();
return S_OK;
}