2010-03-15 02:34:25 -07: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-03-15 02:34:25 -07:00
|
|
|
|
|
|
|
#ifndef GFX_GDIFONT_H
|
|
|
|
#define GFX_GDIFONT_H
|
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2010-03-15 02:34:25 -07:00
|
|
|
#include "gfxFont.h"
|
|
|
|
#include "gfxGDIFontList.h"
|
|
|
|
|
2009-10-07 10:16:52 -07:00
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
|
2010-03-15 02:34:25 -07:00
|
|
|
#include "cairo.h"
|
|
|
|
|
|
|
|
class gfxGDIFont : public gfxFont
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
gfxGDIFont(GDIFontEntry *aFontEntry,
|
|
|
|
const gfxFontStyle *aFontStyle,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNeedsBold,
|
2010-03-15 02:34:25 -07:00
|
|
|
AntialiasOption anAAOption = kAntialiasDefault);
|
|
|
|
|
|
|
|
virtual ~gfxGDIFont();
|
|
|
|
|
2010-06-25 05:43:10 -07:00
|
|
|
HFONT GetHFONT() { if (!mMetrics) Initialize(); return mFont; }
|
2010-03-15 02:34:25 -07:00
|
|
|
|
2011-01-21 08:44:32 -08:00
|
|
|
gfxFloat GetAdjustedSize() { if (!mMetrics) Initialize(); return mAdjustedSize; }
|
2010-03-15 02:34:25 -07:00
|
|
|
|
|
|
|
cairo_font_face_t *CairoFontFace() { return mFontFace; }
|
|
|
|
cairo_scaled_font_t *CairoScaledFont() { return mScaledFont; }
|
|
|
|
|
|
|
|
/* overrides for the pure virtual methods in gfxFont */
|
|
|
|
virtual const gfxFont::Metrics& GetMetrics();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t GetSpaceGlyph();
|
2010-03-15 02:34:25 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool SetupCairoFont(gfxContext *aContext);
|
2010-03-15 02:34:25 -07:00
|
|
|
|
2011-06-22 01:49:53 -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-22 01:49:53 -07:00
|
|
|
BoundingBoxType aBoundingBoxType,
|
|
|
|
gfxContext *aContextForTightBoundingBox,
|
|
|
|
Spacing *aSpacing);
|
|
|
|
|
2010-03-15 02:34:25 -07:00
|
|
|
/* required for MathML to suppress effects of ClearType "padding" */
|
|
|
|
virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ProvidesGlyphWidths() { return true; }
|
2011-01-07 04:38:28 -08:00
|
|
|
|
|
|
|
// get hinted glyph width in pixels as 16.16 fixed-point value
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID);
|
2011-01-07 04:38:28 -08:00
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
2012-03-23 05:14:16 -07:00
|
|
|
FontCacheSizes* aSizes) const;
|
2013-06-23 05:03:39 -07:00
|
|
|
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
2012-03-23 05:14:16 -07:00
|
|
|
FontCacheSizes* aSizes) const;
|
|
|
|
|
2012-04-11 07:55:31 -07:00
|
|
|
virtual FontType GetType() const { return FONT_TYPE_GDI; }
|
|
|
|
|
2011-01-07 04:38:28 -08:00
|
|
|
protected:
|
|
|
|
virtual void CreatePlatformShaper();
|
|
|
|
|
2010-03-15 02:34:25 -07:00
|
|
|
/* override to check for uniscribe failure and fall back to GDI */
|
2013-01-04 10:35:37 -08:00
|
|
|
virtual bool ShapeText(gfxContext *aContext,
|
|
|
|
const PRUnichar *aText,
|
|
|
|
uint32_t aOffset,
|
|
|
|
uint32_t aLength,
|
|
|
|
int32_t aScript,
|
|
|
|
gfxShapedText *aShapedText,
|
|
|
|
bool aPreferPlatformShaping);
|
2009-10-07 10:16:52 -07:00
|
|
|
|
2010-05-05 03:10:36 -07:00
|
|
|
void Initialize(); // creates metrics and Cairo fonts
|
2010-03-15 02:34:25 -07:00
|
|
|
|
2012-07-03 03:42:07 -07:00
|
|
|
// Fill the given LOGFONT record according to our style, but don't adjust
|
|
|
|
// the lfItalic field if we're going to use a cairo transform for fake
|
|
|
|
// italics.
|
|
|
|
void FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize, bool aUseGDIFakeItalic);
|
2010-03-15 02:34:25 -07:00
|
|
|
|
2010-06-25 05:43:10 -07:00
|
|
|
// mPlatformShaper is used for the GDI shaper, mUniscribeShaper
|
|
|
|
// for the Uniscribe version if needed
|
|
|
|
nsAutoPtr<gfxFontShaper> mUniscribeShaper;
|
|
|
|
|
2010-03-15 02:34:25 -07:00
|
|
|
HFONT mFont;
|
|
|
|
cairo_font_face_t *mFontFace;
|
|
|
|
|
2010-05-05 03:10:36 -07:00
|
|
|
Metrics *mMetrics;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mSpaceGlyph;
|
2010-05-05 03:10:36 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mNeedsBold;
|
2009-10-07 10:16:52 -07: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;
|
2010-03-15 02:34:25 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GFX_GDIFONT_H */
|