• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, 2007 Apple Inc.
6  * Copyright (C) 2007-2008 Torch Mobile, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB.  If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  */
24 
25 #ifndef FontPlatformData_h
26 #define FontPlatformData_h
27 
28 #include "FontDescription.h"
29 #include "FontOrientation.h"
30 #include <wtf/Forward.h>
31 #include <wtf/Noncopyable.h>
32 #include <wtf/text/StringImpl.h>
33 
34 typedef struct tagTEXTMETRICW TEXTMETRIC;
35 typedef struct tagLOGFONTW LOGFONT;
36 
37 namespace WebCore {
38 
39     class FontPlatformPrivateData;
40 
41     class FontPlatformData {
42 
43     public:
44 
FontPlatformData()45         FontPlatformData(): m_private(0) {}
46         FontPlatformData(float size, bool bold, bool oblique);
47 
48         // Used for deleted values in the font cache's hash tables.
FontPlatformData(WTF::HashTableDeletedValueType)49         FontPlatformData(WTF::HashTableDeletedValueType) : m_private((FontPlatformPrivateData*)1) {}
isHashTableDeletedValue()50         bool isHashTableDeletedValue() const { return (unsigned)m_private == 1; }
51 
52         FontPlatformData(const FontDescription& fontDescription, const AtomicString& family, bool useDefaultFontIfNotPresent = true);
53 
54         ~FontPlatformData();
55 
FontPlatformData(const FontPlatformData & o)56         FontPlatformData(const FontPlatformData& o) : m_private(0) { operator=(o); }
57         FontPlatformData& operator=(const FontPlatformData& o);
58 
isValid()59         int isValid() const { return reinterpret_cast<unsigned>(m_private) & ~1; }
60         HFONT hfont() const;
61         const TEXTMETRIC& metrics() const;
62         bool isSystemFont() const;
63         int size() const;
hash()64         unsigned hash() const { return (unsigned)m_private; }
65         const FontDescription& fontDescription() const;
66         const AtomicString& family() const;
67         bool operator==(const FontPlatformData& other) const {     return m_private == other.m_private; }
68         HFONT getScaledFontHandle(int height, int width) const;
69         const LOGFONT& logFont() const;
70         int averageCharWidth() const;
71         bool isDisabled() const;
72         bool discardFontHandle();
73         DWORD codePages() const;
74 
75         static bool isSongTiSupported();
76         static bool mapKnownFont(DWORD codePages, String& family);
77         static DWORD getKnownFontCodePages(const wchar_t* family);
78         static const String& defaultFontFamily();
79         static LONG adjustedGDIFontWeight(LONG gdiFontWeight, const String& family);
80 
orientation()81         FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
setOrientation(FontOrientation)82         void setOrientation(FontOrientation) { } // FIXME: Implement.
83 
84 #ifndef NDEBUG
85         String description() const;
86 #endif
87 
88     private:
89         FontPlatformPrivateData* m_private;
90     };
91 
92 }
93 
94 #endif
95