ScaledFontBase.h (1951B)
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 #ifndef MOZILLA_GFX_SCALEDFONTBASE_H_ 8 #define MOZILLA_GFX_SCALEDFONTBASE_H_ 9 10 #include "2D.h" 11 12 #include "skia/include/core/SkFont.h" 13 #include "skia/include/core/SkPath.h" 14 #include "skia/include/core/SkTypeface.h" 15 // Skia uses cairo_scaled_font_t as the internal font type in ScaledFont 16 #include "cairo.h" 17 18 namespace mozilla { 19 namespace gfx { 20 21 class ScaledFontBase : public ScaledFont { 22 public: 23 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontBase, override) 24 25 ScaledFontBase(const RefPtr<UnscaledFont>& aUnscaledFont, Float aSize); 26 virtual ~ScaledFontBase(); 27 28 virtual already_AddRefed<Path> GetPathForGlyphs( 29 const GlyphBuffer& aBuffer, const DrawTarget* aTarget) override; 30 31 virtual void CopyGlyphsToBuilder(const GlyphBuffer& aBuffer, 32 PathBuilder* aBuilder, 33 const Matrix* aTransformHint) override; 34 35 virtual Float GetSize() const override { return mSize; } 36 37 SkTypeface* GetSkTypeface(); 38 virtual void SetupSkFontDrawOptions(SkFont& aFont) {} 39 40 virtual cairo_scaled_font_t* GetCairoScaledFont() override; 41 42 protected: 43 friend class DrawTargetSkia; 44 Atomic<SkTypeface*> mTypeface; 45 virtual SkTypeface* CreateSkTypeface() { return nullptr; } 46 SkPath GetSkiaPathForGlyphs(const GlyphBuffer& aBuffer); 47 virtual cairo_font_face_t* CreateCairoFontFace( 48 cairo_font_options_t* aFontOptions) { 49 return nullptr; 50 } 51 virtual void PrepareCairoScaledFont(cairo_scaled_font_t* aFont) {} 52 cairo_scaled_font_t* mScaledFont; 53 Float mSize; 54 }; 55 56 } // namespace gfx 57 } // namespace mozilla 58 59 #endif /* MOZILLA_GFX_SCALEDFONTBASE_H_ */