2 * This file is part of the internal font implementation.
3 * It should not be included by source files outside it.
5 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
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.
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.
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.
24 #ifndef FontPlatformData_h
25 #define FontPlatformData_h
27 #include "StringImpl.h"
35 #import <GraphicsServices/GSFont.h>
37 typedef struct CGFont
* CGFontRef
;
38 typedef UInt32 ATSUFontID
;
39 #ifndef BUILDING_ON_TIGER
40 typedef const struct __CTFont
* CTFontRef
;
43 #include <CoreFoundation/CFBase.h>
44 #include <objc/objc-auto.h>
45 #include <wtf/RetainPtr.h>
50 struct FontPlatformData
{
51 FontPlatformData(float size
, bool syntheticBold
, bool syntheticOblique
)
52 : m_syntheticBold(syntheticBold
)
53 , m_syntheticOblique(syntheticOblique
)
55 , m_isImageFont(false)
61 FontPlatformData(GSFontRef
= 0, bool syntheticBold
= false, bool syntheticOblique
= false);
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)
68 FontPlatformData(const FontPlatformData
&);
72 FontPlatformData(WTF::HashTableDeletedValueType
) : m_font(hashTableDeletedFontValue()) { }
73 bool isHashTableDeletedValue() const { return m_font
== hashTableDeletedFontValue(); }
75 float size() const { return m_size
; }
78 bool m_syntheticOblique
;
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
));
91 const FontPlatformData
& operator=(const FontPlatformData
& f
);
93 bool operator==(const FontPlatformData
& other
) const
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
;
99 GSFontRef
font() const { return m_font
; }
100 void setFont(GSFontRef font
);
102 bool roundsGlyphAdvances() const { return false; }
104 bool allowsLigatures() const;
106 bool allowsLigatures() const { return false; }
111 static GSFontRef
hashTableDeletedFontValue() { return reinterpret_cast<GSFontRef
>(-1); }