gfx/thebes/gfxMacPlatformFontList.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/thebes/gfxMacPlatformFontList.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,129 @@
     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 gfxMacPlatformFontList_H_
    1.10 +#define gfxMacPlatformFontList_H_
    1.11 +
    1.12 +#include <CoreFoundation/CoreFoundation.h>
    1.13 +
    1.14 +#include "mozilla/MemoryReporting.h"
    1.15 +#include "nsDataHashtable.h"
    1.16 +#include "nsRefPtrHashtable.h"
    1.17 +
    1.18 +#include "gfxPlatformFontList.h"
    1.19 +#include "gfxPlatform.h"
    1.20 +#include "gfxPlatformMac.h"
    1.21 +
    1.22 +#include "nsUnicharUtils.h"
    1.23 +#include "nsTArray.h"
    1.24 +
    1.25 +class gfxMacPlatformFontList;
    1.26 +
    1.27 +// a single member of a font family (i.e. a single face, such as Times Italic)
    1.28 +class MacOSFontEntry : public gfxFontEntry
    1.29 +{
    1.30 +public:
    1.31 +    friend class gfxMacPlatformFontList;
    1.32 +
    1.33 +    MacOSFontEntry(const nsAString& aPostscriptName, int32_t aWeight,
    1.34 +                   bool aIsStandardFace = false);
    1.35 +
    1.36 +    // for use with data fonts
    1.37 +    MacOSFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef,
    1.38 +                   uint16_t aWeight, uint16_t aStretch, uint32_t aItalicStyle,
    1.39 +                   bool aIsUserFont, bool aIsLocal);
    1.40 +
    1.41 +    virtual ~MacOSFontEntry() {
    1.42 +        ::CGFontRelease(mFontRef);
    1.43 +    }
    1.44 +
    1.45 +    virtual CGFontRef GetFontRef();
    1.46 +
    1.47 +    // override gfxFontEntry table access function to bypass table cache,
    1.48 +    // use CGFontRef API to get direct access to system font data
    1.49 +    virtual hb_blob_t *GetFontTable(uint32_t aTag) MOZ_OVERRIDE;
    1.50 +
    1.51 +    virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
    1.52 +                                        FontListSizes* aSizes) const;
    1.53 +
    1.54 +    nsresult ReadCMAP(FontInfoData *aFontInfoData = nullptr);
    1.55 +
    1.56 +    bool RequiresAATLayout() const { return mRequiresAAT; }
    1.57 +
    1.58 +    bool IsCFF();
    1.59 +
    1.60 +protected:
    1.61 +    virtual gfxFont* CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold);
    1.62 +
    1.63 +    virtual bool HasFontTable(uint32_t aTableTag);
    1.64 +
    1.65 +    static void DestroyBlobFunc(void* aUserData);
    1.66 +
    1.67 +    CGFontRef mFontRef; // owning reference to the CGFont, released on destruction
    1.68 +
    1.69 +    bool mFontRefInitialized;
    1.70 +    bool mRequiresAAT;
    1.71 +    bool mIsCFF;
    1.72 +    bool mIsCFFInitialized;
    1.73 +};
    1.74 +
    1.75 +class gfxMacPlatformFontList : public gfxPlatformFontList {
    1.76 +public:
    1.77 +    static gfxMacPlatformFontList* PlatformFontList() {
    1.78 +        return static_cast<gfxMacPlatformFontList*>(sPlatformFontList);
    1.79 +    }
    1.80 +
    1.81 +    static int32_t AppleWeightToCSSWeight(int32_t aAppleWeight);
    1.82 +
    1.83 +    virtual gfxFontFamily* GetDefaultFont(const gfxFontStyle* aStyle);
    1.84 +
    1.85 +    virtual bool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
    1.86 +
    1.87 +    virtual gfxFontEntry* LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
    1.88 +                                          const nsAString& aFontName);
    1.89 +    
    1.90 +    virtual gfxFontEntry* MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
    1.91 +                                           const uint8_t *aFontData, uint32_t aLength);
    1.92 +
    1.93 +    void ClearPrefFonts() { mPrefFonts.Clear(); }
    1.94 +
    1.95 +private:
    1.96 +    friend class gfxPlatformMac;
    1.97 +
    1.98 +    gfxMacPlatformFontList();
    1.99 +    virtual ~gfxMacPlatformFontList();
   1.100 +
   1.101 +    // initialize font lists
   1.102 +    virtual nsresult InitFontList();
   1.103 +
   1.104 +    // special case font faces treated as font families (set via prefs)
   1.105 +    void InitSingleFaceList();
   1.106 +
   1.107 +    static void RegisteredFontsChangedNotificationCallback(CFNotificationCenterRef center,
   1.108 +                                                           void *observer,
   1.109 +                                                           CFStringRef name,
   1.110 +                                                           const void *object,
   1.111 +                                                           CFDictionaryRef userInfo);
   1.112 +
   1.113 +    // search fonts system-wide for a given character, null otherwise
   1.114 +    virtual gfxFontEntry* GlobalFontFallback(const uint32_t aCh,
   1.115 +                                             int32_t aRunScript,
   1.116 +                                             const gfxFontStyle* aMatchStyle,
   1.117 +                                             uint32_t& aCmapCount,
   1.118 +                                             gfxFontFamily** aMatchedFamily);
   1.119 +
   1.120 +    virtual bool UsesSystemFallback() { return true; }
   1.121 +
   1.122 +    virtual already_AddRefed<FontInfoData> CreateFontInfoData();
   1.123 +
   1.124 +    enum {
   1.125 +        kATSGenerationInitial = -1
   1.126 +    };
   1.127 +
   1.128 +    // default font for use with system-wide font fallback
   1.129 +    CTFontRef mDefaultFont;
   1.130 +};
   1.131 +
   1.132 +#endif /* gfxMacPlatformFontList_H_ */

mercurial