2013-06-05 21:48:59 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* 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/. */
|
|
|
|
|
|
|
|
#include "ScaledFontCairo.h"
|
|
|
|
#include "Logging.h"
|
|
|
|
|
|
|
|
#if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
|
2015-07-29 23:31:40 +03:00
|
|
|
#include "skia/include/ports/SkTypeface_cairo.h"
|
2013-06-05 21:48:59 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
// On Linux and Android our "platform" font is a cairo_scaled_font_t and we use
|
|
|
|
// an SkFontHost implementation that allows Skia to render using this.
|
|
|
|
// This is mainly because FT_Face is not good for sharing between libraries, which
|
|
|
|
// is a requirement when we consider runtime switchable backends and so on
|
2017-04-07 00:41:02 +03:00
|
|
|
ScaledFontCairo::ScaledFontCairo(cairo_scaled_font_t* aScaledFont,
|
|
|
|
const RefPtr<UnscaledFont>& aUnscaledFont,
|
|
|
|
Float aSize)
|
|
|
|
: ScaledFontBase(aUnscaledFont, aSize)
|
|
|
|
{
|
2013-06-29 06:50:59 +04:00
|
|
|
SetCairoScaledFont(aScaledFont);
|
2013-06-29 06:50:09 +04:00
|
|
|
}
|
|
|
|
|
2013-06-05 21:48:59 +04:00
|
|
|
#if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
|
2013-06-29 06:50:09 +04:00
|
|
|
SkTypeface* ScaledFontCairo::GetSkTypeface()
|
|
|
|
{
|
|
|
|
if (!mTypeface) {
|
2016-07-20 22:07:11 +03:00
|
|
|
mTypeface = SkCreateTypefaceFromCairoFTFont(mScaledFont);
|
2013-06-29 06:50:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return mTypeface;
|
2013-06-05 21:48:59 +04:00
|
|
|
}
|
2013-06-29 06:50:09 +04:00
|
|
|
#endif
|
2013-06-05 21:48:59 +04:00
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|