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