File tree 1 file changed +5
-10
lines changed
1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change 7
7
*/
8
8
9
9
#include < pybind11/pybind11.h>
10
+ #include < pybind11/stl.h>
10
11
#include " pprdrv.h"
11
- #include < vector>
12
12
13
13
namespace py = pybind11;
14
14
using namespace pybind11 ::literals;
@@ -40,25 +40,20 @@ static void convert_ttf_to_ps(
40
40
const char *filename,
41
41
py::object &output,
42
42
int fonttype,
43
- py::iterable* glyph_ids )
43
+ std::optional<std::vector< int >> glyph_ids_or_none )
44
44
{
45
45
PythonFileWriter output_ (output);
46
46
47
- std::vector<int > glyph_ids_;
48
- if (glyph_ids) {
49
- for (py::handle glyph_id: *glyph_ids) {
50
- glyph_ids_.push_back (glyph_id.cast <int >());
51
- }
52
- }
53
-
54
47
if (fonttype != 3 && fonttype != 42 ) {
55
48
throw py::value_error (
56
49
" fonttype must be either 3 (raw Postscript) or 42 (embedded Truetype)" );
57
50
}
58
51
52
+ auto glyph_ids = glyph_ids_or_none.value_or (std::vector<int >{});
53
+
59
54
try
60
55
{
61
- insert_ttfont (filename, output_, static_cast <font_type_enum>(fonttype), glyph_ids_ );
56
+ insert_ttfont (filename, output_, static_cast <font_type_enum>(fonttype), glyph_ids );
62
57
}
63
58
catch (TTException &e)
64
59
{
You can’t perform that action at this time.
0 commit comments