Changeset 30441 in webkit


Ignore:
Timestamp:
Feb 20, 2008 6:10:56 PM (16 years ago)
Author:
pewtermoose@webkit.org
Message:

2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>2008-02-20 Brent Fulgham <bfulgham@gmail.com>

Reviewed by Dan.

http://bugs.webkit.org/show_bug.cgi?id=17336
Provide implementations for Windows (Cairo) build of WebKit that
handles font formatting.

  • Split font implementation files to allow maximal code sharing between CG and Cairo back-ends.
  • WebCore.vcproj/WebCore.vcproj:
  • platform/graphics/SimpleFontData.h: Add signatures for private win initialization functions.
  • platform/graphics/win/FontCacheWin.cpp: (WebCore::FontCache::platformInit): (WebCore::FontCache::createFontPlatformData):
  • platform/graphics/win/FontCairoWin.cpp: Removed. Universal version is now part of platform/graphics/cairo.
  • platform/graphics/win/FontCustomPlatformDataCairo.cpp: Added. (WebCore::FontCustomPlatformDataCairo::~FontCustomPlatformDataCairo): (WebCore::FontCustomPlatformDataCairo::fontPlatformData): (WebCore::releaseData): (WebCore::createFontCustomPlatformData):
  • platform/graphics/win/FontCustomPlatformDataCairo.h: Added. (WebCore::FontCustomPlatformDataCairo::FontCustomPlatformDataCairo):
  • platform/graphics/win/FontPlatformData.h: (WebCore::FontPlatformData::FontPlatformData): (WebCore::FontPlatformData::fontFace): (WebCore::FontPlatformData::scaledFont): (WebCore::FontPlatformData::operator==):
  • platform/graphics/win/FontPlatformDataCGWin.cpp: Copied from WebCore/platform/graphics/win/FontPlatformDataWin.cpp. (WebCore::FontPlatformData::platformDataInit):
  • platform/graphics/win/FontPlatformDataCairoWin.cpp: Added. (WebCore::FontPlatformData::platformDataInit): (WebCore::FontPlatformData::FontPlatformData): (WebCore::FontPlatformData::setFont):
  • platform/graphics/win/FontPlatformDataWin.cpp: Moved CG-specific code to FontPlatformDataCG.cpp. (WebCore::FontPlatformData::FontPlatformData):
  • platform/graphics/win/GlyphPageTreeNodeCGWin.cpp: Copied from WebCore/platform/graphics/win/GlyphPageTreeNodeWin.cpp.
  • platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp: Copied from WebCore/platform/graphics/win/GlyphPageTreeNodeWin.cpp. (WebCore::GlyphPage::fill):
  • platform/graphics/win/GlyphPageTreeNodeWin.cpp: Removed. Replaced with CG- and Cairo-specific versions.
  • platform/graphics/win/SimpleFontDataCGWin.cpp: (WebCore::SimpleFontData::platformInit): (WebCore::SimpleFontData::platformDestroy): (WebCore::SimpleFontData::platformWidthForGlyph):
  • platform/graphics/win/SimpleFontDataCairoWin.cpp: (WebCore::SimpleFontData::platformInit): (WebCore::SimpleFontData::platformDestroy): (WebCore::SimpleFontData::platformWidthForGlyph): (WebCore::SimpleFontData::setFont):
  • platform/graphics/win/SimpleFontDataWin.cpp: (WebCore::SimpleFontData::initGDIFont): (WebCore::SimpleFontData::platformCommonDestroy): (WebCore::SimpleFontData::widthForGDIGlyph):
Location:
trunk/WebCore
Files:
3 added
1 deleted
10 edited
2 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r30440 r30441  
     12008-02-20  Brent Fulgham  <bfulgham@gmail.com>
     2
     3        Reviewed by Dan.
     4
     5        http://bugs.webkit.org/show_bug.cgi?id=17336
     6        Provide implementations for Windows (Cairo) build of WebKit that
     7        handles font formatting.
     8        - Split font implementation files to allow maximal code sharing
     9          between CG and Cairo back-ends.
     10
     11        * WebCore.vcproj/WebCore.vcproj:
     12        * platform/graphics/SimpleFontData.h:   Add signatures for private win
     13          initialization functions.
     14        * platform/graphics/win/FontCacheWin.cpp:
     15        (WebCore::FontCache::platformInit):
     16        (WebCore::FontCache::createFontPlatformData):
     17        * platform/graphics/win/FontCairoWin.cpp: Removed.  Universal version
     18          is now part of platform/graphics/cairo.
     19        * platform/graphics/win/FontCustomPlatformDataCairo.cpp: Added.
     20        (WebCore::FontCustomPlatformDataCairo::~FontCustomPlatformDataCairo):
     21        (WebCore::FontCustomPlatformDataCairo::fontPlatformData):
     22        (WebCore::releaseData):
     23        (WebCore::createFontCustomPlatformData):
     24        * platform/graphics/win/FontCustomPlatformDataCairo.h: Added.
     25        (WebCore::FontCustomPlatformDataCairo::FontCustomPlatformDataCairo):
     26        * platform/graphics/win/FontPlatformData.h:
     27        (WebCore::FontPlatformData::FontPlatformData):
     28        (WebCore::FontPlatformData::fontFace):
     29        (WebCore::FontPlatformData::scaledFont):
     30        (WebCore::FontPlatformData::operator==):
     31        * platform/graphics/win/FontPlatformDataCGWin.cpp: Copied from WebCore/platform/graphics/win/FontPlatformDataWin.cpp.
     32        (WebCore::FontPlatformData::platformDataInit):
     33        * platform/graphics/win/FontPlatformDataCairoWin.cpp: Added.
     34        (WebCore::FontPlatformData::platformDataInit):
     35        (WebCore::FontPlatformData::FontPlatformData):
     36        (WebCore::FontPlatformData::setFont):
     37        * platform/graphics/win/FontPlatformDataWin.cpp:  Moved CG-specific
     38          code to FontPlatformDataCG.cpp.
     39        (WebCore::FontPlatformData::FontPlatformData):
     40        * platform/graphics/win/GlyphPageTreeNodeCGWin.cpp: Copied from WebCore/platform/graphics/win/GlyphPageTreeNodeWin.cpp.
     41        * platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp: Copied from WebCore/platform/graphics/win/GlyphPageTreeNodeWin.cpp.
     42        (WebCore::GlyphPage::fill):
     43        * platform/graphics/win/GlyphPageTreeNodeWin.cpp: Removed.  Replaced
     44          with CG- and Cairo-specific versions.
     45        * platform/graphics/win/SimpleFontDataCGWin.cpp:
     46        (WebCore::SimpleFontData::platformInit):
     47        (WebCore::SimpleFontData::platformDestroy):
     48        (WebCore::SimpleFontData::platformWidthForGlyph):
     49        * platform/graphics/win/SimpleFontDataCairoWin.cpp:
     50        (WebCore::SimpleFontData::platformInit):
     51        (WebCore::SimpleFontData::platformDestroy):
     52        (WebCore::SimpleFontData::platformWidthForGlyph):
     53        (WebCore::SimpleFontData::setFont):
     54        * platform/graphics/win/SimpleFontDataWin.cpp:
     55        (WebCore::SimpleFontData::initGDIFont):
     56        (WebCore::SimpleFontData::platformCommonDestroy):
     57        (WebCore::SimpleFontData::widthForGDIGlyph):
     58
    1592008-02-20  Darin Adler  <darin@apple.com>
    260
     
    3290        Consider it an error when a 404 is encountered on a CachedResource load.
    3391
     92>>>>>>> .r30440
    34932008-02-20  Anders Carlsson  <andersca@apple.com>
    3594
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r30377 r30441  
    39013901                                        </File>
    39023902                                        <File
     3903                                                RelativePath="..\platform\graphics\win\FontPlatformDataCGWin.cpp"
     3904                                                >
     3905                                        </File>
     3906                                        <File
    39033907                                                RelativePath="..\platform\graphics\win\FontPlatformDataWin.cpp"
    39043908                                                >
     
    39333937                                        </File>
    39343938                                        <File
    3935                                                 RelativePath="..\platform\graphics\win\GlyphPageTreeNodeWin.cpp"
     3939                                                RelativePath="..\platform\graphics\win\GlyphPageTreeNodeCGWin.cpp"
    39363940                                                >
    39373941                                        </File>
  • trunk/WebCore/platform/graphics/SimpleFontData.h

    r30056 r30441  
    22 * This file is part of the internal font implementation.
    33 *
    4  * Copyright (C) 2006 Apple Computer, Inc.
     4 * Copyright (C) 2006, 2008 Apple Computer, Inc.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    3636#if PLATFORM(WIN)
    3737#include <usp10.h>
     38#endif
     39
     40#if PLATFORM(CAIRO)
     41#include <cairo.h>
    3842#endif
    3943
     
    107111#endif
    108112
    109 #if PLATFORM(GTK)
     113#if PLATFORM(CAIRO)
    110114    void setFont(cairo_t*) const;
    111115#endif
     
    120124   
    121125    void commonInit();
     126
     127#if PLATFORM(WIN)
     128    void initGDIFont();
     129    void platformCommonDestroy();
     130    float widthForGDIGlyph(Glyph glyph) const;
     131#endif
    122132
    123133public:
  • trunk/WebCore/platform/graphics/win/FontCacheWin.cpp

    r30179 r30441  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3636#include <windows.h>
    3737#include <mlang.h>
     38#if PLATFORM(CG)
    3839#include <ApplicationServices/ApplicationServices.h>
    3940#include <WebKitSystemInterface/WebKitSystemInterface.h>
     41#endif
    4042
    4143using std::min;
     
    4648void FontCache::platformInit()
    4749{
     50#if PLATFORM(CG)
    4851    wkSetUpFontCache(1536 * 1024 * 4); // This size matches Mac.
     52#endif
    4953}
    5054
     
    415419    FontPlatformData* result = new FontPlatformData(hfont, fontDescription.computedPixelSize(),
    416420                                                    fontDescription.bold(), fontDescription.italic(), useGDI);
    417     if (!result->cgFont()) {
     421
     422#if PLATFORM(CG)
     423    bool fontCreationFailed = !result->cgFont();
     424#elif PLATFORM(CAIRO)
     425    bool fontCreationFailed = !result->fontFace();
     426#endif
     427
     428    if (fontCreationFailed) {
    418429        // The creation of the CGFontRef failed for some reason.  We already asserted in debug builds, but to make
    419430        // absolutely sure that we don't use this font, go ahead and return 0 so that we can fall back to the next
  • trunk/WebCore/platform/graphics/win/FontCustomPlatformData.h

    r28251 r30441  
    3333struct FontCustomPlatformData : Noncopyable {
    3434    FontCustomPlatformData(CGFontRef cgFont)
    35     : m_cgFont(cgFont)
    36     {}
     35        : m_cgFont(cgFont)
     36    {
     37    }
    3738    ~FontCustomPlatformData();
    3839
     
    4243};
    4344
    44 FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer);
     45FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*);
    4546
    4647}
  • trunk/WebCore/platform/graphics/win/FontPlatformData.h

    r29700 r30441  
    33 * FontMac.cpp, FontWin.cpp and Font.cpp.
    44 *
    5  * Copyright (C) 2006, 2007 Apple Inc.
     5 * Copyright (C) 2006, 2007, 2008 Apple Inc.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    2727#include "StringImpl.h"
    2828
    29 typedef struct HFONT__ *HFONT;
    30 typedef struct CGFont *CGFontRef;
     29#if PLATFORM(CAIRO)
     30#include <cairo-win32.h>
     31#endif
     32
     33typedef struct HFONT__* HFONT;
     34typedef struct CGFont* CGFontRef;
    3135
    3236namespace WebCore {
     
    4145    // Used for deleted values in the font cache's hash tables.
    4246    FontPlatformData(Deleted)
    43     : m_font((HFONT)-1)
    44     , m_cgFont(NULL)
    45     , m_size(0)
    46     , m_syntheticBold(false)
    47     , m_syntheticOblique(false)
    48     , m_useGDI(false)
    49     {}
     47        : m_font((HFONT)-1)
     48#if PLATFORM(CG)
     49        , m_cgFont(0)
     50#elif PLATFORM(CAIRO)
     51        , m_fontFace(0)
     52#endif
     53        , m_size(0)
     54        , m_syntheticBold(false)
     55        , m_syntheticOblique(false)
     56        , m_useGDI(false)
     57    {
     58    }
    5059
    5160    FontPlatformData()
    52     : m_font(0)
    53     , m_cgFont(NULL)
    54     , m_size(0)
    55     , m_syntheticBold(false)
    56     , m_syntheticOblique(false)
    57     , m_useGDI(false)
    58     {}
     61        : m_font(0)
     62#if PLATFORM(CG)
     63        , m_cgFont(0)
     64#elif PLATFORM(CAIRO)
     65        , m_fontFace(0)
     66#endif
     67        , m_size(0)
     68        , m_syntheticBold(false)
     69        , m_syntheticOblique(false)
     70        , m_useGDI(false)
     71    {
     72    }
    5973
    6074    FontPlatformData(HFONT, float size, bool bold, bool oblique, bool useGDI);
    6175    FontPlatformData(float size, bool bold, bool oblique);
     76
     77#if PLATFORM(CG)
    6278    FontPlatformData(CGFontRef, float size, bool bold, bool oblique);
     79#elif PLATFORM(CAIRO)
     80    FontPlatformData(cairo_font_face_t*, float size, bool bold, bool oblique);
     81#endif
    6382    ~FontPlatformData();
    6483
     84    void platformDataInit(HFONT font, float size, HDC hdc, WCHAR* faceName);
     85
    6586    HFONT hfont() const { return m_font; }
     87#if PLATFORM(CG)
    6688    CGFontRef cgFont() const { return m_cgFont; }
     89#elif PLATFORM(CAIRO)
     90    void setFont(cairo_t* ft) const;
     91    cairo_font_face_t* fontFace() const { return m_fontFace; }
     92    cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
     93#endif
    6794
    6895    float size() const { return m_size; }
     
    79106    bool operator==(const FontPlatformData& other) const
    80107    {
    81         return m_font == other.m_font && m_cgFont ==other.m_cgFont && m_size == other.m_size &&
     108        return m_font == other.m_font &&
     109#if PLATFORM(CG)
     110               m_cgFont == other.m_cgFont &&
     111#elif PLATFORM(CAIRO)
     112               m_fontFace == other.m_fontFace &&
     113               m_scaledFont == other.m_scaledFont &&
     114#endif
     115               m_size == other.m_size &&
    82116               m_syntheticBold == other.m_syntheticBold && m_syntheticOblique == other.m_syntheticOblique &&
    83117               m_useGDI == other.m_useGDI;
     
    86120private:
    87121    HFONT m_font;
     122#if PLATFORM(CG)
    88123    CGFontRef m_cgFont;
     124#elif PLATFORM(CAIRO)
     125    cairo_font_face_t* m_fontFace;
     126    cairo_scaled_font_t* m_scaledFont;
     127#endif
    89128
    90129    float m_size;
  • trunk/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp

    r30434 r30441  
    33 * FontMac.cpp, FontWin.cpp and Font.cpp.
    44 *
    5  * Copyright (C) 2006, 2007 Apple Inc.
     5 * Copyright (C) 2006, 2007, 2008 Apple Inc.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    3535
    3636namespace WebCore {
    37 
    38 static const int Bold = (1 << 0);
    39 static const int Italic = (1 << 1);
    40 static const int BoldOblique = (1 << 2);
    4137
    4238static inline USHORT readBigEndianWord(const BYTE* word) { return (word[0] << 8) | word[1]; }
     
    111107}
    112108
    113 static int CALLBACK enumStylesCallback(const LOGFONT* logFont, const TEXTMETRIC* metrics, DWORD fontType, LPARAM lParam)
     109void FontPlatformData::platformDataInit(HFONT font, float size, HDC hdc, WCHAR* faceName)
    114110{
    115     int *style = reinterpret_cast<int*>(lParam);
    116 
    117     // FIXME: In order to accommodate Lucida we go ahead and consider a weight of 600 to be bold.
    118     // This does mean we'll consider demibold and semibold fonts on windows to also be bold.  This
    119     // is rare enough that it seems like an ok hack for now.
    120     if (logFont->lfWeight >= 600) {
    121         if (logFont->lfItalic)
    122             *style |= BoldOblique;
    123         else
    124             *style |= Bold;
    125     } else if (logFont->lfItalic)
    126         *style |= Italic;
    127 
    128     return 1;
    129 }
    130 
    131 FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool oblique, bool useGDI)
    132     : m_font(font)
    133     , m_size(size)
    134     , m_cgFont(0)
    135     , m_syntheticBold(false)
    136     , m_syntheticOblique(false)
    137     , m_useGDI(useGDI)
    138 {
    139     HDC hdc = GetDC(0);
    140     SaveDC(hdc);
    141    
    142     SelectObject(hdc, font);
    143     UINT bufferSize = GetOutlineTextMetrics(hdc, 0, NULL);
    144 
    145     ASSERT_WITH_MESSAGE(bufferSize != 0, "Bitmap fonts not supported with CoreGraphics.");
    146 
    147     if (bufferSize != 0) {
    148         OUTLINETEXTMETRICW* metrics = (OUTLINETEXTMETRICW*)malloc(bufferSize);
    149 
    150         GetOutlineTextMetricsW(hdc, bufferSize, metrics);
    151         WCHAR* faceName = (WCHAR*)((uintptr_t)metrics + (uintptr_t)metrics->otmpFaceName);
    152 
    153         if (!useGDI && (bold || oblique)) {
    154             LOGFONT logFont;
    155 
    156             int len = min((int)wcslen(faceName), LF_FACESIZE - 1);
    157             memcpy(logFont.lfFaceName, faceName, len * sizeof(WORD));
    158             logFont.lfFaceName[len] = '\0';
    159             logFont.lfCharSet = metrics->otmTextMetrics.tmCharSet;
    160             logFont.lfPitchAndFamily = 0;
    161 
    162             int styles = 0;
    163             EnumFontFamiliesEx(hdc, &logFont, enumStylesCallback, reinterpret_cast<LPARAM>(&styles), 0);
    164 
    165             // Check if we need to synthesize bold or oblique. The rule that complicates things here
    166             // is that if the requested font is bold and oblique, and both a bold font and an oblique font
    167             // exist, the bold font should be used, and oblique synthesized.
    168             if (bold && oblique) {
    169                 if (styles == 0) {
    170                     m_syntheticBold = true;
    171                     m_syntheticOblique = true;
    172                 } else if (styles & Bold)
    173                     m_syntheticOblique = true;
    174                 else if (styles & Italic)
    175                     m_syntheticBold = true;
    176             } else if (bold && (!(styles & Bold)))
    177                     m_syntheticBold = true;
    178               else if (oblique && !(styles & Italic))
    179                     m_syntheticOblique = true;
     111    // Try the face name first.  Windows may end up localizing this name, and CG doesn't know about
     112    // the localization.  If the create fails, we'll try the PostScript name.
     113    RetainPtr<CFStringRef> fullName(AdoptCF, CFStringCreateWithCharacters(NULL, (const UniChar*)faceName, wcslen(faceName)));
     114    m_cgFont = CGFontCreateWithFontName(fullName.get());
     115    if (!m_cgFont) {
     116        CFStringRef postScriptName = getPostScriptName(fullName.get(), hdc);
     117        if (postScriptName) {
     118            m_cgFont = CGFontCreateWithFontName(postScriptName);
     119            ASSERT(m_cgFont);
    180120        }
    181 
    182         // Try the face name first.  Windows may end up localizing this name, and CG doesn't know about
    183         // the localization.  If the create fails, we'll try the PostScript name.
    184         RetainPtr<CFStringRef> fullName(AdoptCF, CFStringCreateWithCharacters(NULL, (const UniChar*)faceName, wcslen(faceName)));
    185         m_cgFont = CGFontCreateWithFontName(fullName.get());
    186         if (!m_cgFont) {
    187             CFStringRef postScriptName = getPostScriptName(fullName.get(), hdc);
    188             if (postScriptName) {
    189                 m_cgFont = CGFontCreateWithFontName(postScriptName);
    190                 ASSERT(m_cgFont);
    191             }
    192         }
    193         free(metrics);
    194121    }
    195 
    196     RestoreDC(hdc, -1);
    197     ReleaseDC(0, hdc);
    198 }
    199 
    200 FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
    201     : m_font(0)
    202     , m_size(size)
    203     , m_cgFont(0)
    204     , m_syntheticBold(bold)
    205     , m_syntheticOblique(oblique)
    206     , m_useGDI(false)
    207 {
    208122}
    209123
     
    218132}
    219133
    220 FontPlatformData::~FontPlatformData()
    221 {
    222134}
    223 
    224 }
  • trunk/WebCore/platform/graphics/win/FontPlatformDataWin.cpp

    r29700 r30441  
    33 * FontMac.cpp, FontWin.cpp and Font.cpp.
    44 *
    5  * Copyright (C) 2006, 2007 Apple Inc.
     5 * Copyright (C) 2006, 2007, 2008 Apple Inc.
     6 * Copyright (C) 2008 Brent Fulgham
    67 *
    78 * This library is free software; you can redistribute it and/or
     
    2728#include "PlatformString.h"
    2829#include "StringHash.h"
    29 #include <ApplicationServices/ApplicationServices.h>
    3030#include <wtf/HashMap.h>
    3131#include <wtf/RetainPtr.h>
     
    3939static const int Italic = (1 << 1);
    4040static const int BoldOblique = (1 << 2);
    41 
    42 static inline USHORT readBigEndianWord(const BYTE* word) { return (word[0] << 8) | word[1]; }
    43 
    44 static CFStringRef getPostScriptName(CFStringRef faceName, HDC dc)
    45 {
    46     const DWORD cMaxNameTableSize = 1024 * 1024;
    47 
    48     static HashMap<String, RetainPtr<CFStringRef> > nameMap;
    49 
    50     // Check our hash first.
    51     String faceString(faceName);
    52     RetainPtr<CFStringRef> result = nameMap.get(faceString);
    53     if (result)
    54         return result.get();
    55 
    56     // We need to obtain the PostScript name from the name table and use it instead,.
    57     DWORD bufferSize = GetFontData(dc, 'eman', 0, NULL, 0); // "name" backwards
    58     if (bufferSize == 0 || bufferSize == GDI_ERROR || bufferSize > cMaxNameTableSize)
    59         return NULL;
    60    
    61     Vector<BYTE> bufferVector(bufferSize);
    62     BYTE* buffer = bufferVector.data();
    63     if (GetFontData(dc, 'eman', 0, buffer, bufferSize) == GDI_ERROR)
    64         return NULL;
    65 
    66     if (bufferSize < 6)
    67         return NULL;
    68 
    69     USHORT numberOfRecords = readBigEndianWord(buffer + 2);
    70     UINT stringsOffset = readBigEndianWord(buffer + 4);
    71     if (bufferSize < stringsOffset)
    72         return NULL;
    73 
    74     BYTE* strings = buffer + stringsOffset;
    75 
    76     // Now walk each name record looking for a Mac or Windows PostScript name.
    77     UINT offset = 6;
    78     for (int i = 0; i < numberOfRecords; i++) {
    79         if (bufferSize < offset + 12)
    80             return NULL;
    81 
    82         USHORT platformID = readBigEndianWord(buffer + offset);
    83         USHORT encodingID = readBigEndianWord(buffer + offset + 2);
    84         USHORT languageID = readBigEndianWord(buffer + offset + 4);
    85         USHORT nameID = readBigEndianWord(buffer + offset + 6);
    86         USHORT length = readBigEndianWord(buffer + offset + 8);
    87         USHORT nameOffset = readBigEndianWord(buffer + offset + 10);
    88 
    89         if (platformID == 3 && encodingID == 1 && languageID == 0x409 && nameID == 6) {
    90             // This is a Windows PostScript name and is therefore UTF-16.
    91             // Pass Big Endian as the encoding.
    92             if (bufferSize < stringsOffset + nameOffset + length)
    93                 return NULL;
    94             result.adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingUTF16BE, false));
    95             break;
    96         } else if (platformID == 1 && encodingID == 0 && languageID == 0 && nameID == 6) {
    97             // This is a Mac PostScript name and is therefore ASCII.
    98             // See http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html
    99             if (bufferSize < stringsOffset + nameOffset + length)
    100                 return NULL;
    101             result.adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingASCII, false));
    102             break;
    103         }
    104 
    105         offset += 12;
    106     }
    107 
    108     if (result)
    109         nameMap.set(faceString, result);
    110     return result.get();
    111 }
    11241
    11342static int CALLBACK enumStylesCallback(const LOGFONT* logFont, const TEXTMETRIC* metrics, DWORD fontType, LPARAM lParam)
     
    13261    : m_font(font)
    13362    , m_size(size)
     63#if PLATFORM(CG)
    13464    , m_cgFont(0)
     65#elif PLATFORM(CAIRO)
     66    , m_fontFace(0)
     67    , m_scaledFont(0)
     68#endif
    13569    , m_syntheticBold(false)
    13670    , m_syntheticOblique(false)
     
    180114        }
    181115
    182         // Try the face name first.  Windows may end up localizing this name, and CG doesn't know about
    183         // the localization.  If the create fails, we'll try the PostScript name.
    184         RetainPtr<CFStringRef> fullName(AdoptCF, CFStringCreateWithCharacters(NULL, (const UniChar*)faceName, wcslen(faceName)));
    185         m_cgFont = CGFontCreateWithFontName(fullName.get());
    186         if (!m_cgFont) {
    187             CFStringRef postScriptName = getPostScriptName(fullName.get(), hdc);
    188             if (postScriptName) {
    189                 m_cgFont = CGFontCreateWithFontName(postScriptName);
    190                 ASSERT(m_cgFont);
    191             }
    192         }
     116        platformDataInit(font, size, hdc, faceName);
     117
    193118        free(metrics);
    194119    }
     
    201126    : m_font(0)
    202127    , m_size(size)
     128#if PLATFORM(CG)
    203129    , m_cgFont(0)
    204     , m_syntheticBold(bold)
    205     , m_syntheticOblique(oblique)
    206     , m_useGDI(false)
    207 {
    208 }
    209 
    210 FontPlatformData::FontPlatformData(CGFontRef font, float size, bool bold, bool oblique)
    211     : m_font(0)
    212     , m_size(size)
    213     , m_cgFont(font)
     130#elif PLATFORM(CAIRO)
     131    , m_fontFace(0)
     132    , m_scaledFont(0)
     133#endif
    214134    , m_syntheticBold(bold)
    215135    , m_syntheticOblique(oblique)
  • trunk/WebCore/platform/graphics/win/GlyphPageTreeNodeCGWin.cpp

    r30434 r30441  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
  • trunk/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp

    r30434 r30441  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3131
    3232#include "SimpleFontData.h"
    33 #include <WebKitSystemInterface/WebKitSystemInterface.h>
    3433
    3534namespace WebCore {
     
    4342
    4443    bool haveGlyphs = false;
    45     CGGlyph localGlyphBuffer[GlyphPage::size];
    46     wkGetGlyphs(fontData->platformData().cgFont(), buffer, localGlyphBuffer, bufferLength);
    47     for (unsigned i = 0; i < length; i++) {
    48         Glyph glyph = localGlyphBuffer[i];
    49         if (!glyph)
    50             setGlyphDataForIndex(offset + i, 0, 0);
    51         else {
    52             setGlyphDataForIndex(offset + i, glyph, fontData);
    53             haveGlyphs = true;
     44
     45    HDC dc = GetDC((HWND)0);
     46    SaveDC(dc);
     47    SelectObject(dc, fontData->platformData().hfont());
     48
     49    TEXTMETRIC tm;
     50    GetTextMetrics(dc, &tm);
     51
     52    WORD localGlyphBuffer[GlyphPage::size * 2];
     53    DWORD result = GetGlyphIndices(dc, buffer, bufferLength, localGlyphBuffer, 0);
     54    bool success = result != GDI_ERROR && static_cast<unsigned>(result) == bufferLength;
     55    if (success) {
     56        for (unsigned i = 0; i < length; i++) {
     57            Glyph glyph = localGlyphBuffer[i];
     58            if (!glyph)
     59                setGlyphDataForIndex(offset + i, 0, 0);
     60            else {
     61                setGlyphDataForIndex(offset + i, glyph, fontData);
     62                haveGlyphs = true;
     63            }
    5464        }
    5565    }
     66    RestoreDC(dc, -1);
     67    ReleaseDC(0, dc);
     68
    5669    return haveGlyphs;
    5770}
  • trunk/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp

    r30056 r30441  
    5555    m_scriptFontProperties = 0;
    5656    m_isSystemFont = false;
    57    
    58     if (m_font.useGDI()) {
    59         HDC hdc = GetDC(0);
    60         HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont());
    61         OUTLINETEXTMETRIC metrics;
    62         GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics);
    63         TEXTMETRIC& textMetrics = metrics.otmTextMetrics;
    64         m_ascent = textMetrics.tmAscent;
    65         m_descent = textMetrics.tmDescent;
    66         m_lineGap = textMetrics.tmExternalLeading;
    67         m_lineSpacing = m_ascent + m_descent + m_lineGap;
    68         m_xHeight = m_ascent * 0.56f; // Best guess for xHeight if no x glyph is present.
    6957
    70         GLYPHMETRICS gm;
    71         MAT2 mat = { 1, 0, 0, 1 };
    72         DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &mat);
    73         if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0)
    74             m_xHeight = gm.gmptGlyphOrigin.y;
    75 
    76         m_unitsPerEm = metrics.otmEMSquare;
    77 
    78         SelectObject(hdc, oldFont);
    79         ReleaseDC(0, hdc);
    80 
    81         return;
    82     }
     58    if (m_font.useGDI())
     59       return initGDIFont();
    8360
    8461    CGFontRef font = m_font.cgFont();
     
    145122    }
    146123
    147     // We don't hash this on Win32, so it's effectively owned by us.
    148     delete m_smallCapsFontData;
    149 
    150     ScriptFreeCache(&m_scriptCache);
    151     delete m_scriptFontProperties;
     124    platformCommonDestroy();
    152125}
    153126
    154127float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
    155128{
    156     if (m_font.useGDI()) {
    157         HDC hdc = GetDC(0);
    158         HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont());
    159         int width;
    160         GetCharWidthI(hdc, glyph, 1, 0, &width);
    161         SelectObject(hdc, oldFont);
    162         ReleaseDC(0, hdc);
    163         return width;
    164     }
     129    if (m_font.useGDI())
     130       return widthForGDIGlyph(glyph);
    165131
    166132    CGFontRef font = m_font.cgFont();
  • trunk/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp

    r30056 r30441  
    3535#include "FontCache.h"
    3636#include "FontDescription.h"
     37#include "MathExtras.h"
    3738#include "NotImplemented.h"
     39#include <cairo.h>
     40#include <cairo-win32.h>
    3841#include <mlang.h>
    3942#include <tchar.h>
     
    4649    m_scriptFontProperties = 0;
    4750    m_isSystemFont = false;
    48    
    49     if (m_font.useGDI()) {
    50         HDC hdc = GetDC(0);
    51         HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont());
    52         OUTLINETEXTMETRIC metrics;
    53         GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics);
    54         TEXTMETRIC& textMetrics = metrics.otmTextMetrics;
    55         m_ascent = textMetrics.tmAscent;
    56         m_descent = textMetrics.tmDescent;
    57         m_lineGap = textMetrics.tmExternalLeading;
    58         m_lineSpacing = m_ascent + m_descent + m_lineGap;
    59         m_xHeight = m_ascent * 0.56f; // Best guess for xHeight if no x glyph is present.
    6051
     52    if (m_font.useGDI())
     53       return initGDIFont();
     54
     55    HDC hdc = GetDC(0);
     56    SaveDC(hdc);
     57
     58    cairo_scaled_font_t* scaledFont = m_font.scaledFont();
     59    const double metricsMultiplier = cairo_win32_scaled_font_get_metrics_factor(scaledFont) * m_font.size();
     60
     61    cairo_win32_scaled_font_select_font(scaledFont, hdc);
     62
     63    TEXTMETRIC textMetrics;
     64    GetTextMetrics(hdc, &textMetrics);
     65    m_ascent = lroundf(textMetrics.tmAscent * metricsMultiplier);
     66    m_descent = lroundf(textMetrics.tmDescent * metricsMultiplier);
     67    m_xHeight = m_ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts.
     68    m_lineGap = lroundf(textMetrics.tmExternalLeading * metricsMultiplier);
     69    m_lineSpacing = m_ascent + m_descent + m_lineGap;
     70
     71    OUTLINETEXTMETRIC metrics;
     72    if (GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics) > 0) {
     73        // This is a TrueType font.  We might be able to get an accurate xHeight
    6174        GLYPHMETRICS gm;
    6275        MAT2 mat = { 1, 0, 0, 1 };
    6376        DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &mat);
    6477        if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0)
    65             m_xHeight = gm.gmptGlyphOrigin.y;
    66 
    67         m_unitsPerEm = metrics.otmEMSquare;
    68 
    69         SelectObject(hdc, oldFont);
    70         ReleaseDC(0, hdc);
    71 
    72         return;
     78            m_xHeight = gm.gmptGlyphOrigin.y * metricsMultiplier;
    7379    }
    7480
    75     // FIXME: This section should determine font dimensions (see CG implementation).
    76     notImplemented();
     81    cairo_win32_scaled_font_done_font(scaledFont);
     82
     83    m_isSystemFont = false;
     84    m_scriptCache = 0;
     85    m_scriptFontProperties = 0;
     86
     87    RestoreDC(hdc, -1);
     88    ReleaseDC(0, hdc);
    7789}
    7890
    7991void SimpleFontData::platformDestroy()
    8092{
    81     notImplemented();
     93    cairo_font_face_destroy(m_font.fontFace());
     94    cairo_scaled_font_destroy(m_font.scaledFont());
     95
     96    DeleteObject(m_font.hfont());
     97
     98    platformCommonDestroy();
    8299}
    83100
    84101float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
    85102{
    86     if (m_font.useGDI()) {
    87         HDC hdc = GetDC(0);
    88         HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont());
    89         int width;
    90         GetCharWidthI(hdc, glyph, 1, 0, &width);
    91         SelectObject(hdc, oldFont);
    92         ReleaseDC(0, hdc);
    93         return width;
    94     }
     103    if (m_font.useGDI())
     104       return widthForGDIGlyph(glyph);
    95105
    96     // FIXME: Flesh out with Cairo/win32 font implementation
    97     notImplemented();
     106    HDC hdc = GetDC(0);
     107    SaveDC(hdc);
    98108
    99     return 0;
     109    cairo_scaled_font_t* scaledFont = m_font.scaledFont();
     110    cairo_win32_scaled_font_select_font(scaledFont, hdc);
     111
     112    int width;
     113    GetCharWidthI(hdc, glyph, 1, 0, &width);
     114
     115    cairo_win32_scaled_font_done_font(scaledFont);
     116
     117    RestoreDC(hdc, -1);
     118    ReleaseDC(0, hdc);
     119
     120    const double metricsMultiplier = cairo_win32_scaled_font_get_metrics_factor(scaledFont) * m_font.size();
     121    return width * metricsMultiplier;
     122}
     123
     124void SimpleFontData::setFont(cairo_t* cr) const
     125{
     126    ASSERT(cr);
     127    m_font.setFont(cr);
    100128}
    101129
  • trunk/WebCore/platform/graphics/win/SimpleFontDataWin.cpp

    r30056 r30441  
    6161}
    6262
     63void SimpleFontData::initGDIFont()
     64{
     65     HDC hdc = GetDC(0);
     66     HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont());
     67     OUTLINETEXTMETRIC metrics;
     68     GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics);
     69     TEXTMETRIC& textMetrics = metrics.otmTextMetrics;
     70     m_ascent = textMetrics.tmAscent;
     71     m_descent = textMetrics.tmDescent;
     72     m_lineGap = textMetrics.tmExternalLeading;
     73     m_lineSpacing = m_ascent + m_descent + m_lineGap;
     74     m_xHeight = m_ascent * 0.56f; // Best guess for xHeight if no x glyph is present.
     75
     76     GLYPHMETRICS gm;
     77     MAT2 mat = { 1, 0, 0, 1 };
     78     DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &mat);
     79     if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0)
     80         m_xHeight = gm.gmptGlyphOrigin.y;
     81
     82     m_unitsPerEm = metrics.otmEMSquare;
     83
     84     SelectObject(hdc, oldFont);
     85     ReleaseDC(0, hdc);
     86
     87     return;
     88}
     89
     90void SimpleFontData::platformCommonDestroy()
     91{
     92    // We don't hash this on Win32, so it's effectively owned by us.
     93    delete m_smallCapsFontData;
     94
     95    ScriptFreeCache(&m_scriptCache);
     96    delete m_scriptFontProperties;
     97}
     98
    6399SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
    64100{
     
    138174}
    139175
     176float SimpleFontData::widthForGDIGlyph(Glyph glyph) const
     177{
     178    HDC hdc = GetDC(0);
     179    HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont());
     180    int width;
     181    GetCharWidthI(hdc, glyph, 1, 0, &width);
     182    SelectObject(hdc, oldFont);
     183    ReleaseDC(0, hdc);
     184    return width;
     185}
     186
    140187SCRIPT_FONTPROPERTIES* SimpleFontData::scriptFontProperties() const
    141188{
Note: See TracChangeset for help on using the changeset viewer.