- add third_party src.
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / svg / SVGFontData.h
1 /*
2  * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #ifndef SVGFontData_h
21 #define SVGFontData_h
22
23 #if ENABLE(SVG_FONTS)
24 #include "core/platform/graphics/SimpleFontData.h"
25
26 namespace WebCore {
27
28 class SVGFontElement;
29 class SVGFontFaceElement;
30
31 class SVGFontData : public SimpleFontData::AdditionalFontData {
32 public:
33     static PassOwnPtr<SVGFontData> create(SVGFontFaceElement* element)
34     {
35         return adoptPtr(new SVGFontData(element));
36     }
37
38     virtual ~SVGFontData() { }
39
40     virtual void initializeFontData(SimpleFontData*, float fontSize);
41     virtual float widthForSVGGlyph(Glyph, float fontSize) const;
42     virtual bool fillSVGGlyphPage(GlyphPage*, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData*) const;
43     virtual bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool mirror, int currentCharacter, unsigned& advanceLength) const;
44
45     SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement; }
46
47     float horizontalOriginX() const { return m_horizontalOriginX; }
48     float horizontalOriginY() const { return m_horizontalOriginY; }
49     float horizontalAdvanceX() const { return m_horizontalAdvanceX; }
50
51     float verticalOriginX() const { return m_verticalOriginX; }
52     float verticalOriginY() const { return m_verticalOriginY; }
53     float verticalAdvanceY() const { return m_verticalAdvanceY; }
54
55 private:
56     SVGFontData(SVGFontFaceElement*);
57
58     bool fillBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned length, UChar* buffer, const SimpleFontData*) const;
59     bool fillNonBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned length, UChar* buffer, const SimpleFontData*) const;
60
61     String createStringWithMirroredCharacters(const String&) const;
62
63     // Ths SVGFontFaceElement is kept alive --
64     // 1) in the external font case: by the CSSFontFaceSource, which holds a reference to the external SVG document
65     //    containing the element;
66     // 2) in the in-document font case: by virtue of being in the document tree and making sure that when it is removed
67     //    from the document, it removes the @font-face rule it owns from the document's mapped element sheet and forces
68     //    a style update.
69     SVGFontFaceElement* m_svgFontFaceElement;
70
71     float m_horizontalOriginX;
72     float m_horizontalOriginY;
73     float m_horizontalAdvanceX;
74
75     float m_verticalOriginX;
76     float m_verticalOriginY;
77     float m_verticalAdvanceY;
78 };
79
80 } // namespace WebCore
81
82 #endif
83 #endif // SVGFontData_h