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/. */
7 #ifndef MOZILLA_GFX_SCALEDFONTBASE_H_
8 #define MOZILLA_GFX_SCALEDFONTBASE_H_
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
21 class ScaledFontBase
: public ScaledFont
{
23 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontBase
, override
)
25 ScaledFontBase(const RefPtr
<UnscaledFont
>& aUnscaledFont
, Float aSize
);
26 virtual ~ScaledFontBase();
28 virtual already_AddRefed
<Path
> GetPathForGlyphs(
29 const GlyphBuffer
& aBuffer
, const DrawTarget
* aTarget
) override
;
31 virtual void CopyGlyphsToBuilder(const GlyphBuffer
& aBuffer
,
32 PathBuilder
* aBuilder
,
33 const Matrix
* aTransformHint
) override
;
35 virtual Float
GetSize() const override
{ return mSize
; }
37 SkTypeface
* GetSkTypeface();
38 virtual void SetupSkFontDrawOptions(SkFont
& aFont
) {}
40 virtual cairo_scaled_font_t
* GetCairoScaledFont() override
;
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
) {
51 virtual void PrepareCairoScaledFont(cairo_scaled_font_t
* aFont
) {}
52 cairo_scaled_font_t
* mScaledFont
;
57 } // namespace mozilla
59 #endif /* MOZILLA_GFX_SCALEDFONTBASE_H_ */