本文整理汇总了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);
}
}
示例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;
}
示例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()));
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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
}
示例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);
}
示例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())
{
}
示例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());
}
示例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;
}
示例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;
}
示例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());
}
示例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();
}