gfx/thebes/gfxMacFont.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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
    17 {
    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;
    29     }
    31     virtual uint32_t GetSpaceGlyph() {
    32         return mSpaceGlyph;
    33     }
    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 char16_t *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, char16_t 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;
    81 };
    83 #endif /* GFX_MACFONT_H */

mercurial