no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / gfx / 2d / ScaledFontDWrite.h
blobda1568b8caf1b934b5b543c0360be7dbe9f98638
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_SCALEDFONTDWRITE_H_
8 #define MOZILLA_GFX_SCALEDFONTDWRITE_H_
10 #include <dwrite.h>
11 #include "DWriteSettings.h"
12 #include "ScaledFontBase.h"
14 struct ID2D1GeometrySink;
15 struct gfxFontStyle;
17 namespace mozilla {
18 namespace gfx {
20 class NativeFontResourceDWrite;
21 class UnscaledFontDWrite;
23 class ScaledFontDWrite final : public ScaledFontBase {
24 public:
25 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontDWrite, override)
26 ScaledFontDWrite(IDWriteFontFace* aFontFace,
27 const RefPtr<UnscaledFont>& aUnscaledFont, Float aSize,
28 bool aUseEmbeddedBitmap, bool aUseMultistrikeBold,
29 bool aGDIForced, const gfxFontStyle* aStyle);
31 FontType GetType() const override { return FontType::DWRITE; }
33 already_AddRefed<Path> GetPathForGlyphs(const GlyphBuffer& aBuffer,
34 const DrawTarget* aTarget) override;
35 void CopyGlyphsToBuilder(const GlyphBuffer& aBuffer, PathBuilder* aBuilder,
36 const Matrix* aTransformHint) override;
38 void CopyGlyphsToSink(const GlyphBuffer& aBuffer,
39 ID2D1SimplifiedGeometrySink* aSink);
41 bool CanSerialize() override { return true; }
43 bool MayUseBitmaps() override;
45 bool GetFontInstanceData(FontInstanceDataOutput aCb, void* aBaton) override;
47 bool GetWRFontInstanceOptions(
48 Maybe<wr::FontInstanceOptions>* aOutOptions,
49 Maybe<wr::FontInstancePlatformOptions>* aOutPlatformOptions,
50 std::vector<FontVariation>* aOutVariations) override;
52 DWriteSettings& DWriteSettings() const;
54 AntialiasMode GetDefaultAAMode() override;
56 bool UseEmbeddedBitmaps() const { return mUseEmbeddedBitmap; }
57 bool UseMultistrikeBold() const { return mUseMultistrikeBold; }
58 bool ForceGDIMode() const { return mGDIForced; }
60 bool UseSubpixelPosition() const override { return !ForceGDIMode(); }
62 bool HasBoldSimulation() const {
63 return (mFontFace->GetSimulations() & DWRITE_FONT_SIMULATIONS_BOLD) != 0;
66 bool HasVariationSettings() override;
68 SkTypeface* CreateSkTypeface() override;
69 void SetupSkFontDrawOptions(SkFont& aFont) override;
70 SkFontStyle mStyle;
72 RefPtr<IDWriteFontFace> mFontFace;
73 bool mUseEmbeddedBitmap;
74 bool mUseMultistrikeBold = false;
75 bool mGDIForced = false;
77 cairo_font_face_t* CreateCairoFontFace(
78 cairo_font_options_t* aFontOptions) override;
79 void PrepareCairoScaledFont(cairo_scaled_font_t* aFont) override;
81 private:
82 friend class NativeFontResourceDWrite;
83 friend class UnscaledFontDWrite;
85 struct InstanceData {
86 explicit InstanceData(ScaledFontDWrite* aScaledFont)
87 : mUseEmbeddedBitmap(aScaledFont->mUseEmbeddedBitmap),
88 mUseBoldSimulation(aScaledFont->HasBoldSimulation()),
89 mUseMultistrikeBold(aScaledFont->UseMultistrikeBold()),
90 mGDIForced(aScaledFont->mGDIForced) {}
92 InstanceData(const wr::FontInstanceOptions* aOptions,
93 const wr::FontInstancePlatformOptions* aPlatformOptions);
95 bool mUseEmbeddedBitmap = false;
96 bool mUseBoldSimulation = false;
97 bool mUseMultistrikeBold = false;
98 bool mGDIForced = false;
102 } // namespace gfx
103 } // namespace mozilla
105 #endif /* MOZILLA_GFX_SCALEDFONTDWRITE_H_ */