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