Line data Source code
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/. */
5 :
6 : #ifndef GFX_FONTCONFIG_UTILS_H
7 : #define GFX_FONTCONFIG_UTILS_H
8 :
9 : #include "gfxPlatform.h"
10 :
11 : #include "nsAutoRef.h"
12 : #include "gfxFT2FontBase.h"
13 :
14 : #include <fontconfig/fontconfig.h>
15 :
16 :
17 : template <>
18 9540 : class nsAutoRefTraits<FcPattern> : public nsPointerRefTraits<FcPattern>
19 : {
20 : public:
21 2614 : static void Release(FcPattern *ptr) { FcPatternDestroy(ptr); }
22 6907 : static void AddRef(FcPattern *ptr) { FcPatternReference(ptr); }
23 : };
24 :
25 : template <>
26 5 : class nsAutoRefTraits<FcFontSet> : public nsPointerRefTraits<FcFontSet>
27 : {
28 : public:
29 5 : static void Release(FcFontSet *ptr) { FcFontSetDestroy(ptr); }
30 : };
31 :
32 : template <>
33 : class nsAutoRefTraits<FcCharSet> : public nsPointerRefTraits<FcCharSet>
34 : {
35 : public:
36 : static void Release(FcCharSet *ptr) { FcCharSetDestroy(ptr); }
37 : };
38 :
39 0 : class gfxFontconfigFontBase : public gfxFT2FontBase {
40 : public:
41 8 : gfxFontconfigFontBase(const RefPtr<mozilla::gfx::UnscaledFontFontconfig>& aUnscaledFont,
42 : cairo_scaled_font_t *aScaledFont,
43 : FcPattern *aPattern,
44 : gfxFontEntry *aFontEntry,
45 : const gfxFontStyle *aFontStyle)
46 8 : : gfxFT2FontBase(aUnscaledFont, aScaledFont, aFontEntry, aFontStyle)
47 8 : , mPattern(aPattern) { }
48 :
49 21 : virtual FontType GetType() const override { return FONT_TYPE_FONTCONFIG; }
50 21 : virtual FcPattern *GetPattern() const { return mPattern; }
51 :
52 : private:
53 : nsCountedRef<FcPattern> mPattern;
54 : };
55 :
56 : #endif /* GFX_FONTCONFIG_UTILS_H */
|