]> git.saurik.com Git - iphone-api.git/blame - WebCore/FontPlatformData.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / FontPlatformData.h
CommitLineData
a90939db
JF
1/*
2 * This file is part of the internal font implementation.
3 * It should not be included by source files outside it.
4 *
5 * Copyright (C) 2006, 2008 Apple Inc. 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
24#ifndef FontPlatformData_h
25#define FontPlatformData_h
26
27#include "StringImpl.h"
28
29#ifdef __OBJC__
30@class NSFont;
31#else
32class NSFont;
33#endif
34
35#import <GraphicsServices/GSFont.h>
36
37typedef struct CGFont* CGFontRef;
38typedef UInt32 ATSUFontID;
39#ifndef BUILDING_ON_TIGER
40typedef const struct __CTFont* CTFontRef;
41#endif
42
43#include <CoreFoundation/CFBase.h>
44#include <objc/objc-auto.h>
45#include <wtf/RetainPtr.h>
46
47namespace WebCore {
48
49
50struct FontPlatformData {
51 FontPlatformData(float size, bool syntheticBold, bool syntheticOblique)
52 : m_syntheticBold(syntheticBold)
53 , m_syntheticOblique(syntheticOblique)
54 , m_gsFont(0)
55 , m_isImageFont(false)
56 , m_size(size)
57 , m_font(0)
58 {
59 }
60
61 FontPlatformData(GSFontRef = 0, bool syntheticBold = false, bool syntheticOblique = false);
62
63 FontPlatformData(GSFontRef f, float s, bool b , bool o)
64 : m_syntheticBold(b), m_syntheticOblique(o), m_gsFont(f), m_isImageFont(false), m_size(s), m_font(0)
65 {
66 }
67
68 FontPlatformData(const FontPlatformData&);
69
70 ~FontPlatformData();
71
72 FontPlatformData(WTF::HashTableDeletedValueType) : m_font(hashTableDeletedFontValue()) { }
73 bool isHashTableDeletedValue() const { return m_font == hashTableDeletedFontValue(); }
74
75 float size() const { return m_size; }
76
77 bool m_syntheticBold;
78 bool m_syntheticOblique;
79
80 GSFontRef m_gsFont;
81 bool m_isImageFont;
82 float m_size;
83
84 unsigned hash() const
85 {
86 ASSERT(m_font != 0 || m_gsFont == 0 || m_isImageFont != 0);
87 uintptr_t hashCodes[2] = { (uintptr_t)m_font, m_isImageFont << 2 | m_syntheticBold << 1 | m_syntheticOblique };
88 return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));
89 }
90
91 const FontPlatformData& operator=(const FontPlatformData& f);
92
93 bool operator==(const FontPlatformData& other) const
94 {
95 return m_font == other.m_font && m_syntheticBold == other.m_syntheticBold && m_syntheticOblique == other.m_syntheticOblique &&
96 m_gsFont == other.m_gsFont && m_size == other.m_size && m_isImageFont == other.m_isImageFont;
97 }
98
99 GSFontRef font() const { return m_font; }
100 void setFont(GSFontRef font);
101
102 bool roundsGlyphAdvances() const { return false; }
103#if USE(CORE_TEXT)
104 bool allowsLigatures() const;
105#else
106 bool allowsLigatures() const { return false; }
107#endif
108
109
110private:
111 static GSFontRef hashTableDeletedFontValue() { return reinterpret_cast<GSFontRef>(-1); }
112
113 GSFontRef m_font;
114};
115
116}
117
118#endif