FontCustomPlatformData.cpp [plain text]
#include "config.h"
#include "FontCustomPlatformData.h"
#include "FontPlatformData.h"
#include "SharedBuffer.h"
#include <CoreGraphics/CoreGraphics.h>
namespace WebCore {
FontCustomPlatformData::~FontCustomPlatformData()
{
}
FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant widthVariant, FontRenderingMode)
{
return FontPlatformData(m_cgFont.get(), size, bold, italic, orientation, widthVariant);
}
std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer& buffer)
{
ATSFontContainerRef containerRef = 0;
RetainPtr<CFDataRef> bufferData = buffer.createCFData();
RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithCFData(bufferData.get()));
RetainPtr<CGFontRef> cgFontRef = adoptCF(CGFontCreateWithDataProvider(dataProvider.get()));
if (!cgFontRef)
return nullptr;
return std::make_unique<FontCustomPlatformData>(containerRef, cgFontRef.get());
}
bool FontCustomPlatformData::supportsFormat(const String& format)
{
return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype") || equalIgnoringCase(format, "woff");
}
}