本文整理汇总了C++中SVGTextMetrics::glyph方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGTextMetrics::glyph方法的具体用法?C++ SVGTextMetrics::glyph怎么用?C++ SVGTextMetrics::glyph使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGTextMetrics
的用法示例。
在下文中一共展示了SVGTextMetrics::glyph方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layoutTextOnLineOrPath
void SVGTextLayoutEngine::layoutTextOnLineOrPath(SVGInlineTextBox* textBox, RenderSVGInlineText* text, const RenderStyle* style)
{
SVGElement* lengthContext = static_cast<SVGElement*>(text->parent()->node());
RenderObject* textParent = text->parent();
bool definesTextLength = textParent ? parentDefinesTextLength(textParent) : false;
const SVGRenderStyle* svgStyle = style->svgStyle();
ASSERT(svgStyle);
m_visualMetricsListOffset = 0;
m_visualCharacterOffset = 0;
Vector<SVGTextMetrics>& textMetricsValues = text->layoutAttributes().textMetricsValues();
const UChar* characters = text->characters();
const Font& font = style->font();
SVGTextLayoutEngineSpacing spacingLayout(font);
SVGTextLayoutEngineBaseline baselineLayout(font);
bool didStartTextFragment = false;
bool applySpacingToNextCharacter = false;
float lastAngle = 0;
float baselineShift = baselineLayout.calculateBaselineShift(svgStyle, lengthContext);
baselineShift -= baselineLayout.calculateAlignmentBaselineShift(m_isVerticalText, text);
// Main layout algorithm.
while (true) {
// Find the start of the current text box in this list, respecting ligatures.
SVGTextMetrics visualMetrics = SVGTextMetrics::emptyMetrics();
if (!currentVisualCharacterMetrics(textBox, text, visualMetrics))
break;
if (visualMetrics == SVGTextMetrics::emptyMetrics()) {
advanceToNextVisualCharacter(visualMetrics);
continue;
}
SVGTextLayoutAttributes logicalAttributes;
if (!currentLogicalCharacterAttributes(logicalAttributes))
break;
SVGTextMetrics logicalMetrics = SVGTextMetrics::emptyMetrics();
if (!currentLogicalCharacterMetrics(logicalAttributes, logicalMetrics))
break;
Vector<float>& xValues = logicalAttributes.xValues();
Vector<float>& yValues = logicalAttributes.yValues();
Vector<float>& dxValues = logicalAttributes.dxValues();
Vector<float>& dyValues = logicalAttributes.dyValues();
Vector<float>& rotateValues = logicalAttributes.rotateValues();
float x = xValues.at(m_logicalCharacterOffset);
float y = yValues.at(m_logicalCharacterOffset);
// When we've advanced to the box start offset, determine using the original x/y values,
// whether this character starts a new text chunk, before doing any further processing.
if (m_visualCharacterOffset == textBox->start())
textBox->setStartsNewTextChunk(logicalAttributes.context()->characterStartsNewTextChunk(m_logicalCharacterOffset));
float angle = 0;
if (!rotateValues.isEmpty()) {
float newAngle = rotateValues.at(m_logicalCharacterOffset);
if (newAngle != SVGTextLayoutAttributes::emptyValue())
angle = newAngle;
}
// Calculate glyph orientation angle.
const UChar* currentCharacter = characters + m_visualCharacterOffset;
float orientationAngle = baselineLayout.calculateGlyphOrientationAngle(m_isVerticalText, svgStyle, *currentCharacter);
// Calculate glyph advance & x/y orientation shifts.
float xOrientationShift = 0;
float yOrientationShift = 0;
float glyphAdvance = baselineLayout.calculateGlyphAdvanceAndOrientation(m_isVerticalText, visualMetrics, orientationAngle, xOrientationShift, yOrientationShift);
// Assign current text position to x/y values, if needed.
updateCharacerPositionIfNeeded(x, y);
// Apply dx/dy value adjustments to current text position, if needed.
updateRelativePositionAdjustmentsIfNeeded(dxValues, dyValues);
// Calculate SVG Fonts kerning, if needed.
float kerning = spacingLayout.calculateSVGKerning(m_isVerticalText, visualMetrics.glyph());
// Calculate CSS 'kerning', 'letter-spacing' and 'word-spacing' for next character, if needed.
float spacing = spacingLayout.calculateCSSKerningAndSpacing(svgStyle, lengthContext, currentCharacter);
float textPathOffset = 0;
if (m_inPathLayout) {
float scaledGlyphAdvance = glyphAdvance * m_textPathScaling;
if (m_isVerticalText) {
// If there's an absolute y position available, it marks the beginning of a new position along the path.
if (y != SVGTextLayoutAttributes::emptyValue())
m_textPathCurrentOffset = y + m_textPathStartOffset;
m_textPathCurrentOffset += m_dy - kerning;
m_dy = 0;
//.........这里部分代码省略.........