gfx/thebes/gfxDWriteFonts.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef GFX_WINDOWSDWRITEFONTS_H
     7 #define GFX_WINDOWSDWRITEFONTS_H
     9 #include "mozilla/MemoryReporting.h"
    10 #include <dwrite.h>
    12 #include "gfxFont.h"
    13 #include "gfxUserFontSet.h"
    14 #include "cairo-win32.h"
    16 #include "nsDataHashtable.h"
    17 #include "nsHashKeys.h"
    19 /**
    20  * \brief Class representing a font face for a font entry.
    21  */
    22 class gfxDWriteFont : public gfxFont 
    23 {
    24 public:
    25     gfxDWriteFont(gfxFontEntry *aFontEntry,
    26                   const gfxFontStyle *aFontStyle,
    27                   bool aNeedsBold = false,
    28                   AntialiasOption = kAntialiasDefault);
    29     ~gfxDWriteFont();
    31     virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption);
    33     virtual const gfxFont::Metrics& GetMetrics();
    35     virtual uint32_t GetSpaceGlyph();
    37     virtual bool SetupCairoFont(gfxContext *aContext);
    39     virtual bool AllowSubpixelAA() { return mAllowManualShowGlyphs; }
    41     virtual bool IsValid();
    43     gfxFloat GetAdjustedSize() {
    44         return mAdjustedSize;
    45     }
    47     IDWriteFontFace *GetFontFace();
    49     /* override Measure to add padding for antialiasing */
    50     virtual RunMetrics Measure(gfxTextRun *aTextRun,
    51                                uint32_t aStart, uint32_t aEnd,
    52                                BoundingBoxType aBoundingBoxType,
    53                                gfxContext *aContextForTightBoundingBox,
    54                                Spacing *aSpacing);
    56     virtual bool ProvidesGlyphWidths();
    58     virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID);
    60     virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions();
    62     virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
    63                                         FontCacheSizes* aSizes) const;
    64     virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
    65                                         FontCacheSizes* aSizes) const;
    67     virtual FontType GetType() const { return FONT_TYPE_DWRITE; }
    69     virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont> GetScaledFont(mozilla::gfx::DrawTarget *aTarget);
    71     virtual cairo_scaled_font_t *GetCairoScaledFont();
    73 protected:
    74     friend class gfxDWriteShaper;
    76     virtual void CreatePlatformShaper();
    78     bool GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics);
    80     void ComputeMetrics(AntialiasOption anAAOption);
    82     bool HasBitmapStrikeForSize(uint32_t aSize);
    84     cairo_font_face_t *CairoFontFace();
    86     gfxFloat MeasureGlyphWidth(uint16_t aGlyph);
    88     DWRITE_MEASURING_MODE GetMeasuringMode();
    89     bool GetForceGDIClassic();
    91     nsRefPtr<IDWriteFontFace> mFontFace;
    92     cairo_font_face_t *mCairoFontFace;
    94     gfxFont::Metrics          *mMetrics;
    96     // cache of glyph widths in 16.16 fixed-point pixels
    97     nsAutoPtr<nsDataHashtable<nsUint32HashKey,int32_t> > mGlyphWidths;
    99     bool mNeedsOblique;
   100     bool mNeedsBold;
   101     bool mUseSubpixelPositions;
   102     bool mAllowManualShowGlyphs;
   103     bool mAzureScaledFontIsCairo;
   104 };
   106 #endif

mercurial