Blender V5.3
rna_vfont_api.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2015 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "RNA_define.hh"
10#include "RNA_enum_types.hh"
11
12#include "BKE_packedFile.hh"
13
14#include "rna_internal.hh"
15
16#ifdef RNA_RUNTIME
17
18namespace blender {
19
20# include "DNA_vfont_types.h"
21
22# include "BKE_lib_id.hh"
23# include "BKE_library.hh"
24# include "BKE_main.hh"
25# include "BKE_report.hh"
26# include "BKE_vfont.hh"
27
28static void rna_VectorFont_pack(VFont *vfont, Main *bmain, ReportList *reports)
29{
30 BKE_vfont_packfile_ensure(bmain, vfont, reports);
31}
32
33static void rna_VectorFont_unpack(VFont *vfont, Main *bmain, ReportList *reports, int method)
34{
35 if (!vfont->packedfile) {
36 BKE_report(reports, RPT_ERROR, "Font not packed");
37 return;
38 }
39
40 if (!ID_IS_EDITABLE(&vfont->id)) {
41 BKE_report(reports, RPT_ERROR, "Font is not editable");
42 return;
43 }
44
45 /* reports its own error on failure */
46 BKE_packedfile_unpack_vfont(bmain, reports, vfont, ePF_FileStatus(method));
47}
48
49} // namespace blender
50
51#else
52
53namespace blender {
54
56{
57 FunctionRNA *func;
58
59 func = RNA_def_function(srna, "pack", "rna_VectorFont_pack");
60 RNA_def_function_ui_description(func, "Pack the font into the current blend file");
62
63 func = RNA_def_function(srna, "unpack", "rna_VectorFont_unpack");
64 RNA_def_function_ui_description(func, "Unpack the font to the samples filename");
67 func, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "method", "How to unpack");
68}
69
70} // namespace blender
71
72#endif
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
BMesh Iterators.
void BKE_vfont_packfile_ensure(Main *bmain, VFont *vfont, ReportList *reports)
Definition vfont.cc:403
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
@ FUNC_USE_REPORTS
@ FUNC_USE_MAIN
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
int BKE_packedfile_unpack_vfont(Main *bmain, ReportList *reports, VFont *vfont, enum ePF_FileStatus how)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
const EnumPropertyItem rna_enum_unpack_method_items[]
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag flag)
void RNA_api_vfont(StructRNA *srna)