本文整理汇总了C++中RenderStyle::fontMetrics方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderStyle::fontMetrics方法的具体用法?C++ RenderStyle::fontMetrics怎么用?C++ RenderStyle::fontMetrics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderStyle
的用法示例。
在下文中一共展示了RenderStyle::fontMetrics方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visualOverflowForDecorations
GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const InlineTextBox* inlineTextBox)
{
ASSERT(!inlineTextBox || inlineTextBox->lineStyle() == lineStyle);
TextDecoration decoration = lineStyle.textDecorationsInEffect();
if (decoration == TextDecorationNone)
return GlyphOverflow();
float strokeThickness = textDecorationStrokeThickness(lineStyle.fontSize());
float controlPointDistance;
float step;
float wavyOffset;
TextDecorationStyle decorationStyle = lineStyle.textDecorationStyle();
float height = lineStyle.fontCascade().fontMetrics().floatHeight();
GlyphOverflow overflowResult;
if (decorationStyle == TextDecorationStyleWavy) {
getWavyStrokeParameters(strokeThickness, controlPointDistance, step);
wavyOffset = wavyOffsetFromDecoration();
overflowResult.left = strokeThickness;
overflowResult.right = strokeThickness;
}
// These metrics must match where underlines get drawn.
if (decoration & TextDecorationUnderline) {
// Compensate for the integral ceiling in GraphicsContext::computeLineBoundsAndAntialiasingModeForText()
int underlineOffset = 1;
underlineOffset += computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), inlineTextBox, strokeThickness);
if (decorationStyle == TextDecorationStyleWavy) {
extendIntToFloat(overflowResult.bottom, underlineOffset + wavyOffset + controlPointDistance + strokeThickness - height);
extendIntToFloat(overflowResult.top, -(underlineOffset + wavyOffset - controlPointDistance - strokeThickness));
} else {
extendIntToFloat(overflowResult.bottom, underlineOffset + strokeThickness - height);
extendIntToFloat(overflowResult.top, -underlineOffset);
}
}
if (decoration & TextDecorationOverline) {
if (decorationStyle == TextDecorationStyleWavy) {
extendIntToFloat(overflowResult.bottom, -wavyOffset + controlPointDistance + strokeThickness - height);
extendIntToFloat(overflowResult.top, wavyOffset + controlPointDistance + strokeThickness);
} else {
extendIntToFloat(overflowResult.bottom, strokeThickness - height);
// top is untouched
}
}
if (decoration & TextDecorationLineThrough) {
float baseline = lineStyle.fontMetrics().floatAscent();
if (decorationStyle == TextDecorationStyleWavy) {
extendIntToFloat(overflowResult.bottom, 2 * baseline / 3 + controlPointDistance + strokeThickness - height);
extendIntToFloat(overflowResult.top, -(2 * baseline / 3 - controlPointDistance - strokeThickness));
} else {
extendIntToFloat(overflowResult.bottom, 2 * baseline / 3 + strokeThickness - height);
extendIntToFloat(overflowResult.top, -(2 * baseline / 3));
}
}
return overflowResult;
}
示例2: nodeAtPoint
bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
LayoutPoint adjustedLocation = accumulatedOffset + roundedLayoutPoint(topLeft());
// Hit test the markup box.
if (InlineBox* markupBox = this->markupBox()) {
RenderStyle* style = renderer().style(isFirstLineStyle());
LayoutUnit mtx = adjustedLocation.x() + m_logicalWidth - markupBox->x();
LayoutUnit mty = adjustedLocation.y() + style->fontMetrics().ascent() - (markupBox->y() + markupBox->renderer().style(isFirstLineStyle())->fontMetrics().ascent());
if (markupBox->nodeAtPoint(request, result, locationInContainer, LayoutPoint(mtx, mty), lineTop, lineBottom)) {
renderer().updateHitTestResult(result, locationInContainer.point() - LayoutSize(mtx, mty));
return true;
}
}
FloatPoint boxOrigin = locationIncludingFlipping();
boxOrigin.moveBy(accumulatedOffset);
FloatRect boundsRect(boxOrigin, size());
if (visibleToHitTestRequest(request) && boundsRect.intersects(HitTestLocation::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) {
renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(adjustedLocation));
if (!result.addNodeToRectBasedTestResult(renderer().node(), request, locationInContainer, boundsRect))
return true;
}
return false;
}
示例3: paintMarkupBox
void EllipsisBox::paintMarkupBox(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, const RenderStyle& style)
{
InlineBox* markupBox = this->markupBox();
if (!markupBox)
return;
LayoutPoint adjustedPaintOffset = paintOffset;
adjustedPaintOffset.move(x() + m_logicalWidth - markupBox->x(),
y() + style.fontMetrics().ascent() - (markupBox->y() + markupBox->lineStyle().fontMetrics().ascent()));
markupBox->paint(paintInfo, adjustedPaintOffset, lineTop, lineBottom);
}
示例4: convertValueFromEXSToUserUnits
float SVGLengthContext::convertValueFromEXSToUserUnits(float value, ExceptionState& es) const
{
RenderStyle* style = renderStyleForLengthResolving(m_context);
if (!style) {
es.throwDOMException(NotSupportedError);
return 0;
}
// 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->fontMetrics().xHeight());
}
示例5: 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->fontMetrics().xHeight());
}
示例6: baselinePosition
LayoutUnit RenderMathMLFraction::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const
{
if (firstChild() && firstChild()->isRenderMathMLBlock()) {
RenderMathMLBlock* numerator = toRenderMathMLBlock(firstChild());
RenderStyle* refStyle = style();
if (previousSibling())
refStyle = previousSibling()->style();
else if (nextSibling())
refStyle = nextSibling()->style();
int shift = int(ceil((refStyle->fontMetrics().xHeight() + 1) / 2));
return numerator->offsetHeight() + shift;
}
return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, lineDirection, linePositionMode);
}
示例7: convertValueFromUserUnitsToEXS
float SVGLengthContext::convertValueFromUserUnitsToEXS(float value, ExceptionState& exceptionState) const
{
RenderStyle* style = renderStyleForLengthResolving(m_context);
if (!style) {
exceptionState.throwDOMException(NotSupportedError, "No context could be found.");
return 0;
}
// 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
float xHeight = ceilf(style->fontMetrics().xHeight());
if (!xHeight) {
exceptionState.throwDOMException(NotSupportedError, "No x-height could be determined.");
return 0;
}
return value / xHeight;
}
示例8: lineHeight
short RenderFlow::lineHeight(bool firstLine, bool isRootLineBox) const
{
if (firstLine) {
RenderStyle* s = style(firstLine);
Length lh = s->lineHeight();
if (lh.value < 0) {
if (s == style()) {
if (m_lineHeight == -1)
m_lineHeight = RenderObject::lineHeight(false);
return m_lineHeight;
}
return s->fontMetrics().lineSpacing();
}
if (lh.isPercent())
return lh.minWidth(s->font().pixelSize());
return lh.value;
}
if (m_lineHeight == -1)
m_lineHeight = RenderObject::lineHeight(false);
return m_lineHeight;
}