Krita Source Code Documentation
Loading...
Searching...
No Matches
KoFontLibraryResourceUtils.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com>
3 * SPDX-FileCopyrightText: 2022 L. E. Segovia <amy@amyspark.me>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7#ifndef KOFONTLIBRARYRESOURCEUTILS_H
8#define KOFONTLIBRARYRESOURCEUTILS_H
9
10#include <ft2build.h>
11#include FT_FREETYPE_H
12#include FT_MULTIPLE_MASTERS_H
13#include <fontconfig/fontconfig.h>
14
15#include <hb-ft.h>
16#include <hb-ot.h>
17#include <hb.h>
18
19#include <QSharedPointer>
20
21#include <kis_debug.h>
22
23namespace detail {
24
25template <typename T, int (*P)(T *)>
27{
28 const int result = P(ptr);
29 if (result != 0) {
30 qWarning() << "WARNING: failed to release a library resource";
31#ifdef __GNUC__
32 qWarning() << " source:" << __PRETTY_FUNCTION__;
33#endif
34 }
35}
36
37}
38
45template<typename T, void (*P)(T *)>
47public:
49 : QSharedPointer<T>(nullptr)
50 {
51 }
52
57
58 using QSharedPointer<T>::operator->;
59
63
64 void reset() {
66 }
67
68 auto data() const
69 {
70 return this->get();
71 }
72
73private:
74 static void noDestroy(T *ptr) {
75 Q_UNUSED(ptr);
76 }
77};
78
85template<typename T, int (*P)(T *)>
87
88
93
96 FT_Done_FreeType>;
98 FT_Done_Face>;
99
104
105#endif // KOFONTLIBRARYRESOURCEUTILS_H
VertexDescriptor get(PredecessorMap const &m, VertexDescriptor v)
#define P(i, j, k)
void checkCStyleResultWrapper(T *ptr)