diff --git a/src/_ttconv.cpp b/src/_ttconv.cpp index a99ea9d1c891..a9c1f7fb9f91 100644 --- a/src/_ttconv.cpp +++ b/src/_ttconv.cpp @@ -7,8 +7,8 @@ */ #include +#include #include "pprdrv.h" -#include namespace py = pybind11; using namespace pybind11::literals; @@ -40,25 +40,20 @@ static void convert_ttf_to_ps( const char *filename, py::object &output, int fonttype, - py::iterable* glyph_ids) + std::optional> glyph_ids_or_none) { PythonFileWriter output_(output); - std::vector glyph_ids_; - if (glyph_ids) { - for (py::handle glyph_id: *glyph_ids) { - glyph_ids_.push_back(glyph_id.cast()); - } - } - if (fonttype != 3 && fonttype != 42) { throw py::value_error( "fonttype must be either 3 (raw Postscript) or 42 (embedded Truetype)"); } + auto glyph_ids = glyph_ids_or_none.value_or(std::vector{}); + try { - insert_ttfont(filename, output_, static_cast(fonttype), glyph_ids_); + insert_ttfont(filename, output_, static_cast(fonttype), glyph_ids); } catch (TTException &e) {