• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
3  * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4  * Copyright (C) 2008 Rob Buis <buis@kde.org>
5  * Copyright (C) Research In Motion Limited 2011. All rights reserved.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef SVGGlyph_h
24 #define SVGGlyph_h
25 
26 #if ENABLE(SVG_FONTS)
27 #include "platform/PlatformExport.h"
28 #include "platform/fonts/Glyph.h"
29 #include "platform/graphics/Path.h"
30 
31 #include <limits>
32 #include "wtf/text/WTFString.h"
33 #include "wtf/Vector.h"
34 
35 namespace WebCore {
36 
37 // Describe a glyph from a SVG Font.
38 struct SVGGlyph {
39     enum Orientation {
40         Vertical,
41         Horizontal,
42         Both
43     };
44 
45     // SVG Font depends on exactly this order.
46     enum ArabicForm {
47         None = 0,
48         Isolated,
49         Terminal,
50         Initial,
51         Medial
52     };
53 
SVGGlyphSVGGlyph54     SVGGlyph()
55         : isPartOfLigature(false)
56         , orientation(Both)
57         , arabicForm(None)
58         , priority(0)
59         , tableEntry(0)
60         , unicodeStringLength(0)
61         , horizontalAdvanceX(0)
62         , verticalOriginX(0)
63         , verticalOriginY(0)
64         , verticalAdvanceY(0)
65     {
66     }
67 
68     // Used to mark our float properties as "to be inherited from SVGFontData"
inheritedValueSVGGlyph69     static float inheritedValue()
70     {
71         static float s_inheritedValue = std::numeric_limits<float>::infinity();
72         return s_inheritedValue;
73     }
74 
75     bool operator==(const SVGGlyph& other) const
76     {
77         return isPartOfLigature == other.isPartOfLigature
78             && orientation == other.orientation
79             && arabicForm == other.arabicForm
80             && tableEntry == other.tableEntry
81             && unicodeStringLength == other.unicodeStringLength
82             && glyphName == other.glyphName
83             && horizontalAdvanceX == other.horizontalAdvanceX
84             && verticalOriginX == other.verticalOriginX
85             && verticalOriginY == other.verticalOriginY
86             && verticalAdvanceY == other.verticalAdvanceY
87             && languages == other.languages;
88     }
89 
90     bool isPartOfLigature : 1;
91 
92     unsigned orientation : 2; // Orientation
93     unsigned arabicForm : 3; // ArabicForm
94     int priority;
95     Glyph tableEntry;
96     size_t unicodeStringLength;
97     String glyphName;
98 
99     float horizontalAdvanceX;
100     float verticalOriginX;
101     float verticalOriginY;
102     float verticalAdvanceY;
103 
104     Path pathData;
105     Vector<String> languages;
106 };
107 
108 Vector<SVGGlyph::ArabicForm> PLATFORM_EXPORT charactersWithArabicForm(const String& input, bool rtl);
109 bool PLATFORM_EXPORT isCompatibleGlyph(const SVGGlyph&, bool isVerticalText, const String& language, const Vector<SVGGlyph::ArabicForm>&, unsigned startPosition, unsigned endPosition);
110 
111 } // namespace WebCore
112 
113 #endif // ENABLE(SVG_FONTS)
114 #endif
115