1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #include "mozilla/MemoryReporting.h"
12 #include <ApplicationServices/ApplicationServices.h>
16 class gfxMacFont
: public gfxFont
19 gfxMacFont(MacOSFontEntry
*aFontEntry
, const gfxFontStyle
*aFontStyle
,
22 virtual ~gfxMacFont();
24 CGFontRef
GetCGFontRef() const { return mCGFont
; }
26 /* overrides for the pure virtual methods in gfxFont */
27 virtual const gfxFont::Metrics
& GetMetrics() {
31 virtual uint32_t GetSpaceGlyph() {
35 virtual bool SetupCairoFont(gfxContext
*aContext
);
37 /* override Measure to add padding for antialiasing */
38 virtual RunMetrics
Measure(gfxTextRun
*aTextRun
,
39 uint32_t aStart
, uint32_t aEnd
,
40 BoundingBoxType aBoundingBoxType
,
41 gfxContext
*aContextForTightBoundingBox
,
44 virtual mozilla::TemporaryRef
<mozilla::gfx::ScaledFont
> GetScaledFont(mozilla::gfx::DrawTarget
*aTarget
);
46 virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf
,
47 FontCacheSizes
* aSizes
) const;
48 virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf
,
49 FontCacheSizes
* aSizes
) const;
51 virtual FontType
GetType() const { return FONT_TYPE_MAC
; }
54 virtual void CreatePlatformShaper();
56 // override to prefer CoreText shaping with fonts that depend on AAT
57 virtual bool ShapeText(gfxContext
*aContext
,
58 const PRUnichar
*aText
,
62 gfxShapedText
*aShapedText
,
63 bool aPreferPlatformShaping
= false);
66 void InitMetricsFromPlatform();
68 // Get width and glyph ID for a character; uses aConvFactor
69 // to convert font units as returned by CG to actual dimensions
70 gfxFloat
GetCharWidth(CFDataRef aCmap
, PRUnichar aUniChar
,
71 uint32_t *aGlyphID
, gfxFloat aConvFactor
);
73 // a weak reference to the CoreGraphics font: this is owned by the
74 // MacOSFontEntry, it is not retained or released by gfxMacFont
77 cairo_font_face_t
*mFontFace
;
83 #endif /* GFX_MACFONT_H */