FontPlatformData.h revision 2bde8e466a4451c7319e3a072d118917957d6554
1/* 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. 3 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com 4 * Copyright (C) 2007 Holger Hans Peter Freyther 5 * Copyright (C) 2007 Pioneer Research Center USA, Inc. 6 * All rights reserved. 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 FontPlatformDataPango_h 26#define FontPlatformDataPango_h 27 28#include "FontDescription.h" 29#include "FontOrientation.h" 30#include "GlyphBuffer.h" 31#include <cairo.h> 32#include <pango/pangocairo.h> 33#include <wtf/Forward.h> 34 35namespace WebCore { 36 37class FontPlatformData { 38public: 39 FontPlatformData(WTF::HashTableDeletedValueType) 40 : m_context(0) 41 , m_font(hashTableDeletedFontValue()) 42 , m_size(0) 43 , m_syntheticBold(false) 44 , m_syntheticOblique(false) 45 , m_scaledFont(0) 46 { } 47 48 FontPlatformData() 49 : m_context(0) 50 , m_font(0) 51 , m_size(0) 52 , m_syntheticBold(false) 53 , m_syntheticOblique(false) 54 , m_scaledFont(0) 55 { } 56 57 FontPlatformData(const FontDescription&, const AtomicString& family); 58 FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool italic); 59 FontPlatformData(float size, bool bold, bool italic); 60 FontPlatformData(const FontPlatformData&); 61 ~FontPlatformData(); 62 63 static bool init(); 64 bool isFixedPitch(); 65 float size() const { return m_size; } 66 void setSize(float size) { m_size = size; } 67 bool syntheticBold() const { return m_syntheticBold; } 68 bool syntheticOblique() const { return m_syntheticOblique; } 69 70 FontOrientation orientation() const { return Horizontal; } // FIXME: Implement. 71 72 cairo_scaled_font_t* scaledFont() const { return m_scaledFont; } 73 74 unsigned hash() const 75 { 76 uintptr_t hashCodes[1] = { reinterpret_cast<uintptr_t>(m_scaledFont) }; 77 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); 78 } 79 80 bool operator==(const FontPlatformData&) const; 81 FontPlatformData& operator=(const FontPlatformData&); 82 bool isHashTableDeletedValue() const 83 { 84 return m_font == hashTableDeletedFontValue(); 85 } 86 87#ifndef NDEBUG 88 String description() const; 89#endif 90 91 static PangoFontMap* m_fontMap; 92 static GHashTable* m_hashTable; 93 PangoContext* m_context; 94 PangoFont* m_font; 95 float m_size; 96 bool m_syntheticBold; 97 bool m_syntheticOblique; 98 cairo_scaled_font_t* m_scaledFont; 99private: 100 static PangoFont *hashTableDeletedFontValue() { return reinterpret_cast<PangoFont*>(-1); } 101}; 102 103} 104 105#endif // FontPlatformDataPango_h 106