Merge m-c to inbound.
[gecko.git] / gfx / thebes / gfxMacFont.h
blobe352d43ef0e104a50b8877815a90e446f76f1032
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/. */
6 #ifndef GFX_MACFONT_H
7 #define GFX_MACFONT_H
9 #include "mozilla/MemoryReporting.h"
10 #include "gfxFont.h"
11 #include "cairo.h"
12 #include <ApplicationServices/ApplicationServices.h>
14 class MacOSFontEntry;
16 class gfxMacFont : public gfxFont
18 public:
19 gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyle,
20 bool aNeedsBold);
22 virtual ~gfxMacFont();
24 CGFontRef GetCGFontRef() const { return mCGFont; }
26 /* overrides for the pure virtual methods in gfxFont */
27 virtual const gfxFont::Metrics& GetMetrics() {
28 return mMetrics;
31 virtual uint32_t GetSpaceGlyph() {
32 return mSpaceGlyph;
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,
42 Spacing *aSpacing);
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; }
53 protected:
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,
59 uint32_t aOffset,
60 uint32_t aLength,
61 int32_t aScript,
62 gfxShapedText *aShapedText,
63 bool aPreferPlatformShaping = false);
65 void InitMetrics();
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
75 CGFontRef mCGFont;
77 cairo_font_face_t *mFontFace;
79 Metrics mMetrics;
80 uint32_t mSpaceGlyph;
83 #endif /* GFX_MACFONT_H */