#include "ScaledFontSkia.h"
#include "Logging.h"
#include "SkTypeface.h"
#include "SkStream.h"
#include <string>
using namespace std;
namespace mozilla {
namespace gfx {
#ifdef USE_SKIA
static SkTypeface::Style
fontStyleToSkia(FontStyle aStyle)
{
switch (aStyle) {
case FontStyle::NORMAL:
return SkTypeface::kNormal;
case FontStyle::ITALIC:
return SkTypeface::kItalic;
case FontStyle::BOLD:
return SkTypeface::kBold;
case FontStyle::BOLD_ITALIC:
return SkTypeface::kBoldItalic;
}
gfxWarning() << "Unknown font style";
return SkTypeface::kNormal;
}
#endif
ScaledFontSkia::ScaledFontSkia(FontOptions* aFont, Float aSize)
: ScaledFontBase(aSize)
{
mTypeface = SkTypeface::CreateFromName(aFont->mName.c_str(), fontStyleToSkia(aFont->mStyle));
}
ScaledFontSkia::ScaledFontSkia(const uint8_t* aData, uint32_t aFileSize, uint32_t aIndex, Float aSize)
: ScaledFontBase(aSize)
{
SkStream *stream = new SkMemoryStream(aData, aFileSize, true);
mTypeface = SkTypeface::CreateFromStream(stream);
}
ScaledFontSkia::~ScaledFontSkia()
{
}
}
}