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
23
namespace
detail
{
24
25
template
<
typename
T,
int
(*P)(T *)>
26
void
checkCStyleResultWrapper
(T *ptr)
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
45
template
<
typename
T,
void
(*P)(T *)>
46
struct
KisLibraryResourcePointer
:
private
QSharedPointer
<T> {
47
public
:
48
KisLibraryResourcePointer
()
49
:
QSharedPointer
<T>(nullptr)
50
{
51
}
52
53
KisLibraryResourcePointer
(T *ptr)
54
:
QSharedPointer
<T>(ptr, ptr ?
P
: &
KisLibraryResourcePointer
::
noDestroy
)
55
{
56
}
57
58
using
QSharedPointer
<T>::operator->;
59
60
void
reset
(T *ptr) {
61
QSharedPointer<T>::reset
(ptr, ptr ?
P
: &
KisLibraryResourcePointer::noDestroy
);
62
}
63
64
void
reset
() {
65
QSharedPointer<T>::reset
();
66
}
67
68
auto
data
()
const
69
{
70
return
this->
get
();
71
}
72
73
private
:
74
static
void
noDestroy
(T *ptr) {
75
Q_UNUSED(ptr);
76
}
77
};
78
85
template
<
typename
T,
int
(*P)(T *)>
86
using
KisLibraryResourcePointerWithSanityCheck
=
KisLibraryResourcePointer<T, detail::checkCStyleResultWrapper<T, P>
>;
87
88
89
using
FcConfigSP
=
KisLibraryResourcePointer<FcConfig, FcConfigDestroy>
;
90
using
FcCharSetSP
=
KisLibraryResourcePointer<FcCharSet, FcCharSetDestroy>
;
91
using
FcPatternSP
=
KisLibraryResourcePointer<FcPattern, FcPatternDestroy>
;
92
using
FcFontSetSP
=
KisLibraryResourcePointer<FcFontSet, FcFontSetDestroy>
;
93
94
using
FT_LibrarySP
=
95
KisLibraryResourcePointerWithSanityCheck<std::remove_pointer_t<FT_Library>
,
96
FT_Done_FreeType>;
97
using
FT_FaceSP
=
KisLibraryResourcePointerWithSanityCheck<std::remove_pointer_t<FT_Face>
,
98
FT_Done_Face>;
99
100
using
hb_font_t_sp
=
KisLibraryResourcePointer<hb_font_t, hb_font_destroy>
;
101
using
hb_face_t_sp
=
KisLibraryResourcePointer<hb_face_t, hb_face_destroy>
;
102
using
hb_set_t_sp
=
KisLibraryResourcePointer<hb_set_t, hb_set_destroy>
;
103
using
hb_blob_t_sp
=
KisLibraryResourcePointer<hb_blob_t, hb_blob_destroy>
;
104
105
#endif
// KOFONTLIBRARYRESOURCEUTILS_H
get
VertexDescriptor get(PredecessorMap const &m, VertexDescriptor v)
Definition
KisMagneticWorker.cc:62
P
#define P(i, j, k)
QSharedPointer
Definition
KoCanvasResourceProvider.h:20
kis_debug.h
detail
Definition
kis_brush.cpp:105
detail::checkCStyleResultWrapper
void checkCStyleResultWrapper(T *ptr)
Definition
KoFontLibraryResourceUtils.h:26
KisLibraryResourcePointer
Definition
KoFontLibraryResourceUtils.h:46
KisLibraryResourcePointer::noDestroy
static void noDestroy(T *ptr)
Definition
KoFontLibraryResourceUtils.h:74
KisLibraryResourcePointer::KisLibraryResourcePointer
KisLibraryResourcePointer()
Definition
KoFontLibraryResourceUtils.h:48
KisLibraryResourcePointer::KisLibraryResourcePointer
KisLibraryResourcePointer(T *ptr)
Definition
KoFontLibraryResourceUtils.h:53
KisLibraryResourcePointer::data
auto data() const
Definition
KoFontLibraryResourceUtils.h:68
KisLibraryResourcePointer::reset
void reset()
Definition
KoFontLibraryResourceUtils.h:64
KisLibraryResourcePointer::reset
void reset(T *ptr)
Definition
KoFontLibraryResourceUtils.h:60
libs
flake
text
KoFontLibraryResourceUtils.h
Generated at
2025-11-04 02:30:02+01:00
from
Krita
branch
master
, commit
c9dde2e79561a8aea4a7e8d9ac99c98a7bac9e52