Changeset 29839 in webkit
- Timestamp:
- Jan 28, 2008 3:37:04 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r29838 r29839 1 2008-01-28 Nikolas Zimmermann <zimmermann@kde.org> 2 3 Reviewed by Eric, Dan & Oliver. 4 5 Update layout tests after adding external SVG Fonts support. 6 7 * platform/mac/svg/W3C-SVG-1.1/fonts-elem-03-b-expected.checksum: 8 * platform/mac/svg/W3C-SVG-1.1/fonts-elem-03-b-expected.png: 9 * platform/mac/svg/W3C-SVG-1.1/fonts-elem-03-b-expected.txt: 10 * platform/mac/svg/W3C-SVG-1.1/fonts-elem-04-b-expected.checksum: 11 * platform/mac/svg/W3C-SVG-1.1/fonts-elem-04-b-expected.png: 12 * platform/mac/svg/W3C-SVG-1.1/fonts-elem-04-b-expected.txt: 13 * platform/mac/svg/W3C-SVG-1.1/fonts-elem-07-b-expected.checksum: 14 * platform/mac/svg/W3C-SVG-1.1/fonts-elem-07-b-expected.png: 15 * platform/mac/svg/W3C-SVG-1.1/fonts-elem-07-b-expected.txt: 16 * platform/mac/svg/custom/svg-fonts-in-html-expected.checksum: Added. 17 * platform/mac/svg/custom/svg-fonts-in-html-expected.png: Added. 18 * platform/mac/svg/custom/svg-fonts-in-html-expected.txt: Added. 19 * svg/custom/resources/graffiti.svg: Added. 20 * svg/custom/svg-fonts-in-html.html: Added. 21 1 22 2008-01-28 Dan Bernstein <mitz@apple.com> 2 23 -
trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-elem-03-b-expected.checksum
r27850 r29839 1 69da9bd20420dbff4d3cb6dbd1600c5b 1 eba2190f5fda7b0f31bd8c21914c56c8 -
trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-elem-03-b-expected.txt
r26599 r29839 29 29 RenderSVGInlineText {#text} at (0,-17) size 74x22 30 30 chunk 1 text run 1 at (67.00,210.00) startOffset 0 endOffset 8 width 74.00: "SVG Font" 31 RenderSVGContainer {g} at (165,1 66) size 210x69[transform={m=((1.00,0.00)(0.00,1.00)) t=(165.00,220.00)}]31 RenderSVGContainer {g} at (165,172) size 210x60 [transform={m=((1.00,0.00)(0.00,1.00)) t=(165.00,220.00)}] 32 32 RenderPath {line} at (165,219.50) size 210x1 [stroke={[type=SOLID] [color=#888888]}] [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00L210.00,0.00"] 33 RenderSVGText {text} at (0,0) size 198x69contains 1 chunk(s)34 RenderSVGInlineText {#text} at (0,- 54) size 198x6935 chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 5 width 198.00: "Ay\x{D6}@\x{E7}"33 RenderSVGText {text} at (0,0) size 210x60 contains 1 chunk(s) 34 RenderSVGInlineText {#text} at (0,-48) size 210x60 35 chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 5 width 209.71: "Ay\x{D6}@\x{E7}" 36 36 RenderSVGText {text} at (10,340) size 264x46 contains 1 chunk(s) 37 37 RenderSVGInlineText {#text} at (0,-36) size 264x46 -
trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-elem-04-b-expected.checksum
r27850 r29839 1 fd770c729d92e1ff25890592d2aa786c 1 ae5055bccd277a00b383c5118ff19215 -
trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-elem-04-b-expected.txt
r26599 r29839 29 29 RenderSVGInlineText {#text} at (0,-17) size 74x22 30 30 chunk 1 text run 1 at (67.00,210.00) startOffset 0 endOffset 8 width 74.00: "SVG Font" 31 RenderSVGContainer {g} at (165,1 66) size 210x69[transform={m=((1.00,0.00)(0.00,1.00)) t=(165.00,220.00)}]31 RenderSVGContainer {g} at (165,172) size 210x60 [transform={m=((1.00,0.00)(0.00,1.00)) t=(165.00,220.00)}] 32 32 RenderPath {line} at (165,219.50) size 210x1 [stroke={[type=SOLID] [color=#888888]}] [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00L210.00,0.00"] 33 RenderSVGText {text} at (0,0) size 198x69contains 1 chunk(s)34 RenderSVGInlineText {#text} at (0,- 54) size 198x6935 chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 5 width 198.00: "Ay\x{D6}@\x{E7}"33 RenderSVGText {text} at (0,0) size 210x60 contains 1 chunk(s) 34 RenderSVGInlineText {#text} at (0,-48) size 210x60 35 chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 5 width 209.71: "Ay\x{D6}@\x{E7}" 36 36 RenderSVGText {text} at (10,340) size 264x46 contains 1 chunk(s) 37 37 RenderSVGInlineText {#text} at (0,-36) size 264x46 -
trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-elem-07-b-expected.checksum
r27850 r29839 1 824f78aa5e369a55cb492952e2150734 1 979e7c3eb5f8f6fecf13f084192db268 -
trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-elem-07-b-expected.txt
r26599 r29839 30 30 RenderSVGInlineText {#text} at (0,-17) size 74x22 31 31 chunk 1 text run 1 at (65.00,210.00) startOffset 0 endOffset 8 width 74.00: "SVG Font" 32 RenderSVGContainer {g} at (165,1 66) size 210x69[transform={m=((1.00,0.00)(0.00,1.00)) t=(165.00,220.00)}]32 RenderSVGContainer {g} at (165,172) size 210x60 [transform={m=((1.00,0.00)(0.00,1.00)) t=(165.00,220.00)}] 33 33 RenderPath {line} at (165,219.50) size 210x1 [stroke={[type=SOLID] [color=#888888]}] [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00L210.00,0.00"] 34 RenderSVGText {text} at (0,0) size 198x69contains 1 chunk(s)35 RenderSVGInlineText {#text} at (0,- 54) size 198x6936 chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 5 width 198.00: "Ay\x{D6}@\x{E7}"34 RenderSVGText {text} at (0,0) size 210x60 contains 1 chunk(s) 35 RenderSVGInlineText {#text} at (0,-48) size 210x60 36 chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 5 width 209.71: "Ay\x{D6}@\x{E7}" 37 37 RenderSVGText {text} at (10,340) size 264x46 contains 1 chunk(s) 38 38 RenderSVGInlineText {#text} at (0,-36) size 264x46 -
trunk/WebCore/ChangeLog
r29838 r29839 1 2008-01-28 Nikolas Zimmermann <zimmermann@kde.org> 2 3 Reviewed by Eric, Dan & Oliver. 4 5 Fixes: http://bugs.webkit.org/show_bug.cgi?id=16980 6 7 Support external SVG Fonts, by reusing the custom font handling logic. 8 This enables us - as first engine - to render HTML pages using SVG Fonts. 9 10 Fixes fonts-elem-03-b.svg / fonts-elem-04-b.svg / fonts-elem-07-b.svg 11 Add new testcase svg-fonts-in-html.html. 12 13 * css/CSSFontFaceSource.cpp: 14 (WebCore::CSSFontFaceSource::getFontData): 15 * css/CSSFontFaceSource.h: 16 * css/CSSFontFaceSrcValue.cpp: 17 (WebCore::CSSFontFaceSrcValue::isSVGFontFaceSrc): 18 (WebCore::CSSFontFaceSrcValue::isSupportedFormat): 19 * css/CSSFontFaceSrcValue.h: 20 * css/CSSFontSelector.cpp: 21 (WebCore::CSSFontSelector::addFontFaceRule): 22 * loader/CachedFont.cpp: 23 (WebCore::CachedFont::~CachedFont): 24 (WebCore::CachedFont::ensureSVGFontData): 25 (WebCore::CachedFont::extractFontFromSVGData): 26 (WebCore::CachedFont::platformDataFromSVGData): 27 * loader/CachedFont.h: 28 * platform/graphics/Font.cpp: 29 (WebCore::Font::offsetForPosition): 30 * platform/graphics/Font.h: 31 * svg/SVGFont.cpp: 32 (WebCore::floatWidthOfSubStringUsingSVGFont): 33 (WebCore::Font::drawTextUsingSVGFont): 34 (WebCore::Font::offsetForPositionForTextUsingSVGFont): 35 * svg/SVGFontFaceElement.cpp: 36 (WebCore::SVGFontFaceElement::rebuildFontFace): 37 * svg/SVGFontFaceElement.h: 38 * svg/SVGFontFaceUriElement.cpp: 39 (WebCore::SVGFontFaceUriElement::srcValue): 40 1 41 2008-01-28 Dan Bernstein <mitz@apple.com> 2 42 -
trunk/WebCore/css/CSSFontFaceSource.cpp
r29700 r29839 37 37 38 38 #if ENABLE(SVG_FONTS) 39 #include "FontCustomPlatformData.h" 40 #include "HTMLNames.h" 39 41 #include "SVGFontData.h" 40 #include "FontCustomPlatformData.h" 42 #include "SVGFontElement.h" 43 #include "SVGURIReference.h" 41 44 #endif 42 45 … … 114 117 // If we are still loading, then we let the system pick a font. 115 118 if (isLoaded()) { 119 if (m_font) { 116 120 #if ENABLE(SVG_FONTS) 117 if (m_svgFontFaceElement) 118 fontData.set(new SimpleFontData(FontPlatformData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic), 119 true, false, new SVGFontData(m_svgFontFaceElement.get()))); 120 #endif 121 122 if (!fontData) { 123 ASSERT(m_font); 124 125 // Create new FontPlatformData from our CGFontRef, point size and ATSFontRef. 126 if (!m_font->ensureCustomFontData()) 121 // For SVG fonts parse the external SVG document, and extract the <font> element. 122 if (!m_font->ensureSVGFontData()) 127 123 return 0; 128 124 129 fontData.set(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic), true, false)); 125 if (!m_externalSVGFontElement) 126 m_externalSVGFontElement = m_font->getSVGFontById(SVGURIReference::getTarget(m_string)); 127 128 if (m_externalSVGFontElement) { 129 SVGFontFaceElement* fontFaceElement = 0; 130 131 // Select first <font-face> child 132 for (Node* fontChild = m_externalSVGFontElement->firstChild(); fontChild; fontChild = fontChild->nextSibling()) { 133 if (fontChild->hasTagName(SVGNames::font_faceTag)) { 134 fontFaceElement = static_cast<SVGFontFaceElement*>(fontChild); 135 break; 136 } 137 } 138 139 if (fontFaceElement) { 140 if (!m_svgFontFaceElement) { 141 // We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement. 142 // Use the imported <font-face> tag as referencing font-face element for these cases. 143 m_svgFontFaceElement = fontFaceElement; 144 } 145 146 SVGFontData* svgFontData = new SVGFontData(fontFaceElement); 147 fontData.set(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic), true, false, svgFontData)); 148 } 149 } else 150 #endif 151 { 152 // Create new FontPlatformData from our CGFontRef, point size and ATSFontRef. 153 if (!m_font->ensureCustomFontData()) 154 return 0; 155 156 fontData.set(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic), true, false)); 157 } 158 } else { 159 #if ENABLE(SVG_FONTS) 160 // In-Document SVG Fonts 161 if (m_svgFontFaceElement) { 162 SVGFontData* svgFontData = new SVGFontData(m_svgFontFaceElement.get()); 163 fontData.set(new SimpleFontData(FontPlatformData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic), true, false, svgFontData)); 164 } 165 #endif 130 166 } 131 167 } else { 132 168 // Kick off the load now. 133 169 m_font->beginLoadIfNeeded(fontSelector->docLoader()); 134 135 170 FontPlatformData* tempData = FontCache::getCachedFontPlatformData(fontDescription, m_string); 136 171 if (!tempData) -
trunk/WebCore/css/CSSFontFaceSource.h
r29703 r29839 74 74 #if ENABLE(SVG_FONTS) 75 75 RefPtr<SVGFontFaceElement> m_svgFontFaceElement; 76 RefPtr<SVGFontElement> m_externalSVGFontElement; 76 77 #endif 77 78 }; -
trunk/WebCore/css/CSSFontFaceSrcValue.cpp
r29663 r29839 29 29 namespace WebCore { 30 30 31 #if ENABLE(SVG_FONTS) 32 bool CSSFontFaceSrcValue::isSVGFontFaceSrc() const 33 { 34 return equalIgnoringCase(m_format, "svg"); 35 } 36 #endif 37 31 38 bool CSSFontFaceSrcValue::isSupportedFormat() const 32 39 { … … 39 46 return true; 40 47 } 41 42 return equalIgnoringCase(m_format, "truetype") || equalIgnoringCase(m_format, "opentype"); 48 49 return equalIgnoringCase(m_format, "truetype") || equalIgnoringCase(m_format, "opentype") 50 #if ENABLE(SVG_FONTS) 51 || isSVGFontFaceSrc() 52 #endif 53 ; 43 54 } 44 55 -
trunk/WebCore/css/CSSFontFaceSrcValue.h
r29703 r29839 52 52 53 53 #if ENABLE(SVG_FONTS) 54 bool isSVGFontFaceSrc() const; 55 54 56 SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement.get(); } 55 57 void setSVGFontFaceElement(SVGFontFaceElement* element) { m_svgFontFaceElement = element; } -
trunk/WebCore/css/CSSFontSelector.cpp
r29704 r29839 1 1 /* 2 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 * (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>3 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 141 141 142 142 #if ENABLE(SVG_FONTS) 143 bool found InDocumentSVGFont = false;143 bool foundSVGFont = false; 144 144 #endif 145 145 … … 148 148 CSSFontFaceSrcValue* item = static_cast<CSSFontFaceSrcValue*>(srcList->item(i)); 149 149 CSSFontFaceSource* source = 0; 150 151 #if ENABLE(SVG_FONTS) 152 foundSVGFont = item->isSVGFontFaceSrc() || item->svgFontFaceElement(); 153 #endif 150 154 151 155 if (!item->isLocal()) { … … 158 162 String family = item->resource(); 159 163 160 #if ENABLE(SVG_FONTS)161 foundInDocumentSVGFont = item->svgFontFaceElement() != 0;162 #endif163 164 164 // Test the validity of the local font now. We don't want to include this font if it does not exist 165 165 // on the system. If it *does* exist on the system, then we don't need to look any further. 166 166 if (FontCache::fontExists(fontDescription, family) 167 #if ENABLE(SVG_FONTS) 168 || found InDocumentSVGFont167 #if ENABLE(SVG_FONTS) 168 || foundSVGFont 169 169 #endif 170 170 ) { 171 171 source = new CSSFontFaceSource(family); 172 #if ENABLE(SVG_FONTS)173 source->setSVGFontFaceElement(item->svgFontFaceElement());174 #endif175 172 foundLocal = true; 176 173 } … … 180 177 fontFace = new CSSFontFace(); 181 178 182 if (source) 179 if (source) { 180 #if ENABLE(SVG_FONTS) 181 source->setSVGFontFaceElement(item->svgFontFaceElement()); 182 #endif 183 183 fontFace->addSource(source); 184 } 184 185 185 186 // We can just break if we see a local font that is valid. … … 233 234 // SVG allows several <font> elements with the same font-family, differing only 234 235 // in ie. font-variant. Be sure to pick up the right one - in getFontData below. 235 if (found InDocumentSVGFont && fontDescription.smallCaps())236 if (foundSVGFont && fontDescription.smallCaps()) 236 237 familyName += "-webkit-svg-small-caps"; 237 238 #endif 239 238 240 String hash = hashForFont(familyName.lower(), fontDescription.bold(), fontDescription.italic()); 239 241 CSSSegmentedFontFace* segmentedFontFace = m_fonts.get(hash).get(); -
trunk/WebCore/loader/CachedFont.cpp
r29781 r29839 30 30 #include "CachedResourceClient.h" 31 31 #include "CachedResourceClientWalker.h" 32 #include "DOMImplementation.h" 32 33 #include "FontPlatformData.h" 33 34 #if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) … … 37 38 #include "loader.h" 38 39 #include <wtf/Vector.h> 40 41 #if ENABLE(SVG_FONTS) 42 #include "HTMLNames.h" 43 #include "NodeList.h" 44 #include "SVGElement.h" 45 #include "SVGFontElement.h" 46 #include "SVGGElement.h" 47 #endif 39 48 40 49 namespace WebCore { … … 94 103 } 95 104 96 FontPlatformData CachedFont::platformDataFromCustomData( int size, bool bold, bool italic)105 FontPlatformData CachedFont::platformDataFromCustomData(float size, bool bold, bool italic) 97 106 { 107 #if ENABLE(SVG_FONTS) 108 if (m_externalSVGDocument) 109 return FontPlatformData(size, bold, italic); 110 #endif 98 111 #if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) 99 112 ASSERT(m_fontData); 100 return m_fontData->fontPlatformData(s ize, bold, italic);113 return m_fontData->fontPlatformData(static_cast<int>(size), bold, italic); 101 114 #else 102 115 return FontPlatformData(); 103 116 #endif 104 117 } 118 119 #if ENABLE(SVG_FONTS) 120 bool CachedFont::ensureSVGFontData() 121 { 122 if (!m_externalSVGDocument && !m_errorOccurred && !m_loading && m_data) { 123 m_externalSVGDocument = new SVGDocument(DOMImplementation::instance(), 0); 124 m_externalSVGDocument->open(); 125 126 TextResourceDecoder decoder("application/xml"); 127 m_externalSVGDocument->write(decoder.decode(m_data->data(), m_data->size())); 128 129 m_externalSVGDocument->finishParsing(); 130 m_externalSVGDocument->close(); 131 } 132 133 return m_externalSVGDocument; 134 } 135 136 SVGFontElement* CachedFont::getSVGFontById(const String& fontName) const 137 { 138 RefPtr<NodeList> list = m_externalSVGDocument->getElementsByTagName(SVGNames::fontTag.localName()); 139 if (!list) 140 return 0; 141 142 unsigned fonts = list->length(); 143 for (unsigned i = 0; i < fonts; ++i) { 144 Node* node = list->item(i); 145 ASSERT(node); 146 147 if (static_cast<Element*>(node)->getAttribute(HTMLNames::idAttr) != fontName) 148 continue; 149 150 ASSERT(node->hasTagName(SVGNames::fontTag)); 151 return static_cast<SVGFontElement*>(node); 152 } 153 154 return 0; 155 } 156 #endif 105 157 106 158 void CachedFont::allReferencesRemoved() -
trunk/WebCore/loader/CachedFont.h
r29663 r29839 30 30 #include <wtf/Vector.h> 31 31 32 #if ENABLE(SVG_FONTS) 33 #include "SVGElement.h" 34 #include "SVGDocument.h" 35 #endif 36 32 37 namespace WebCore { 33 38 … … 36 41 class FontCustomPlatformData; 37 42 class FontPlatformData; 43 class SVGFontElement; 38 44 39 45 class CachedFont : public CachedResource { … … 53 59 54 60 void beginLoadIfNeeded(DocLoader* dl); 61 55 62 bool ensureCustomFontData(); 63 FontPlatformData platformDataFromCustomData(float size, bool bold, bool italic); 56 64 57 FontPlatformData platformDataFromCustomData(int size, bool bold, bool italic); 65 #if ENABLE(SVG_FONTS) 66 bool ensureSVGFontData(); 67 SVGFontElement* getSVGFontById(const String&) const; 68 #endif 58 69 59 70 private: 60 71 FontCustomPlatformData* m_fontData; 61 72 bool m_loadInitiated; 73 74 #if ENABLE(SVG_FONTS) 75 RefPtr<SVGDocument> m_externalSVGDocument; 76 #endif 62 77 63 78 friend class Cache; -
trunk/WebCore/platform/graphics/Font.cpp
r29700 r29839 742 742 int Font::offsetForPosition(const TextRun& run, int x, bool includePartialGlyphs) const 743 743 { 744 #if ENABLE(SVG_FONTS) 745 if (primaryFont()->isSVGFont()) 746 return offsetForPositionForTextUsingSVGFont(run, x, includePartialGlyphs); 747 #endif 748 744 749 if (canUseGlyphCache(run)) 745 750 return offsetForPositionForSimpleText(run, x, includePartialGlyphs); -
trunk/WebCore/platform/graphics/Font.h
r29712 r29839 231 231 float floatWidthUsingSVGFont(const TextRun&) const; 232 232 FloatRect selectionRectForTextUsingSVGFont(const TextRun&, const IntPoint&, int h, int from, int to) const; 233 int offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const; 233 234 #endif 234 235 void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const; -
trunk/WebCore/svg/SVGFont.cpp
r29838 r29839 34 34 #include "SVGMissingGlyphElement.h" 35 35 #include "SVGPaintServer.h" 36 #include "SVGPaintServerSolid.h" 36 37 #include "XMLNames.h" 37 38 … … 367 368 data.length = 0.0f; 368 369 370 String language; 371 bool isVerticalText = false; // Holds true for HTML text 372 373 // TODO: language matching & svg glyphs should be possible for HTML text, too. 369 374 if (RenderObject* renderObject = run.referencingRenderObject()) { 370 bool isVerticalText = isVerticalWritingMode(renderObject->style()->svgStyle()); 371 372 String language; 375 isVerticalText = isVerticalWritingMode(renderObject->style()->svgStyle()); 376 373 377 if (SVGElement* element = static_cast<SVGElement*>(renderObject->element())) 374 378 language = element->getAttribute(XMLNames::langAttr); 375 376 SVGTextRunWalker<SVGTextRunWalkerMeasuredLengthData> runWalker(fontData, fontElement, data, floatWidthUsingSVGFontCallback, floatWidthMissingGlyphCallback); 377 runWalker.walk(run, isVerticalText, language, 0, run.length()); 378 } 379 379 } 380 381 SVGTextRunWalker<SVGTextRunWalkerMeasuredLengthData> runWalker(fontData, fontElement, data, floatWidthUsingSVGFontCallback, floatWidthMissingGlyphCallback); 382 runWalker.walk(run, isVerticalText, language, 0, run.length()); 380 383 return data.length; 381 384 } … … 471 474 472 475 SVGTextRunWalkerDrawTextData data; 473 476 data.currentPoint = point; 477 data.scale = convertEmUnitToPixel(size(), fontFaceElement->unitsPerEm(), 1.0f); 478 479 // Required to be valid for SVG text only. 474 480 data.renderObject = run.referencingRenderObject(); 475 ASSERT(data.renderObject);476 477 481 data.activePaintServer = run.activePaintServer(); 482 483 // If renderObject is not set, we're dealing for HTML text rendered using SVG Fonts. 484 if (!data.renderObject) { 485 ASSERT(!data.activePaintServer); 486 487 // TODO: We're only supporting simple filled HTML text so far. 488 SVGPaintServerSolid* solidPaintServer = SVGPaintServer::sharedSolidPaintServer(); 489 solidPaintServer->setColor(context->fillColor()); 490 491 data.activePaintServer = solidPaintServer; 492 } 493 478 494 ASSERT(data.activePaintServer); 479 495 480 data.scale = convertEmUnitToPixel(size(), fontFaceElement->unitsPerEm(), 1.0f); 481 data.isVerticalText = isVerticalWritingMode(data.renderObject->style()->svgStyle()); 496 data.isVerticalText = false; 482 497 data.xStartOffset = floatWidthOfSubStringUsingSVGFont(this, run, run.rtl() ? to : 0, run.rtl() ? run.length() : from); 483 data.currentPoint = point;484 498 data.glyphOrigin = FloatPoint(); 485 499 data.context = context; 486 500 487 501 String language; 488 if (SVGElement* element = static_cast<SVGElement*>(data.renderObject->element())) 489 language = element->getAttribute(XMLNames::langAttr); 490 502 503 // TODO: language matching & svg glyphs should be possible for HTML text, too. 504 if (data.renderObject) { 505 data.isVerticalText = isVerticalWritingMode(data.renderObject->style()->svgStyle()); 506 507 if (SVGElement* element = static_cast<SVGElement*>(data.renderObject->element())) 508 language = element->getAttribute(XMLNames::langAttr); 509 } 510 491 511 if (!data.isVerticalText) { 492 512 data.glyphOrigin.setX(fontData->horizontalOriginX() * data.scale); … … 505 525 } 506 526 527 int Font::offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const 528 { 529 // TODO: Fix text selection when HTML text is drawn using a SVG Font 530 // We need to integrate the SVG text selection code in the offsetForPosition() framework. 531 // This will also fix a major issue, that SVG Text code can't select arabic strings properly. 532 return 0; 533 } 534 507 535 } 508 536 -
trunk/WebCore/svg/SVGFontFaceElement.cpp
r29805 r29839 304 304 return; 305 305 306 // Special handling for local SVG fonts (those which have a <font> parent, and are only used within the document)307 if (parentNode() && parentNode()->hasTagName(fontTag)) {308 RefPtr<CSSValueList> list = new CSSValueList;309 310 RefPtr<CSSFontFaceSrcValue> src = new CSSFontFaceSrcValue(fontFamily(), true /* isLocal */);311 src->setSVGFontFaceElement(this);312 list->append(src);313 314 CSSProperty srcProperty(CSS_PROP_SRC, list);315 const CSSProperty* srcPropertyRef = &srcProperty;316 m_styleDeclaration->addParsedProperties(&srcPropertyRef, 1);317 318 m_fontElement = static_cast<SVGFontElement*>(parentNode());319 document()->updateStyleSelector();320 return;321 }322 323 // TODO: External SVG fonts support - re use existing "custom font" handling logic.324 325 306 // we currently ignore all but the first src element, alternatively we could concat them 326 307 SVGFontFaceSrcElement* srcElement = 0; … … 340 321 #endif 341 322 342 if (srcElement) { 343 // This is the only class (other than CSSParser) to create CSSValue objects and set them on the CSSStyleDeclaration manually 344 // we use the addParsedProperties method, and fake having an array of CSSProperty pointers. 345 CSSProperty srcProperty(CSS_PROP_SRC, srcElement->srcValue()); 346 const CSSProperty* srcPropertyRef = &srcProperty; 347 m_styleDeclaration->addParsedProperties(&srcPropertyRef, 1); 323 bool describesParentFont = parentNode()->hasTagName(fontTag); 324 RefPtr<CSSValueList> list; 325 326 if (describesParentFont) { 327 m_fontElement = static_cast<SVGFontElement*>(parentNode()); 328 329 list = new CSSValueList; 330 list->append(new CSSFontFaceSrcValue(fontFamily(), true)); 331 } else if (srcElement) 332 list = srcElement->srcValue(); 333 334 if (!list) 335 return; 336 337 // Parse in-memory CSS rules 338 CSSProperty srcProperty(CSS_PROP_SRC, list); 339 const CSSProperty* srcPropertyRef = &srcProperty; 340 m_styleDeclaration->addParsedProperties(&srcPropertyRef, 1); 341 342 if (describesParentFont) { 343 // Traverse parsed CSS values and associate CSSFontFaceSrcValue elements with ourselves. 344 RefPtr<CSSValue> src = m_styleDeclaration->getPropertyCSSValue(CSS_PROP_SRC); 345 CSSValueList* srcList = static_cast<CSSValueList*>(src.get()); 346 347 unsigned srcLength = srcList ? srcList->length() : 0; 348 for (unsigned i = 0; i < srcLength; i++) { 349 if (CSSFontFaceSrcValue* item = static_cast<CSSFontFaceSrcValue*>(srcList->item(i))) 350 item->setSVGFontFaceElement(this); 351 } 348 352 } 349 353 -
trunk/WebCore/svg/SVGFontFaceUriElement.cpp
r29663 r29839 40 40 { 41 41 RefPtr<CSSFontFaceSrcValue> src = new CSSFontFaceSrcValue(getAttribute(XLinkNames::hrefAttr), false); 42 src->setFormat(getAttribute(formatAttr)); 42 AtomicString value(getAttribute(formatAttr)); 43 src->setFormat(value.isEmpty() ? "svg" : value); // Default format 43 44 return src.release(); 44 45 }
Note: See TracChangeset
for help on using the changeset viewer.