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_SCALEDFONTCAIRO_H_
8 #define MOZILLA_GFX_SCALEDFONTCAIRO_H_
10 #include "ScaledFontBase.h"
17 class UnscaledFontFreeType
;
19 class ScaledFontFreeType
: public ScaledFontBase
{
21 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontFreeType
, override
)
23 ScaledFontFreeType(RefPtr
<SharedFTFace
>&& aFace
,
24 const RefPtr
<UnscaledFont
>& aUnscaledFont
, Float aSize
,
25 bool aApplySyntheticBold
= false);
27 FontType
GetType() const override
{ return FontType::FREETYPE
; }
30 SkTypeface
* CreateSkTypeface() override
;
31 void SetupSkFontDrawOptions(SkFont
& aFont
) override
;
34 AntialiasMode
GetDefaultAAMode() override
{ return AntialiasMode::GRAY
; }
36 bool UseSubpixelPosition() const;
38 bool CanSerialize() override
{ return true; }
40 bool GetFontInstanceData(FontInstanceDataOutput aCb
, void* aBaton
) override
;
42 bool GetWRFontInstanceOptions(
43 Maybe
<wr::FontInstanceOptions
>* aOutOptions
,
44 Maybe
<wr::FontInstancePlatformOptions
>* aOutPlatformOptions
,
45 std::vector
<FontVariation
>* aOutVariations
) override
;
47 bool HasVariationSettings() override
;
50 #ifdef USE_CAIRO_SCALED_FONT
51 cairo_font_face_t
* CreateCairoFontFace(
52 cairo_font_options_t
* aFontOptions
) override
;
56 friend UnscaledFontFreeType
;
58 RefPtr
<SharedFTFace
> mFace
;
60 bool mApplySyntheticBold
;
63 explicit InstanceData(ScaledFontFreeType
* aScaledFont
)
64 : mApplySyntheticBold(aScaledFont
->mApplySyntheticBold
) {}
66 InstanceData(const wr::FontInstanceOptions
* aOptions
,
67 const wr::FontInstancePlatformOptions
* aPlatformOptions
);
69 bool mApplySyntheticBold
;
74 } // namespace mozilla
76 #endif /* MOZILLA_GFX_SCALEDFONTCAIRO_H_ */