| 1 | /* |
| 2 | * Copyright (C) 2011 Brent Fulgham |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Library General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Library General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Library General Public License |
| 15 | * along with this library; see the file COPYING.LIB. If not, write to |
| 16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | * Boston, MA 02110-1301, USA. |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | #include "FontPlatformData.h" |
| 23 | |
| 24 | #include <wtf/HashMap.h> |
| 25 | #include <wtf/RetainPtr.h> |
| 26 | #include <wtf/text/StringHash.h> |
| 27 | #include <wtf/text/WTFString.h> |
| 28 | |
| 29 | #if OS(DARWIN) && USE(CG) |
| 30 | #include "SharedBuffer.h" |
| 31 | #include <CoreGraphics/CGFont.h> |
| 32 | #endif |
| 33 | |
| 34 | #if USE(DIRECT2D) |
| 35 | #include <dwrite.h> |
| 36 | #endif |
| 37 | |
| 38 | namespace WebCore { |
| 39 | |
| 40 | FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) |
| 41 | : m_isHashTableDeletedValue(true) |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | FontPlatformData::FontPlatformData() |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | FontPlatformData::FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode) |
| 50 | : m_size(size) |
| 51 | , m_orientation(orientation) |
| 52 | , m_widthVariant(widthVariant) |
| 53 | , m_textRenderingMode(textRenderingMode) |
| 54 | , m_syntheticBold(syntheticBold) |
| 55 | , m_syntheticOblique(syntheticOblique) |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | #if USE(CG) && PLATFORM(WIN) |
| 60 | FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode) |
| 61 | : FontPlatformData(size, syntheticBold, syntheticOblique, orientation, widthVariant, textRenderingMode) |
| 62 | { |
| 63 | m_cgFont = cgFont; |
| 64 | ASSERT(m_cgFont); |
| 65 | } |
| 66 | #endif |
| 67 | |
| 68 | #if !USE(FREETYPE) |
| 69 | FontPlatformData FontPlatformData::cloneWithOrientation(const FontPlatformData& source, FontOrientation orientation) |
| 70 | { |
| 71 | FontPlatformData copy(source); |
| 72 | copy.m_orientation = orientation; |
| 73 | return copy; |
| 74 | } |
| 75 | |
| 76 | FontPlatformData FontPlatformData::cloneWithSyntheticOblique(const FontPlatformData& source, bool syntheticOblique) |
| 77 | { |
| 78 | FontPlatformData copy(source); |
| 79 | copy.m_syntheticOblique = syntheticOblique; |
| 80 | return copy; |
| 81 | } |
| 82 | |
| 83 | FontPlatformData FontPlatformData::cloneWithSize(const FontPlatformData& source, float size) |
| 84 | { |
| 85 | FontPlatformData copy(source); |
| 86 | copy.m_size = size; |
| 87 | return copy; |
| 88 | } |
| 89 | #endif |
| 90 | |
| 91 | } |
| 92 | |