| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. |
| 3 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com | 3 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com |
| 4 * Copyright (C) 2007 Holger Hans Peter Freyther | 4 * Copyright (C) 2007 Holger Hans Peter Freyther |
| 5 * Copyright (C) 2007 Pioneer Research Center USA, Inc. | 5 * Copyright (C) 2007 Pioneer Research Center USA, Inc. |
| 6 * Copyright (C) 2010, 2011 Brent Fulgham <bfulgham@webkit.org> | 6 * Copyright (C) 2010, 2011 Brent Fulgham <bfulgham@webkit.org> |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| 11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
| 12 * | 12 * |
| 13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
| 17 * | 17 * |
| 18 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
| 22 * | 22 * |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 // FIXME: This is temporary until mac switch to using FontPlatformDataHarfBuzz.h
and we merge it with this file. | 25 // FIXME: This is temporary until mac switch to using FontPlatformDataHarfBuzz.h
and we merge it with this file. |
| 26 #if !OS(MACOSX) |
| 26 #include "platform/fonts/harfbuzz/FontPlatformDataHarfBuzz.h" | 27 #include "platform/fonts/harfbuzz/FontPlatformDataHarfBuzz.h" |
| 28 |
| 29 #else |
| 30 |
| 31 #ifndef FontPlatformData_h |
| 32 #define FontPlatformData_h |
| 33 |
| 34 #include "platform/PlatformExport.h" |
| 35 #include "platform/fonts/FontOrientation.h" |
| 36 #include "platform/fonts/FontWidthVariant.h" |
| 37 |
| 38 OBJC_CLASS NSFont; |
| 39 |
| 40 typedef struct CGFont* CGFontRef; |
| 41 typedef const struct __CTFont* CTFontRef; |
| 42 |
| 43 #include <CoreFoundation/CFBase.h> |
| 44 #include <objc/objc-auto.h> |
| 45 |
| 46 #include "wtf/Forward.h" |
| 47 #include "wtf/HashTableDeletedValueType.h" |
| 48 #include "wtf/PassRefPtr.h" |
| 49 #include "wtf/RefCounted.h" |
| 50 #include "wtf/RetainPtr.h" |
| 51 #include "wtf/text/StringImpl.h" |
| 52 |
| 53 #include "platform/fonts/mac/MemoryActivatedFont.h" |
| 54 #include "third_party/skia/include/core/SkTypeface.h" |
| 55 |
| 56 typedef struct CGFont* CGFontRef; |
| 57 typedef const struct __CTFont* CTFontRef; |
| 58 typedef UInt32 FMFont; |
| 59 typedef FMFont ATSUFontID; |
| 60 typedef UInt32 ATSFontRef; |
| 61 |
| 62 namespace blink { |
| 63 |
| 64 class HarfBuzzFace; |
| 65 |
| 66 inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef
>(nsFont); } |
| 67 |
| 68 class PLATFORM_EXPORT FontPlatformData { |
| 69 public: |
| 70 FontPlatformData(WTF::HashTableDeletedValueType); |
| 71 FontPlatformData(); |
| 72 FontPlatformData(const FontPlatformData&); |
| 73 FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, Font
Orientation = Horizontal, FontWidthVariant = RegularWidth); |
| 74 FontPlatformData(NSFont*, float size, bool syntheticBold = false, bool synth
eticOblique = false, |
| 75 FontOrientation = Horizontal, FontWidthVariant = RegularWid
th); |
| 76 FontPlatformData(CGFontRef, float size, bool syntheticBold, bool syntheticOb
lique, FontOrientation, FontWidthVariant); |
| 77 |
| 78 ~FontPlatformData(); |
| 79 |
| 80 NSFont* font() const { return m_font; } |
| 81 void setFont(NSFont*); |
| 82 |
| 83 CGFontRef cgFont() const { return m_cgFont.get(); } |
| 84 CTFontRef ctFont() const; |
| 85 SkTypeface* typeface() const; |
| 86 |
| 87 bool roundsGlyphAdvances() const; |
| 88 bool allowsLigatures() const; |
| 89 |
| 90 String fontFamilyName() const; |
| 91 bool isFixedPitch() const; |
| 92 float size() const { return m_size; } |
| 93 void setSize(float size) { m_size = size; } |
| 94 bool syntheticBold() const { return m_syntheticBold; } |
| 95 bool syntheticOblique() const { return m_syntheticOblique; } |
| 96 bool isColorBitmapFont() const { return m_isColorBitmapFont; } |
| 97 bool isCompositeFontReference() const { return m_isCompositeFontReference; } |
| 98 |
| 99 FontOrientation orientation() const { return m_orientation; } |
| 100 FontWidthVariant widthVariant() const { return m_widthVariant; } |
| 101 |
| 102 void setOrientation(FontOrientation orientation) { m_orientation = orientati
on; } |
| 103 |
| 104 HarfBuzzFace* harfBuzzFace(); |
| 105 |
| 106 unsigned hash() const |
| 107 { |
| 108 ASSERT(m_font || !m_cgFont); |
| 109 uintptr_t hashCodes[3] = { (uintptr_t)m_font, m_widthVariant, static_cas
t<uintptr_t>(m_orientation << 2 | m_syntheticBold << 1 | m_syntheticOblique) }; |
| 110 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); |
| 111 } |
| 112 |
| 113 const FontPlatformData& operator=(const FontPlatformData&); |
| 114 |
| 115 bool operator==(const FontPlatformData& other) const |
| 116 { |
| 117 return platformIsEqual(other) |
| 118 && m_size == other.m_size |
| 119 && m_syntheticBold == other.m_syntheticBold |
| 120 && m_syntheticOblique == other.m_syntheticOblique |
| 121 && m_isColorBitmapFont == other.m_isColorBitmapFont |
| 122 && m_isCompositeFontReference == other.m_isCompositeFontReference |
| 123 && m_orientation == other.m_orientation |
| 124 && m_widthVariant == other.m_widthVariant; |
| 125 } |
| 126 |
| 127 bool isHashTableDeletedValue() const |
| 128 { |
| 129 return m_font == hashTableDeletedFontValue(); |
| 130 } |
| 131 |
| 132 #ifndef NDEBUG |
| 133 String description() const; |
| 134 #endif |
| 135 |
| 136 private: |
| 137 bool platformIsEqual(const FontPlatformData&) const; |
| 138 void platformDataInit(const FontPlatformData&); |
| 139 const FontPlatformData& platformDataAssign(const FontPlatformData&); |
| 140 #if OS(MACOSX) |
| 141 // Load various data about the font specified by |nsFont| with the size font
Size into the following output paramters: |
| 142 // Note: Callers should always take into account that for the Chromium port,
|outNSFont| isn't necessarily the same |
| 143 // font as |nsFont|. This because the sandbox may block loading of the origi
nal font. |
| 144 // * outNSFont - The font that was actually loaded, for the Chromium port th
is may be different than nsFont. |
| 145 // The caller is responsible for calling CFRelease() on this parameter when
done with it. |
| 146 // * cgFont - CGFontRef representing the input font at the specified point s
ize. |
| 147 void loadFont(NSFont*, float fontSize, NSFont*& outNSFont, CGFontRef&); |
| 148 static NSFont* hashTableDeletedFontValue() { return reinterpret_cast<NSFont
*>(-1); } |
| 149 #endif |
| 150 |
| 151 public: |
| 152 bool m_syntheticBold; |
| 153 bool m_syntheticOblique; |
| 154 FontOrientation m_orientation; |
| 155 float m_size; |
| 156 FontWidthVariant m_widthVariant; |
| 157 |
| 158 private: |
| 159 NSFont* m_font; |
| 160 RetainPtr<CGFontRef> m_cgFont; |
| 161 mutable RetainPtr<CTFontRef> m_CTFont; |
| 162 |
| 163 RefPtr<MemoryActivatedFont> m_inMemoryFont; |
| 164 RefPtr<HarfBuzzFace> m_harfBuzzFace; |
| 165 mutable RefPtr<SkTypeface> m_typeface; |
| 166 |
| 167 bool m_isColorBitmapFont; |
| 168 bool m_isCompositeFontReference; |
| 169 }; |
| 170 |
| 171 } // namespace blink |
| 172 |
| 173 #endif // FontPlatformData_h |
| 174 |
| 175 #endif |
| OLD | NEW |