summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/svg/SVGFont.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGFont.cpp')
-rw-r--r--Source/WebCore/svg/SVGFont.cpp40
1 files changed, 27 insertions, 13 deletions
diff --git a/Source/WebCore/svg/SVGFont.cpp b/Source/WebCore/svg/SVGFont.cpp
index e5164c0..a92b9b6 100644
--- a/Source/WebCore/svg/SVGFont.cpp
+++ b/Source/WebCore/svg/SVGFont.cpp
@@ -26,6 +26,7 @@
#include "CSSFontSelector.h"
#include "GraphicsContext.h"
#include "RenderObject.h"
+#include "RenderSVGInlineText.h"
#include "RenderSVGResourceSolidColor.h"
#include "SVGAltGlyphElement.h"
#include "SVGFontData.h"
@@ -243,7 +244,7 @@ struct SVGTextRunWalker {
{
ASSERT(0 <= from && from <= to && to - from <= run.length());
- const String text = Font::normalizeSpaces(String(run.data(from), run.length()));
+ const String text = Font::normalizeSpaces(run.data(from), to - from);
Vector<SVGGlyphIdentifier::ArabicForm> chars(charactersWithArabicForm(text, run.rtl()));
SVGGlyphIdentifier identifier;
@@ -254,8 +255,10 @@ struct SVGTextRunWalker {
bool haveAltGlyph = false;
SVGGlyphIdentifier altGlyphIdentifier;
if (RenderObject* renderObject = run.referencingRenderObject()) {
- if (renderObject->node() && renderObject->node()->hasTagName(SVGNames::altGlyphTag)) {
- SVGGlyphElement* glyphElement = static_cast<SVGAltGlyphElement*>(renderObject->node())->glyphElement();
+ RenderObject* parentRenderer = renderObject->parent();
+ ASSERT(parentRenderer);
+ if (parentRenderer->node() && parentRenderer->node()->hasTagName(SVGNames::altGlyphTag)) {
+ SVGGlyphElement* glyphElement = static_cast<SVGAltGlyphElement*>(parentRenderer->node())->glyphElement();
if (glyphElement) {
haveAltGlyph = true;
altGlyphIdentifier = glyphElement->buildGlyphIdentifier();
@@ -271,7 +274,7 @@ struct SVGTextRunWalker {
// extended to the n-th next character (where n is 'characterLookupRange'), to check for any possible ligature.
characterLookupRange = endOfScanRange - i;
- String lookupString = Font::normalizeSpaces(String(run.data(i), characterLookupRange));
+ String lookupString = Font::normalizeSpaces(run.data(i), characterLookupRange);
Vector<SVGGlyphIdentifier> glyphs;
if (haveAltGlyph)
@@ -407,9 +410,11 @@ static float floatWidthOfSubStringUsingSVGFont(const Font* font, const TextRun&
// TODO: language matching & svg glyphs should be possible for HTML text, too.
if (RenderObject* renderObject = run.referencingRenderObject()) {
- isVerticalText = isVerticalWritingMode(renderObject->style()->svgStyle());
+ RenderObject* parentRenderer = renderObject->parent();
+ ASSERT(parentRenderer);
+ isVerticalText = isVerticalWritingMode(parentRenderer->style()->svgStyle());
- if (SVGElement* element = static_cast<SVGElement*>(renderObject->node()))
+ if (SVGElement* element = static_cast<SVGElement*>(parentRenderer->node()))
language = element->getAttribute(XMLNames::langAttr);
}
@@ -495,10 +500,15 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
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()->node()))
+ RenderObject* referencingRenderObject = run.referencingRenderObject();
+ RenderObject* referencingRenderObjectParent = referencingRenderObject ? referencingRenderObject->parent() : 0;
+ RenderStyle* referencingRenderObjectParentStyle = 0;
+ if (referencingRenderObject) {
+ ASSERT(referencingRenderObjectParent);
+ referencingRenderObjectParentStyle = referencingRenderObjectParent->style();
+
+ isVerticalText = isVerticalWritingMode(referencingRenderObjectParentStyle->svgStyle());
+ if (SVGElement* element = static_cast<SVGElement*>(referencingRenderObjectParent->node()))
language = element->getAttribute(XMLNames::langAttr);
}
@@ -536,9 +546,13 @@ void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
Path glyphPath = identifier.pathData;
glyphPath.transform(glyphPathTransform);
- RenderStyle* style = run.referencingRenderObject() ? run.referencingRenderObject()->style() : 0;
- if (activePaintingResource->applyResource(run.referencingRenderObject(), style, context, resourceMode))
- activePaintingResource->postApplyResource(run.referencingRenderObject(), context, resourceMode, &glyphPath);
+ if (activePaintingResource->applyResource(referencingRenderObjectParent, referencingRenderObjectParentStyle, context, resourceMode)) {
+ if (referencingRenderObject) {
+ RenderSVGInlineText* textRenderer = toRenderSVGInlineText(referencingRenderObject);
+ context->setStrokeThickness(context->strokeThickness() * textRenderer->scalingFactor());
+ }
+ activePaintingResource->postApplyResource(referencingRenderObjectParent, context, resourceMode, &glyphPath);
+ }
context->restore();
}