diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
commit | 9364f22aed35e1a1e9d07c121510f80be3ab0502 (patch) | |
tree | d49911209b132da58d838efa852daf28d516df21 /WebCore/platform/graphics/win | |
parent | 87eb0cb35bad8784770ebc807e6c982432e47107 (diff) | |
download | external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.zip external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.gz external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.bz2 |
Initial Contribution
Diffstat (limited to 'WebCore/platform/graphics/win')
19 files changed, 320 insertions, 702 deletions
diff --git a/WebCore/platform/graphics/win/FontCacheWin.cpp b/WebCore/platform/graphics/win/FontCacheWin.cpp index 1ee6818..502863b 100644 --- a/WebCore/platform/graphics/win/FontCacheWin.cpp +++ b/WebCore/platform/graphics/win/FontCacheWin.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,10 +35,8 @@ #include "UnicodeRange.h" #include <windows.h> #include <mlang.h> -#if PLATFORM(CG) #include <ApplicationServices/ApplicationServices.h> #include <WebKitSystemInterface/WebKitSystemInterface.h> -#endif using std::min; @@ -47,9 +45,7 @@ namespace WebCore void FontCache::platformInit() { -#if PLATFORM(CG) wkSetUpFontCache(1536 * 1024 * 4); // This size matches Mac. -#endif } IMLangFontLink2* FontCache::getFontLinkInterface() @@ -418,14 +414,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD FontPlatformData* result = new FontPlatformData(hfont, fontDescription.computedPixelSize(), fontDescription.bold(), fontDescription.italic(), useGDI); - -#if PLATFORM(CG) - bool fontCreationFailed = !result->cgFont(); -#elif PLATFORM(CAIRO) - bool fontCreationFailed = !result->fontFace(); -#endif - - if (fontCreationFailed) { + if (!result->cgFont()) { // The creation of the CGFontRef failed for some reason. We already asserted in debug builds, but to make // absolutely sure that we don't use this font, go ahead and return 0 so that we can fall back to the next // font. diff --git a/WebCore/platform/graphics/win/FontCairoWin.cpp b/WebCore/platform/graphics/win/FontCairoWin.cpp new file mode 100644 index 0000000..302e79d --- /dev/null +++ b/WebCore/platform/graphics/win/FontCairoWin.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Font.h" + +#include "GlyphBuffer.h" +#include "GraphicsContext.h" +#include "NotImplemented.h" +#include "SimpleFontData.h" + +namespace WebCore { + +void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, + int from, int numGlyphs, const FloatPoint& point) const +{ + notImplemented(); +} + +} diff --git a/WebCore/platform/graphics/win/FontCustomPlatformData.h b/WebCore/platform/graphics/win/FontCustomPlatformData.h index 909b79e..9f30424 100644 --- a/WebCore/platform/graphics/win/FontCustomPlatformData.h +++ b/WebCore/platform/graphics/win/FontCustomPlatformData.h @@ -32,9 +32,8 @@ class SharedBuffer; struct FontCustomPlatformData : Noncopyable { FontCustomPlatformData(CGFontRef cgFont) - : m_cgFont(cgFont) - { - } + : m_cgFont(cgFont) + {} ~FontCustomPlatformData(); FontPlatformData fontPlatformData(int size, bool bold, bool italic); @@ -42,7 +41,7 @@ struct FontCustomPlatformData : Noncopyable { CGFontRef m_cgFont; }; -FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*); +FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer); } diff --git a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp b/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp deleted file mode 100644 index e54d85a..0000000 --- a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "FontCustomPlatformDataCairo.h" - -#include "SharedBuffer.h" -#include "FontPlatformData.h" -#include <wtf/RetainPtr.h> - -namespace WebCore { - -FontCustomPlatformDataCairo::~FontCustomPlatformDataCairo() -{ - cairo_font_face_destroy(m_fontFace); -} - -FontPlatformData FontCustomPlatformDataCairo::fontPlatformData(int size, bool bold, bool italic) -{ - return FontPlatformData(m_fontFace, size, bold, italic); -} - -static void releaseData(void* data) -{ - static_cast<SharedBuffer*>(data)->deref(); -} - -FontCustomPlatformDataCairo* createFontCustomPlatformData(SharedBuffer* buffer) -{ - ASSERT_ARG(buffer, buffer); - - buffer->ref(); - HFONT font = reinterpret_cast<HFONT>(buffer); - cairo_font_face_t* fontFace = cairo_win32_font_face_create_for_hfont(font); - if (!fontFace) - return 0; - - static cairo_user_data_key_t bufferKey; - cairo_font_face_set_user_data(fontFace, &bufferKey, buffer, releaseData); - - return new FontCustomPlatformDataCairo(fontFace); -} - -} diff --git a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h b/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h deleted file mode 100644 index 87794b5..0000000 --- a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2007 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef FontCustomPlatformDataCairo_h -#define FontCustomPlatformDataCairo_h - -#include <wtf/Noncopyable.h> - -#include <cairo.h> - -namespace WebCore { - -class FontPlatformData; -class SharedBuffer; - -struct FontCustomPlatformDataCairo : Noncopyable { - FontCustomPlatformDataCairo(cairo_font_face_t* fontFace) - : m_fontFace(fontFace) - { - } - ~FontCustomPlatformDataCairo(); - - FontPlatformData fontPlatformData(int size, bool bold, bool italic); - - cairo_font_face_t* m_fontFace; -}; - -FontCustomPlatformDataCairo* createFontCustomPlatformData(SharedBuffer*); - -} - -#endif diff --git a/WebCore/platform/graphics/win/FontPlatformData.h b/WebCore/platform/graphics/win/FontPlatformData.h index 5bbda2f..15d23cd 100644 --- a/WebCore/platform/graphics/win/FontPlatformData.h +++ b/WebCore/platform/graphics/win/FontPlatformData.h @@ -2,7 +2,7 @@ * This file is part of the internal font implementation. It should not be included by anyone other than * FontMac.cpp, FontWin.cpp and Font.cpp. * - * Copyright (C) 2006, 2007, 2008 Apple Inc. + * Copyright (C) 2006, 2007 Apple Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -26,12 +26,8 @@ #include "StringImpl.h" -#if PLATFORM(CAIRO) -#include <cairo-win32.h> -#endif - -typedef struct HFONT__* HFONT; -typedef struct CGFont* CGFontRef; +typedef struct HFONT__ *HFONT; +typedef struct CGFont *CGFontRef; namespace WebCore { @@ -44,53 +40,30 @@ public: // Used for deleted values in the font cache's hash tables. FontPlatformData(Deleted) - : m_font((HFONT)-1) -#if PLATFORM(CG) - , m_cgFont(0) -#elif PLATFORM(CAIRO) - , m_fontFace(0) -#endif - , m_size(0) - , m_syntheticBold(false) - , m_syntheticOblique(false) - , m_useGDI(false) - { - } + : m_font((HFONT)-1) + , m_cgFont(NULL) + , m_size(0) + , m_syntheticBold(false) + , m_syntheticOblique(false) + , m_useGDI(false) + {} FontPlatformData() - : m_font(0) -#if PLATFORM(CG) - , m_cgFont(0) -#elif PLATFORM(CAIRO) - , m_fontFace(0) -#endif - , m_size(0) - , m_syntheticBold(false) - , m_syntheticOblique(false) - , m_useGDI(false) - { - } + : m_font(0) + , m_cgFont(NULL) + , m_size(0) + , m_syntheticBold(false) + , m_syntheticOblique(false) + , m_useGDI(false) + {} FontPlatformData(HFONT, float size, bool bold, bool oblique, bool useGDI); FontPlatformData(float size, bool bold, bool oblique); - -#if PLATFORM(CG) FontPlatformData(CGFontRef, float size, bool bold, bool oblique); -#elif PLATFORM(CAIRO) - FontPlatformData(cairo_font_face_t*, float size, bool bold, bool oblique); -#endif ~FontPlatformData(); - void platformDataInit(HFONT font, float size, HDC hdc, WCHAR* faceName); - HFONT hfont() const { return m_font; } -#if PLATFORM(CG) CGFontRef cgFont() const { return m_cgFont; } -#elif PLATFORM(CAIRO) - void setFont(cairo_t* ft) const; - cairo_font_face_t* fontFace() const { return m_fontFace; } - cairo_scaled_font_t* scaledFont() const { return m_scaledFont; } -#endif float size() const { return m_size; } void setSize(float size) { m_size = size; } @@ -105,26 +78,14 @@ public: bool operator==(const FontPlatformData& other) const { - return m_font == other.m_font && -#if PLATFORM(CG) - m_cgFont == other.m_cgFont && -#elif PLATFORM(CAIRO) - m_fontFace == other.m_fontFace && - m_scaledFont == other.m_scaledFont && -#endif - m_size == other.m_size && + return m_font == other.m_font && m_cgFont ==other.m_cgFont && m_size == other.m_size && m_syntheticBold == other.m_syntheticBold && m_syntheticOblique == other.m_syntheticOblique && m_useGDI == other.m_useGDI; } private: HFONT m_font; -#if PLATFORM(CG) CGFontRef m_cgFont; -#elif PLATFORM(CAIRO) - cairo_font_face_t* m_fontFace; - cairo_scaled_font_t* m_scaledFont; -#endif float m_size; bool m_syntheticBold; diff --git a/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp b/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp deleted file mode 100644 index ddd3104..0000000 --- a/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * This file is part of the internal font implementation. It should not be included by anyone other than - * FontMac.cpp, FontWin.cpp and Font.cpp. - * - * Copyright (C) 2006, 2007, 2008 Apple Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "FontPlatformData.h" - -#include "PlatformString.h" -#include "StringHash.h" -#include <ApplicationServices/ApplicationServices.h> -#include <wtf/HashMap.h> -#include <wtf/RetainPtr.h> -#include <wtf/Vector.h> - -using std::min; - -namespace WebCore { - -static inline USHORT readBigEndianWord(const BYTE* word) { return (word[0] << 8) | word[1]; } - -static CFStringRef getPostScriptName(CFStringRef faceName, HDC dc) -{ - const DWORD cMaxNameTableSize = 1024 * 1024; - - static HashMap<String, RetainPtr<CFStringRef> > nameMap; - - // Check our hash first. - String faceString(faceName); - RetainPtr<CFStringRef> result = nameMap.get(faceString); - if (result) - return result.get(); - - // We need to obtain the PostScript name from the name table and use it instead,. - DWORD bufferSize = GetFontData(dc, 'eman', 0, NULL, 0); // "name" backwards - if (bufferSize == 0 || bufferSize == GDI_ERROR || bufferSize > cMaxNameTableSize) - return NULL; - - Vector<BYTE> bufferVector(bufferSize); - BYTE* buffer = bufferVector.data(); - if (GetFontData(dc, 'eman', 0, buffer, bufferSize) == GDI_ERROR) - return NULL; - - if (bufferSize < 6) - return NULL; - - USHORT numberOfRecords = readBigEndianWord(buffer + 2); - UINT stringsOffset = readBigEndianWord(buffer + 4); - if (bufferSize < stringsOffset) - return NULL; - - BYTE* strings = buffer + stringsOffset; - - // Now walk each name record looking for a Mac or Windows PostScript name. - UINT offset = 6; - for (int i = 0; i < numberOfRecords; i++) { - if (bufferSize < offset + 12) - return NULL; - - USHORT platformID = readBigEndianWord(buffer + offset); - USHORT encodingID = readBigEndianWord(buffer + offset + 2); - USHORT languageID = readBigEndianWord(buffer + offset + 4); - USHORT nameID = readBigEndianWord(buffer + offset + 6); - USHORT length = readBigEndianWord(buffer + offset + 8); - USHORT nameOffset = readBigEndianWord(buffer + offset + 10); - - if (platformID == 3 && encodingID == 1 && languageID == 0x409 && nameID == 6) { - // This is a Windows PostScript name and is therefore UTF-16. - // Pass Big Endian as the encoding. - if (bufferSize < stringsOffset + nameOffset + length) - return NULL; - result.adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingUTF16BE, false)); - break; - } else if (platformID == 1 && encodingID == 0 && languageID == 0 && nameID == 6) { - // This is a Mac PostScript name and is therefore ASCII. - // See http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html - if (bufferSize < stringsOffset + nameOffset + length) - return NULL; - result.adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingASCII, false)); - break; - } - - offset += 12; - } - - if (result) - nameMap.set(faceString, result); - return result.get(); -} - -void FontPlatformData::platformDataInit(HFONT font, float size, HDC hdc, WCHAR* faceName) -{ - // Try the face name first. Windows may end up localizing this name, and CG doesn't know about - // the localization. If the create fails, we'll try the PostScript name. - RetainPtr<CFStringRef> fullName(AdoptCF, CFStringCreateWithCharacters(NULL, (const UniChar*)faceName, wcslen(faceName))); - m_cgFont = CGFontCreateWithFontName(fullName.get()); - if (!m_cgFont) { - CFStringRef postScriptName = getPostScriptName(fullName.get(), hdc); - if (postScriptName) { - m_cgFont = CGFontCreateWithFontName(postScriptName); - ASSERT(m_cgFont); - } - } -} - -FontPlatformData::FontPlatformData(CGFontRef font, float size, bool bold, bool oblique) - : m_font(0) - , m_size(size) - , m_cgFont(font) - , m_syntheticBold(bold) - , m_syntheticOblique(oblique) - , m_useGDI(false) -{ -} - -} diff --git a/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp b/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp deleted file mode 100644 index 438d0a9..0000000 --- a/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This file is part of the internal font implementation. It should not be included by anyone other than - * FontMac.cpp, FontWin.cpp and Font.cpp. - * - * Copyright (C) 2006, 2007, 2008 Apple Inc. - * Copyright (C) 2007 Alp Toker - * Copyright (C) 2008 Brent Fulgham - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "FontPlatformData.h" - -#include "PlatformString.h" -#include "StringHash.h" -#include <wtf/HashMap.h> -#include <wtf/RetainPtr.h> -#include <wtf/Vector.h> - -#include <cairo-win32.h> - -using std::min; - -namespace WebCore { - -void FontPlatformData::platformDataInit(HFONT font, float size, HDC hdc, WCHAR* faceName) -{ - m_fontFace = cairo_win32_font_face_create_for_hfont(font); - cairo_matrix_t sizeMatrix, ctm; - cairo_matrix_init_identity(&ctm); - cairo_matrix_init_scale(&sizeMatrix, size, size); - - static cairo_font_options_t* fontOptions = 0; - if (!fontOptions) - { - fontOptions = cairo_font_options_create(); - cairo_font_options_set_antialias(fontOptions, CAIRO_ANTIALIAS_SUBPIXEL); - } - - m_scaledFont = cairo_scaled_font_create(m_fontFace, &sizeMatrix, &ctm, fontOptions); -} - -FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool oblique) - : m_font(0) - , m_size(size) - , m_fontFace(fontFace) - , m_scaledFont(0) - , m_syntheticBold(bold) - , m_syntheticOblique(oblique) - , m_useGDI(false) -{ - cairo_matrix_t fontMatrix; - cairo_matrix_init_scale(&fontMatrix, size, size); - cairo_matrix_t ctm; - cairo_matrix_init_identity(&ctm); - cairo_font_options_t* options = cairo_font_options_create(); - - // We force antialiasing and disable hinting to provide consistent - // typographic qualities for custom fonts on all platforms. - cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE); - cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY); - - m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options); - cairo_font_options_destroy(options); -} - -void FontPlatformData::setFont(cairo_t* cr) const -{ - ASSERT(m_scaledFont); - - cairo_set_scaled_font(cr, m_scaledFont); -} - -} diff --git a/WebCore/platform/graphics/win/FontPlatformDataWin.cpp b/WebCore/platform/graphics/win/FontPlatformDataWin.cpp index f209dbf..a5fab36 100644 --- a/WebCore/platform/graphics/win/FontPlatformDataWin.cpp +++ b/WebCore/platform/graphics/win/FontPlatformDataWin.cpp @@ -2,8 +2,7 @@ * This file is part of the internal font implementation. It should not be included by anyone other than * FontMac.cpp, FontWin.cpp and Font.cpp. * - * Copyright (C) 2006, 2007, 2008 Apple Inc. - * Copyright (C) 2008 Brent Fulgham + * Copyright (C) 2006, 2007 Apple Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -27,6 +26,7 @@ #include "PlatformString.h" #include "StringHash.h" +#include <ApplicationServices/ApplicationServices.h> #include <wtf/HashMap.h> #include <wtf/RetainPtr.h> #include <wtf/Vector.h> @@ -39,6 +39,77 @@ static const int Bold = (1 << 0); static const int Italic = (1 << 1); static const int BoldOblique = (1 << 2); +static inline USHORT readBigEndianWord(const BYTE* word) { return (word[0] << 8) | word[1]; } + +static CFStringRef getPostScriptName(CFStringRef faceName, HDC dc) +{ + const DWORD cMaxNameTableSize = 1024 * 1024; + + static HashMap<String, RetainPtr<CFStringRef> > nameMap; + + // Check our hash first. + String faceString(faceName); + RetainPtr<CFStringRef> result = nameMap.get(faceString); + if (result) + return result.get(); + + // We need to obtain the PostScript name from the name table and use it instead,. + DWORD bufferSize = GetFontData(dc, 'eman', 0, NULL, 0); // "name" backwards + if (bufferSize == 0 || bufferSize == GDI_ERROR || bufferSize > cMaxNameTableSize) + return NULL; + + Vector<BYTE> bufferVector(bufferSize); + BYTE* buffer = bufferVector.data(); + if (GetFontData(dc, 'eman', 0, buffer, bufferSize) == GDI_ERROR) + return NULL; + + if (bufferSize < 6) + return NULL; + + USHORT numberOfRecords = readBigEndianWord(buffer + 2); + UINT stringsOffset = readBigEndianWord(buffer + 4); + if (bufferSize < stringsOffset) + return NULL; + + BYTE* strings = buffer + stringsOffset; + + // Now walk each name record looking for a Mac or Windows PostScript name. + UINT offset = 6; + for (int i = 0; i < numberOfRecords; i++) { + if (bufferSize < offset + 12) + return NULL; + + USHORT platformID = readBigEndianWord(buffer + offset); + USHORT encodingID = readBigEndianWord(buffer + offset + 2); + USHORT languageID = readBigEndianWord(buffer + offset + 4); + USHORT nameID = readBigEndianWord(buffer + offset + 6); + USHORT length = readBigEndianWord(buffer + offset + 8); + USHORT nameOffset = readBigEndianWord(buffer + offset + 10); + + if (platformID == 3 && encodingID == 1 && languageID == 0x409 && nameID == 6) { + // This is a Windows PostScript name and is therefore UTF-16. + // Pass Big Endian as the encoding. + if (bufferSize < stringsOffset + nameOffset + length) + return NULL; + result.adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingUTF16BE, false)); + break; + } else if (platformID == 1 && encodingID == 0 && languageID == 0 && nameID == 6) { + // This is a Mac PostScript name and is therefore ASCII. + // See http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html + if (bufferSize < stringsOffset + nameOffset + length) + return NULL; + result.adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingASCII, false)); + break; + } + + offset += 12; + } + + if (result) + nameMap.set(faceString, result); + return result.get(); +} + static int CALLBACK enumStylesCallback(const LOGFONT* logFont, const TEXTMETRIC* metrics, DWORD fontType, LPARAM lParam) { int *style = reinterpret_cast<int*>(lParam); @@ -60,12 +131,7 @@ static int CALLBACK enumStylesCallback(const LOGFONT* logFont, const TEXTMETRIC* FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool oblique, bool useGDI) : m_font(font) , m_size(size) -#if PLATFORM(CG) , m_cgFont(0) -#elif PLATFORM(CAIRO) - , m_fontFace(0) - , m_scaledFont(0) -#endif , m_syntheticBold(false) , m_syntheticOblique(false) , m_useGDI(useGDI) @@ -113,8 +179,17 @@ FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool obliq m_syntheticOblique = true; } - platformDataInit(font, size, hdc, faceName); - + // Try the face name first. Windows may end up localizing this name, and CG doesn't know about + // the localization. If the create fails, we'll try the PostScript name. + RetainPtr<CFStringRef> fullName(AdoptCF, CFStringCreateWithCharacters(NULL, (const UniChar*)faceName, wcslen(faceName))); + m_cgFont = CGFontCreateWithFontName(fullName.get()); + if (!m_cgFont) { + CFStringRef postScriptName = getPostScriptName(fullName.get(), hdc); + if (postScriptName) { + m_cgFont = CGFontCreateWithFontName(postScriptName); + ASSERT(m_cgFont); + } + } free(metrics); } @@ -125,12 +200,17 @@ FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool obliq FontPlatformData::FontPlatformData(float size, bool bold, bool oblique) : m_font(0) , m_size(size) -#if PLATFORM(CG) , m_cgFont(0) -#elif PLATFORM(CAIRO) - , m_fontFace(0) - , m_scaledFont(0) -#endif + , m_syntheticBold(bold) + , m_syntheticOblique(oblique) + , m_useGDI(false) +{ +} + +FontPlatformData::FontPlatformData(CGFontRef font, float size, bool bold, bool oblique) + : m_font(0) + , m_size(size) + , m_cgFont(font) , m_syntheticBold(bold) , m_syntheticOblique(oblique) , m_useGDI(false) diff --git a/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp b/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp deleted file mode 100644 index b679ced..0000000 --- a/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "GlyphPageTreeNode.h" - -#include "SimpleFontData.h" - -namespace WebCore { - -bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData) -{ - // bufferLength will be greater than the requested number of glyphs if the buffer contains surrogate pairs. - // We won't support this for now. - if (bufferLength > length) - return false; - - bool haveGlyphs = false; - - HDC dc = GetDC((HWND)0); - SaveDC(dc); - SelectObject(dc, fontData->platformData().hfont()); - - TEXTMETRIC tm; - GetTextMetrics(dc, &tm); - - WORD localGlyphBuffer[GlyphPage::size * 2]; - DWORD result = GetGlyphIndices(dc, buffer, bufferLength, localGlyphBuffer, 0); - bool success = result != GDI_ERROR && static_cast<unsigned>(result) == bufferLength; - if (success) { - for (unsigned i = 0; i < length; i++) { - Glyph glyph = localGlyphBuffer[i]; - if (!glyph) - setGlyphDataForIndex(offset + i, 0, 0); - else { - setGlyphDataForIndex(offset + i, glyph, fontData); - haveGlyphs = true; - } - } - } - RestoreDC(dc, -1); - ReleaseDC(0, dc); - - return haveGlyphs; -} - -} diff --git a/WebCore/platform/graphics/win/GlyphPageTreeNodeCGWin.cpp b/WebCore/platform/graphics/win/GlyphPageTreeNodeWin.cpp index c11fc1b..23b756c 100644 --- a/WebCore/platform/graphics/win/GlyphPageTreeNodeCGWin.cpp +++ b/WebCore/platform/graphics/win/GlyphPageTreeNodeWin.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,9 +36,9 @@ namespace WebCore { bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData) { - // bufferLength will be greater than the requested number of glyphs if the buffer contains surrogate pairs. + // The bufferLength will be greater than the glyph page size if the buffer has Unicode supplementary characters. // We won't support this for now. - if (bufferLength > length) + if (bufferLength > GlyphPage::size) return false; bool haveGlyphs = false; diff --git a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp b/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp index 99d528d..58829b5 100644 --- a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp +++ b/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp @@ -168,6 +168,77 @@ void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, boo m_data->restore(); } +void GraphicsContextPlatformPrivate::save() +{ + if (!m_hdc) + return; + SaveDC(m_hdc); +} + +void GraphicsContextPlatformPrivate::restore() +{ + if (!m_hdc) + return; + RestoreDC(m_hdc, -1); +} + +void GraphicsContextPlatformPrivate::clip(const IntRect& clipRect) +{ + if (!m_hdc) + return; + IntersectClipRect(m_hdc, clipRect.x(), clipRect.y(), clipRect.right(), clipRect.bottom()); +} + +void GraphicsContextPlatformPrivate::clip(const Path&) +{ + notImplemented(); +} + +void GraphicsContextPlatformPrivate::scale(const FloatSize& size) +{ + if (!m_hdc) + return; + XFORM xform; + xform.eM11 = size.width(); + xform.eM12 = 0.0f; + xform.eM21 = 0.0f; + xform.eM22 = size.height(); + xform.eDx = 0.0f; + xform.eDy = 0.0f; + ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY); +} + +static const double deg2rad = 0.017453292519943295769; // pi/180 + +void GraphicsContextPlatformPrivate::rotate(float degreesAngle) +{ + float radiansAngle = degreesAngle * deg2rad; + float cosAngle = cosf(radiansAngle); + float sinAngle = sinf(radiansAngle); + XFORM xform; + xform.eM11 = cosAngle; + xform.eM12 = -sinAngle; + xform.eM21 = sinAngle; + xform.eM22 = cosAngle; + xform.eDx = 0.0f; + xform.eDy = 0.0f; + ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY); +} + +void GraphicsContextPlatformPrivate::translate(float x , float y) +{ + if (!m_hdc) + return; + XFORM xform; + xform.eM11 = 1.0f; + xform.eM12 = 0.0f; + xform.eM21 = 0.0f; + xform.eM22 = 1.0f; + xform.eDx = x; + xform.eDy = y; + ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY); +} + void GraphicsContextPlatformPrivate::concatCTM(const AffineTransform& transform) { if (!m_hdc) diff --git a/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp b/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp index 0e9c636..c3fbdd7 100644 --- a/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp +++ b/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp @@ -92,21 +92,21 @@ void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, boo cairo_surface_mark_dirty(surface); } -void GraphicsContextPlatformPrivate::concatCTM(const AffineTransform& transform) +void GraphicsContext::concatCTM(const AffineTransform& transform) { - cairo_surface_t* surface = cairo_get_target(cr); + cairo_surface_t* surface = cairo_get_target(platformContext()); HDC hdc = cairo_win32_surface_get_dc(surface); SaveDC(hdc); - const cairo_matrix_t* matrix = reinterpret_cast<const cairo_matrix_t*>(&transform); - + cairo_matrix_t mat; + cairo_get_matrix(platformContext(), &mat); XFORM xform; - xform.eM11 = matrix->xx; - xform.eM12 = matrix->xy; - xform.eM21 = matrix->yx; - xform.eM22 = matrix->yy; - xform.eDx = matrix->x0; - xform.eDy = matrix->y0; + xform.eM11 = mat.xx; + xform.eM12 = mat.xy; + xform.eM21 = mat.yx; + xform.eM22 = mat.yy; + xform.eDx = mat.x0; + xform.eDy = mat.y0; ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY); } diff --git a/WebCore/platform/graphics/win/GraphicsContextWin.cpp b/WebCore/platform/graphics/win/GraphicsContextWin.cpp index 373d2cf..a8f2148 100644 --- a/WebCore/platform/graphics/win/GraphicsContextWin.cpp +++ b/WebCore/platform/graphics/win/GraphicsContextWin.cpp @@ -26,12 +26,6 @@ #include "config.h" #include "GraphicsContext.h" -#if PLATFORM(CG) -#include "GraphicsContextPlatformPrivateCG.h" -#elif PLATFORM(CAIRO) -#include "GraphicsContextPlatformPrivateCairo.h" -#endif - #include "AffineTransform.h" #include "NotImplemented.h" #include "Path.h" @@ -43,77 +37,6 @@ namespace WebCore { class SVGResourceImage; -void GraphicsContextPlatformPrivate::save() -{ - if (!m_hdc) - return; - SaveDC(m_hdc); -} - -void GraphicsContextPlatformPrivate::restore() -{ - if (!m_hdc) - return; - RestoreDC(m_hdc, -1); -} - -void GraphicsContextPlatformPrivate::clip(const IntRect& clipRect) -{ - if (!m_hdc) - return; - IntersectClipRect(m_hdc, clipRect.x(), clipRect.y(), clipRect.right(), clipRect.bottom()); -} - -void GraphicsContextPlatformPrivate::clip(const Path&) -{ - notImplemented(); -} - -void GraphicsContextPlatformPrivate::scale(const FloatSize& size) -{ - if (!m_hdc) - return; - XFORM xform; - xform.eM11 = size.width(); - xform.eM12 = 0.0f; - xform.eM21 = 0.0f; - xform.eM22 = size.height(); - xform.eDx = 0.0f; - xform.eDy = 0.0f; - ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY); -} - -static const double deg2rad = 0.017453292519943295769; // pi/180 - -void GraphicsContextPlatformPrivate::rotate(float degreesAngle) -{ - float radiansAngle = degreesAngle * deg2rad; - float cosAngle = cosf(radiansAngle); - float sinAngle = sinf(radiansAngle); - XFORM xform; - xform.eM11 = cosAngle; - xform.eM12 = -sinAngle; - xform.eM21 = sinAngle; - xform.eM22 = cosAngle; - xform.eDx = 0.0f; - xform.eDy = 0.0f; - ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY); -} - -void GraphicsContextPlatformPrivate::translate(float x , float y) -{ - if (!m_hdc) - return; - XFORM xform; - xform.eM11 = 1.0f; - xform.eM12 = 0.0f; - xform.eM21 = 0.0f; - xform.eM22 = 1.0f; - xform.eDx = x; - xform.eDy = y; - ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY); -} - #if ENABLE(SVG) GraphicsContext* contextForImage(SVGResourceImage*) { diff --git a/WebCore/platform/graphics/win/IconWin.cpp b/WebCore/platform/graphics/win/IconWin.cpp index b6bc926..60cebe3 100644 --- a/WebCore/platform/graphics/win/IconWin.cpp +++ b/WebCore/platform/graphics/win/IconWin.cpp @@ -28,14 +28,12 @@ namespace WebCore { Icon::Icon() - : RefCounted<Icon>(0) - , m_hIcon(0) + : m_hIcon(0) { } Icon::Icon(HICON icon) - : RefCounted<Icon>(0) - , m_hIcon(icon) + : m_hIcon(icon) { } diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp index c7d3bf8..65b3db6 100644 --- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp +++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp @@ -28,6 +28,7 @@ #if ENABLE(VIDEO) #include "MediaPlayerPrivateQuickTimeWin.h" +#include "DeprecatedString.h" #include "GraphicsContext.h" #include "KURL.h" #include "QTMovieWin.h" diff --git a/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp b/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp index 4040ed8..0c31672 100644 --- a/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp +++ b/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp @@ -54,9 +54,32 @@ void SimpleFontData::platformInit() m_scriptCache = 0; m_scriptFontProperties = 0; m_isSystemFont = false; - - if (m_font.useGDI()) - return initGDIFont(); + + if (m_font.useGDI()) { + HDC hdc = GetDC(0); + HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont()); + OUTLINETEXTMETRIC metrics; + GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics); + TEXTMETRIC& textMetrics = metrics.otmTextMetrics; + m_ascent = textMetrics.tmAscent; + m_descent = textMetrics.tmDescent; + m_lineGap = textMetrics.tmExternalLeading; + m_lineSpacing = m_ascent + m_descent + m_lineGap; + m_xHeight = m_ascent * 0.56f; // Best guess for xHeight if no x glyph is present. + + GLYPHMETRICS gm; + MAT2 mat = { 1, 0, 0, 1 }; + DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &mat); + if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0) + m_xHeight = gm.gmptGlyphOrigin.y; + + m_unitsPerEm = metrics.otmEMSquare; + + SelectObject(hdc, oldFont); + ReleaseDC(0, hdc); + + return; + } CGFontRef font = m_font.cgFont(); int iAscent = CGFontGetAscent(font); @@ -121,13 +144,24 @@ void SimpleFontData::platformDestroy() CGFontRelease(m_font.cgFont()); } - platformCommonDestroy(); + // We don't hash this on Win32, so it's effectively owned by us. + delete m_smallCapsFontData; + + ScriptFreeCache(&m_scriptCache); + delete m_scriptFontProperties; } float SimpleFontData::platformWidthForGlyph(Glyph glyph) const { - if (m_font.useGDI()) - return widthForGDIGlyph(glyph); + if (m_font.useGDI()) { + HDC hdc = GetDC(0); + HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont()); + int width; + GetCharWidthI(hdc, glyph, 1, 0, &width); + SelectObject(hdc, oldFont); + ReleaseDC(0, hdc); + return width; + } CGFontRef font = m_font.cgFont(); float pointSize = m_font.size(); diff --git a/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp b/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp index fd017b4..e7b2c81 100644 --- a/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp +++ b/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp @@ -34,10 +34,7 @@ #include "Font.h" #include "FontCache.h" #include "FontDescription.h" -#include "MathExtras.h" #include "NotImplemented.h" -#include <cairo.h> -#include <cairo-win32.h> #include <mlang.h> #include <tchar.h> @@ -48,83 +45,58 @@ void SimpleFontData::platformInit() m_scriptCache = 0; m_scriptFontProperties = 0; m_isSystemFont = false; + + if (m_font.useGDI()) { + HDC hdc = GetDC(0); + HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont()); + OUTLINETEXTMETRIC metrics; + GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics); + TEXTMETRIC& textMetrics = metrics.otmTextMetrics; + m_ascent = textMetrics.tmAscent; + m_descent = textMetrics.tmDescent; + m_lineGap = textMetrics.tmExternalLeading; + m_lineSpacing = m_ascent + m_descent + m_lineGap; + m_xHeight = m_ascent * 0.56f; // Best guess for xHeight if no x glyph is present. - if (m_font.useGDI()) - return initGDIFont(); - - HDC hdc = GetDC(0); - SaveDC(hdc); - - cairo_scaled_font_t* scaledFont = m_font.scaledFont(); - const double metricsMultiplier = cairo_win32_scaled_font_get_metrics_factor(scaledFont) * m_font.size(); - - cairo_win32_scaled_font_select_font(scaledFont, hdc); - - TEXTMETRIC textMetrics; - GetTextMetrics(hdc, &textMetrics); - m_ascent = lroundf(textMetrics.tmAscent * metricsMultiplier); - m_descent = lroundf(textMetrics.tmDescent * metricsMultiplier); - m_xHeight = m_ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts. - m_lineGap = lroundf(textMetrics.tmExternalLeading * metricsMultiplier); - m_lineSpacing = m_ascent + m_descent + m_lineGap; - - OUTLINETEXTMETRIC metrics; - if (GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics) > 0) { - // This is a TrueType font. We might be able to get an accurate xHeight GLYPHMETRICS gm; MAT2 mat = { 1, 0, 0, 1 }; DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &mat); if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0) - m_xHeight = gm.gmptGlyphOrigin.y * metricsMultiplier; - } + m_xHeight = gm.gmptGlyphOrigin.y; - cairo_win32_scaled_font_done_font(scaledFont); + m_unitsPerEm = metrics.otmEMSquare; - m_isSystemFont = false; - m_scriptCache = 0; - m_scriptFontProperties = 0; + SelectObject(hdc, oldFont); + ReleaseDC(0, hdc); + + return; + } - RestoreDC(hdc, -1); - ReleaseDC(0, hdc); + // FIXME: This section should determine font dimensions (see CG implementation). + notImplemented(); } void SimpleFontData::platformDestroy() { - cairo_font_face_destroy(m_font.fontFace()); - cairo_scaled_font_destroy(m_font.scaledFont()); - - DeleteObject(m_font.hfont()); - - platformCommonDestroy(); + notImplemented(); } float SimpleFontData::platformWidthForGlyph(Glyph glyph) const { - if (m_font.useGDI()) - return widthForGDIGlyph(glyph); - - HDC hdc = GetDC(0); - SaveDC(hdc); - - cairo_scaled_font_t* scaledFont = m_font.scaledFont(); - cairo_win32_scaled_font_select_font(scaledFont, hdc); - - int width; - GetCharWidthI(hdc, glyph, 1, 0, &width); - - cairo_win32_scaled_font_done_font(scaledFont); + if (m_font.useGDI()) { + HDC hdc = GetDC(0); + HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont()); + int width; + GetCharWidthI(hdc, glyph, 1, 0, &width); + SelectObject(hdc, oldFont); + ReleaseDC(0, hdc); + return width; + } - RestoreDC(hdc, -1); - ReleaseDC(0, hdc); + // FIXME: Flesh out with Cairo/win32 font implementation + notImplemented(); - const double metricsMultiplier = cairo_win32_scaled_font_get_metrics_factor(scaledFont) * m_font.size(); - return width * metricsMultiplier; -} - -void SimpleFontData::setFont(cairo_t* cr) const -{ - ASSERT(cr); - m_font.setFont(cr); + return 0; } } diff --git a/WebCore/platform/graphics/win/SimpleFontDataWin.cpp b/WebCore/platform/graphics/win/SimpleFontDataWin.cpp index 6d1c417..344d964 100644 --- a/WebCore/platform/graphics/win/SimpleFontDataWin.cpp +++ b/WebCore/platform/graphics/win/SimpleFontDataWin.cpp @@ -60,42 +60,6 @@ bool SimpleFontData::shouldApplyMacAscentHack() return g_shouldApplyMacAscentHack; } -void SimpleFontData::initGDIFont() -{ - HDC hdc = GetDC(0); - HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont()); - OUTLINETEXTMETRIC metrics; - GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics); - TEXTMETRIC& textMetrics = metrics.otmTextMetrics; - m_ascent = textMetrics.tmAscent; - m_descent = textMetrics.tmDescent; - m_lineGap = textMetrics.tmExternalLeading; - m_lineSpacing = m_ascent + m_descent + m_lineGap; - m_xHeight = m_ascent * 0.56f; // Best guess for xHeight if no x glyph is present. - - GLYPHMETRICS gm; - MAT2 mat = { 1, 0, 0, 1 }; - DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &mat); - if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0) - m_xHeight = gm.gmptGlyphOrigin.y; - - m_unitsPerEm = metrics.otmEMSquare; - - SelectObject(hdc, oldFont); - ReleaseDC(0, hdc); - - return; -} - -void SimpleFontData::platformCommonDestroy() -{ - // We don't hash this on Win32, so it's effectively owned by us. - delete m_smallCapsFontData; - - ScriptFreeCache(&m_scriptCache); - delete m_scriptFontProperties; -} - SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const { if (!m_smallCapsFontData) { @@ -173,17 +137,6 @@ void SimpleFontData::determinePitch() ReleaseDC(0, dc); } -float SimpleFontData::widthForGDIGlyph(Glyph glyph) const -{ - HDC hdc = GetDC(0); - HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont()); - int width; - GetCharWidthI(hdc, glyph, 1, 0, &width); - SelectObject(hdc, oldFont); - ReleaseDC(0, hdc); - return width; -} - SCRIPT_FONTPROPERTIES* SimpleFontData::scriptFontProperties() const { if (!m_scriptFontProperties) { |