Switch on Cairo-based text rendering on win32.
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 21 May 2006 06:58:12 +0000 (06:58 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 21 May 2006 06:58:12 +0000 (06:58 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14507 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
WebCore/ChangeLog
WebCore/WebCore.vcproj/WebCore/WebCore.vcproj
WebCore/config.h
WebCore/platform/Font.cpp
WebCore/platform/Font.h
WebCore/platform/FontCache.cpp
WebCore/platform/FontData.cpp
WebCore/platform/FontData.h
WebCore/platform/GlyphBuffer.h
WebCore/platform/GlyphMap.cpp
WebCore/platform/cairo/cairo/src/cairo-win32-font.c
WebCore/platform/cairo/font-bug-patch.txt [new file with mode: 0644]
WebCore/platform/mac/FontDataMac.mm
WebCore/platform/mac/FontPlatformData.h [moved from WebCore/platform/FontPlatformData.h with 66% similarity]
WebCore/platform/win/FontDataWin.cpp [new file with mode: 0755]
WebCore/platform/win/FontPlatformDataWin.cpp
WebCore/platform/win/FontWin.cpp

index 24a3d432c1eb8316fbd7badfbc012df32d581e7f..cf1c9e157969a06bce0e7ab76f59f0844c3950ba 100644 (file)
@@ -1,3 +1,64 @@
+2006-05-20  Dave Hyatt <hyatt@apple.com>
+
+        Switch on Cairo-based text rendering on Win32.  This is tracked
+        by bug 9019.
+
+        Reviewed by maciej
+
+        * WebCore.vcproj/WebCore/WebCore.vcproj:
+        * config.h:
+        * platform/Font.cpp:
+        (WebCore::WidthIterator::advance):
+        (WebCore::WidthIterator::normalizeVoicingMarks):
+        (WebCore::Font::width):
+        * platform/Font.h:
+        (WebCore::Font::isRoundingHackCharacter):
+        * platform/FontCache.cpp:
+        (WebCore::computeHash):
+        (WebCore::FontPlatformDataCacheKeyTraits::deletedValue):
+        (WebCore::FontPlatformDataCacheKeyTraits::emptyValue):
+        (WebCore::FontDataCacheKeyTraits::deletedValue):
+        (WebCore::FontDataCacheKeyTraits::emptyValue):
+        * platform/FontData.cpp:
+        (WebCore::m_smallCapsFontData):
+        (WebCore::FontData::widthForGlyph):
+        * platform/FontData.h:
+        * platform/FontPlatformData.h: Removed.
+        * platform/GlyphBuffer.h:
+        (WebCore::GlyphBuffer::clear):
+        (WebCore::GlyphBuffer::glyphs):
+        (WebCore::GlyphBuffer::advances):
+        (WebCore::GlyphBuffer::swap):
+        (WebCore::GlyphBuffer::glyphAt):
+        (WebCore::GlyphBuffer::advanceAt):
+        (WebCore::GlyphBuffer::add):
+        * platform/GlyphMap.cpp:
+        (WebCore::GlyphMap::locatePage):
+        * platform/cairo/cairo/src/cairo-win32-font.c:
+        (cairo_win32_scaled_font_select_font):
+        * platform/cairo/font-bug-patch.txt: Added.
+        * platform/mac/FontDataMac.mm:
+        (-[NSFont WebCore]):
+        * platform/mac/FontPlatformData.h: Added.
+        (WebCore::FontPlatformData::FontPlatformData):
+        * platform/win/FontDataWin.cpp: Added.
+        (WebCore::FontData::platformInit):
+        (WebCore::FontData::platformDestroy):
+        (WebCore::FontData::smallCapsFontData):
+        (WebCore::FontData::containsCharacters):
+        (WebCore::FontData::determinePitch):
+        (WebCore::FontData::platformWidthForGlyph):
+        * platform/win/FontPlatformDataWin.cpp:
+        (WebCore::m_size):
+        (WebCore::FontPlatformData::~FontPlatformData):
+        * platform/win/FontWin.cpp:
+        (WebCore::notImplemented):
+        (WebCore::Font::drawGlyphs):
+        (WebCore::Font::selectionRectForComplexText):
+        (WebCore::Font::drawComplexText):
+        (WebCore::Font::floatWidthForComplexText):
+        (WebCore::Font::offsetForPositionForComplexText):
+
 2006-05-20  Alexey Proskuryakov  <ap@nypop.com>
 
         Reviewed by Darin.
index d390804c0dcd7690885c61ae5811750e01ab56c1..2c61b9c9e63fe0d41d65f0a8e17d205ca599a559 100644 (file)
@@ -41,7 +41,7 @@
                        <Tool\r
                                Name="VCCLCompilerTool"\r
                                Optimization="0"\r
-                               AdditionalIncludeDirectories="&quot;$(ProjectDir)\..\..\..\iconv\include&quot;;&quot;$(ProjectDir)\..\..\..\icu\include&quot;;&quot;$(ProjectDir)\..\..\..\libxml\include&quot;;&quot;$(ProjectDir)\..\..\..\libxslt\include&quot;;&quot;$(ProjectDir)\..\..\DerivedSources\WebCore&quot;;&quot;$(ProjectDir)\..\..\&quot;;&quot;$(ProjectDir)\..\..\css&quot;;&quot;$(ProjectDir)\..\..\khtml\dom&quot;;&quot;$(ProjectDir)\..\..\editing&quot;;&quot;$(ProjectDir)\..\..\khtml\misc&quot;;&quot;$(ProjectDir)\..\..\rendering&quot;;&quot;$(ProjectDir)\..\..\bindings\js&quot;;&quot;$(ProjectDir)\..\..\dom&quot;;&quot;$(ProjectDir)\..\..\html&quot;;&quot;$(ProjectDir)\..\..\khtml&quot;;&quot;$(ProjectDir)\..\..\kwq&quot;;&quot;$(ProjectDir)\..\..\bridge&quot;;&quot;$(ProjectDir)\..\..\bridge\win&quot;;&quot;$(ProjectDir)\..\..\loader&quot;;&quot;$(ProjectDir)\..\..\page&quot;;&quot;$(ProjectDir)\..\..\platform&quot;;&quot;$(ProjectDir)\..\..\platform\cairo&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\gif&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\jpeg&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\png&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\zlib&quot;;&quot;$(ProjectDir)\..\..\xml&quot;;&quot;$(ProjectDir)\..\..\xpath&quot;;&quot;$(ProjectDir)\..\..\xpath\impl&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore\os-win32&quot;;&quot;$(ProjectDir)\..\..\ForwardingHeaders&quot;;&quot;$(WebKitOutputDir)\WebCore.intermediate\$(ConfigurationName)\WebCore.intermediate\DerivedSources&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore\kjs&quot;;&quot;$(ProjectDir)\..\..\platform\cairo\pixman\src&quot;;&quot;$(ProjectDir)\..\..\platform\cairo\cairo\src&quot;"\r
+                               AdditionalIncludeDirectories="&quot;$(ProjectDir)\..\..\..\iconv\include&quot;;&quot;$(ProjectDir)\..\..\..\icu\include&quot;;&quot;$(ProjectDir)\..\..\..\libxml\include&quot;;&quot;$(ProjectDir)\..\..\..\libxslt\include&quot;;&quot;$(ProjectDir)\..\..\DerivedSources\WebCore&quot;;&quot;$(ProjectDir)\..\..\&quot;;&quot;$(ProjectDir)\..\..\css&quot;;&quot;$(ProjectDir)\..\..\khtml\dom&quot;;&quot;$(ProjectDir)\..\..\editing&quot;;&quot;$(ProjectDir)\..\..\khtml\misc&quot;;&quot;$(ProjectDir)\..\..\rendering&quot;;&quot;$(ProjectDir)\..\..\bindings\js&quot;;&quot;$(ProjectDir)\..\..\dom&quot;;&quot;$(ProjectDir)\..\..\html&quot;;&quot;$(ProjectDir)\..\..\khtml&quot;;&quot;$(ProjectDir)\..\..\kwq&quot;;&quot;$(ProjectDir)\..\..\bridge&quot;;&quot;$(ProjectDir)\..\..\bridge\win&quot;;&quot;$(ProjectDir)\..\..\loader&quot;;&quot;$(ProjectDir)\..\..\page&quot;;&quot;$(ProjectDir)\..\..\platform&quot;;&quot;$(ProjectDir)\..\..\platform\cairo&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\gif&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\jpeg&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\png&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\zlib&quot;;&quot;$(ProjectDir)\..\..\xml&quot;;&quot;$(ProjectDir)\..\..\xpath&quot;;&quot;$(ProjectDir)\..\..\xpath\impl&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore\os-win32&quot;;&quot;$(ProjectDir)\..\..\ForwardingHeaders&quot;;&quot;$(WebKitOutputDir)\WebCore.intermediate\$(ConfigurationName)\WebCore.intermediate\DerivedSources&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore\kjs&quot;;&quot;$(ProjectDir)\..\..\platform\win&quot;;&quot;$(ProjectDir)\..\..\platform\cairo\pixman\src&quot;;&quot;$(ProjectDir)\..\..\platform\cairo\cairo\src&quot;"\r
                                PreprocessorDefinitions="WIN32; KHTML_NO_XBL; KHTML_XSLT; XPATH_SUPPORT"\r
                                MinimalRebuild="true"\r
                                ExceptionHandling="0"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               AdditionalIncludeDirectories="&quot;$(ProjectDir)\..\..\..\iconv\include&quot;;&quot;$(ProjectDir)\..\..\..\icu\include&quot;;&quot;$(ProjectDir)\..\..\..\libxml\include&quot;;&quot;$(ProjectDir)\..\..\..\libxslt\include&quot;;&quot;$(ProjectDir)\..\..\DerivedSources\WebCore&quot;;&quot;$(ProjectDir)\..\..\&quot;;&quot;$(ProjectDir)\..\..\css&quot;;&quot;$(ProjectDir)\..\..\khtml\dom&quot;;&quot;$(ProjectDir)\..\..\editing&quot;;&quot;$(ProjectDir)\..\..\khtml\misc&quot;;&quot;$(ProjectDir)\..\..\rendering&quot;;&quot;$(ProjectDir)\..\..\bindings\js&quot;;&quot;$(ProjectDir)\..\..\dom&quot;;&quot;$(ProjectDir)\..\..\html&quot;;&quot;$(ProjectDir)\..\..\khtml&quot;;&quot;$(ProjectDir)\..\..\kwq&quot;;&quot;$(ProjectDir)\..\..\bridge&quot;;&quot;$(ProjectDir)\..\..\bridge\win&quot;;&quot;$(ProjectDir)\..\..\loader&quot;;&quot;$(ProjectDir)\..\..\page&quot;;&quot;$(ProjectDir)\..\..\platform&quot;;&quot;$(ProjectDir)\..\..\platform\cairo&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\gif&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\jpeg&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\png&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\zlib&quot;;&quot;$(ProjectDir)\..\..\xml&quot;;&quot;$(ProjectDir)\..\..\xpath&quot;;&quot;$(ProjectDir)\..\..\xpath\impl&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore\os-win32&quot;;&quot;$(ProjectDir)\..\..\ForwardingHeaders&quot;;&quot;$(WebKitOutputDir)\WebCore.intermediate\$(ConfigurationName)\WebCore.intermediate\DerivedSources&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore\kjs&quot;;&quot;$(ProjectDir)\..\..\platform\cairo\pixman\src&quot;;&quot;$(ProjectDir)\..\..\platform\cairo\cairo\src&quot;"\r
+                               AdditionalIncludeDirectories="&quot;$(ProjectDir)\..\..\..\iconv\include&quot;;&quot;$(ProjectDir)\..\..\..\icu\include&quot;;&quot;$(ProjectDir)\..\..\..\libxml\include&quot;;&quot;$(ProjectDir)\..\..\..\libxslt\include&quot;;&quot;$(ProjectDir)\..\..\DerivedSources\WebCore&quot;;&quot;$(ProjectDir)\..\..\&quot;;&quot;$(ProjectDir)\..\..\css&quot;;&quot;$(ProjectDir)\..\..\khtml\dom&quot;;&quot;$(ProjectDir)\..\..\editing&quot;;&quot;$(ProjectDir)\..\..\khtml\misc&quot;;&quot;$(ProjectDir)\..\..\rendering&quot;;&quot;$(ProjectDir)\..\..\bindings\js&quot;;&quot;$(ProjectDir)\..\..\dom&quot;;&quot;$(ProjectDir)\..\..\html&quot;;&quot;$(ProjectDir)\..\..\khtml&quot;;&quot;$(ProjectDir)\..\..\kwq&quot;;&quot;$(ProjectDir)\..\..\bridge&quot;;&quot;$(ProjectDir)\..\..\bridge\win&quot;;&quot;$(ProjectDir)\..\..\loader&quot;;&quot;$(ProjectDir)\..\..\page&quot;;&quot;$(ProjectDir)\..\..\platform&quot;;&quot;$(ProjectDir)\..\..\platform\cairo&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\gif&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\jpeg&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\png&quot;;&quot;$(ProjectDir)\..\..\platform\image-decoders\zlib&quot;;&quot;$(ProjectDir)\..\..\xml&quot;;&quot;$(ProjectDir)\..\..\xpath&quot;;&quot;$(ProjectDir)\..\..\xpath\impl&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore\os-win32&quot;;&quot;$(ProjectDir)\..\..\ForwardingHeaders&quot;;&quot;$(WebKitOutputDir)\WebCore.intermediate\$(ConfigurationName)\WebCore.intermediate\DerivedSources&quot;;&quot;$(ProjectDir)\..\..\..\JavaScriptCore\kjs&quot;;&quot;$(ProjectDir)\..\..\platform\win&quot;;&quot;$(ProjectDir)\..\..\platform\cairo\pixman\src&quot;;&quot;$(ProjectDir)\..\..\platform\cairo\cairo\src&quot;"\r
                                PreprocessorDefinitions="WIN32; KHTML_NO_XBL; KHTML_XSLT; XPATH_SUPPORT; NDEBUG"\r
                                ExceptionHandling="0"\r
                                RuntimeLibrary="2"\r
                                RelativePath="..\..\platform\Font.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\platform\FontCache.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\platform\FontCache.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\platform\FontData.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\platform\FontData.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\platform\FontDescription.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\platform\FontFallbackList.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\platform\FontFallbackList.h"\r
                                >\r
                                RelativePath="..\..\platform\FontFamily.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\platform\GlyphBuffer.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\platform\GlyphMap.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\platform\GlyphMap.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\platform\GlyphWidthMap.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\platform\GlyphWidthMap.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\platform\GraphicsContext.cpp"\r
                                >\r
                                        RelativePath="..\..\platform\win\CursorWin.cpp"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath="..\..\platform\win\FontCacheWin.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\platform\win\FontDataWin.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath="..\..\platform\win\FontPlatformData.h"\r
+                                       >\r
+                               </File>\r
                                <File\r
                                        RelativePath="..\..\platform\win\FontPlatformDataWin.cpp"\r
                                        >\r
                                        RelativePath="..\..\platform\win\FontWin.cpp"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath="..\..\platform\win\GlyphMapWin.cpp"\r
+                                       >\r
+                               </File>\r
                                <File\r
                                        RelativePath="..\..\platform\win\IntPointWin.cpp"\r
                                        >\r
index f44eb1b56f2db67cb9c0375ba215b61131b21b30..7d0b609ee036a207ff30dfd16c6ec65dde99254a 100644 (file)
@@ -39,6 +39,9 @@ typedef float CGFloat;
 
 #if WIN32
 
+#define WINVER 0x0500
+#define _WIN32_WINNT 0x0500
+
 // Hack to match configuration of JavaScriptCore.
 // Maybe there's a better way to do this.
 #define USE_SYSTEM_MALLOC 1
index 762dde2f6bbac6bcc52837f492274e58cb8573eb..1731317f6abd2037d1d29a8fdd6412bbb1ca6b43 100644 (file)
 #include <unicode/umachine.h>
 #include <unicode/unorm.h>
 
-namespace WebCore {
-
-#if __APPLE__
+#include <wtf/MathExtras.h>
 
-// FIXME: Cross-platform eventually, but for now we compile only on OS X.
+namespace WebCore {
 
 // According to http://www.unicode.org/Public/UNIDATA/UCD.html#Canonical_Combining_Class_Values
 #define HIRAGANA_KATAKANA_VOICING_MARKS 8
@@ -133,7 +131,7 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
     float lastRoundingWidth = m_finalRoundingWidth;
     
     const FontData* primaryFont = m_font->primaryFont();
-    
+
     while (currentCharacter < offset) {
         UChar32 c = *cp;
         unsigned clusterLength = 1;
@@ -156,7 +154,7 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
                 // Make sure we have another character and it's a low surrogate.
                 if (currentCharacter + 1 >= m_run.length())
                     break;
-                UniChar low = cp[1];
+                UChar low = cp[1];
                 if (!U16_IS_TRAIL(low))
                     break;
                 c = U16_GET_SUPPLEMENTARY(c, low);
@@ -208,7 +206,7 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
         if (c == '\t' && m_style.tabWidth())
             width = m_style.tabWidth() - fmodf(m_style.xPos() + runWidthSoFar, m_style.tabWidth());
         else {
-            width = fontData->widthForGlyph(glyph);
+            width = fontData->widthForGlyph(glyph, c);
             // We special case spaces in two ways when applying word rounding.
             // First, we round spaces to an adjusted width in all fonts.
             // Second, in fixed-pitch fonts we ensure that all characters that
@@ -307,7 +305,6 @@ UChar32 WidthIterator::normalizeVoicingMarks()
     }
     return 0;
 }
-#endif
 
 // ============================================================================================
 // Font Implementation (Cross-Platform Portion)
@@ -376,12 +373,7 @@ void Font::update() const
 
 int Font::width(const TextRun& run, const TextStyle& style) const
 {
-    // FIXME: Want to define an lroundf for win32.
-#if __APPLE__
     return lroundf(floatWidth(run, style));
-#else
-    return floatWidth(run, style) + 0.5f;
-#endif
 }
 
 int Font::ascent() const
@@ -410,7 +402,6 @@ bool Font::isFixedPitch() const
     return m_fontList->isFixedPitch(this);
 }
 
-#if __APPLE__
 // FIXME: These methods will eventually be cross-platform, but to keep Windows compiling we'll make this Apple-only for now.
 bool Font::gAlwaysUseComplexPath = false;
 void Font::setAlwaysUseComplexPath(bool alwaysUse)
@@ -626,6 +617,4 @@ int Font::offsetForPositionForSimpleText(const TextRun& run, const TextStyle& st
     return offset - run.from();
 }
 
-#endif
-
 }
index dd11c97a79b1a490e913a7fd994d1047b6db6b6b..ec8d34176cb53fcdd3d8a100fdfc97a8f5ddcfa1 100644 (file)
@@ -180,7 +180,6 @@ public:
     const FontData* fontDataForCharacters(const UChar*, int length) const;
 
 private:
-#if __APPLE__
     // FIXME: This will eventually be cross-platform, but we want to keep Windows compiling for now.
     bool canUseGlyphCache(const TextRun&) const;
     void drawSimpleText(GraphicsContext*, const TextRun&, const TextStyle&, const FloatPoint&) const;
@@ -207,7 +206,6 @@ public:
     {
         return (((c & ~0xFF) == 0 && gRoundingHackCharacterTable[c])); 
     }
-#endif
 
 private:
     FontDescription m_fontDescription;
index f321c0b3525c42f8f7c75025560da66d62062cb4..6b82618a0a6e9b590b321c8fa9e7af5492042e1f 100644 (file)
@@ -56,7 +56,11 @@ struct FontPlatformDataCacheKey
 
 inline unsigned computeHash(const FontPlatformDataCacheKey& fontKey)
 {
-    unsigned hashCodes[3] = { CaseInsensitiveHash::hash(fontKey.m_family.impl()), fontKey.m_size, fontKey.m_bold << 1 | fontKey.m_italic };
+    unsigned hashCodes[3] = {
+        CaseInsensitiveHash::hash(fontKey.m_family.impl()),
+        fontKey.m_size,
+        static_cast<unsigned>(fontKey.m_bold) << 1 | static_cast<unsigned>(fontKey.m_italic)
+    };
     return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), 3 * sizeof(unsigned) / sizeof(UChar));
 }
 
@@ -77,7 +81,12 @@ struct FontPlatformDataCacheKeyTraits : WTF::GenericHashTraits<FontPlatformDataC
     static const bool needsDestruction = false;
     static const FontPlatformDataCacheKey& deletedValue()
     {
-        static FontPlatformDataCacheKey key(nullAtom, 0, -1, -1);
+        static FontPlatformDataCacheKey key(nullAtom, 0xFFFFFFFFU, false, false);
+        return key;
+    }
+    static const FontPlatformDataCacheKey& emptyValue()
+    {
+        static FontPlatformDataCacheKey key(nullAtom, 0, false, false);
         return key;
     }
 };
@@ -122,7 +131,12 @@ struct FontDataCacheKeyTraits : WTF::GenericHashTraits<FontPlatformData> {
     static const bool needsDestruction = false;
     static const FontPlatformData& deletedValue()
     {
-        static FontPlatformData key(0, -1, -1);
+        static FontPlatformData key = FontPlatformData::Deleted();
+        return key;
+    }
+    static const FontPlatformData& emptyValue()
+    {
+        static FontPlatformData key;
         return key;
     }
 };
index c4c8ea2fa924a0520fc6028b10ffbad0b15a5342..99cded5c74d3a55be3db987b0639a0bb67b20a46 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import "config.h"
-#import "Font.h"
+#include "config.h"
+#include "Font.h"
+
+#include <wtf/MathExtras.h>
 
 namespace WebCore
 {
@@ -44,7 +46,7 @@ FontData::FontData(const FontPlatformData& f)
     // If the font is monospace or fake monospace we ceil to ensure that 
     // every character and the space are the same width.  Otherwise we round.
     m_spaceGlyph = m_characterToGlyphMap.glyphDataForCharacter(' ', this).glyph;
-    float width = widthForGlyph(m_spaceGlyph);
+    float width = widthForGlyph(m_spaceGlyph, ' ');
     m_spaceWidth = width;
     determinePitch();
     m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width);
@@ -58,13 +60,13 @@ FontData::~FontData()
     // it will be deleted then, so we don't need to do anything here.
 }
 
-float FontData::widthForGlyph(Glyph glyph) const
+float FontData::widthForGlyph(Glyph glyph, UChar c) const
 {
     float width = m_glyphToWidthMap.widthForGlyph(glyph);
     if (width != cGlyphWidthUnknown)
         return width;
     
-    width = platformWidthForGlyph(glyph);
+    width = platformWidthForGlyph(glyph, c);
     m_glyphToWidthMap.setWidthForGlyph(glyph, width);
     
     return width;
index 7383babc3b47a52181fb3c196388e9092bde24bd..fffdc006e52c11b0d73a252b880c01f4cd304eb1 100644 (file)
@@ -24,9 +24,6 @@
 #ifndef FONTDATA_H
 #define FONTDATA_H
 
-#if __APPLE__
-// FIXME: This is going to be cross-platform eventually, but for now we just compile on OS X.
-
 #include "FontPlatformData.h"
 #include "GlyphMap.h"
 #include "GlyphWidthMap.h"
@@ -61,8 +58,8 @@ public:
     int lineGap() const { return m_lineGap; }
     float xHeight() const { return m_xHeight; }
 
-    float widthForGlyph(Glyph glyph) const;
-    float platformWidthForGlyph(Glyph glyph) const;
+    float widthForGlyph(Glyph glyph, UChar c) const;
+    float platformWidthForGlyph(Glyph glyph, UChar c) const;
 
     bool containsCharacters(const UChar* characters, int length) const;
 
@@ -87,69 +84,28 @@ public:
     int m_lineSpacing;
     int m_lineGap;
     float m_xHeight;
-
-    void* m_styleGroup;
     
     FontPlatformData m_font;
     mutable GlyphMap m_characterToGlyphMap;
     mutable GlyphWidthMap m_glyphToWidthMap;
 
     bool m_treatAsFixedPitch;
-    ATSGlyphRef m_spaceGlyph;
+    Glyph m_spaceGlyph;
     float m_spaceWidth;
     float m_adjustedSpaceWidth;
-    float m_syntheticBoldOffset;
-    
+
     mutable FontData* m_smallCapsFontData;
+
+#if __APPLE__
+    void* m_styleGroup;
+    float m_syntheticBoldOffset;
     mutable ATSUStyle m_ATSUStyle;
     mutable bool m_ATSUStyleInitialized;
     mutable bool m_ATSUMirrors;
-};
-
-}
-
-#else
-
-#include "FontPlatformData.h"
-
-namespace WebCore {
-
-class FontDescription;
-
-enum Pitch { UnknownPitch, FixedPitch, VariablePitch };
-
-class FontData
-{
-public:
-#if WIN32
-    FontData(HFONT font, const FontDescription& fontDescription)
-        :m_platformData(font, fontDescription) {}
 #endif
 
-    const FontPlatformData& platformData() const { return m_platformData; }
-
-    void setMetrics(int ascent, int descent, int xHeight, int lineSpacing)
-    {
-        m_ascent = ascent;
-        m_descent = descent;
-        m_xHeight = xHeight;
-        m_lineSpacing = lineSpacing;
-    }
-
-    int ascent() const { return m_ascent; }
-    int descent() const { return m_descent; }
-    int xHeight() const { return m_xHeight; }
-    int lineSpacing() const { return m_lineSpacing; }
-
-private:
-    FontPlatformData m_platformData;
-    int m_ascent;
-    int m_descent;
-    int m_xHeight;
-    int m_lineSpacing;
 };
 
 }
-#endif
 
 #endif
index da7d29814542672912f0c466bad9861827cdeec3..7554832058b4b86e5cbc1655f6e76c85d30a5255 100644 (file)
@@ -36,6 +36,9 @@
 
 #if __APPLE__
 #include <ApplicationServices/ApplicationServices.h>
+#elif PLATFORM(WIN)
+#include <cairo.h>
+#include "FloatSize.h"
 #endif
 
 #include <wtf/Vector.h>
@@ -45,6 +48,14 @@ namespace WebCore
 typedef unsigned short Glyph;
 class FontData;
 
+#if __APPLE__
+typedef Glyph GlyphBufferGlyph;
+typedef CGSize GlyphBufferAdvance;
+#elif PLATFORM(WIN)
+typedef cairo_glyph_t GlyphBufferGlyph;
+typedef FloatSize GlyphBufferAdvance;
+#endif
+
 class GlyphBuffer
 {
 public:
@@ -56,16 +67,12 @@ public:
     void clear()
     {
         m_fontData.clear();
-#if __APPLE__
         m_glyphs.clear();
         m_advances.clear();
-#endif
     }
 
-#if __APPLE__
-    Glyph* glyphs(int from) const { return ((Glyph*)m_glyphs.data()) + from; }
-    CGSize* advances(int from) const { return ((CGSize*)m_advances.data()) + from; }
-#endif
+    GlyphBufferGlyph* glyphs(int from) const { return ((GlyphBufferGlyph*)m_glyphs.data()) + from; }
+    GlyphBufferAdvance* advances(int from) const { return ((GlyphBufferAdvance*)m_advances.data()) + from; }
 
     const FontData* fontDataAt(int index) const { return m_fontData[index]; }
     
@@ -75,23 +82,21 @@ public:
         m_fontData[index1] = m_fontData[index2];
         m_fontData[index2] = f;
 
-#if __APPLE__
-        Glyph g = m_glyphs[index1];
+        GlyphBufferGlyph g = m_glyphs[index1];
         m_glyphs[index1] = m_glyphs[index2];
         m_glyphs[index2] = g;
 
-        CGSize s = m_advances[index1];
+        GlyphBufferAdvance s = m_advances[index1];
         m_advances[index1] = m_advances[index2];
         m_advances[index2] = s;
-#endif
     }
 
     Glyph glyphAt(int index) const
     {
 #if __APPLE__
         return m_glyphs[index];
-#else
-        return 0;
+#elif PLATFORM(WIN)
+        return m_glyphs[index].index;
 #endif
     }
 
@@ -99,8 +104,8 @@ public:
     {
 #if __APPLE__
         return m_advances[index].width;
-#else
-        return 0;
+#elif PLATFORM(WIN)
+        return m_advances[index].width();
 #endif
     }
 
@@ -113,19 +118,20 @@ public:
         advance.width = width;
         advance.height = 0;
         m_advances.append(advance);
+#elif PLATFORM(WIN)
+        cairo_glyph_t cairoGlyph;
+        cairoGlyph.index = glyph;
+        cairoGlyph.x = (m_glyphs.size() ? m_glyphs[m_glyphs.size() - 1].x + m_advances[m_glyphs.size() - 1].width() : 0);
+        cairoGlyph.y = 0;
+        m_glyphs.append(cairoGlyph);
+        m_advances.append(FloatSize(width, 0));
 #endif
     }
     
 private:
     Vector<const FontData*, GLYPH_BUFFER_SIZE> m_fontData;
-#if __APPLE__
-    // Store the advances as CGSizes separately from the glyph indices.
-    Vector<Glyph, GLYPH_BUFFER_SIZE> m_glyphs;
-    Vector<CGSize, GLYPH_BUFFER_SIZE> m_advances;
-#else
-    // We will store cairo_glyphs, and they incorporate the glyph index as well as
-    // the advances.
-#endif
+    Vector<GlyphBufferGlyph, GLYPH_BUFFER_SIZE> m_glyphs;
+    Vector<GlyphBufferAdvance, GLYPH_BUFFER_SIZE> m_advances;
 };
 
 }
index 50b546117084a1f7f4c39b76419595bae9c1f8df..8128d3a4c6f12673b87f16049ad2b4a09ff1a1b5 100644 (file)
@@ -73,7 +73,7 @@ inline GlyphMap::GlyphPage* GlyphMap::locatePage(unsigned pageNumber, const Font
     }
       
     unsigned start = pageNumber * cGlyphPageSize;
-    unsigned short buffer[cGlyphPageSize * 2 + 2];
+    UChar buffer[cGlyphPageSize * 2 + 2];
     unsigned bufferLength;
     unsigned i;
 
index 89c95e944ef11ed00e2c544607f1d5076462b9f4..f7629eb1cc7f137e89252873bb9b0fcaa17a89fe 100644 (file)
@@ -1503,8 +1503,10 @@ cairo_win32_scaled_font_select_font (cairo_scaled_font_t *scaled_font,
        return CAIRO_STATUS_NO_MEMORY;
 
     old_hfont = SelectObject (hdc, hfont);
-    if (!old_hfont)
-       return _cairo_win32_print_gdi_error ("cairo_win32_scaled_font_select_font:SelectObject");
+    // FIXME: This error is occurring and killing all subsequent text drawing.
+    // Probably my fault, but comment it out until we're certain.
+    //if (!old_hfont)
+    // return _cairo_win32_print_gdi_error ("cairo_win32_scaled_font_select_font:SelectObject");
 
     old_mode = SetGraphicsMode (hdc, GM_ADVANCED);
     if (!old_mode) {
diff --git a/WebCore/platform/cairo/font-bug-patch.txt b/WebCore/platform/cairo/font-bug-patch.txt
new file mode 100644 (file)
index 0000000..9e803ac
--- /dev/null
@@ -0,0 +1,17 @@
+Index: cairo/src/cairo-win32-font.c
+===================================================================
+--- cairo/src/cairo-win32-font.c       (revision 14498)
++++ cairo/src/cairo-win32-font.c       (working copy)
+@@ -1503,8 +1503,10 @@
+       return CAIRO_STATUS_NO_MEMORY;
+     old_hfont = SelectObject (hdc, hfont);
+-    if (!old_hfont)
+-      return _cairo_win32_print_gdi_error ("cairo_win32_scaled_font_select_font:SelectObject");
++    // FIXME: This error is occurring and killing all subsequent text drawing.
++    // Probably my fault, but comment it out until we're certain.
++    //if (!old_hfont)
++    //        return _cairo_win32_print_gdi_error ("cairo_win32_scaled_font_select_font:SelectObject");
+     old_mode = SetGraphicsMode (hdc, GM_ADVANCED);
+     if (!old_mode) {
index 9d1e3106fca6dc98457c62e0b502f04c6e62d49e..cec860d325fc64b537e40aa1061a8f71238b0bb3 100644 (file)
@@ -303,7 +303,7 @@ void FontData::determinePitch()
           ![name caseInsensitiveCompare:@"MS-PGothic"] == NSOrderedSame;
 }
 
-float FontData::platformWidthForGlyph(Glyph glyph) const
+float FontData::platformWidthForGlyph(Glyph glyph, UChar) const
 {
     NSFont *font = m_font.font;
     float pointSize = [font pointSize];
similarity index 66%
rename from WebCore/platform/FontPlatformData.h
rename to WebCore/platform/mac/FontPlatformData.h
index a264c795c64ac12f68d1cf234552a33ff1bc3d36..61512c9b4f9b906e11d548ed61031663f3c7dbfe 100644 (file)
 
 #include "StringImpl.h"
 
-// FIXME: This file should probably be split and moved into platform-specific subdirectories.  There's nothing
-// "cross-platform" about it.
-
-#ifdef __APPLE__
-
 #ifdef __OBJC__
 @class NSFont;
 #else
@@ -40,14 +35,20 @@ class NSFont;
 namespace WebCore {
 
 struct FontPlatformData {
+    class Deleted {};
+
+    FontPlatformData(Deleted)
+    : font((NSFont*)-1), syntheticBold(b), syntheticOblique(o)
+    {}
+
     FontPlatformData(NSFont* f = 0, bool b = false, bool o = false)
-    :font(f), syntheticBold(b), syntheticOblique(o)
+    : font(f), syntheticBold(b), syntheticOblique(o)
     {}
 
     NSFont *font;
     bool syntheticBold;
     bool syntheticOblique;
-    
+
     unsigned hash() const
     { 
         uintptr_t hashCodes[2] = { (uintptr_t)font, syntheticBold << 1 | syntheticOblique };
@@ -62,43 +63,4 @@ struct FontPlatformData {
 
 }
 
-#else
-
-#include <wtf/Noncopyable.h>
-
-#if WIN32
-typedef struct HFONT__ *HFONT;
-typedef struct _cairo_scaled_font cairo_scaled_font_t;
-typedef struct _cairo_font_face cairo_font_face_t;
-#endif
-
-namespace WebCore {
-
-class FontDescription;
-
-class FontPlatformData : Noncopyable
-{
-public:
-#if WIN32
-    FontPlatformData(HFONT font, const FontDescription& fontDescription);
-#endif
-    ~FontPlatformData();
-
-#if WIN32
-    HFONT hfont() const { return m_font; }
-    cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
-#endif
-
-private:
-#if WIN32
-    HFONT m_font;
-    cairo_font_face_t* m_fontFace;
-    cairo_scaled_font_t* m_scaledFont;
-#endif
-};
-
-}
-
-#endif
-
 #endif
diff --git a/WebCore/platform/win/FontDataWin.cpp b/WebCore/platform/win/FontDataWin.cpp
new file mode 100755 (executable)
index 0000000..96060f9
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2006 Apple Computer, 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 "Font.h"
+#include "FontCache.h"
+#include "FloatRect.h"
+#include "FontDescription.h"
+#include <wtf/MathExtras.h>
+#include <unicode/uchar.h>
+#include <unicode/unorm.h>
+#include <cairo.h>
+#include <cairo-win32.h>
+
+namespace WebCore
+{
+
+void FontData::platformInit()
+{    
+    HDC dc = GetDC(0);
+    SaveDC(dc);
+
+    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, dc);
+
+    TEXTMETRIC tm;
+    GetTextMetrics(dc, &tm);
+    m_ascent = lroundf(tm.tmAscent * metricsMultiplier);
+    m_descent = lroundf(tm.tmDescent * metricsMultiplier);
+    m_xHeight = m_ascent * 0.56f;  // Best guess for xHeight for non-Truetype fonts.
+    m_lineGap = lroundf(tm.tmExternalLeading * metricsMultiplier);
+    m_lineSpacing = m_ascent + m_descent + m_lineGap;
+
+    OUTLINETEXTMETRIC otm;
+    if (GetOutlineTextMetrics(dc, sizeof(otm), &otm) > 0) {
+        // This is a TrueType font.  We might be able to get an accurate xHeight.
+        GLYPHMETRICS gm;
+        MAT2 mat = { 1, 0, 0, 1 }; // The identity matrix.
+        DWORD len = GetGlyphOutlineW(dc, 'x', GGO_METRICS, &gm, 0, 0, &mat);
+        if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0)
+            m_xHeight = gm.gmptGlyphOrigin.y * metricsMultiplier;
+    }
+
+    cairo_win32_scaled_font_done_font(scaledFont);
+    
+    RestoreDC(dc, -1);
+    ReleaseDC(0, dc);
+}
+
+void FontData::platformDestroy()
+{
+}
+
+FontData* FontData::smallCapsFontData(const FontDescription& fontDescription) const
+{
+    if (!m_smallCapsFontData) {
+        // Need to make this cross-platform instead.
+        // FIXME: For now just return ourselves.
+        return (FontData*)this;
+    }
+    return m_smallCapsFontData;
+}
+
+bool FontData::containsCharacters(const UChar* characters, int length) const
+{
+    // FIXME: Need to check character ranges.
+    // IMLangFontLink2::GetFontUnicodeRanges does what we want. 
+    return false;
+}
+
+void FontData::determinePitch()
+{
+    // TEXTMETRICS have this.  Set m_treatAsFixedPitch based off that.
+    HDC dc = GetDC((HWND)0);
+    SaveDC(dc);
+    SelectObject(dc, m_font.hfont());
+
+    // Yes, this looks backwards, but the fixed pitch bit is actually set if the font
+    // is *not* fixed pitch.  Unbelievable but true.
+    TEXTMETRIC tm;
+    GetTextMetrics(dc, &tm);
+    m_treatAsFixedPitch = ((tm.tmPitchAndFamily & TMPF_FIXED_PITCH) == 0);
+
+    RestoreDC(dc, -1);
+    ReleaseDC(0, dc);
+}
+
+float FontData::platformWidthForGlyph(Glyph, UChar c) const
+{
+    HDC dc = GetDC(0);
+    SaveDC(dc);
+
+    cairo_scaled_font_t* scaledFont = m_font.scaledFont();
+    cairo_win32_scaled_font_select_font(scaledFont, dc);
+
+    // Get the width of the character.
+    int width;
+    GCP_RESULTS results;
+    memset(&results, 0, sizeof(GCP_RESULTS));
+    results.lStructSize = sizeof(GCP_RESULTS);
+    results.nGlyphs = 1;
+    results.lpDx = &width;
+    GetCharacterPlacement(dc, &c, 1, 0, &results, 0);\r
+    \r
+    cairo_win32_scaled_font_done_font(scaledFont);
+
+    RestoreDC(dc, -1);
+    ReleaseDC(0, dc);
+
+    const double metricsMultiplier = cairo_win32_scaled_font_get_metrics_factor(scaledFont) * m_font.size();
+
+    return width * metricsMultiplier;
+}
+
+}
index af783d17854a7e499607244b08767d1390c29376..d5ef5d5f4978112532b7f2737b87f186a0015bd4 100644 (file)
 
 #include "config.h"
 #include "FontPlatformData.h"
-
-#include "FontDescription.h"
 #include <cairo-win32.h>
 
 namespace WebCore {
 
-FontPlatformData::FontPlatformData(HFONT font, const FontDescription& fontDescription)
-{
-    m_font = font;  
+FontPlatformData::FontPlatformData(HFONT font, int size)
+:m_font(font), m_size(size)
+{  
     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, fontDescription.computedPixelSize(), fontDescription.computedPixelSize());
-    cairo_font_options_t* fontOptions = cairo_font_options_create();
+    cairo_matrix_init_scale(&sizeMatrix, size, size);
+
+    static cairo_font_options_t* fontOptions;
+    if (!fontOptions)
+        // Force ClearType-level quality.
+        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);
-    cairo_font_options_destroy(fontOptions);
 }
     
-FontPlatformData::~FontPlatformData() {
-    cairo_font_face_destroy(m_fontFace);
-    cairo_scaled_font_destroy(m_scaledFont);
-    DeleteObject(m_font);
+FontPlatformData::~FontPlatformData()
+{
+    if (m_font && m_font != (HFONT)-1) {
+        cairo_font_face_destroy(m_fontFace);
+        cairo_scaled_font_destroy(m_scaledFont);
+        DeleteObject(m_font);
+    }
 }
 
 }
index b6dc4fd0342b71e51c72e30574dfed24fa608a06..9c4e9b7e6ef27b9abda9d0e7eb2ad251e2268259 100644 (file)
 
 namespace WebCore {
 
-FontData* getFontData(const FontDescription& fontDescription, const AtomicString& fontFace)
-{
-    // FIXME: Look this up in a hashtable so that we can cache Cairo fonts.  For now we just grab the
-    // font over and over.
-    LOGFONTW winfont;
-    winfont.lfHeight = -fontDescription.computedPixelSize(); // The negative number is intentional.
-    winfont.lfWidth = 0;
-    winfont.lfEscapement = 0;
-    winfont.lfOrientation = 0;
-    winfont.lfUnderline = false;
-    winfont.lfStrikeOut = false;
-    winfont.lfCharSet = DEFAULT_CHARSET;
-    winfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
-    const int CLEARTYPE_QUALITY = 5;
-    winfont.lfQuality = CLEARTYPE_QUALITY; // FIXME: This is the Windows XP constant to force ClearType on.
-    winfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
-    winfont.lfItalic = fontDescription.italic();
-    winfont.lfWeight = fontDescription.weight() == cBoldWeight ? 700 : 400; // FIXME: Support weights for real.
-    int len = min(fontFace.length(), LF_FACESIZE - 1);
-    memcpy(winfont.lfFaceName, fontFace.characters(), len * sizeof(WORD));
-    winfont.lfFaceName[len] = '\0';
-
-    HFONT font = CreateFontIndirectW(&winfont);
-    
-    // Windows will always give us a valid pointer here, even if the face name is non-existent.  We have to double-check
-    // and see if the family name was really used.
-    HDC dc = GetDC((HWND)0);
-    SaveDC(dc);
-    SelectObject(dc, font);
-    
-    int ascent, descent, xHeight, lineSpacing;
-
-    TEXTMETRIC tm;
-    GetTextMetrics(dc, &tm);
-    ascent = tm.tmAscent;
-    descent = tm.tmDescent;
-    xHeight = ascent * 0.56f;  // Best guess for xHeight for non-Truetype fonts.
-    lineSpacing = tm.tmExternalLeading + tm.tmHeight;
-
-    OUTLINETEXTMETRIC otm;
-    if (GetOutlineTextMetrics(dc, sizeof(otm), &otm) > 0) {
-        // This is a TrueType font.  We might be able to get an accurate xHeight.
-        GLYPHMETRICS gm;
-        MAT2 mat = { 1, 0, 0, 1 }; // The identity matrix.
-        DWORD len = GetGlyphOutlineW(dc, 'x', GGO_METRICS, &gm, 0, 0, &mat);
-        if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0)
-            xHeight = int(gm.gmptGlyphOrigin.y + 0.5f);
-    }
-
-    WCHAR name[LF_FACESIZE];
-    unsigned resultLength = GetTextFaceW(dc, LF_FACESIZE, name);
-    if (resultLength > 0)
-        resultLength--; // ignore the null terminator
-    RestoreDC(dc, -1);
-    ReleaseDC(0, dc);
-    dc = 0;
-    if (!equalIgnoringCase(fontFace, String(name, resultLength))) {
-        DeleteObject(font);
-        return 0;
-    }
-    
-    // This font face is valid.  Create a FontData now.
-    FontData* result = new FontData(font, fontDescription);
-    result->setMetrics(ascent, descent, xHeight, lineSpacing);
-    return result;
-}
-
-FontFallbackList::FontFallbackList()
-:m_pitch(UnknownPitch)
-{
-    
-}
+static void notImplemented() { puts("Not yet implemented"); _CrtDbgBreak(); }
 
-FontFallbackList::~FontFallbackList()
+void Font::drawGlyphs(GraphicsContext* graphicsContext, const FontData* font, const GlyphBuffer& glyphBuffer, 
+                      int from, int numGlyphs, const FloatPoint& point) const
 {
-    deleteAllValues(m_fontList);
-}
+    cairo_t* context = graphicsContext->platformContext();
+    cairo_surface_t* surface = cairo_get_target(context);
+    HDC dc = cairo_win32_surface_get_dc(surface);
 
-void FontFallbackList::determinePitch(const Font* font) const
-{
-    // FIXME: Implement this.
-    m_pitch = VariablePitch;
-}
+    // Cairo alters this but we need to preserve it.
+    XFORM savedxform;
+    GetWorldTransform(dc, &savedxform);
 
-void FontFallbackList::invalidate()
-{
-    // Delete the Cairo fonts.
-    m_pitch = UnknownPitch;
-    deleteAllValues(m_fontList);
-    m_fontList.clear();
-}
+    // Select our font face/size.
+    cairo_set_font_face(context, font->m_font.fontFace());
+    cairo_set_font_size(context, font->m_font.size());
 
-const FontData* FontFallbackList::fontDataAt(const Font* font, unsigned index) const
-{
-    // FIXME: Only returning the primary font on Windows right now.
-    if (!m_fontList.isEmpty())
-        return m_fontList[0];
+    // Set the text color to use for drawing.
+    float red, green, blue, alpha;
+    Color penColor = graphicsContext->pen().color();
+    penColor.getRGBA(red, green, blue, alpha);
+    cairo_set_source_rgba(context, red, green, blue, alpha);
 
-    // We want to ensure that the primary Cairo font face exists.
-    for (const FontFamily* currFamily = &font->fontDescription().family(); 
-         currFamily;
-         currFamily = currFamily->next()) {
-        if (!currFamily->familyIsEmpty()) {
-            // Attempt to create a FontData.
-            FontData* fontData = getFontData(font->fontDescription(), currFamily->family());
-            if (fontData) {
-                m_fontList.append(fontData);
-                return fontData;
-            }
-        }
-    }
+    SaveDC(dc);
 
-    // FIXME: Go ahead and use the serif default.  For now hardcode Times New Roman.
-    // We'll need a way to either get to the settings without going through a frame, or we'll
-    // need this to be passed in as part of the fallback list.
-    FontData* defaultFont = getFontData(font->fontDescription(), AtomicString("Times New Roman"));
-    if (defaultFont)
-        m_fontList.append(defaultFont);
-    return defaultFont;
-}
+    // Select the scaled font.
+    cairo_scaled_font_t* scaledFont = font->m_font.scaledFont();
+    cairo_win32_scaled_font_select_font(scaledFont, dc);
 
-const FontData* FontFallbackList::fontDataForCharacters(const Font*, const UChar* characters, int length) const
-{
-    // FIXME: Not used yet on Windows.
-    return 0;
-}
+    // Restore the original transform.
+    SetWorldTransform(dc, &savedxform);
 
-static IntSize hackishExtentForString(HDC dc, const FontData* font, const TextRun& run, int tabWidth, int xpos)
-{
-    SaveDC(dc);
+    GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from);
 
-    SelectObject(dc, font->platformData().hfont());
+    for (unsigned i = 0; i < numGlyphs; i++) {
+        glyphs[i].x += point.x();
+        glyphs[i].y += point.y();
+    }
 
-    // Get the text extent of the characters.
-    // FIXME: Eventually we will have to go glyph by glyph.  For now we just assume that all
-    // glyphs are present in the primary font.
-    // FIXME: Support letter-spacing, word-spacing, smallcaps.
-    // FIXME: Handle tabs (the tabWidth and xpos parameters)
-    // FIXME: Handle RTL.
-    SIZE s;
-    BOOL result = GetTextExtentPoint32W(dc, (WCHAR*)(run.characters()), run.length(), &s);
+    cairo_show_glyphs(context, glyphs, numGlyphs);
 
+    cairo_win32_scaled_font_done_font(scaledFont);
     RestoreDC(dc, -1);
-
-    if (!result)
-        return IntSize();
-    return s;
 }
 
-float Font::floatWidth(const TextRun& run, const TextStyle& textStyle) const
+FloatRect Font::selectionRectForComplexText(const TextRun& run, const TextStyle& style, const IntPoint& point, int h) const
 {
-    const FontData* font = primaryFont();
-    if (!font)
-        return 0;
-
-    HDC dc = GetDC((HWND)0); // FIXME: Need a way to get to the real HDC.
-    IntSize runSize = hackishExtentForString(dc, font, run, textStyle.tabWidth(), textStyle.tabWidth());
-    ReleaseDC(0, dc);
-    return runSize.width();
+    notImplemented();
+    return FloatRect();
 }
 
-void Font::drawText(GraphicsContext* context, const TextRun& run, const TextStyle& textStyle, const FloatPoint& point) const
+void Font::drawComplexText(GraphicsContext* graphicsContext, const TextRun& run, const TextStyle& style, const FloatPoint& point) const
 {
-    const FontData* font = primaryFont();
-    if (!font)
-        return;
-
-    cairo_surface_t* surface = cairo_get_target(context->platformContext());
-    HDC dc = cairo_win32_surface_get_dc(surface);
-
-    SaveDC(dc);
-    SelectObject(dc, font->platformData().hfont());
-
-    int x = (int)point.x();
-    int y = (int)point.y();
-    y -= font->ascent();
-
-    SetBkMode(dc, TRANSPARENT);
-    const Color& color = context->pen().color();
-    SetTextColor(dc, RGB(color.red(), color.green(), color.blue())); // FIXME: Need to support alpha in the text color.
-    TextOutW(dc, x, y, (LPCWSTR)(run.characters()), run.length());
-
-    RestoreDC(dc, -1);
-    // No need to ReleaseDC the HDC borrowed from cairo
-} 
+    notImplemented();
+}
 
-FloatRect Font::selectionRectForText(const TextRun& run, const TextStyle& textStyle, const IntPoint& point, int h) const
+float Font::floatWidthForComplexText(const TextRun& run, const TextStyle& style) const
 {
-    const FontData* font = primaryFont();
-    if (!font)
-        return IntRect();
-
-    HDC dc = GetDC((HWND)0); // FIXME: Need a way to get to the real HDC.
-    IntSize runSize = hackishExtentForString(dc, font, run, textStyle.tabWidth(), textStyle.xPos());
-    ReleaseDC(0, dc);
-    return FloatRect(point, runSize);
+    notImplemented();
+    return 0;
 }
 
-int Font::offsetForPosition(const TextRun& run, const TextStyle& style, int x, bool includePartialGlyphs) const
+int Font::offsetForPositionForComplexText(const TextRun& run, const TextStyle& style, int x, bool includePartialGlyphs) const
 {
-    const FontData* font = primaryFont();
-    if (!font)
-        return 0;
-
-    HDC dc = GetDC((HWND)0); // FIXME: Need a way to get to the real HDC.
-
-    SaveDC(dc);
-    SelectObject(dc, font->platformData().hfont());
-    
-    int* caretPositions = (int*)fastMalloc(run.length() * sizeof(int));
-    GCP_RESULTS results;
-    memset(&results, 0, sizeof(GCP_RESULTS));
-    results.lStructSize = sizeof(GCP_RESULTS);
-    results.lpCaretPos = caretPositions;
-    results.nGlyphs = run.length();
-    
-    GetCharacterPlacement(dc, (LPCTSTR)(run.characters()), run.length(), 0, &results, 0);
-
-    unsigned selectionOffset = 0;
-    while (selectionOffset < run.length() && caretPositions[selectionOffset] < x)
-        selectionOffset++;
-
-    fastFree(caretPositions);
-
-    RestoreDC(dc, -1);
-    ReleaseDC(0, dc);
-    return selectionOffset;
+    notImplemented();
+    return 0;
 }
 
 }