2010-03-15 09:34:25 +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-03-15 09:34:25 +00:00
|
|
|
|
|
|
|
#ifndef GFX_GDIFONT_H
|
|
|
|
#define GFX_GDIFONT_H
|
|
|
|
|
2013-06-23 12:03:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2010-03-15 09:34:25 +00:00
|
|
|
#include "gfxFont.h"
|
|
|
|
#include "gfxGDIFontList.h"
|
|
|
|
|
2009-10-07 17:16:52 +00:00
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
|
2010-03-15 09:34:25 +00:00
|
|
|
#include "cairo.h"
|
|
|
|
|
|
|
|
class gfxGDIFont : public gfxFont
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
gfxGDIFont(GDIFontEntry *aFontEntry,
|
|
|
|
const gfxFontStyle *aFontStyle,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aNeedsBold,
|
2010-03-15 09:34:25 +00:00
|
|
|
AntialiasOption anAAOption = kAntialiasDefault);
|
|
|
|
|
|
|
|
virtual ~gfxGDIFont();
|
|
|
|
|
2010-06-25 12:43:10 +00:00
|
|
|
HFONT GetHFONT() { if (!mMetrics) Initialize(); return mFont; }
|
2010-03-15 09:34:25 +00:00
|
|
|
|
2011-01-21 16:44:32 +00:00
|
|
|
gfxFloat GetAdjustedSize() { if (!mMetrics) Initialize(); return mAdjustedSize; }
|
2010-03-15 09:34:25 +00: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 15:56:38 +00:00
|
|
|
virtual uint32_t GetSpaceGlyph();
|
2010-03-15 09:34:25 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool SetupCairoFont(gfxContext *aContext);
|
2010-03-15 09:34:25 +00:00
|
|
|
|
2011-06-22 08:49:53 +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-06-22 08:49:53 +00:00
|
|
|
BoundingBoxType aBoundingBoxType,
|
|
|
|
gfxContext *aContextForTightBoundingBox,
|
|
|
|
Spacing *aSpacing);
|
|
|
|
|
2010-03-15 09:34:25 +00:00
|
|
|
/* required for MathML to suppress effects of ClearType "padding" */
|
|
|
|
virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool ProvidesGlyphWidths() { return true; }
|
2011-01-07 12:38:28 +00:00
|
|
|
|
|
|
|
// get hinted glyph width in pixels as 16.16 fixed-point value
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID);
|
2011-01-07 12:38:28 +00:00
|
|
|
|
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_GDI; }
|
|
|
|
|
2011-01-07 12:38:28 +00:00
|
|
|
protected:
|
|
|
|
virtual void CreatePlatformShaper();
|
|
|
|
|
2010-03-15 09:34:25 +00:00
|
|
|
/* override to check for uniscribe failure and fall back to GDI */
|
2013-01-04 18:35:37 +00: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 17:16:52 +00:00
|
|
|
|
2010-05-05 10:10:36 +00:00
|
|
|
void Initialize(); // creates metrics and Cairo fonts
|
2010-03-15 09:34:25 +00:00
|
|
|
|
2012-07-03 10:42:07 +00: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 09:34:25 +00:00
|
|
|
|
2010-06-25 12:43:10 +00:00
|
|
|
// mPlatformShaper is used for the GDI shaper, mUniscribeShaper
|
|
|
|
// for the Uniscribe version if needed
|
|
|
|
nsAutoPtr<gfxFontShaper> mUniscribeShaper;
|
|
|
|
|
2010-03-15 09:34:25 +00:00
|
|
|
HFONT mFont;
|
|
|
|
cairo_font_face_t *mFontFace;
|
|
|
|
|
2010-05-05 10:10:36 +00:00
|
|
|
Metrics *mMetrics;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mSpaceGlyph;
|
2010-05-05 10:10:36 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mNeedsBold;
|
2009-10-07 17:16:52 +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;
|
2010-03-15 09:34:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GFX_GDIFONT_H */
|