michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_MACFONT_H michael@0: #define GFX_MACFONT_H michael@0: michael@0: #include "mozilla/MemoryReporting.h" michael@0: #include "gfxFont.h" michael@0: #include "cairo.h" michael@0: #include michael@0: michael@0: class MacOSFontEntry; michael@0: michael@0: class gfxMacFont : public gfxFont michael@0: { michael@0: public: michael@0: gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, michael@0: bool aNeedsBold); michael@0: michael@0: virtual ~gfxMacFont(); michael@0: michael@0: CGFontRef GetCGFontRef() const { return mCGFont; } michael@0: michael@0: /* overrides for the pure virtual methods in gfxFont */ michael@0: virtual const gfxFont::Metrics& GetMetrics() { michael@0: return mMetrics; michael@0: } michael@0: michael@0: virtual uint32_t GetSpaceGlyph() { michael@0: return mSpaceGlyph; michael@0: } michael@0: michael@0: virtual bool SetupCairoFont(gfxContext *aContext); michael@0: michael@0: /* override Measure to add padding for antialiasing */ michael@0: virtual RunMetrics Measure(gfxTextRun *aTextRun, michael@0: uint32_t aStart, uint32_t aEnd, michael@0: BoundingBoxType aBoundingBoxType, michael@0: gfxContext *aContextForTightBoundingBox, michael@0: Spacing *aSpacing); michael@0: michael@0: virtual mozilla::TemporaryRef GetScaledFont(mozilla::gfx::DrawTarget *aTarget); michael@0: michael@0: virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, michael@0: FontCacheSizes* aSizes) const; michael@0: virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, michael@0: FontCacheSizes* aSizes) const; michael@0: michael@0: virtual FontType GetType() const { return FONT_TYPE_MAC; } michael@0: michael@0: protected: michael@0: virtual void CreatePlatformShaper(); michael@0: michael@0: // override to prefer CoreText shaping with fonts that depend on AAT michael@0: virtual bool ShapeText(gfxContext *aContext, michael@0: const char16_t *aText, michael@0: uint32_t aOffset, michael@0: uint32_t aLength, michael@0: int32_t aScript, michael@0: gfxShapedText *aShapedText, michael@0: bool aPreferPlatformShaping = false); michael@0: michael@0: void InitMetrics(); michael@0: void InitMetricsFromPlatform(); michael@0: michael@0: // Get width and glyph ID for a character; uses aConvFactor michael@0: // to convert font units as returned by CG to actual dimensions michael@0: gfxFloat GetCharWidth(CFDataRef aCmap, char16_t aUniChar, michael@0: uint32_t *aGlyphID, gfxFloat aConvFactor); michael@0: michael@0: // a weak reference to the CoreGraphics font: this is owned by the michael@0: // MacOSFontEntry, it is not retained or released by gfxMacFont michael@0: CGFontRef mCGFont; michael@0: michael@0: cairo_font_face_t *mFontFace; michael@0: michael@0: Metrics mMetrics; michael@0: uint32_t mSpaceGlyph; michael@0: }; michael@0: michael@0: #endif /* GFX_MACFONT_H */