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
|
|
|
|
|
|
|
|
#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();
|
|
|
|
|
2010-06-10 11:19:51 -07:00
|
|
|
virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption);
|
|
|
|
|
2010-02-25 22:36:07 -08:00
|
|
|
virtual const gfxFont::Metrics& GetMetrics();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t GetSpaceGlyph();
|
2010-02-25 22:36:07 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool SetupCairoFont(gfxContext *aContext);
|
2010-02-25 22:36:07 -08:00
|
|
|
|
2012-05-24 08:43:55 -07:00
|
|
|
virtual bool AllowSubpixelAA() { return mAllowManualShowGlyphs; }
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsValid();
|
2010-03-12 03:57:49 -08:00
|
|
|
|
2011-01-21 08:44:32 -08:00
|
|
|
gfxFloat GetAdjustedSize() {
|
|
|
|
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,
|
|
|
|
Spacing *aSpacing);
|
|
|
|
|
2010-06-11 12:14:38 -07:00
|
|
|
// override gfxFont table access function to bypass gfxFontEntry cache,
|
|
|
|
// use DWrite API to get direct access to system font data
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual hb_blob_t *GetFontTable(uint32_t aTag);
|
2010-06-11 12:14:38 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ProvidesGlyphWidths();
|
2011-01-04 08:58:31 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID);
|
2011-01-04 08:58:31 -08:00
|
|
|
|
2012-03-19 12:20:18 -07:00
|
|
|
virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions();
|
|
|
|
|
2012-03-23 05:14:16 -07:00
|
|
|
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
|
|
|
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
|
|
|
|
2012-04-11 07:55:31 -07:00
|
|
|
virtual FontType GetType() const { return FONT_TYPE_DWRITE; }
|
|
|
|
|
2010-04-06 13:19:39 -07:00
|
|
|
protected:
|
2011-01-21 02:35:21 -08:00
|
|
|
friend class gfxDWriteShaper;
|
|
|
|
|
2009-10-07 10:16:52 -07:00
|
|
|
virtual void CreatePlatformShaper();
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
cairo_scaled_font_t *CairoScaledFont();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
gfxFloat MeasureGlyphWidth(uint16_t aGlyph);
|
2011-04-20 23:29:50 -07:00
|
|
|
|
2010-06-11 12:14:38 -07:00
|
|
|
static void DestroyBlobFunc(void* userArg);
|
|
|
|
|
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;
|
|
|
|
|
2011-01-21 08:44:32 -08:00
|
|
|
gfxFont::Metrics *mMetrics;
|
2011-01-04 08:58:31 -08:00
|
|
|
|
|
|
|
// cache of glyph widths in 16.16 fixed-point pixels
|
2012-08-22 08:56:38 -07:00
|
|
|
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;
|
2010-02-25 22:36:07 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|