本文整理汇总了C++中TextRun::activePaintServer方法的典型用法代码示例。如果您正苦于以下问题:C++ TextRun::activePaintServer方法的具体用法?C++ TextRun::activePaintServer怎么用?C++ TextRun::activePaintServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextRun
的用法示例。
在下文中一共展示了TextRun::activePaintServer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawTextUsingSVGFont
void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
const FloatPoint& point, int from, int to) const
{
SVGFontElement* fontElement = 0;
SVGFontFaceElement* fontFaceElement = 0;
if (const SVGFontData* fontData = svgFontAndFontFaceElementForFontData(primaryFont(), fontFaceElement, fontElement)) {
if (!fontElement)
return;
SVGTextRunWalkerDrawTextData data;
FloatPoint currentPoint = point;
float scale = convertEmUnitToPixel(size(), fontFaceElement->unitsPerEm(), 1.0f);
SVGPaintServer* activePaintServer = run.activePaintServer();
// If renderObject is not set, we're dealing for HTML text rendered using SVG Fonts.
if (!run.referencingRenderObject()) {
ASSERT(!activePaintServer);
// TODO: We're only supporting simple filled HTML text so far.
SVGPaintServerSolid* solidPaintServer = SVGPaintServer::sharedSolidPaintServer();
solidPaintServer->setColor(context->fillColor());
activePaintServer = solidPaintServer;
}
ASSERT(activePaintServer);
int charsConsumed;
String glyphName;
bool isVerticalText = false;
float xStartOffset = floatWidthOfSubStringUsingSVGFont(this, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed, glyphName);
FloatPoint glyphOrigin;
String language;
// TODO: language matching & svg glyphs should be possible for HTML text, too.
if (run.referencingRenderObject()) {
isVerticalText = isVerticalWritingMode(run.referencingRenderObject()->style()->svgStyle());
if (SVGElement* element = static_cast<SVGElement*>(run.referencingRenderObject()->element()))
language = element->getAttribute(XMLNames::langAttr);
}
if (!isVerticalText) {
glyphOrigin.setX(fontData->horizontalOriginX() * scale);
glyphOrigin.setY(fontData->horizontalOriginY() * scale);
}
data.extraCharsAvailable = 0;
data.charsConsumed = 0;
SVGTextRunWalker<SVGTextRunWalkerDrawTextData> runWalker(fontData, fontElement, data, drawTextUsingSVGFontCallback, drawTextMissingGlyphCallback);
runWalker.walk(run, isVerticalText, language, from, to);
SVGPaintTargetType targetType = context->textDrawingMode() == cTextStroke ? ApplyToStrokeTargetType : ApplyToFillTargetType;
unsigned numGlyphs = data.glyphIdentifiers.size();
unsigned fallbackCharacterIndex = 0;
for (unsigned i = 0; i < numGlyphs; ++i) {
const SVGGlyphIdentifier& identifier = data.glyphIdentifiers[run.rtl() ? numGlyphs - i - 1 : i];
if (identifier.isValid) {
// FIXME: Support arbitary SVG content as glyph (currently limited to <glyph d="..."> situations).
if (!identifier.pathData.isEmpty()) {
context->save();
if (isVerticalText) {
glyphOrigin.setX(identifier.verticalOriginX * scale);
glyphOrigin.setY(identifier.verticalOriginY * scale);
}
context->translate(xStartOffset + currentPoint.x() + glyphOrigin.x(), currentPoint.y() + glyphOrigin.y());
context->scale(FloatSize(scale, -scale));
context->beginPath();
context->addPath(identifier.pathData);
if (activePaintServer->setup(context, run.referencingRenderObject(), targetType)) {
// Spec: Any properties specified on a text elements which represents a length, such as the
// 'stroke-width' property, might produce surprising results since the length value will be
// processed in the coordinate system of the glyph. (TODO: What other lengths? miter-limit? dash-offset?)
if (targetType == ApplyToStrokeTargetType && scale != 0.0f)
context->setStrokeThickness(context->strokeThickness() / scale);
activePaintServer->renderPath(context, run.referencingRenderObject(), targetType);
activePaintServer->teardown(context, run.referencingRenderObject(), targetType);
}
context->restore();
}
if (isVerticalText)
currentPoint.move(0.0f, identifier.verticalAdvanceY * scale);
else
currentPoint.move(identifier.horizontalAdvanceX * scale, 0.0f);
} else {
// Handle system font fallback
FontDescription fontDescription(context->font().fontDescription());
fontDescription.setFamily(FontFamily());
//.........这里部分代码省略.........