/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef GFX_FONTCONFIG_UTILS_H #define GFX_FONTCONFIG_UTILS_H #include "gfxPlatform.h" #include "nsAutoRef.h" #include "gfxFT2FontBase.h" #include template <> class nsAutoRefTraits : public nsPointerRefTraits { public: static void Release(FcPattern *ptr) { FcPatternDestroy(ptr); } static void AddRef(FcPattern *ptr) { FcPatternReference(ptr); } }; template <> class nsAutoRefTraits : public nsPointerRefTraits { public: static void Release(FcFontSet *ptr) { FcFontSetDestroy(ptr); } }; template <> class nsAutoRefTraits : public nsPointerRefTraits { public: static void Release(FcCharSet *ptr) { FcCharSetDestroy(ptr); } }; class gfxFontconfigFontBase : public gfxFT2FontBase { public: gfxFontconfigFontBase(const RefPtr& aUnscaledFont, cairo_scaled_font_t *aScaledFont, FcPattern *aPattern, gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle) : gfxFT2FontBase(aUnscaledFont, aScaledFont, aFontEntry, aFontStyle) , mPattern(aPattern) { } virtual FontType GetType() const override { return FONT_TYPE_FONTCONFIG; } virtual FcPattern *GetPattern() const { return mPattern; } private: nsCountedRef mPattern; }; #endif /* GFX_FONTCONFIG_UTILS_H */