Bug 1686668 [wpt PR 27185] - Update wpt metadata, a=testonly
[gecko.git] / gfx / 2d / ScaledFontFontconfig.h
blobaefb097c823a12cde0bfd380de8e6b95ed9a249b
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_SCALEDFONTFONTCONFIG_H_
8 #define MOZILLA_GFX_SCALEDFONTFONTCONFIG_H_
10 #include "ScaledFontBase.h"
12 #include <cairo-ft.h>
14 namespace mozilla {
15 namespace gfx {
17 class NativeFontResourceFontconfig;
18 class UnscaledFontFontconfig;
20 class ScaledFontFontconfig : public ScaledFontBase {
21 public:
22 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontFontconfig, override)
23 ScaledFontFontconfig(RefPtr<SharedFTFace>&& aFace, FcPattern* aPattern,
24 const RefPtr<UnscaledFont>& aUnscaledFont, Float aSize);
26 FontType GetType() const override { return FontType::FONTCONFIG; }
28 #ifdef USE_SKIA
29 SkTypeface* CreateSkTypeface() override;
30 void SetupSkFontDrawOptions(SkFont& aFont) override;
31 #endif
33 AntialiasMode GetDefaultAAMode() override;
35 bool UseSubpixelPosition() const;
37 bool CanSerialize() override { return true; }
39 bool GetFontInstanceData(FontInstanceDataOutput aCb, void* aBaton) override;
41 bool GetWRFontInstanceOptions(
42 Maybe<wr::FontInstanceOptions>* aOutOptions,
43 Maybe<wr::FontInstancePlatformOptions>* aOutPlatformOptions,
44 std::vector<FontVariation>* aOutVariations) override;
46 bool HasVariationSettings() override;
48 protected:
49 #ifdef USE_CAIRO_SCALED_FONT
50 cairo_font_face_t* CreateCairoFontFace(
51 cairo_font_options_t* aFontOptions) override;
52 #endif
54 private:
55 friend class NativeFontResourceFontconfig;
56 friend class UnscaledFontFontconfig;
58 struct InstanceData {
59 enum {
60 AUTOHINT = 1 << 0,
61 EMBEDDED_BITMAP = 1 << 1,
62 EMBOLDEN = 1 << 2,
63 HINT_METRICS = 1 << 3,
64 LCD_VERTICAL = 1 << 4,
65 SUBPIXEL_BGR = 1 << 5,
68 explicit InstanceData(FcPattern* aPattern);
69 InstanceData(const wr::FontInstanceOptions* aOptions,
70 const wr::FontInstancePlatformOptions* aPlatformOptions);
72 void SetupFontOptions(cairo_font_options_t* aFontOptions,
73 int* aOutLoadFlags,
74 unsigned int* aOutSynthFlags) const;
76 uint8_t mFlags;
77 AntialiasMode mAntialias;
78 FontHinting mHinting;
79 uint8_t mLcdFilter;
82 ScaledFontFontconfig(RefPtr<SharedFTFace>&& aFace,
83 const InstanceData& aInstanceData,
84 const RefPtr<UnscaledFont>& aUnscaledFont, Float aSize);
86 RefPtr<SharedFTFace> mFace;
87 InstanceData mInstanceData;
90 } // namespace gfx
91 } // namespace mozilla
93 #endif /* MOZILLA_GFX_SCALEDFONTFONTCONFIG_H_ */