]> git.saurik.com Git - iphone-api.git/blob - WebCore/FontFallbackList.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / FontFallbackList.h
1 /*
2 * This file is part of the internal font implementation. It should not be included by anyone other than
3 * FontMac.cpp, FontWin.cpp and Font.cpp.
4 *
5 * Copyright (C) 2006 Apple Computer, Inc.
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
24 // This file has no guards on purpose in order to detect redundant includes. This is a private header
25 // and so this may catch someone trying to include this file in public cpp files.
26
27 #include "FontSelector.h"
28 #include "SimpleFontData.h"
29 #include <wtf/Forward.h>
30
31 namespace WebCore {
32
33 class Font;
34 class GraphicsContext;
35 class IntRect;
36 class FontDescription;
37 class FontPlatformData;
38 class FontSelector;
39
40 const int cAllFamiliesScanned = -1;
41
42 class FontFallbackList : public RefCounted<FontFallbackList> {
43 public:
44 static PassRefPtr<FontFallbackList> create() { return adoptRef(new FontFallbackList()); }
45
46 ~FontFallbackList() { releaseFontData(); }
47 void invalidate(PassRefPtr<FontSelector>);
48
49 bool isFixedPitch(const Font* f) const { if (m_pitch == UnknownPitch) determinePitch(f); return m_pitch == FixedPitch; };
50 void determinePitch(const Font*) const;
51
52 bool loadingCustomFonts() const { return m_loadingCustomFonts; }
53
54 FontSelector* fontSelector() const { return m_fontSelector.get(); }
55 unsigned generation() const { return m_generation; }
56
57 private:
58 FontFallbackList();
59
60 const FontData* primaryFont(const Font* f) const { return fontDataAt(f, 0); }
61 const FontData* fontDataAt(const Font*, unsigned index) const;
62 const FontData* fontDataForCharacters(const Font*, const UChar*, int length) const;
63
64 void setPlatformFont(const FontPlatformData&);
65
66 void releaseFontData();
67
68 mutable Vector<pair<const FontData*, bool>, 1> m_fontList;
69 mutable int m_familyIndex;
70 mutable Pitch m_pitch;
71 mutable bool m_loadingCustomFonts;
72 RefPtr<FontSelector> m_fontSelector;
73 unsigned m_generation;
74
75 friend class Font;
76 };
77
78 }
79