Bug 1638136 [wpt PR 23617] - Clipboard API Tests: Move permissions tests to WPT....
[gecko.git] / gfx / 2d / ScaledFontFreeType.h
blob3d4e18472bb884f4a3b275f4a45e25be97327632
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"
12 #include <cairo-ft.h>
14 namespace mozilla {
15 namespace gfx {
17 class UnscaledFontFreeType;
19 class ScaledFontFreeType : public ScaledFontBase {
20 public:
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; }
29 #ifdef USE_SKIA
30 SkTypeface* CreateSkTypeface() override;
31 void SetupSkFontDrawOptions(SkFont& aFont) override;
32 #endif
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;
49 protected:
50 #ifdef USE_CAIRO_SCALED_FONT
51 cairo_font_face_t* CreateCairoFontFace(
52 cairo_font_options_t* aFontOptions) override;
53 #endif
55 private:
56 friend UnscaledFontFreeType;
58 RefPtr<SharedFTFace> mFace;
60 bool mApplySyntheticBold;
62 struct InstanceData {
63 explicit InstanceData(ScaledFontFreeType* aScaledFont)
64 : mApplySyntheticBold(aScaledFont->mApplySyntheticBold) {}
66 InstanceData(const wr::FontInstanceOptions* aOptions,
67 const wr::FontInstancePlatformOptions* aPlatformOptions);
69 bool mApplySyntheticBold;
73 } // namespace gfx
74 } // namespace mozilla
76 #endif /* MOZILLA_GFX_SCALEDFONTCAIRO_H_ */