FontPlatformData.h [plain text]
#ifndef FontPlatformData_H
#define FontPlatformData_H
#include "StringImpl.h"
#import <GraphicsServices/GSFont.h>
#ifdef __OBJC__
@class NSFont;
#else
class NSFont;
#endif
#include <CoreFoundation/CFBase.h>
#include <objc/objc-auto.h>
namespace WebCore {
struct FontPlatformData {
class Deleted {};
FontPlatformData(Deleted)
: font((GSFontRef)-1), syntheticBold(false), syntheticOblique(false)
{}
FontPlatformData(GSFontRef f = 0, bool b = false, bool o = false)
: font(f), syntheticBold(b), syntheticOblique(o)
{
if (f) CFRetain(f); }
FontPlatformData(const FontPlatformData& f)
{
font = (f.font && f.font != (GSFontRef)-1) ? (GSFontRef)CFRetain(f.font) : f.font;
syntheticBold = f.syntheticBold;
syntheticOblique = f.syntheticOblique;
}
~FontPlatformData()
{
if (font && font != (GSFontRef)-1) CFRelease(font);
}
GSFontRef font;
bool syntheticBold;
bool syntheticOblique;
unsigned hash() const
{
uintptr_t hashCodes[2] = { (uintptr_t)font, syntheticBold << 1 | syntheticOblique };
return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));
}
bool operator==(const FontPlatformData& other) const
{
return font == other.font && syntheticBold == other.syntheticBold && syntheticOblique == other.syntheticOblique;
}
};
}
#endif