当前位置: 首页>>代码示例>>C++>>正文


C++ FontDescription::computedSize方法代码示例

本文整理汇总了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);
}
开发者ID:alexanderbill,项目名称:blink-crosswalk,代码行数:26,代码来源:FontBuilder.cpp

示例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);
}
开发者ID:pial003,项目名称:RespImg-WebCore,代码行数:7,代码来源:SimpleFontDataWx.cpp

示例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;
}
开发者ID:clbr,项目名称:webkitfltk,代码行数:28,代码来源:DOMCoreClasses.cpp

示例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);
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例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));
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例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));
}
开发者ID:sysrqb,项目名称:chromium-src,代码行数:9,代码来源:SimpleFontDataChromiumWin.cpp

示例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);
}
开发者ID:Igalia,项目名称:blink,代码行数:9,代码来源:SimpleFontDataWin.cpp

示例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);
}
开发者ID:mirror,项目名称:chromium,代码行数:9,代码来源:SimpleFontData.cpp

示例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());
    }
}
开发者ID:,项目名称:,代码行数:55,代码来源:

示例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));
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:12,代码来源:SimpleFontDataBlackBerry.cpp

示例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());
    }
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例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);
}
开发者ID:biddyweb,项目名称:switch-oss,代码行数:15,代码来源:FontCacheWKC.cpp

示例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();
}
开发者ID:acss,项目名称:owb-mirror,代码行数:17,代码来源:BCFontPlatformDataEmbedded.cpp

示例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();
}
开发者ID:azrul2202,项目名称:WebKit-Smartphone,代码行数:19,代码来源:FontPlatformDataQt.cpp

示例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;
}
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:23,代码来源:DOMCoreClasses.cpp


注:本文中的FontDescription::computedSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。