1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/gfxDWriteFonts.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,106 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 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 GFX_WINDOWSDWRITEFONTS_H 1.10 +#define GFX_WINDOWSDWRITEFONTS_H 1.11 + 1.12 +#include "mozilla/MemoryReporting.h" 1.13 +#include <dwrite.h> 1.14 + 1.15 +#include "gfxFont.h" 1.16 +#include "gfxUserFontSet.h" 1.17 +#include "cairo-win32.h" 1.18 + 1.19 +#include "nsDataHashtable.h" 1.20 +#include "nsHashKeys.h" 1.21 + 1.22 +/** 1.23 + * \brief Class representing a font face for a font entry. 1.24 + */ 1.25 +class gfxDWriteFont : public gfxFont 1.26 +{ 1.27 +public: 1.28 + gfxDWriteFont(gfxFontEntry *aFontEntry, 1.29 + const gfxFontStyle *aFontStyle, 1.30 + bool aNeedsBold = false, 1.31 + AntialiasOption = kAntialiasDefault); 1.32 + ~gfxDWriteFont(); 1.33 + 1.34 + virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption); 1.35 + 1.36 + virtual const gfxFont::Metrics& GetMetrics(); 1.37 + 1.38 + virtual uint32_t GetSpaceGlyph(); 1.39 + 1.40 + virtual bool SetupCairoFont(gfxContext *aContext); 1.41 + 1.42 + virtual bool AllowSubpixelAA() { return mAllowManualShowGlyphs; } 1.43 + 1.44 + virtual bool IsValid(); 1.45 + 1.46 + gfxFloat GetAdjustedSize() { 1.47 + return mAdjustedSize; 1.48 + } 1.49 + 1.50 + IDWriteFontFace *GetFontFace(); 1.51 + 1.52 + /* override Measure to add padding for antialiasing */ 1.53 + virtual RunMetrics Measure(gfxTextRun *aTextRun, 1.54 + uint32_t aStart, uint32_t aEnd, 1.55 + BoundingBoxType aBoundingBoxType, 1.56 + gfxContext *aContextForTightBoundingBox, 1.57 + Spacing *aSpacing); 1.58 + 1.59 + virtual bool ProvidesGlyphWidths(); 1.60 + 1.61 + virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID); 1.62 + 1.63 + virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions(); 1.64 + 1.65 + virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, 1.66 + FontCacheSizes* aSizes) const; 1.67 + virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, 1.68 + FontCacheSizes* aSizes) const; 1.69 + 1.70 + virtual FontType GetType() const { return FONT_TYPE_DWRITE; } 1.71 + 1.72 + virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont> GetScaledFont(mozilla::gfx::DrawTarget *aTarget); 1.73 + 1.74 + virtual cairo_scaled_font_t *GetCairoScaledFont(); 1.75 + 1.76 +protected: 1.77 + friend class gfxDWriteShaper; 1.78 + 1.79 + virtual void CreatePlatformShaper(); 1.80 + 1.81 + bool GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics); 1.82 + 1.83 + void ComputeMetrics(AntialiasOption anAAOption); 1.84 + 1.85 + bool HasBitmapStrikeForSize(uint32_t aSize); 1.86 + 1.87 + cairo_font_face_t *CairoFontFace(); 1.88 + 1.89 + gfxFloat MeasureGlyphWidth(uint16_t aGlyph); 1.90 + 1.91 + DWRITE_MEASURING_MODE GetMeasuringMode(); 1.92 + bool GetForceGDIClassic(); 1.93 + 1.94 + nsRefPtr<IDWriteFontFace> mFontFace; 1.95 + cairo_font_face_t *mCairoFontFace; 1.96 + 1.97 + gfxFont::Metrics *mMetrics; 1.98 + 1.99 + // cache of glyph widths in 16.16 fixed-point pixels 1.100 + nsAutoPtr<nsDataHashtable<nsUint32HashKey,int32_t> > mGlyphWidths; 1.101 + 1.102 + bool mNeedsOblique; 1.103 + bool mNeedsBold; 1.104 + bool mUseSubpixelPositions; 1.105 + bool mAllowManualShowGlyphs; 1.106 + bool mAzureScaledFontIsCairo; 1.107 +}; 1.108 + 1.109 +#endif