| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * This file is part of the internal font implementation. It should not be incl
uded by anyone other than | |
| 3 * FontMac.cpp, FontWin.cpp and Font.cpp. | |
| 4 * | |
| 5 * Copyright (C) 2006, 2007, 2008 Apple Inc. | |
| 6 * Copyright (C) 2008 Brent Fulgham | |
| 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 #include "config.h" | |
| 26 #include "FontPlatformData.h" | |
| 27 | |
| 28 #include "HWndDC.h" | |
| 29 #include "SharedBuffer.h" | |
| 30 #include <wtf/HashMap.h> | |
| 31 #include <wtf/RetainPtr.h> | |
| 32 #include <wtf/Vector.h> | |
| 33 #include <wtf/text/StringHash.h> | |
| 34 #include <wtf/text/WTFString.h> | |
| 35 | |
| 36 using std::min; | |
| 37 | |
| 38 namespace WebCore { | |
| 39 | |
| 40 FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool obliq
ue, bool useGDI) | |
| 41 : m_font(RefCountedGDIHandle<HFONT>::create(font)) | |
| 42 , m_size(size) | |
| 43 , m_orientation(Horizontal) | |
| 44 , m_widthVariant(RegularWidth) | |
| 45 , m_isColorBitmapFont(false) | |
| 46 , m_syntheticBold(bold) | |
| 47 , m_syntheticOblique(oblique) | |
| 48 , m_useGDI(useGDI) | |
| 49 { | |
| 50 HWndDC hdc(0); | |
| 51 SaveDC(hdc); | |
| 52 | |
| 53 SelectObject(hdc, font); | |
| 54 UINT bufferSize = GetOutlineTextMetrics(hdc, 0, NULL); | |
| 55 | |
| 56 ASSERT_WITH_MESSAGE(bufferSize, "Bitmap fonts not supported with CoreGraphic
s."); | |
| 57 | |
| 58 if (bufferSize) { | |
| 59 OUTLINETEXTMETRICW* metrics = (OUTLINETEXTMETRICW*)malloc(bufferSize); | |
| 60 | |
| 61 GetOutlineTextMetricsW(hdc, bufferSize, metrics); | |
| 62 WCHAR* faceName = (WCHAR*)((uintptr_t)metrics + (uintptr_t)metrics->otmp
FaceName); | |
| 63 | |
| 64 platformDataInit(font, size, hdc, faceName); | |
| 65 | |
| 66 free(metrics); | |
| 67 } | |
| 68 | |
| 69 RestoreDC(hdc, -1); | |
| 70 } | |
| 71 | |
| 72 PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const | |
| 73 { | |
| 74 HWndDC hdc(0); | |
| 75 HGDIOBJ oldFont = SelectObject(hdc, hfont()); | |
| 76 | |
| 77 DWORD size = GetFontData(hdc, table, 0, 0, 0); | |
| 78 RefPtr<SharedBuffer> buffer; | |
| 79 if (size != GDI_ERROR) { | |
| 80 buffer = SharedBuffer::create(size); | |
| 81 DWORD result = GetFontData(hdc, table, 0, (PVOID)buffer->data(), size); | |
| 82 ASSERT(result == size); | |
| 83 } | |
| 84 | |
| 85 SelectObject(hdc, oldFont); | |
| 86 return buffer.release(); | |
| 87 } | |
| 88 | |
| 89 #ifndef NDEBUG | |
| 90 String FontPlatformData::description() const | |
| 91 { | |
| 92 return String(); | |
| 93 } | |
| 94 #endif | |
| 95 | |
| 96 } | |
| OLD | NEW |