Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "ScaledFontCairo.h"
7 : #include "Logging.h"
8 :
9 : #if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
10 : #include "skia/include/ports/SkTypeface_cairo.h"
11 : #endif
12 :
13 : namespace mozilla {
14 : namespace gfx {
15 :
16 : // On Linux and Android our "platform" font is a cairo_scaled_font_t and we use
17 : // an SkFontHost implementation that allows Skia to render using this.
18 : // This is mainly because FT_Face is not good for sharing between libraries, which
19 : // is a requirement when we consider runtime switchable backends and so on
20 0 : ScaledFontCairo::ScaledFontCairo(cairo_scaled_font_t* aScaledFont,
21 : const RefPtr<UnscaledFont>& aUnscaledFont,
22 0 : Float aSize)
23 0 : : ScaledFontBase(aUnscaledFont, aSize)
24 : {
25 0 : SetCairoScaledFont(aScaledFont);
26 0 : }
27 :
28 : #if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
29 0 : SkTypeface* ScaledFontCairo::GetSkTypeface()
30 : {
31 0 : if (!mTypeface) {
32 0 : mTypeface = SkCreateTypefaceFromCairoFTFont(mScaledFont);
33 : }
34 :
35 0 : return mTypeface;
36 : }
37 : #endif
38 :
39 : } // namespace gfx
40 : } // namespace mozilla
|