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


C++ RenderStyle::font方法代码示例

本文整理汇总了C++中RenderStyle::font方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderStyle::font方法的具体用法?C++ RenderStyle::font怎么用?C++ RenderStyle::font使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RenderStyle的用法示例。


在下文中一共展示了RenderStyle::font方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: paint

void EllipsisBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
{
    GraphicsContext* context = paintInfo.context;
    RenderStyle* style = m_object->style(m_firstLine);
    if (style->font() != context->font())
        context->setFont(style->font());

    Color textColor = style->color();
    if (textColor != context->fillColor())
        context->setFillColor(textColor);
    bool setShadow = false;
    if (style->textShadow()) {
        context->setShadow(IntSize(style->textShadow()->x, style->textShadow()->y),
                           style->textShadow()->blur, style->textShadow()->color);
        setShadow = true;
    }

    const String& str = m_str;
    TextStyle textStyle(0, 0, 0, false, style->visuallyOrdered());
    context->drawText(TextRun(str.impl()), IntPoint(m_x + tx, m_y + ty + m_baseline), textStyle);

    if (setShadow)
        context->clearShadow();

    if (m_markupBox) {
        // Paint the markup box
        tx += m_x + m_width - m_markupBox->xPos();
        ty += m_y + m_baseline - (m_markupBox->yPos() + m_markupBox->baseline());
        m_markupBox->paint(paintInfo, tx, ty);
    }
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:31,代码来源:EllipsisBox.cpp

示例2: lineHeight

int RenderBR::lineHeight(bool firstLine, bool /*isRootLineBox*/) const
{
    if (firstTextBox() && !firstTextBox()->isText())
        return 0;

    if (firstLine) {
        RenderStyle* s = style(firstLine);
        Length lh = s->lineHeight();
        if (lh.isNegative()) {
            if (s == style()) {
                if (m_lineHeight == -1)
                    m_lineHeight = RenderObject::lineHeight(false);
                return m_lineHeight;
            }
            return s->font().lineSpacing();
        }
        if (lh.isPercent())
            return lh.calcMinValue(s->fontSize());
        return lh.value();
    }

    if (m_lineHeight == -1)
        m_lineHeight = RenderObject::lineHeight(false);
    return m_lineHeight;
}
开发者ID:halfkiss,项目名称:ComponentSuperAccessor,代码行数:25,代码来源:RenderBR.cpp

示例3: selectionRect

IntRect EllipsisBox::selectionRect()
{
    RenderStyle* style = m_renderer->style(isFirstLineStyle());
    const Font& font = style->font();
    // FIXME: Why is this always LTR? Fix by passing correct text run flags below.
    return enclosingIntRect(font.selectionRectForText(RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(x(), y() + root()->selectionTopAdjustedForPrecedingBlock()), root()->selectionHeightAdjustedForPrecedingBlock()));
}
开发者ID:fatman2021,项目名称:webkitgtk,代码行数:7,代码来源:EllipsisBox.cpp

示例4: paint

void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
    GraphicsContext* context = paintInfo.context;
    RenderStyle* style = renderer().style(isFirstLineStyle());
    const Font& font = style->font();
    FloatPoint boxOrigin = locationIncludingFlipping();
    boxOrigin.moveBy(FloatPoint(paintOffset));
    if (!isHorizontal())
        boxOrigin.move(0, -virtualLogicalHeight());
    FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), virtualLogicalHeight()));
    GraphicsContextStateSaver stateSaver(*context);
    if (!isHorizontal())
        context->concatCTM(InlineTextBox::rotation(boxRect, InlineTextBox::Clockwise));
    FloatPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());

    bool isPrinting = renderer().document().printing();
    bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip && selectionState() != RenderObject::SelectionNone;

    if (haveSelection)
        paintSelection(context, boxOrigin, style, font);
    else if (paintInfo.phase == PaintPhaseSelection)
        return;

    TextPainter::Style textStyle = TextPainter::textPaintingStyle(renderer(), style, paintInfo.forceBlackText(), isPrinting);
    if (haveSelection)
        textStyle = TextPainter::selectionPaintingStyle(renderer(), true, paintInfo.forceBlackText(), isPrinting, textStyle);

    TextRun textRun = constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion);
    TextPainter textPainter(context, font, textRun, textOrigin, boxRect, isHorizontal());
    textPainter.paint(0, m_str.length(), m_str.length(), textStyle);

    paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style);
}
开发者ID:335969568,项目名称:Blink-1,代码行数:33,代码来源:EllipsisBox.cpp

示例5: constructTextRun

TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned position, unsigned length, TextDirection textDirection)
{
    RenderStyle* style = text->style();
    ASSERT(style);

    TextRun run(static_cast<const LChar*>(0) // characters, will be set below if non-zero.
                , 0 // length, will be set below if non-zero.
                , 0 // xPos, only relevant with allowTabs=true
                , 0 // padding, only relevant for justified text, not relevant for SVG
                , TextRun::AllowTrailingExpansion
                , textDirection
                , isOverride(style->unicodeBidi()) /* directionalOverride */);

    if (length) {
        if (text->is8Bit())
            run.setText(text->characters8() + position, length);
        else
            run.setText(text->characters16() + position, length);
    }

    if (textRunNeedsRenderingContext(style->font()))
        run.setRenderingContext(SVGTextRunRenderingContext::create(text));

    // We handle letter & word spacing ourselves.
    run.disableSpacing();

    // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring.
    run.setCharactersLength(text->textLength() - position);
    ASSERT(run.charactersLength() >= run.length());
    return run;
}
开发者ID:smil-in-javascript,项目名称:blink,代码行数:31,代码来源:SVGTextMetrics.cpp

示例6: nodeAtPoint

bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty)
{
    tx += m_x;
    ty += m_y;

    // Hit test the markup box.
    if (m_markupBox) {
        RenderStyle* style = m_renderer->style(m_firstLine);
        int mtx = tx + m_width - m_markupBox->x();
        int mty = ty + style->font().ascent() - (m_markupBox->y() + m_markupBox->renderer()->style(m_firstLine)->font().ascent());
        if (m_markupBox->nodeAtPoint(request, result, x, y, mtx, mty)) {
            renderer()->updateHitTestResult(result, IntPoint(x - mtx, y - mty));
            return true;
        }
    }

    IntRect boundsRect = IntRect(tx, ty, m_width, m_height);
    if (visibleToHitTesting() && boundsRect.intersects(result.rectFromPoint(x, y))) {
        renderer()->updateHitTestResult(result, IntPoint(x - tx, y - ty));
        if (!result.addNodeToRectBasedTestResult(renderer()->node(), x, y, boundsRect))
            return true;
    }

    return false;
}
开发者ID:azrul2202,项目名称:WebKit-Smartphone,代码行数:25,代码来源:EllipsisBox.cpp

示例7: paint

void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
    GraphicsContext* context = paintInfo.context;
    RenderStyle* style = renderer().style(isFirstLineStyle());

    const Font& font = style->font();
    FloatPoint boxOrigin = locationIncludingFlipping();
    boxOrigin.moveBy(FloatPoint(paintOffset));
    if (!isHorizontal())
        boxOrigin.move(0, -virtualLogicalHeight());
    FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), virtualLogicalHeight()));
    GraphicsContextStateSaver stateSaver(*context);
    if (!isHorizontal())
        context->concatCTM(InlineTextBox::rotation(boxRect, InlineTextBox::Clockwise));
    FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());

    Color styleTextColor = renderer().resolveColor(style, CSSPropertyWebkitTextFillColor);
    if (styleTextColor != context->fillColor())
        context->setFillColor(styleTextColor);

    if (selectionState() != RenderObject::SelectionNone) {
        paintSelection(context, boxOrigin, style, font);

        // Select the correct color for painting the text.
        Color foreground = paintInfo.forceBlackText() ? Color::black : renderer().selectionForegroundColor();
        if (foreground != styleTextColor)
            context->setFillColor(foreground);
    }

    // Text shadows are disabled when printing. http://crbug.com/258321
    const ShadowList* shadowList = context->printing() ? 0 : style->textShadow();
    bool hasShadow = shadowList;
    if (hasShadow) {
        OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create();
        for (size_t i = shadowList->shadows().size(); i--; ) {
            const ShadowData& shadow = shadowList->shadows()[i];
            float shadowX = isHorizontal() ? shadow.x() : shadow.y();
            float shadowY = isHorizontal() ? shadow.y() : -shadow.x();
            FloatSize offset(shadowX, shadowY);
            drawLooperBuilder->addShadow(offset, shadow.blur(), shadow.color(),
                DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIgnoresAlpha);
        }
        drawLooperBuilder->addUnmodifiedContent();
        context->setDrawLooper(drawLooperBuilder.release());
    }

    TextRun textRun = RenderBlockFlow::constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion);
    TextRunPaintInfo textRunPaintInfo(textRun);
    textRunPaintInfo.bounds = boxRect;
    context->drawText(font, textRunPaintInfo, textOrigin);

    // Restore the regular fill color.
    if (styleTextColor != context->fillColor())
        context->setFillColor(styleTextColor);

    if (hasShadow)
        context->clearDrawLooper();

    paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:60,代码来源:EllipsisBox.cpp

示例8: paint

void MediaPlayerPrivate::paint(GraphicsContext* p, const IntRect& r)
{
    if (p->paintingDisabled() || !m_qtMovie || m_hasUnsupportedTracks)
        return;

    bool usingTempBitmap = false;
    OwnPtr<GraphicsContext::WindowsBitmap> bitmap;
    HDC hdc = p->getWindowsContext(r);
    if (!hdc) {
        // The graphics context doesn't have an associated HDC so create a temporary
        // bitmap where QTMovieWin can draw the frame and we can copy it.
        usingTempBitmap = true;
        bitmap.set(p->createWindowsBitmap(r.size()));
        hdc = bitmap->hdc();

        // FIXME: is this necessary??
        XFORM xform;
        xform.eM11 = 1.0f;
        xform.eM12 = 0.0f;
        xform.eM21 = 0.0f;
        xform.eM22 = 1.0f;
        xform.eDx = -r.x();
        xform.eDy = -r.y();
        SetWorldTransform(hdc, &xform);
    }

    m_qtMovie->paint(hdc, r.x(), r.y());
    if (usingTempBitmap)
        p->drawWindowsBitmap(bitmap.get(), r.topLeft());
    else
        p->releaseWindowsContext(hdc, r);

#if DRAW_FRAME_RATE
    if (m_frameCountWhilePlaying > 10) {
        Frame* frame = m_player->frameView() ? m_player->frameView()->frame() : NULL;
        Document* document = frame ? frame->document() : NULL;
        RenderObject* renderer = document ? document->renderer() : NULL;
        RenderStyle* styleToUse = renderer ? renderer->style() : NULL;
        if (styleToUse) {
            double frameRate = (m_frameCountWhilePlaying - 1) / (0.001 * ( m_startedPlaying ? (GetTickCount() - m_timeStartedPlaying) :
                (m_timeStoppedPlaying - m_timeStartedPlaying) ));
            String text = String::format("%1.2f", frameRate);
            TextRun textRun(text.characters(), text.length());
            const Color color(255, 0, 0);
            p->save();
            p->translate(r.x(), r.y() + r.height());
            p->setFont(styleToUse->font());
            p->setStrokeColor(color);
            p->setStrokeStyle(SolidStroke);
            p->setStrokeThickness(1.0f);
            p->setFillColor(color);
            p->drawText(textRun, IntPoint(2, -3));
            p->restore();
        }
    }
#endif
}
开发者ID:dzip,项目名称:webkit,代码行数:57,代码来源:MediaPlayerPrivateQuickTimeWin.cpp

示例9: offsetForPosition

int InlineTextBox::offsetForPosition(int _x, bool includePartialGlyphs) const
{
    if (isLineBreak())
        return 0;

    RenderText* text = static_cast<RenderText*>(m_object);
    RenderStyle *style = text->style(m_firstLine);
    const Font* f = &style->font();
    return f->offsetForPosition(TextRun(textObject()->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, direction() == RTL, m_dirOverride || style->visuallyOrdered()),
                                _x - m_x, includePartialGlyphs);
}
开发者ID:Fale,项目名称:qtmoko,代码行数:11,代码来源:InlineTextBox.cpp

示例10: Style

 Style(const RenderStyle& style)
     : font(style.font())
     , textAlign(style.textAlign())
     , collapseWhitespace(style.collapseWhiteSpace())
     , preserveNewline(style.preserveNewline())
     , wrapLines(style.autoWrap())
     , breakWordOnOverflow(style.overflowWrap() == BreakOverflowWrap && (wrapLines || preserveNewline))
     , spaceWidth(font.width(TextRun(&space, 1)))
     , tabWidth(collapseWhitespace ? 0 : style.tabSize())
 {
 }
开发者ID:Wrichik1999,项目名称:webkit,代码行数:11,代码来源:SimpleLineLayout.cpp

示例11: convertValueFromEXSToUserUnits

float SVGLength::convertValueFromEXSToUserUnits(float value, const SVGElement* context, ExceptionCode& ec) const
{
    if (!context || !context->renderer() || !context->renderer()->style()) {
        ec = NOT_SUPPORTED_ERR;
        return 0;
    }

    RenderStyle* style = context->renderer()->style();
    // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg
    // if this causes problems in real world cases maybe it would be best to remove this
    return value * ceilf(style->font().xHeight());
}
开发者ID:dslab-epfl,项目名称:warr,代码行数:12,代码来源:SVGLength.cpp

示例12: createDiff

TQString RenderStyle::createDiff( const RenderStyle &parent ) const
{
    TQString res;
      if ( color().isValid() && parent.color() != color() )
        res += " [color=" + color().name() + "]";
    if ( backgroundColor().isValid() && parent.backgroundColor() != backgroundColor() )
        res += " [bgcolor=" + backgroundColor().name() + "]";
    if ( parent.font() != font() )
        res += " [font=" + describeFont( font() ) + "]";

    return res;
}
开发者ID:Fat-Zer,项目名称:tdelibs,代码行数:12,代码来源:render_style.cpp

示例13: value

float SVGLength::value() const
{
    SVGLengthType type = extractType(m_unit);
    if (type == LengthTypeUnknown)
        return 0.0f;

    switch (type) {
    case LengthTypeNumber:
        return m_valueInSpecifiedUnits;
    case LengthTypePercentage:
        return SVGLength::PercentageOfViewport(m_valueInSpecifiedUnits / 100.0f, m_context, extractMode(m_unit));
    case LengthTypeEMS:
    case LengthTypeEXS:
    {
        RenderStyle* style = 0;
        if (m_context && m_context->renderer())
            style = m_context->renderer()->style();
        if (style) {
            float useSize = style->fontSize();
            ASSERT(useSize > 0);
            if (type == LengthTypeEMS)
                return m_valueInSpecifiedUnits * useSize;
            else {
                float xHeight = style->font().xHeight();
                // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg
                // if this causes problems in real world cases maybe it would be best to remove this
                return m_valueInSpecifiedUnits * ceilf(xHeight);
            }
        }
        return 0.0f;
    }
    case LengthTypePX:
        return m_valueInSpecifiedUnits;
    case LengthTypeCM:
        return m_valueInSpecifiedUnits / 2.54f * cssPixelsPerInch;
    case LengthTypeMM:
        return m_valueInSpecifiedUnits / 25.4f * cssPixelsPerInch;
    case LengthTypeIN:
        return m_valueInSpecifiedUnits * cssPixelsPerInch;
    case LengthTypePT:
        return m_valueInSpecifiedUnits / 72.0f * cssPixelsPerInch;
    case LengthTypePC:
        return m_valueInSpecifiedUnits / 6.0f * cssPixelsPerInch;
    default:
        break;
    }

    ASSERT_NOT_REACHED();
    return 0.0f;
}
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:50,代码来源:SVGLength.cpp

示例14: setFontFromControlSize

void RenderThemeSafari::setFontFromControlSize(StyleResolver& styleResolver, RenderStyle& style, NSControlSize controlSize) const
{
    FontDescription fontDescription;
    fontDescription.setIsAbsoluteSize(true);
    fontDescription.setGenericFamily(FontDescription::SerifFamily);

    float fontSize = systemFontSizeForControlSize(controlSize);
    fontDescription.setOneFamily("Lucida Grande");
    fontDescription.setComputedSize(fontSize);
    fontDescription.setSpecifiedSize(fontSize);

    // Reset line height
    style.setLineHeight(RenderStyle::initialLineHeight());

    if (style.setFontDescription(fontDescription))
        style.font().update(styleResolver.fontSelector());
}
开发者ID:ddxxyy,项目名称:webkit,代码行数:17,代码来源:RenderThemeSafari.cpp

示例15: updateValue

void SVGLength::updateValue(bool notify)
{
    switch(m_unitType)
    {
        case SVG_LENGTHTYPE_PX:
            m_value = m_valueInSpecifiedUnits;
            break;
        case SVG_LENGTHTYPE_CM:
            m_value = (m_valueInSpecifiedUnits / 2.54) * dpi();
            break;
        case SVG_LENGTHTYPE_MM:
            m_value = (m_valueInSpecifiedUnits / 25.4) * dpi();
            break;
        case SVG_LENGTHTYPE_IN:
            m_value = m_valueInSpecifiedUnits * dpi();
            break;
        case SVG_LENGTHTYPE_PT:
            m_value = (m_valueInSpecifiedUnits / 72.0) * dpi();
            break;
        case SVG_LENGTHTYPE_PC:
            m_value = (m_valueInSpecifiedUnits / 6.0) * dpi();
            break;
        case SVG_LENGTHTYPE_EMS:
        case SVG_LENGTHTYPE_EXS:
            if (m_context && m_context->renderer()) {
                RenderStyle *style = m_context->renderer()->style();
                float useSize = style->fontSize();
                ASSERT(useSize > 0);
                if (m_unitType == SVG_LENGTHTYPE_EMS)
                    m_value = m_valueInSpecifiedUnits * useSize;
                else {
                    float xHeight = style->font().xHeight();
                    // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg
                    // if this causes problems in real world cases maybe it would be best to remove this
                    m_value = m_valueInSpecifiedUnits * ceil(xHeight);
                }
                m_requiresLayout = false;
            } else {
                m_requiresLayout = true;
            }
            break;
    }
    if (notify && m_context)
        m_context->notifyAttributeChange();
}
开发者ID:oroisec,项目名称:ios,代码行数:45,代码来源:SVGLength.cpp


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