2010-02-25 22:36:07 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-02-25 22:36:07 -08:00
|
|
|
|
|
|
|
#ifndef GFX_WINDOWSDWRITEFONTS_H
|
|
|
|
#define GFX_WINDOWSDWRITEFONTS_H
|
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2010-02-25 22:36:07 -08:00
|
|
|
#include <dwrite.h>
|
|
|
|
|
|
|
|
#include "gfxFont.h"
|
|
|
|
#include "gfxUserFontSet.h"
|
|
|
|
#include "cairo-win32.h"
|
|
|
|
|
2010-06-11 12:14:38 -07:00
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
|
2010-02-25 22:36:07 -08:00
|
|
|
/**
|
|
|
|
* \brief Class representing a font face for a font entry.
|
|
|
|
*/
|
|
|
|
class gfxDWriteFont : public gfxFont
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
gfxDWriteFont(gfxFontEntry *aFontEntry,
|
2010-03-11 20:25:35 -08:00
|
|
|
const gfxFontStyle *aFontStyle,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNeedsBold = false,
|
2010-06-10 11:19:51 -07:00
|
|
|
AntialiasOption = kAntialiasDefault);
|
2010-02-25 22:36:07 -08:00
|
|
|
~gfxDWriteFont();
|
|
|
|
|
2014-11-17 01:59:50 -08:00
|
|
|
virtual gfxFont*
|
|
|
|
CopyWithAntialiasOption(AntialiasOption anAAOption) MOZ_OVERRIDE;
|
2010-06-10 11:19:51 -07:00
|
|
|
|
2014-11-17 01:59:50 -08:00
|
|
|
virtual uint32_t GetSpaceGlyph() MOZ_OVERRIDE;
|
2010-02-25 22:36:07 -08:00
|
|
|
|
2014-11-17 01:59:50 -08:00
|
|
|
virtual bool SetupCairoFont(gfxContext *aContext) MOZ_OVERRIDE;
|
2010-02-25 22:36:07 -08:00
|
|
|
|
2014-11-17 01:59:50 -08:00
|
|
|
virtual bool AllowSubpixelAA() MOZ_OVERRIDE
|
|
|
|
{ return mAllowManualShowGlyphs; }
|
2012-05-24 08:43:55 -07:00
|
|
|
|
2014-11-17 01:59:50 -08:00
|
|
|
bool IsValid() const;
|
2010-03-12 03:57:49 -08:00
|
|
|
|
2014-11-17 01:59:50 -08:00
|
|
|
virtual gfxFloat GetAdjustedSize() const MOZ_OVERRIDE {
|
2011-01-21 08:44:32 -08:00
|
|
|
return mAdjustedSize;
|
|
|
|
}
|
2010-03-12 03:57:49 -08:00
|
|
|
|
2011-01-21 08:44:32 -08:00
|
|
|
IDWriteFontFace *GetFontFace();
|
2010-02-25 22:36:07 -08:00
|
|
|
|
2011-06-30 23:38:17 -07:00
|
|
|
/* override Measure to add padding for antialiasing */
|
|
|
|
virtual RunMetrics Measure(gfxTextRun *aTextRun,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aStart, uint32_t aEnd,
|
2011-06-30 23:38:17 -07:00
|
|
|
BoundingBoxType aBoundingBoxType,
|
|
|
|
gfxContext *aContextForTightBoundingBox,
|
2014-10-16 01:40:19 -07:00
|
|
|
Spacing *aSpacing,
|
2014-11-17 01:59:50 -08:00
|
|
|
uint16_t aOrientation) MOZ_OVERRIDE;
|
2011-06-30 23:38:17 -07:00
|
|
|
|
2014-11-17 01:59:50 -08:00
|
|
|
virtual bool ProvidesGlyphWidths() const MOZ_OVERRIDE;
|
2011-01-04 08:58:31 -08:00
|
|
|
|
2014-11-17 01:59:50 -08:00
|
|
|
virtual int32_t GetGlyphWidth(DrawTarget& aDrawTarget,
|
|
|
|
uint16_t aGID) MOZ_OVERRIDE;
|
2011-01-04 08:58:31 -08:00
|
|
|
|
2014-10-24 09:32:23 -07:00
|
|
|
virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions>
|
2014-11-17 01:59:50 -08:00
|
|
|
GetGlyphRenderingOptions(const TextRunDrawParams* aRunParams = nullptr) MOZ_OVERRIDE;
|
2012-03-19 12:20:18 -07:00
|
|
|
|
2013-10-14 19:19:47 -07:00
|
|
|
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
|
|
|
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
2012-03-23 05:14:16 -07:00
|
|
|
|
2012-04-11 07:55:31 -07:00
|
|
|
virtual FontType GetType() const { return FONT_TYPE_DWRITE; }
|
|
|
|
|
2014-11-17 01:59:50 -08:00
|
|
|
virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
|
|
|
|
GetScaledFont(mozilla::gfx::DrawTarget *aTarget) MOZ_OVERRIDE;
|
2012-09-24 08:02:49 -07:00
|
|
|
|
2014-11-17 01:59:50 -08:00
|
|
|
virtual cairo_scaled_font_t *GetCairoScaledFont() MOZ_OVERRIDE;
|
2012-11-12 11:35:49 -08:00
|
|
|
|
2010-04-06 13:19:39 -07:00
|
|
|
protected:
|
2014-11-17 01:59:50 -08:00
|
|
|
virtual const Metrics& GetHorizontalMetrics() MOZ_OVERRIDE;
|
2014-09-29 23:37:40 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics);
|
2011-03-23 20:01:14 -07:00
|
|
|
|
2011-06-02 21:31:08 -07:00
|
|
|
void ComputeMetrics(AntialiasOption anAAOption);
|
2010-02-25 22:36:07 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
bool HasBitmapStrikeForSize(uint32_t aSize);
|
2011-01-21 02:36:28 -08:00
|
|
|
|
2010-02-25 22:36:07 -08:00
|
|
|
cairo_font_face_t *CairoFontFace();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
gfxFloat MeasureGlyphWidth(uint16_t aGlyph);
|
2011-04-20 23:29:50 -07:00
|
|
|
|
2011-06-02 21:31:07 -07:00
|
|
|
DWRITE_MEASURING_MODE GetMeasuringMode();
|
2011-06-02 21:31:08 -07:00
|
|
|
bool GetForceGDIClassic();
|
2011-06-02 21:31:07 -07:00
|
|
|
|
2010-02-25 22:36:07 -08:00
|
|
|
nsRefPtr<IDWriteFontFace> mFontFace;
|
|
|
|
cairo_font_face_t *mCairoFontFace;
|
|
|
|
|
2014-09-29 23:37:40 -07:00
|
|
|
Metrics *mMetrics;
|
2011-01-04 08:58:31 -08:00
|
|
|
|
|
|
|
// cache of glyph widths in 16.16 fixed-point pixels
|
2013-09-02 01:41:57 -07:00
|
|
|
nsAutoPtr<nsDataHashtable<nsUint32HashKey,int32_t> > mGlyphWidths;
|
2011-01-04 08:58:31 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mNeedsOblique;
|
|
|
|
bool mNeedsBold;
|
|
|
|
bool mUseSubpixelPositions;
|
|
|
|
bool mAllowManualShowGlyphs;
|
2012-09-24 08:02:49 -07:00
|
|
|
bool mAzureScaledFontIsCairo;
|
2010-02-25 22:36:07 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|