2012-02-13 11:58:01 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-02-13 11:58:01 -08:00
|
|
|
|
|
|
|
#include "ScaledFontFreetype.h"
|
2012-05-16 15:30:10 -07:00
|
|
|
#include "Logging.h"
|
2012-02-13 11:58:01 -08:00
|
|
|
|
|
|
|
#include "gfxFont.h"
|
|
|
|
|
|
|
|
#ifdef USE_SKIA
|
|
|
|
#include "skia/SkTypeface.h"
|
|
|
|
#endif
|
|
|
|
|
2012-05-16 15:30:10 -07:00
|
|
|
#include <string>
|
|
|
|
|
2012-02-13 11:58:01 -08:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
#ifdef USE_SKIA
|
|
|
|
static SkTypeface::Style
|
2012-05-16 15:30:10 -07:00
|
|
|
fontStyleToSkia(FontStyle aStyle)
|
2012-02-13 11:58:01 -08:00
|
|
|
{
|
2012-05-16 15:30:10 -07:00
|
|
|
switch (aStyle) {
|
|
|
|
case FONT_STYLE_NORMAL:
|
|
|
|
return SkTypeface::kNormal;
|
|
|
|
case FONT_STYLE_ITALIC:
|
2012-02-13 11:58:01 -08:00
|
|
|
return SkTypeface::kItalic;
|
2012-05-16 15:30:10 -07:00
|
|
|
case FONT_STYLE_BOLD:
|
2012-02-13 11:58:01 -08:00
|
|
|
return SkTypeface::kBold;
|
2012-05-16 15:30:10 -07:00
|
|
|
case FONT_STYLE_BOLD_ITALIC:
|
|
|
|
return SkTypeface::kBoldItalic;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxWarning() << "Unknown font style";
|
2012-02-13 11:58:01 -08:00
|
|
|
return SkTypeface::kNormal;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Ideally we want to use FT_Face here but as there is currently no way to get
|
|
|
|
// an SkTypeface from an FT_Face we do this.
|
2012-05-16 15:30:10 -07:00
|
|
|
ScaledFontFreetype::ScaledFontFreetype(FontOptions* aFont, Float aSize)
|
2012-02-13 11:58:01 -08:00
|
|
|
: ScaledFontBase(aSize)
|
|
|
|
{
|
|
|
|
#ifdef USE_SKIA
|
2012-05-16 15:30:10 -07:00
|
|
|
mTypeface = SkTypeface::CreateFromName(aFont->mName.c_str(), fontStyleToSkia(aFont->mStyle));
|
2012-02-13 11:58:01 -08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|