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