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 "Glyph.h"
28#include "Path.h"
29
30#include <limits>
31#include <wtf/Vector.h>
32#include <wtf/text/WTFString.h>
33
34namespace WebCore {
35
36// Describe a glyph from a SVG Font.
37struct SVGGlyph {
38    enum Orientation {
39        Vertical,
40        Horizontal,
41        Both
42    };
43
44    // SVG Font depends on exactly this order.
45    enum ArabicForm {
46        None = 0,
47        Isolated,
48        Terminal,
49        Initial,
50        Medial
51    };
52
53    SVGGlyph()
54        : isPartOfLigature(false)
55        , orientation(Both)
56        , arabicForm(None)
57        , priority(0)
58        , tableEntry(0)
59        , unicodeStringLength(0)
60        , horizontalAdvanceX(0)
61        , verticalOriginX(0)
62        , verticalOriginY(0)
63        , verticalAdvanceY(0)
64    {
65    }
66
67    // Used to mark our float properties as "to be inherited from SVGFontData"
68    static float inheritedValue()
69    {
70        static float s_inheritedValue = std::numeric_limits<float>::infinity();
71        return s_inheritedValue;
72    }
73
74    bool operator==(const SVGGlyph& other) const
75    {
76        return isPartOfLigature == other.isPartOfLigature
77            && orientation == other.orientation
78            && arabicForm == other.arabicForm
79            && tableEntry == other.tableEntry
80            && unicodeStringLength == other.unicodeStringLength
81            && glyphName == other.glyphName
82            && horizontalAdvanceX == other.horizontalAdvanceX
83            && verticalOriginX == other.verticalOriginX
84            && verticalOriginY == other.verticalOriginY
85            && verticalAdvanceY == other.verticalAdvanceY
86            && languages == other.languages;
87    }
88
89    bool isPartOfLigature : 1;
90
91    unsigned orientation : 2; // Orientation
92    unsigned arabicForm : 3; // ArabicForm
93    int priority;
94    Glyph tableEntry;
95    size_t unicodeStringLength;
96    String glyphName;
97
98    float horizontalAdvanceX;
99    float verticalOriginX;
100    float verticalOriginY;
101    float verticalAdvanceY;
102
103    Path pathData;
104    Vector<String> languages;
105};
106
107Vector<SVGGlyph::ArabicForm> charactersWithArabicForm(const String& input, bool rtl);
108bool isCompatibleGlyph(const SVGGlyph&, bool isVerticalText, const String& language, const Vector<SVGGlyph::ArabicForm>&, unsigned startPosition, unsigned endPosition);
109
110} // namespace WebCore
111
112#endif // ENABLE(SVG_FONTS)
113#endif
114