1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/gfxMacFont.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,83 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef GFX_MACFONT_H 1.10 +#define GFX_MACFONT_H 1.11 + 1.12 +#include "mozilla/MemoryReporting.h" 1.13 +#include "gfxFont.h" 1.14 +#include "cairo.h" 1.15 +#include <ApplicationServices/ApplicationServices.h> 1.16 + 1.17 +class MacOSFontEntry; 1.18 + 1.19 +class gfxMacFont : public gfxFont 1.20 +{ 1.21 +public: 1.22 + gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, 1.23 + bool aNeedsBold); 1.24 + 1.25 + virtual ~gfxMacFont(); 1.26 + 1.27 + CGFontRef GetCGFontRef() const { return mCGFont; } 1.28 + 1.29 + /* overrides for the pure virtual methods in gfxFont */ 1.30 + virtual const gfxFont::Metrics& GetMetrics() { 1.31 + return mMetrics; 1.32 + } 1.33 + 1.34 + virtual uint32_t GetSpaceGlyph() { 1.35 + return mSpaceGlyph; 1.36 + } 1.37 + 1.38 + virtual bool SetupCairoFont(gfxContext *aContext); 1.39 + 1.40 + /* override Measure to add padding for antialiasing */ 1.41 + virtual RunMetrics Measure(gfxTextRun *aTextRun, 1.42 + uint32_t aStart, uint32_t aEnd, 1.43 + BoundingBoxType aBoundingBoxType, 1.44 + gfxContext *aContextForTightBoundingBox, 1.45 + Spacing *aSpacing); 1.46 + 1.47 + virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont> GetScaledFont(mozilla::gfx::DrawTarget *aTarget); 1.48 + 1.49 + virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, 1.50 + FontCacheSizes* aSizes) const; 1.51 + virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, 1.52 + FontCacheSizes* aSizes) const; 1.53 + 1.54 + virtual FontType GetType() const { return FONT_TYPE_MAC; } 1.55 + 1.56 +protected: 1.57 + virtual void CreatePlatformShaper(); 1.58 + 1.59 + // override to prefer CoreText shaping with fonts that depend on AAT 1.60 + virtual bool ShapeText(gfxContext *aContext, 1.61 + const char16_t *aText, 1.62 + uint32_t aOffset, 1.63 + uint32_t aLength, 1.64 + int32_t aScript, 1.65 + gfxShapedText *aShapedText, 1.66 + bool aPreferPlatformShaping = false); 1.67 + 1.68 + void InitMetrics(); 1.69 + void InitMetricsFromPlatform(); 1.70 + 1.71 + // Get width and glyph ID for a character; uses aConvFactor 1.72 + // to convert font units as returned by CG to actual dimensions 1.73 + gfxFloat GetCharWidth(CFDataRef aCmap, char16_t aUniChar, 1.74 + uint32_t *aGlyphID, gfxFloat aConvFactor); 1.75 + 1.76 + // a weak reference to the CoreGraphics font: this is owned by the 1.77 + // MacOSFontEntry, it is not retained or released by gfxMacFont 1.78 + CGFontRef mCGFont; 1.79 + 1.80 + cairo_font_face_t *mFontFace; 1.81 + 1.82 + Metrics mMetrics; 1.83 + uint32_t mSpaceGlyph; 1.84 +}; 1.85 + 1.86 +#endif /* GFX_MACFONT_H */