Rubber-stamped by Brady Eidson.
[webbrowser.git] / WebCore / svg / SVGFont.cpp
blob7e3cec049f2876104d85a50591d6a6b202829a86
1 /**
2 * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #include "config.h"
23 #if ENABLE(SVG_FONTS)
24 #include "Font.h"
26 #include "CSSFontSelector.h"
27 #include "GraphicsContext.h"
28 #include "RenderObject.h"
29 #include "SimpleFontData.h"
30 #include "SVGAltGlyphElement.h"
31 #include "SVGFontData.h"
32 #include "SVGGlyphElement.h"
33 #include "SVGGlyphMap.h"
34 #include "SVGFontElement.h"
35 #include "SVGFontFaceElement.h"
36 #include "SVGMissingGlyphElement.h"
37 #include "SVGPaintServer.h"
38 #include "SVGPaintServerSolid.h"
39 #include "XMLNames.h"
41 using namespace WTF::Unicode;
43 namespace WebCore {
45 static inline float convertEmUnitToPixel(float fontSize, float unitsPerEm, float value)
47 if (unitsPerEm == 0.0f)
48 return 0.0f;
50 return value * fontSize / unitsPerEm;
53 static inline bool isVerticalWritingMode(const SVGRenderStyle* style)
55 return style->writingMode() == WM_TBRL || style->writingMode() == WM_TB;
58 // Helper functions to determine the arabic character forms (initial, medial, terminal, isolated)
59 enum ArabicCharShapingMode {
60 SNone = 0,
61 SRight = 1,
62 SDual = 2
65 static const ArabicCharShapingMode s_arabicCharShapingMode[222] = {
66 SRight, SRight, SRight, SRight, SDual , SRight, SDual , SRight, SDual , SDual , SDual , SDual , SDual , SRight, /* 0x0622 - 0x062F */
67 SRight, SRight, SRight, SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SNone , SNone , SNone , SNone , SNone , /* 0x0630 - 0x063F */
68 SNone , SDual , SDual , SDual , SDual , SDual , SDual , SRight, SDual , SDual , SNone , SNone , SNone , SNone , SNone , SNone , /* 0x0640 - 0x064F */
69 SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , /* 0x0650 - 0x065F */
70 SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , /* 0x0660 - 0x066F */
71 SNone , SRight, SRight, SRight, SNone , SRight, SRight, SRight, SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , /* 0x0670 - 0x067F */
72 SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, /* 0x0680 - 0x068F */
73 SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, SDual , SDual , SDual , SDual , SDual , SDual , /* 0x0690 - 0x069F */
74 SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , /* 0x06A0 - 0x06AF */
75 SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , SDual , /* 0x06B0 - 0x06BF */
76 SRight, SDual , SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, SRight, SDual , SRight, SDual , SRight, /* 0x06C0 - 0x06CF */
77 SDual , SDual , SRight, SRight, SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , /* 0x06D0 - 0x06DF */
78 SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , /* 0x06E0 - 0x06EF */
79 SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SNone , SDual , SDual , SDual , SNone , SNone , SNone /* 0x06F0 - 0x06FF */
82 static inline SVGGlyphIdentifier::ArabicForm processArabicFormDetection(const UChar& curChar, bool& lastCharShapesRight, SVGGlyphIdentifier::ArabicForm* prevForm)
84 SVGGlyphIdentifier::ArabicForm curForm;
86 ArabicCharShapingMode shapingMode = SNone;
87 if (curChar >= 0x0622 && curChar <= 0x06FF)
88 shapingMode = s_arabicCharShapingMode[curChar - 0x0622];
90 // Use a simple state machine to identify the actual arabic form
91 // It depends on the order of the arabic form enum:
92 // enum ArabicForm { None = 0, Isolated, Terminal, Initial, Medial };
94 if (lastCharShapesRight && shapingMode == SDual) {
95 if (prevForm) {
96 int correctedForm = (int) *prevForm + 1;
97 ASSERT(correctedForm >= SVGGlyphIdentifier::None && correctedForm <= SVGGlyphIdentifier::Medial);
98 *prevForm = static_cast<SVGGlyphIdentifier::ArabicForm>(correctedForm);
101 curForm = SVGGlyphIdentifier::Initial;
102 } else
103 curForm = shapingMode == SNone ? SVGGlyphIdentifier::None : SVGGlyphIdentifier::Isolated;
105 lastCharShapesRight = shapingMode != SNone;
106 return curForm;
109 static Vector<SVGGlyphIdentifier::ArabicForm> charactersWithArabicForm(const String& input, bool rtl)
111 Vector<SVGGlyphIdentifier::ArabicForm> forms;
112 unsigned length = input.length();
114 bool containsArabic = false;
115 for (unsigned i = 0; i < length; ++i) {
116 if (isArabicChar(input[i])) {
117 containsArabic = true;
118 break;
122 if (!containsArabic)
123 return forms;
125 bool lastCharShapesRight = false;
127 // Start identifying arabic forms
128 if (rtl) {
129 for (int i = length - 1; i >= 0; --i)
130 forms.prepend(processArabicFormDetection(input[i], lastCharShapesRight, forms.isEmpty() ? 0 : &forms.first()));
131 } else {
132 for (unsigned i = 0; i < length; ++i)
133 forms.append(processArabicFormDetection(input[i], lastCharShapesRight, forms.isEmpty() ? 0 : &forms.last()));
136 return forms;
139 static inline bool isCompatibleArabicForm(const SVGGlyphIdentifier& identifier, const Vector<SVGGlyphIdentifier::ArabicForm>& chars, unsigned startPosition, unsigned endPosition)
141 if (chars.isEmpty())
142 return true;
144 Vector<SVGGlyphIdentifier::ArabicForm>::const_iterator it = chars.begin() + startPosition;
145 Vector<SVGGlyphIdentifier::ArabicForm>::const_iterator end = chars.begin() + endPosition;
147 ASSERT(end <= chars.end());
148 for (; it != end; ++it) {
149 if (*it != static_cast<SVGGlyphIdentifier::ArabicForm>(identifier.arabicForm) && *it != SVGGlyphIdentifier::None)
150 return false;
153 return true;
156 static inline bool isCompatibleGlyph(const SVGGlyphIdentifier& identifier, bool isVerticalText, const String& language,
157 const Vector<SVGGlyphIdentifier::ArabicForm>& chars, unsigned startPosition, unsigned endPosition)
159 bool valid = true;
161 // Check wheter orientation if glyph fits within the request
162 switch (identifier.orientation) {
163 case SVGGlyphIdentifier::Vertical:
164 valid = isVerticalText;
165 break;
166 case SVGGlyphIdentifier::Horizontal:
167 valid = !isVerticalText;
168 break;
169 case SVGGlyphIdentifier::Both:
170 break;
173 if (!valid)
174 return false;
176 // Check wheter languages are compatible
177 if (!identifier.languages.isEmpty()) {
178 // This glyph exists only in certain languages, if we're not specifying a
179 // language on the referencing element we're unable to use this glyph.
180 if (language.isEmpty())
181 return false;
183 // Split subcode from language, if existant.
184 String languagePrefix;
186 int subCodeSeparator = language.find('-');
187 if (subCodeSeparator != -1)
188 languagePrefix = language.left(subCodeSeparator);
190 Vector<String>::const_iterator it = identifier.languages.begin();
191 Vector<String>::const_iterator end = identifier.languages.end();
193 bool found = false;
194 for (; it != end; ++it) {
195 const String& cur = *it;
196 if (cur == language || cur == languagePrefix) {
197 found = true;
198 break;
202 if (!found)
203 return false;
206 // Check wheter arabic form is compatible
207 return isCompatibleArabicForm(identifier, chars, startPosition, endPosition);
210 static inline const SVGFontData* svgFontAndFontFaceElementForFontData(const SimpleFontData* fontData, SVGFontFaceElement*& fontFace, SVGFontElement*& font)
212 ASSERT(fontData->isCustomFont());
213 ASSERT(fontData->isSVGFont());
215 const SVGFontData* svgFontData = static_cast<const SVGFontData*>(fontData->svgFontData());
217 fontFace = svgFontData->svgFontFaceElement();
218 ASSERT(fontFace);
220 font = fontFace->associatedFontElement();
221 return svgFontData;
224 // Helper class to walk a text run. Lookup a SVGGlyphIdentifier for each character
225 // - also respecting possibly defined ligatures - and invoke a callback for each found glyph.
226 template<typename SVGTextRunData>
227 struct SVGTextRunWalker {
228 typedef bool (*SVGTextRunWalkerCallback)(const SVGGlyphIdentifier&, SVGTextRunData&);
229 typedef void (*SVGTextRunWalkerMissingGlyphCallback)(const TextRun&, SVGTextRunData&);
231 SVGTextRunWalker(const SVGFontData* fontData, SVGFontElement* fontElement, SVGTextRunData& data,
232 SVGTextRunWalkerCallback callback, SVGTextRunWalkerMissingGlyphCallback missingGlyphCallback)
233 : m_fontData(fontData)
234 , m_fontElement(fontElement)
235 , m_walkerData(data)
236 , m_walkerCallback(callback)
237 , m_walkerMissingGlyphCallback(missingGlyphCallback)
241 void walk(const TextRun& run, bool isVerticalText, const String& language, int from, int to)
243 // Should hold true for SVG text, otherwhise sth. is wrong
244 ASSERT(to - from == run.length());
246 Vector<SVGGlyphIdentifier::ArabicForm> chars(charactersWithArabicForm(String(run.data(from), run.length()), run.rtl()));
248 SVGGlyphIdentifier identifier;
249 bool foundGlyph = false;
250 int characterLookupRange;
251 int endOfScanRange = to + m_walkerData.extraCharsAvailable;
253 bool haveAltGlyph = false;
254 SVGGlyphIdentifier altGlyphIdentifier;
255 if (RenderObject* renderObject = run.referencingRenderObject()) {
256 if (renderObject->node() && renderObject->node()->hasTagName(SVGNames::altGlyphTag)) {
257 SVGGlyphElement* glyphElement = static_cast<SVGAltGlyphElement*>(renderObject->node())->glyphElement();
258 if (glyphElement) {
259 haveAltGlyph = true;
260 altGlyphIdentifier = glyphElement->buildGlyphIdentifier();
261 altGlyphIdentifier.isValid = true;
262 altGlyphIdentifier.nameLength = to - from;
267 for (int i = from; i < to; ++i) {
268 // If characterLookupRange is > 0, then the font defined ligatures (length of unicode property value > 1).
269 // We have to check wheter the current character & the next character define a ligature. This needs to be
270 // extended to the n-th next character (where n is 'characterLookupRange'), to check for any possible ligature.
271 characterLookupRange = endOfScanRange - i;
273 String lookupString(run.data(i), characterLookupRange);
274 Vector<SVGGlyphIdentifier> glyphs;
275 if (haveAltGlyph)
276 glyphs.append(altGlyphIdentifier);
277 else
278 m_fontElement->getGlyphIdentifiersForString(lookupString, glyphs);
280 Vector<SVGGlyphIdentifier>::iterator it = glyphs.begin();
281 Vector<SVGGlyphIdentifier>::iterator end = glyphs.end();
283 for (; it != end; ++it) {
284 identifier = *it;
285 if (identifier.isValid && isCompatibleGlyph(identifier, isVerticalText, language, chars, i, i + identifier.nameLength)) {
286 ASSERT(characterLookupRange > 0);
287 i += identifier.nameLength - 1;
288 m_walkerData.charsConsumed += identifier.nameLength;
289 m_walkerData.glyphName = identifier.glyphName;
291 foundGlyph = true;
292 SVGGlyphElement::inheritUnspecifiedAttributes(identifier, m_fontData);
293 break;
297 if (!foundGlyph) {
298 ++m_walkerData.charsConsumed;
299 if (SVGMissingGlyphElement* element = m_fontElement->firstMissingGlyphElement()) {
300 // <missing-glyph> element support
301 identifier = SVGGlyphElement::buildGenericGlyphIdentifier(element);
302 SVGGlyphElement::inheritUnspecifiedAttributes(identifier, m_fontData);
303 identifier.isValid = true;
304 } else {
305 // Fallback to system font fallback
306 TextRun subRun(run);
307 subRun.setText(subRun.data(i), 1);
309 (*m_walkerMissingGlyphCallback)(subRun, m_walkerData);
310 continue;
314 if (!(*m_walkerCallback)(identifier, m_walkerData))
315 break;
317 foundGlyph = false;
321 private:
322 const SVGFontData* m_fontData;
323 SVGFontElement* m_fontElement;
324 SVGTextRunData& m_walkerData;
325 SVGTextRunWalkerCallback m_walkerCallback;
326 SVGTextRunWalkerMissingGlyphCallback m_walkerMissingGlyphCallback;
329 // Callback & data structures to compute the width of text using SVG Fonts
330 struct SVGTextRunWalkerMeasuredLengthData {
331 int at;
332 int from;
333 int to;
334 int extraCharsAvailable;
335 int charsConsumed;
336 String glyphName;
338 float scale;
339 float length;
340 const Font* font;
343 static bool floatWidthUsingSVGFontCallback(const SVGGlyphIdentifier& identifier, SVGTextRunWalkerMeasuredLengthData& data)
345 if (data.at >= data.from && data.at < data.to)
346 data.length += identifier.horizontalAdvanceX * data.scale;
348 data.at++;
349 return data.at < data.to;
352 static void floatWidthMissingGlyphCallback(const TextRun& run, SVGTextRunWalkerMeasuredLengthData& data)
354 // Handle system font fallback
355 FontDescription fontDescription(data.font->fontDescription());
356 fontDescription.setFamily(FontFamily());
357 Font font(fontDescription, 0, 0); // spacing handled by SVG text code.
358 font.update(data.font->fontSelector());
360 data.length += font.floatWidth(run);
364 SVGFontElement* Font::svgFont() const
366 if (!isSVGFont())
367 return 0;
369 SVGFontElement* fontElement = 0;
370 SVGFontFaceElement* fontFaceElement = 0;
371 if (svgFontAndFontFaceElementForFontData(primaryFont(), fontFaceElement, fontElement))
372 return fontElement;
374 return 0;
377 static float floatWidthOfSubStringUsingSVGFont(const Font* font, const TextRun& run, int extraCharsAvailable, int from, int to, int& charsConsumed, String& glyphName)
379 int newFrom = to > from ? from : to;
380 int newTo = to > from ? to : from;
382 from = newFrom;
383 to = newTo;
385 SVGFontElement* fontElement = 0;
386 SVGFontFaceElement* fontFaceElement = 0;
388 if (const SVGFontData* fontData = svgFontAndFontFaceElementForFontData(font->primaryFont(), fontFaceElement, fontElement)) {
389 if (!fontElement)
390 return 0.0f;
392 SVGTextRunWalkerMeasuredLengthData data;
394 data.font = font;
395 data.at = from;
396 data.from = from;
397 data.to = to;
398 data.extraCharsAvailable = extraCharsAvailable;
399 data.charsConsumed = 0;
400 data.scale = convertEmUnitToPixel(font->size(), fontFaceElement->unitsPerEm(), 1.0f);
401 data.length = 0.0f;
403 String language;
404 bool isVerticalText = false; // Holds true for HTML text
406 // TODO: language matching & svg glyphs should be possible for HTML text, too.
407 if (RenderObject* renderObject = run.referencingRenderObject()) {
408 isVerticalText = isVerticalWritingMode(renderObject->style()->svgStyle());
410 if (SVGElement* element = static_cast<SVGElement*>(renderObject->node()))
411 language = element->getAttribute(XMLNames::langAttr);
414 SVGTextRunWalker<SVGTextRunWalkerMeasuredLengthData> runWalker(fontData, fontElement, data, floatWidthUsingSVGFontCallback, floatWidthMissingGlyphCallback);
415 runWalker.walk(run, isVerticalText, language, 0, run.length());
416 charsConsumed = data.charsConsumed;
417 glyphName = data.glyphName;
418 return data.length;
421 return 0.0f;
424 float Font::floatWidthUsingSVGFont(const TextRun& run) const
426 int charsConsumed;
427 String glyphName;
428 return floatWidthOfSubStringUsingSVGFont(this, run, 0, 0, run.length(), charsConsumed, glyphName);
431 float Font::floatWidthUsingSVGFont(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const
433 return floatWidthOfSubStringUsingSVGFont(this, run, extraCharsAvailable, 0, run.length(), charsConsumed, glyphName);
436 // Callback & data structures to draw text using SVG Fonts
437 struct SVGTextRunWalkerDrawTextData {
438 int extraCharsAvailable;
439 int charsConsumed;
440 String glyphName;
441 Vector<SVGGlyphIdentifier> glyphIdentifiers;
442 Vector<UChar> fallbackCharacters;
445 static bool drawTextUsingSVGFontCallback(const SVGGlyphIdentifier& identifier, SVGTextRunWalkerDrawTextData& data)
447 data.glyphIdentifiers.append(identifier);
448 return true;
451 static void drawTextMissingGlyphCallback(const TextRun& run, SVGTextRunWalkerDrawTextData& data)
453 ASSERT(run.length() == 1);
454 data.glyphIdentifiers.append(SVGGlyphIdentifier());
455 data.fallbackCharacters.append(run[0]);
458 void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run,
459 const FloatPoint& point, int from, int to) const
461 SVGFontElement* fontElement = 0;
462 SVGFontFaceElement* fontFaceElement = 0;
464 if (const SVGFontData* fontData = svgFontAndFontFaceElementForFontData(primaryFont(), fontFaceElement, fontElement)) {
465 if (!fontElement)
466 return;
468 SVGTextRunWalkerDrawTextData data;
469 FloatPoint currentPoint = point;
470 float scale = convertEmUnitToPixel(size(), fontFaceElement->unitsPerEm(), 1.0f);
472 SVGPaintServer* activePaintServer = run.activePaintServer();
474 // If renderObject is not set, we're dealing for HTML text rendered using SVG Fonts.
475 if (!run.referencingRenderObject()) {
476 ASSERT(!activePaintServer);
478 // TODO: We're only supporting simple filled HTML text so far.
479 SVGPaintServerSolid* solidPaintServer = SVGPaintServer::sharedSolidPaintServer();
480 solidPaintServer->setColor(context->fillColor());
482 activePaintServer = solidPaintServer;
485 ASSERT(activePaintServer);
487 int charsConsumed;
488 String glyphName;
489 bool isVerticalText = false;
490 float xStartOffset = floatWidthOfSubStringUsingSVGFont(this, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed, glyphName);
491 FloatPoint glyphOrigin;
493 String language;
495 // TODO: language matching & svg glyphs should be possible for HTML text, too.
496 if (run.referencingRenderObject()) {
497 isVerticalText = isVerticalWritingMode(run.referencingRenderObject()->style()->svgStyle());
499 if (SVGElement* element = static_cast<SVGElement*>(run.referencingRenderObject()->node()))
500 language = element->getAttribute(XMLNames::langAttr);
503 if (!isVerticalText) {
504 glyphOrigin.setX(fontData->horizontalOriginX() * scale);
505 glyphOrigin.setY(fontData->horizontalOriginY() * scale);
508 data.extraCharsAvailable = 0;
509 data.charsConsumed = 0;
511 SVGTextRunWalker<SVGTextRunWalkerDrawTextData> runWalker(fontData, fontElement, data, drawTextUsingSVGFontCallback, drawTextMissingGlyphCallback);
512 runWalker.walk(run, isVerticalText, language, from, to);
514 SVGPaintTargetType targetType = context->textDrawingMode() == cTextStroke ? ApplyToStrokeTargetType : ApplyToFillTargetType;
516 unsigned numGlyphs = data.glyphIdentifiers.size();
517 unsigned fallbackCharacterIndex = 0;
518 for (unsigned i = 0; i < numGlyphs; ++i) {
519 const SVGGlyphIdentifier& identifier = data.glyphIdentifiers[run.rtl() ? numGlyphs - i - 1 : i];
520 if (identifier.isValid) {
521 // FIXME: Support arbitary SVG content as glyph (currently limited to <glyph d="..."> situations).
522 if (!identifier.pathData.isEmpty()) {
523 context->save();
525 if (isVerticalText) {
526 glyphOrigin.setX(identifier.verticalOriginX * scale);
527 glyphOrigin.setY(identifier.verticalOriginY * scale);
530 context->translate(xStartOffset + currentPoint.x() + glyphOrigin.x(), currentPoint.y() + glyphOrigin.y());
531 context->scale(FloatSize(scale, -scale));
533 context->beginPath();
534 context->addPath(identifier.pathData);
536 // FIXME: setup() tries to get objectBoundingBox() from run.referencingRenderObject()
537 // which is wrong. We need to change setup() to take a bounding box instead, or pass
538 // a RenderObject which would return the bounding box for identifier.pathData
539 if (activePaintServer->setup(context, run.referencingRenderObject(), targetType)) {
540 // Spec: Any properties specified on a text elements which represents a length, such as the
541 // 'stroke-width' property, might produce surprising results since the length value will be
542 // processed in the coordinate system of the glyph. (TODO: What other lengths? miter-limit? dash-offset?)
543 if (targetType == ApplyToStrokeTargetType && scale != 0.0f)
544 context->setStrokeThickness(context->strokeThickness() / scale);
546 activePaintServer->renderPath(context, run.referencingRenderObject(), targetType);
547 activePaintServer->teardown(context, run.referencingRenderObject(), targetType);
550 context->restore();
553 if (isVerticalText)
554 currentPoint.move(0.0f, identifier.verticalAdvanceY * scale);
555 else
556 currentPoint.move(identifier.horizontalAdvanceX * scale, 0.0f);
557 } else {
558 // Handle system font fallback
559 FontDescription fontDescription(m_fontDescription);
560 fontDescription.setFamily(FontFamily());
561 Font font(fontDescription, 0, 0); // spacing handled by SVG text code.
562 font.update(fontSelector());
564 TextRun fallbackCharacterRun(run);
565 fallbackCharacterRun.setText(&data.fallbackCharacters[run.rtl() ? data.fallbackCharacters.size() - fallbackCharacterIndex - 1 : fallbackCharacterIndex], 1);
566 font.drawText(context, fallbackCharacterRun, currentPoint);
568 if (isVerticalText)
569 currentPoint.move(0.0f, font.floatWidth(fallbackCharacterRun));
570 else
571 currentPoint.move(font.floatWidth(fallbackCharacterRun), 0.0f);
573 fallbackCharacterIndex++;
579 FloatRect Font::selectionRectForTextUsingSVGFont(const TextRun& run, const IntPoint& point, int height, int from, int to) const
581 int charsConsumed;
582 String glyphName;
584 return FloatRect(point.x() + floatWidthOfSubStringUsingSVGFont(this, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed, glyphName),
585 point.y(), floatWidthOfSubStringUsingSVGFont(this, run, 0, from, to, charsConsumed, glyphName), height);
588 int Font::offsetForPositionForTextUsingSVGFont(const TextRun&, int, bool) const
590 // TODO: Fix text selection when HTML text is drawn using a SVG Font
591 // We need to integrate the SVG text selection code in the offsetForPosition() framework.
592 // This will also fix a major issue, that SVG Text code can't select arabic strings properly.
593 return 0;
598 #endif