void SVGTextRunRenderingContext::drawSVGGlyphs(GraphicsContext* context, const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const { auto activePaintingResource = this->activePaintingResource(); if (!activePaintingResource) { // TODO: We're only supporting simple filled HTML text so far. RenderSVGResourceSolidColor* solidPaintingResource = RenderSVGResource::sharedSolidPaintingResource(); solidPaintingResource->setColor(context->fillColor()); activePaintingResource = solidPaintingResource; } auto& elementRenderer = renderer().isRenderElement() ? toRenderElement(renderer()) : *renderer().parent(); RenderStyle& style = elementRenderer.style(); ASSERT(activePaintingResource); RenderSVGResourceMode resourceMode = context->textDrawingMode() == TextModeStroke ? ApplyToStrokeMode : ApplyToFillMode; auto translator(createGlyphToPathTranslator(*fontData, glyphBuffer, from, numGlyphs, point)); while (translator->containsMorePaths()) { Path glyphPath = translator->nextPath(); if (activePaintingResource->applyResource(elementRenderer, style, context, resourceMode)) { float strokeThickness = context->strokeThickness(); if (renderer().isSVGInlineText()) context->setStrokeThickness(strokeThickness * toRenderSVGInlineText(renderer()).scalingFactor()); activePaintingResource->postApplyResource(elementRenderer, context, resourceMode, &glyphPath, 0); context->setStrokeThickness(strokeThickness); } } }
void SVGGlyphToPathTranslator::advance() { do { if (m_glyph) { float advance = m_glyphBuffer.advanceAt(m_index).width(); if (m_isVerticalText) m_currentPoint.move(0, advance); else m_currentPoint.move(advance, 0); } ++m_index; if (m_index >= m_stoppingPoint || !m_glyphBuffer.fontDataAt(m_index)->isSVGFont()) break; m_glyph = m_glyphBuffer.glyphAt(m_index); if (!m_glyph) continue; m_svgGlyph = m_fontElement.svgGlyphForGlyph(m_glyph); ASSERT(!m_svgGlyph.isPartOfLigature); ASSERT(m_svgGlyph.tableEntry == m_glyph); SVGGlyphElement::inheritUnspecifiedAttributes(m_svgGlyph, &m_svgFontData); } while ((!m_glyph || m_svgGlyph.pathData.isEmpty()) && m_index < m_stoppingPoint); if (containsMorePaths() && m_isVerticalText) { m_glyphOrigin.setX(m_svgGlyph.verticalOriginX * m_scale); m_glyphOrigin.setY(m_svgGlyph.verticalOriginY * m_scale); } }