Reviewed by Darin Adler and Sam Weinig.
- <rdar://problem/
4433248> use CoreText API instead of SPI on Leopard
Use CTFontCopyGraphicsFont and CTFontGetPlatformFont on Leopard instead
of wkGetCGFontFromNSFont and wkGetNSFontATSUFontId, relying on NSFont
and CTFontRef being toll-free bridged.
* WebCore.Tiger.exp:
* WebCore.base.exp:
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::drawGlyphs): Changed to use the cgFont() accessor.
* platform/graphics/mac/FontPlatformData.h:
Made m_cgFont a RetainPtr on Leopard.
(WebCore::toCTFontRef): Added a function that encapsulates the
toll-free bridging.
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::cgFont): Added this accessor method.
* platform/graphics/mac/FontPlatformDataMac.mm:
(WebCore::FontPlatformData::FontPlatformData): Changed to use
CoreText API on Leopard.
(WebCore::FontPlatformData::setFont): Ditto.
* platform/graphics/mac/SimpleFontDataMac.mm:
(WebCore::initFontData):
(WebCore::pathFromFont):
(WebCore::SimpleFontData::platformInit):
(WebCore::SimpleFontData::platformWidthForGlyph):
* platform/mac/WebCoreSystemInterface.mm:
WebKit/mac:
Reviewed by Darin Adler and Sam Weinig.
- <rdar://problem/
4433248> use CoreText API instead of SPI on Leopard
* WebCoreSupport/WebSystemInterface.m:
(InitWebCoreSystemInterface): Made WKGetCGFontFromNSFont and
WKGetNSFontATSUFontId Tiger-only.
WebKitLibraries:
Reviewed by Darin Adler and Sam Weinig.
- <rdar://problem/
4433248> use CoreText API instead of SPI on Leopard
* WebKitSystemInterface.h:
* libWebKitSystemInterfaceLeopard.a:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30997
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-03-12 Dan Bernstein <mitz@apple.com>
+
+ Reviewed by Darin Adler and Sam Weinig.
+
+ - <rdar://problem/4433248> use CoreText API instead of SPI on Leopard
+
+ Use CTFontCopyGraphicsFont and CTFontGetPlatformFont on Leopard instead
+ of wkGetCGFontFromNSFont and wkGetNSFontATSUFontId, relying on NSFont
+ and CTFontRef being toll-free bridged.
+
+ * WebCore.Tiger.exp:
+ * WebCore.base.exp:
+ * platform/graphics/mac/FontMac.mm:
+ (WebCore::Font::drawGlyphs): Changed to use the cgFont() accessor.
+ * platform/graphics/mac/FontPlatformData.h:
+ Made m_cgFont a RetainPtr on Leopard.
+ (WebCore::toCTFontRef): Added a function that encapsulates the
+ toll-free bridging.
+ (WebCore::FontPlatformData::FontPlatformData):
+ (WebCore::FontPlatformData::cgFont): Added this accessor method.
+ * platform/graphics/mac/FontPlatformDataMac.mm:
+ (WebCore::FontPlatformData::FontPlatformData): Changed to use
+ CoreText API on Leopard.
+ (WebCore::FontPlatformData::setFont): Ditto.
+ * platform/graphics/mac/SimpleFontDataMac.mm:
+ (WebCore::initFontData):
+ (WebCore::pathFromFont):
+ (WebCore::SimpleFontData::platformInit):
+ (WebCore::SimpleFontData::platformWidthForGlyph):
+ * platform/mac/WebCoreSystemInterface.mm:
+
2008-03-12 David Harrison <harrison@apple.com>
Reviewed by Darin.
+_wkGetCGFontFromNSFont
_wkGetFontMetrics
+_wkGetNSFontATSUFontId
_wkSupportsMultipartXMixedReplace
_wkDrawTextFieldCellFocusRing
_wkFontSmoothingModeIsLCD
_wkGetATSStyleGroup
-_wkGetCGFontFromNSFont
_wkGetExtensionsForMIMEType
_wkGetFontInLanguageForCharacter
_wkGetFontInLanguageForRange
_wkGetGlyphVectorNumGlyphs
_wkGetGlyphVectorRecordSize
_wkGetMIMETypeForExtension
-_wkGetNSFontATSUFontId
_wkGetNSURLResponseCalculatedExpiration
_wkGetNSURLResponseLastModifiedDate
_wkGetNSURLResponseMustRevalidate
[[[platformData.font() fontDescriptor] fontAttributes] objectForKey:NSFontNameAttribute]);
}
- CGContextSetFont(cgContext, platformData.m_cgFont);
+ CGContextSetFont(cgContext, platformData.cgFont());
CGAffineTransform matrix = CGAffineTransformIdentity;
if (drawFont)
typedef struct CGFont* CGFontRef;
typedef UInt32 ATSUFontID;
+#ifndef BUILDING_ON_TIGER
+typedef const struct __CTFont* CTFontRef;
+#endif
#include <CoreFoundation/CFBase.h>
#include <objc/objc-auto.h>
+#include <wtf/RetainPtr.h>
namespace WebCore {
+#ifndef BUILDING_ON_TIGER
+inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef>(nsFont); }
+#endif
+
struct FontPlatformData {
class Deleted {};
FontPlatformData(Deleted)
- : m_syntheticBold(false), m_syntheticOblique(false), m_cgFont(0), m_atsuFontID(0), m_size(0), m_font((NSFont*)-1)
- {}
+ : m_syntheticBold(false)
+ , m_syntheticOblique(false)
+ , m_atsuFontID(0)
+ , m_size(0)
+ , m_font((NSFont*)-1)
+#ifdef BUILDING_ON_TIGER
+ , m_cgFont(0)
+#endif
+ {
+ }
FontPlatformData(float s, bool b, bool o)
: m_syntheticBold(b)
, m_syntheticOblique(o)
- , m_cgFont(0)
, m_atsuFontID(0)
, m_size(s)
, m_font(0)
+#ifdef BUILDING_ON_TIGER
+ , m_cgFont(0)
+#endif
{
}
FontPlatformData(NSFont* f = 0, bool b = false, bool o = false);
FontPlatformData(CGFontRef f, ATSUFontID fontID, float s, bool b , bool o)
- : m_syntheticBold(b), m_syntheticOblique(o), m_cgFont(f), m_atsuFontID(fontID), m_size(s), m_font(0)
+ : m_syntheticBold(b), m_syntheticOblique(o), m_atsuFontID(fontID), m_size(s), m_font(0), m_cgFont(f)
{
}
bool m_syntheticBold;
bool m_syntheticOblique;
-
- CGFontRef m_cgFont; // It is not necessary to refcount this, since either an NSFont owns it or some CachedFont has it referenced.
+
ATSUFontID m_atsuFontID;
float m_size;
NSFont *font() const { return m_font; }
void setFont(NSFont* font);
+#ifndef BUILDING_ON_TIGER
+ CGFontRef cgFont() const { return m_cgFont.get(); }
+#else
+ CGFontRef cgFont() const { return m_cgFont; }
+#endif
+
private:
NSFont *m_font;
+#ifndef BUILDING_ON_TIGER
+ RetainPtr<CGFontRef> m_cgFont;
+#else
+ CGFontRef m_cgFont; // It is not necessary to refcount this, since either an NSFont owns it or some CachedFont has it referenced.
+#endif
};
}
if (f)
CFRetain(f);
m_size = f ? [f pointSize] : 0.0f;
+#ifndef BUILDING_ON_TIGER
+ m_cgFont = CTFontCopyGraphicsFont(toCTFontRef(f), 0);
+ m_atsuFontID = CTFontGetPlatformFont(toCTFontRef(f), 0);
+#else
m_cgFont = wkGetCGFontFromNSFont(f);
m_atsuFontID = wkGetNSFontATSUFontId(f);
+#endif
}
FontPlatformData::FontPlatformData(const FontPlatformData& f)
CFRelease(m_font);
m_font = font;
m_size = font ? [font pointSize] : 0.0f;
+#ifndef BUILDING_ON_TIGER
+ m_cgFont = CTFontCopyGraphicsFont(toCTFontRef(font), 0);
+ m_atsuFontID = CTFontGetPlatformFont(toCTFontRef(font), 0);
+#else
m_cgFont = wkGetCGFontFromNSFont(font);
m_atsuFontID = wkGetNSFontATSUFontId(font);
+#endif
}
}
bool initFontData(SimpleFontData* fontData)
{
- if (!fontData->m_font.m_cgFont)
+ if (!fontData->m_font.cgFont())
return false;
ATSUStyle fontStyle;
#else
static NSString* pathFromFont(NSFont *font)
{
+#ifndef BUILDING_ON_TIGER
+ ATSFontRef atsFont = FMGetATSFontRefFromFont(CTFontGetPlatformFont(toCTFontRef(font), 0));
+#else
ATSFontRef atsFont = FMGetATSFontRefFromFont(wkGetNSFontATSUFontId(font));
+#endif
FSRef fileRef;
#ifndef BUILDING_ON_TIGER
int iDescent;
int iLineGap;
#ifdef BUILDING_ON_TIGER
- wkGetFontMetrics(m_font.m_cgFont, &iAscent, &iDescent, &iLineGap, &m_unitsPerEm);
+ wkGetFontMetrics(m_font.cgFont(), &iAscent, &iDescent, &iLineGap, &m_unitsPerEm);
#else
- iAscent = CGFontGetAscent(m_font.m_cgFont);
- iDescent = CGFontGetDescent(m_font.m_cgFont);
- iLineGap = CGFontGetLeading(m_font.m_cgFont);
- m_unitsPerEm = CGFontGetUnitsPerEm(m_font.m_cgFont);
+ iAscent = CGFontGetAscent(m_font.cgFont());
+ iDescent = CGFontGetDescent(m_font.cgFont());
+ iLineGap = CGFontGetLeading(m_font.cgFont());
+ m_unitsPerEm = CGFontGetUnitsPerEm(m_font.cgFont());
#endif
float pointSize = m_font.m_size;
float pointSize = m_font.m_size;
CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
CGSize advance;
- if (!wkGetGlyphTransformedAdvances(m_font.m_cgFont, font, &m, &glyph, &advance)) {
+ if (!wkGetGlyphTransformedAdvances(m_font.cgFont(), font, &m, &glyph, &advance)) {
LOG_ERROR("Unable to cache glyph widths for %@ %f", [font displayName], pointSize);
advance.width = 0;
}
void (*wkDrawFocusRing)(CGContextRef, CGColorRef, int radius);
BOOL (*wkFontSmoothingModeIsLCD)(int mode);
OSStatus (*wkGetATSStyleGroup)(ATSUStyle, void** styleGroup);
-CGFontRef (*wkGetCGFontFromNSFont)(NSFont*);
NSFont* (*wkGetFontInLanguageForRange)(NSFont*, NSString*, NSRange);
NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar);
BOOL (*wkGetGlyphTransformedAdvances)(CGFontRef, NSFont*, CGAffineTransform*, ATSGlyphRef*, CGSize* advance);
NSString* (*wkGetPreferredExtensionForMIMEType)(NSString*);
NSArray* (*wkGetExtensionsForMIMEType)(NSString*);
NSString* (*wkGetMIMETypeForExtension)(NSString*);
-ATSUFontID (*wkGetNSFontATSUFontId)(NSFont*);
NSTimeInterval (*wkGetNSURLResponseCalculatedExpiration)(NSURLResponse *response);
NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response);
BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response);
id (*wkCreateNSURLConnectionDelegateProxy)(void);
#ifdef BUILDING_ON_TIGER
+CGFontRef (*wkGetCGFontFromNSFont)(NSFont*);
void (*wkGetFontMetrics)(CGFontRef, int* ascent, int* descent, int* lineGap, unsigned* unitsPerEm);
+ATSUFontID (*wkGetNSFontATSUFontId)(NSFont*);
BOOL (*wkSupportsMultipartXMixedReplace)(NSMutableURLRequest *);
#endif
+2008-03-12 Dan Bernstein <mitz@apple.com>
+
+ Reviewed by Darin Adler and Sam Weinig.
+
+ - <rdar://problem/4433248> use CoreText API instead of SPI on Leopard
+
+ * WebCoreSupport/WebSystemInterface.m:
+ (InitWebCoreSystemInterface): Made WKGetCGFontFromNSFont and
+ WKGetNSFontATSUFontId Tiger-only.
+
2008-03-12 Darin Adler <darin@apple.com>
- fix http://bugs.webkit.org/show_bug.cgi?id=17794
INIT(DrawTextFieldCellFocusRing);
INIT(FontSmoothingModeIsLCD);
INIT(GetATSStyleGroup);
- INIT(GetCGFontFromNSFont);
INIT(GetExtensionsForMIMEType);
INIT(GetFontInLanguageForCharacter);
INIT(GetFontInLanguageForRange);
INIT(GetGlyphVectorNumGlyphs);
INIT(GetGlyphVectorRecordSize);
INIT(GetMIMETypeForExtension);
- INIT(GetNSFontATSUFontId);
INIT(GetNSURLResponseLastModifiedDate);
INIT(GetPreferredExtensionForMIMEType);
INIT(GetWheelEventDeltas);
INIT(QTMovieViewSetDrawSynchronously);
#ifdef BUILDING_ON_TIGER
+ INIT(GetCGFontFromNSFont);
INIT(GetFontMetrics);
+ INIT(GetNSFontATSUFontId);
INIT(SupportsMultipartXMixedReplace);
#endif
+2008-03-12 Dan Bernstein <mitz@apple.com>
+
+ Reviewed by Darin Adler and Sam Weinig.
+
+ - <rdar://problem/4433248> use CoreText API instead of SPI on Leopard
+
+ * WebKitSystemInterface.h:
+ * libWebKitSystemInterfaceLeopard.a:
+
2008-03-11 Steve Falkenburg <sfalken@apple.com>
Disable two PGO/LTCG specific warnings.
#endif
BOOL WKGetGlyphTransformedAdvances(CGFontRef, NSFont*, CGAffineTransform *m, ATSGlyphRef *glyph, CGSize *advance);
-CGFontRef WKGetCGFontFromNSFont(NSFont *font);
NSFont *WKGetFontInLanguageForRange(NSFont *font, NSString *string, NSRange range);
NSFont *WKGetFontInLanguageForCharacter(NSFont *font, UniChar ch);
void WKSetCGFontRenderingMode(CGContextRef cgContext, NSFont *font);
-ATSUFontID WKGetNSFontATSUFontId(NSFont *font);
void WKReleaseStyleGroup(void *group);
BOOL WKCGContextGetShouldSmoothFonts(CGContextRef cgContext);
#ifdef BUILDING_ON_TIGER
// CGFontGetAscent, CGFontGetDescent, CGFontGetLeading and CGFontGetUnitsPerEm were not available until Leopard
void WKGetFontMetrics(CGFontRef font, int *ascent, int *descent, int *lineGap, unsigned *unitsPerEm);
+// CTFontCopyGraphicsFont was not available until Leopard
+CGFontRef WKGetCGFontFromNSFont(NSFont *font);
+// CTFontGetPlatformFont was not available until Leopard
+ATSUFontID WKGetNSFontATSUFontId(NSFont *font);
#endif
void WKSetPatternBaseCTM(CGContextRef, CGAffineTransform);