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 34typedef struct tagTEXTMETRICW TEXTMETRIC; 35typedef struct tagLOGFONTW LOGFONT; 36 37namespace WebCore { 38 39 class FontPlatformPrivateData; 40 41 class FontPlatformData { 42 43 public: 44 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. 49 FontPlatformData(WTF::HashTableDeletedValueType) : m_private((FontPlatformPrivateData*)1) {} 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 56 FontPlatformData(const FontPlatformData& o) : m_private(0) { operator=(o); } 57 FontPlatformData& operator=(const FontPlatformData& o); 58 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; 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 bool isDisabled() const; 71 bool discardFontHandle(); 72 DWORD codePages() const; 73 74 static bool isSongTiSupported(); 75 static bool mapKnownFont(DWORD codePages, String& family); 76 static DWORD getKnownFontCodePages(const wchar_t* family); 77 static const String& defaultFontFamily(); 78 static LONG adjustedGDIFontWeight(LONG gdiFontWeight, const String& family); 79 80 FontOrientation orientation() const { return Horizontal; } // FIXME: Implement. 81 void setOrientation(FontOrientation) { } // FIXME: Implement. 82 83#ifndef NDEBUG 84 String description() const; 85#endif 86 87 private: 88 FontPlatformPrivateData* m_private; 89 }; 90 91} 92 93#endif 94