tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ScaledFontFreeType.h (2170B)


      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/. */
      6 
      7 #ifndef MOZILLA_GFX_SCALEDFONTCAIRO_H_
      8 #define MOZILLA_GFX_SCALEDFONTCAIRO_H_
      9 
     10 #include "ScaledFontBase.h"
     11 
     12 #include <cairo-ft.h>
     13 
     14 namespace mozilla {
     15 namespace gfx {
     16 
     17 class UnscaledFontFreeType;
     18 
     19 class ScaledFontFreeType : public ScaledFontBase {
     20 public:
     21  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontFreeType, override)
     22 
     23  ScaledFontFreeType(RefPtr<SharedFTFace>&& aFace,
     24                     const RefPtr<UnscaledFont>& aUnscaledFont, Float aSize,
     25                     bool aApplySyntheticBold = false);
     26 
     27  FontType GetType() const override { return FontType::FREETYPE; }
     28 
     29  SkTypeface* CreateSkTypeface() override;
     30  void SetupSkFontDrawOptions(SkFont& aFont) override;
     31 
     32  AntialiasMode GetDefaultAAMode() override { return AntialiasMode::GRAY; }
     33 
     34  bool UseSubpixelPosition() const override;
     35 
     36  bool CanSerialize() override { return true; }
     37 
     38  bool MayUseBitmaps() override;
     39 
     40  bool GetFontInstanceData(FontInstanceDataOutput aCb, void* aBaton) override;
     41 
     42  bool GetWRFontInstanceOptions(
     43      Maybe<wr::FontInstanceOptions>* aOutOptions,
     44      Maybe<wr::FontInstancePlatformOptions>* aOutPlatformOptions,
     45      std::vector<FontVariation>* aOutVariations) override;
     46 
     47  bool HasVariationSettings() override;
     48 
     49 protected:
     50  cairo_font_face_t* CreateCairoFontFace(
     51      cairo_font_options_t* aFontOptions) override;
     52 
     53 private:
     54  friend UnscaledFontFreeType;
     55 
     56  RefPtr<SharedFTFace> mFace;
     57 
     58  bool mApplySyntheticBold;
     59 
     60  struct InstanceData {
     61    explicit InstanceData(ScaledFontFreeType* aScaledFont)
     62        : mApplySyntheticBold(aScaledFont->mApplySyntheticBold) {}
     63 
     64    InstanceData(const wr::FontInstanceOptions* aOptions,
     65                 const wr::FontInstancePlatformOptions* aPlatformOptions);
     66 
     67    bool mApplySyntheticBold;
     68  };
     69 };
     70 
     71 }  // namespace gfx
     72 }  // namespace mozilla
     73 
     74 #endif /* MOZILLA_GFX_SCALEDFONTCAIRO_H_ */