本文整理汇总了C++中FontDescription::computedSize方法的典型用法代码示例。如果您正苦于以下问题:C++ FontDescription::computedSize方法的具体用法?C++ FontDescription::computedSize怎么用?C++ FontDescription::computedSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FontDescription
的用法示例。
在下文中一共展示了FontDescription::computedSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateAdjustedSize
void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, const ComputedStyle& style, FontSelector* fontSelector)
{
const float specifiedSize = fontDescription.specifiedSize();
if (!fontDescription.hasSizeAdjust() || !specifiedSize)
return;
// We need to create a temporal Font to get xHeight of a primary font.
// The aspect value is based on the xHeight of the font for the computed font size,
// so we need to reset the adjustedSize to computedSize. See FontDescription::effectiveFontSize.
fontDescription.setAdjustedSize(fontDescription.computedSize());
Font font(fontDescription);
font.update(fontSelector);
if (!font.fontMetrics().hasXHeight())
return;
const float sizeAdjust = fontDescription.sizeAdjust();
float aspectValue = font.fontMetrics().xHeight() / specifiedSize;
float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize;
adjustedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effectiveZoom(), adjustedSize);
float multiplier = style.textAutosizingMultiplier();
if (multiplier > 1)
adjustedSize = TextAutosizer::computeAutosizedFontSize(adjustedSize, multiplier);
fontDescription.setAdjustedSize(adjustedSize);
}
示例2: platformData
PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
FontDescription desc = FontDescription(fontDescription);
desc.setSpecifiedSize(scaleFactor * fontDescription.computedSize());
FontPlatformData platformData(desc, desc.family().family());
return SimpleFontData::create(platformData, isCustomFont(), false);
}
示例3: 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;
}
示例4: create
PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
ASSERT(m_platformData.scaledFont());
return SimpleFontData::create(FontPlatformData(cairo_scaled_font_get_font_face(m_platformData.scaledFont()),
scaleFactor * fontDescription.computedSize(),
m_platformData.syntheticBold(),
m_platformData.syntheticOblique()), isCustomFont(), false);
}
示例5: adoptPtr
PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
return adoptPtr(new SimpleFontData(FontPlatformData(m_platformData.m_font.get(),
scaleFactor * fontDescription.computedSize(),
m_platformData.syntheticBold(),
m_platformData.syntheticOblique()),
isCustomFont(), false));
}
示例6: adoptPtr
PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
LOGFONT winFont;
GetObject(m_platformData.hfont(), sizeof(LOGFONT), &winFont);
float scaledSize = scaleFactor * fontDescription.computedSize();
winFont.lfHeight = -lroundf(scaledSize);
HFONT hfont = CreateFontIndirect(&winFont);
return adoptPtr(new SimpleFontData(FontPlatformData(hfont, scaledSize), isCustomFont(), false));
}
示例7: create
PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
LOGFONT winFont;
GetObject(m_platformData.hfont(), sizeof(LOGFONT), &winFont);
float scaledSize = scaleFactor * fontDescription.computedSize();
winFont.lfHeight = -lroundf(scaledSize);
HFONT hfont = CreateFontIndirect(&winFont);
return SimpleFontData::create(FontPlatformData(hfont, scaledSize, m_platformData.orientation()), isCustomFont() ? CustomFontData::create(false) : 0);
}
示例8: create
PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(
const FontDescription& fontDescription,
float scaleFactor) const {
const float scaledSize =
lroundf(fontDescription.computedSize() * scaleFactor);
return SimpleFontData::create(
FontPlatformData(m_platformData, scaledSize),
isCustomFont() ? CustomFontData::create() : nullptr);
}
示例9: combineText
void RenderCombineText::combineText()
{
if (!m_needsFontUpdate)
return;
m_isCombined = false;
m_needsFontUpdate = false;
// CSS3 spec says text-combine works only in vertical writing mode.
if (style()->isHorizontalWritingMode())
return;
TextRun run = RenderBlock::constructTextRun(this, originalFont(), this, *style());
FontDescription description = originalFont().fontDescription();
float emWidth = description.computedSize() * textCombineMargin;
bool shouldUpdateFont = false;
description.setOrientation(Horizontal); // We are going to draw combined text horizontally.
m_combinedTextWidth = originalFont().width(run);
m_isCombined = m_combinedTextWidth <= emWidth;
FontSelector* fontSelector = style()->font().fontSelector();
if (m_isCombined)
shouldUpdateFont = m_combineFontStyle->setFontDescription(description); // Need to change font orientation to horizontal.
else {
// Need to try compressed glyphs.
static const FontWidthVariant widthVariants[] = { HalfWidth, ThirdWidth, QuarterWidth };
for (size_t i = 0 ; i < WTF_ARRAY_LENGTH(widthVariants) ; ++i) {
description.setWidthVariant(widthVariants[i]);
Font compressedFont = Font(description, style()->font().letterSpacing(), style()->font().wordSpacing());
compressedFont.update(fontSelector);
float runWidth = compressedFont.width(run);
if (runWidth <= emWidth) {
m_combinedTextWidth = runWidth;
m_isCombined = true;
// Replace my font with the new one.
shouldUpdateFont = m_combineFontStyle->setFontDescription(description);
break;
}
}
}
if (!m_isCombined)
shouldUpdateFont = m_combineFontStyle->setFontDescription(originalFont().fontDescription());
if (shouldUpdateFont)
m_combineFontStyle->font().update(fontSelector);
if (m_isCombined) {
DEFINE_STATIC_LOCAL(String, objectReplacementCharacterString, (&objectReplacementCharacter, 1));
RenderText::setTextInternal(objectReplacementCharacterString.impl());
}
}
示例10: adoptRef
PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
const float scaledSize = lroundf(fontDescription.computedSize() * scaleFactor);
return adoptRef(new SimpleFontData(
FontPlatformData(m_platformData.font()->cur_lfnt->name,
scaledSize,
m_platformData.syntheticBold(),
m_platformData.syntheticOblique(),
m_platformData.orientation(),
m_platformData.widthVariant()),
isCustomFont(), false));
}
示例11: QFont
FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName)
: m_font(new QFont("Times New Roman", 12))
{
m_font->setFamily(familyName.domString());
m_font->setPixelSize(qRound(fontDescription.computedSize()));
m_font->setItalic(fontDescription.italic());
if (fontDescription.bold()) {
// Qt's Bold is 75, Webkit is 63.
m_font->setWeight(QFont::Bold);
} else {
m_font->setWeight(fontDescription.weight());
}
}
示例12: d
PassRefPtr<Font>
Font::platformCreateScaledFont(const FontDescription& orig, float scaleFactor) const
{
FontDescription d(orig);
d.setComputedSize(orig.computedSize() * scaleFactor);
d.setSpecifiedSize(orig.specifiedSize() * scaleFactor);
FontPlatformData* ret = new FontPlatformData(d, m_platformData.font()->familyName().data());
if (!ret || !ret->font() || !ret->font()->font()) {
delete ret;
return adoptRef((Font *)0);
}
return Font::create(*ret);
}
示例13: if
FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName)
: m_pattern(0)
, m_size(fontDescription.computedSize())
, m_syntheticBold(false)
, m_syntheticOblique(false)
, m_scaledFont(0)
{
if (fontDescription.italic()) {
m_pixelFont = &NormalItalicPixelFont;
m_syntheticOblique = true;
} else if (fontDescription.weight() >= FontWeightBold) {
m_pixelFont = &NormalBoldPixelFont;
m_syntheticBold = true;
} else
m_pixelFont = &NormalPixelFont;
FontPlatformData::init();
}
示例14: FontPlatformDataPrivate
FontPlatformData::FontPlatformData(const FontDescription& description, const AtomicString& familyName, int wordSpacing, int letterSpacing)
: m_data(new FontPlatformDataPrivate())
{
QFont& font = m_data->font;
font.setFamily(familyName);
font.setPixelSize(qRound(description.computedSize()));
font.setItalic(description.italic());
font.setWeight(toQFontWeight(description.weight()));
font.setWordSpacing(wordSpacing);
font.setLetterSpacing(QFont::AbsoluteSpacing, letterSpacing);
const bool smallCaps = description.smallCaps();
font.setCapitalization(smallCaps ? QFont::SmallCaps : QFont::MixedCase);
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
font.setStyleStrategy(QFont::ForceIntegerMetrics);
#endif
m_data->bold = font.bold();
m_data->size = font.pointSizeF();
}
示例15: 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;
}