本文整理汇总了C++中RenderStyle::fontCascade方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderStyle::fontCascade方法的具体用法?C++ RenderStyle::fontCascade怎么用?C++ RenderStyle::fontCascade使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderStyle
的用法示例。
在下文中一共展示了RenderStyle::fontCascade方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: font
TextFragmentIterator::Style::Style(const RenderStyle& style)
: font(style.fontCascade())
, textAlign(style.textAlign())
, collapseWhitespace(style.collapseWhiteSpace())
, preserveNewline(style.preserveNewline())
, wrapLines(style.autoWrap())
, breakWordOnOverflow(style.overflowWrap() == BreakOverflowWrap && (wrapLines || preserveNewline))
, spaceWidth(font.width(TextRun(StringView(&space, 1))))
, tabWidth(collapseWhitespace ? 0 : style.tabSize())
, locale(style.locale())
{
}
示例3: setFontFromControlSize
void RenderThemeSafari::setFontFromControlSize(StyleResolver& styleResolver, RenderStyle& style, NSControlSize controlSize) const
{
FontDescription fontDescription;
fontDescription.setIsAbsoluteSize(true);
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.fontCascade().update(&styleResolver.document().fontSelector());
}
示例4: computeNewScaledFontForStyle
void RenderSVGInlineText::computeNewScaledFontForStyle(const RenderObject& renderer, const RenderStyle& style, float& scalingFactor, FontCascade& scaledFont)
{
// Alter font-size to the right on-screen value to avoid scaling the glyphs themselves, except when GeometricPrecision is specified
scalingFactor = SVGRenderingContext::calculateScreenFontSizeScalingFactor(renderer);
if (scalingFactor == 1 || !scalingFactor || style.fontDescription().textRenderingMode() == GeometricPrecision) {
scalingFactor = 1;
scaledFont = style.fontCascade();
return;
}
FontDescription fontDescription(style.fontDescription());
// FIXME: We need to better handle the case when we compute very small fonts below (below 1pt).
fontDescription.setComputedSize(Style::computedFontSizeFromSpecifiedSizeForSVGInlineText(fontDescription.computedSize(), fontDescription.isAbsoluteSize(), scalingFactor, renderer.document()));
scaledFont = FontCascade(fontDescription, 0, 0);
scaledFont.update(&renderer.document().fontSelector());
}
示例5: adjustStyle
void RenderTheme::adjustStyle(StyleResolver& styleResolver, RenderStyle& style, Element* element, bool UAHasAppearance, const BorderData& border, const FillLayer& background, const Color& backgroundColor)
{
// Force inline and table display styles to be inline-block (except for table- which is block)
ControlPart part = style.appearance();
if (style.display() == INLINE || style.display() == INLINE_TABLE || style.display() == TABLE_ROW_GROUP
|| style.display() == TABLE_HEADER_GROUP || style.display() == TABLE_FOOTER_GROUP
|| style.display() == TABLE_ROW || style.display() == TABLE_COLUMN_GROUP || style.display() == TABLE_COLUMN
|| style.display() == TABLE_CELL || style.display() == TABLE_CAPTION)
style.setDisplay(INLINE_BLOCK);
else if (style.display() == COMPACT || style.display() == LIST_ITEM || style.display() == TABLE)
style.setDisplay(BLOCK);
if (UAHasAppearance && isControlStyled(style, border, background, backgroundColor)) {
if (part == MenulistPart) {
style.setAppearance(MenulistButtonPart);
part = MenulistButtonPart;
} else
style.setAppearance(NoControlPart);
}
if (!style.hasAppearance())
return;
// Never support box-shadow on native controls.
style.setBoxShadow(nullptr);
#if USE(NEW_THEME)
switch (part) {
case CheckboxPart:
case InnerSpinButtonPart:
case RadioPart:
case PushButtonPart:
case SquareButtonPart:
case DefaultButtonPart:
case ButtonPart: {
// Border
LengthBox borderBox(style.borderTopWidth(), style.borderRightWidth(), style.borderBottomWidth(), style.borderLeftWidth());
borderBox = m_theme->controlBorder(part, style.fontCascade(), borderBox, style.effectiveZoom());
if (borderBox.top().value() != static_cast<int>(style.borderTopWidth())) {
if (borderBox.top().value())
style.setBorderTopWidth(borderBox.top().value());
else
style.resetBorderTop();
}
if (borderBox.right().value() != static_cast<int>(style.borderRightWidth())) {
if (borderBox.right().value())
style.setBorderRightWidth(borderBox.right().value());
else
style.resetBorderRight();
}
if (borderBox.bottom().value() != static_cast<int>(style.borderBottomWidth())) {
style.setBorderBottomWidth(borderBox.bottom().value());
if (borderBox.bottom().value())
style.setBorderBottomWidth(borderBox.bottom().value());
else
style.resetBorderBottom();
}
if (borderBox.left().value() != static_cast<int>(style.borderLeftWidth())) {
style.setBorderLeftWidth(borderBox.left().value());
if (borderBox.left().value())
style.setBorderLeftWidth(borderBox.left().value());
else
style.resetBorderLeft();
}
// Padding
LengthBox paddingBox = m_theme->controlPadding(part, style.fontCascade(), style.paddingBox(), style.effectiveZoom());
if (paddingBox != style.paddingBox())
style.setPaddingBox(paddingBox);
// Whitespace
if (m_theme->controlRequiresPreWhiteSpace(part))
style.setWhiteSpace(PRE);
// Width / Height
// The width and height here are affected by the zoom.
// FIXME: Check is flawed, since it doesn't take min-width/max-width into account.
LengthSize controlSize = m_theme->controlSize(part, style.fontCascade(), LengthSize(style.width(), style.height()), style.effectiveZoom());
if (controlSize.width() != style.width())
style.setWidth(controlSize.width());
if (controlSize.height() != style.height())
style.setHeight(controlSize.height());
// Min-Width / Min-Height
LengthSize minControlSize = m_theme->minimumControlSize(part, style.fontCascade(), style.effectiveZoom());
if (minControlSize.width() != style.minWidth())
style.setMinWidth(minControlSize.width());
if (minControlSize.height() != style.minHeight())
style.setMinHeight(minControlSize.height());
// Font
if (auto themeFont = m_theme->controlFont(part, style.fontCascade(), style.effectiveZoom())) {
// If overriding the specified font with the theme font, also override the line height with the standard line height.
style.setLineHeight(RenderStyle::initialLineHeight());
if (style.setFontDescription(themeFont.value()))
style.fontCascade().update(nullptr);
}
// Special style that tells enabled default buttons in active windows to use the ActiveButtonText color.
// The active window part of the test has to be done at paint time since it's not triggered by a style change.
//.........这里部分代码省略.........