gfx/2d/ScaledFontCairo.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/2d/ScaledFontCairo.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,56 @@
     1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef MOZILLA_GFX_SCALEDFONTCAIRO_H_
    1.10 +#define MOZILLA_GFX_SCALEDFONTCAIRO_H_
    1.11 +
    1.12 +#include "ScaledFontBase.h"
    1.13 +
    1.14 +#include "cairo.h"
    1.15 +
    1.16 +namespace mozilla {
    1.17 +namespace gfx {
    1.18 +
    1.19 +class ScaledFontCairo : public ScaledFontBase
    1.20 +{
    1.21 +public:
    1.22 +  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontCairo)
    1.23 +
    1.24 +  ScaledFontCairo(cairo_scaled_font_t* aScaledFont, Float aSize);
    1.25 +
    1.26 +#if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
    1.27 +  virtual SkTypeface* GetSkTypeface();
    1.28 +#endif
    1.29 +};
    1.30 +
    1.31 +// We need to be able to tell Skia whether or not to use
    1.32 +// hinting when rendering text, so that the glyphs it renders
    1.33 +// are the same as what layout is expecting. At the moment, only
    1.34 +// Skia uses this class when rendering with FreeType, as gfxFT2Font
    1.35 +// is the only gfxFont that honours gfxPlatform::FontHintingEnabled().
    1.36 +class GlyphRenderingOptionsCairo : public GlyphRenderingOptions
    1.37 +{
    1.38 +public:
    1.39 +  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GlyphRenderingOptionsCairo)
    1.40 +  GlyphRenderingOptionsCairo()
    1.41 +    : mHinting(FontHinting::NORMAL)
    1.42 +    , mAutoHinting(false)
    1.43 +  {
    1.44 +  }
    1.45 +
    1.46 +  void SetHinting(FontHinting aHinting) { mHinting = aHinting; }
    1.47 +  void SetAutoHinting(bool aAutoHinting) { mAutoHinting = aAutoHinting; }
    1.48 +  FontHinting GetHinting() const { return mHinting; }
    1.49 +  bool GetAutoHinting() const { return mAutoHinting; }
    1.50 +  virtual FontType GetType() const { return FontType::CAIRO; }
    1.51 +private:
    1.52 +  FontHinting mHinting;
    1.53 +  bool mAutoHinting;
    1.54 +};
    1.55 +
    1.56 +}
    1.57 +}
    1.58 +
    1.59 +#endif /* MOZILLA_GFX_SCALEDFONTCAIRO_H_ */

mercurial