Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 32e9fba

Browse filesBrowse files
committed
Simplify ttconv python<->C++ conversion using std::optional.
1 parent bcfecca commit 32e9fba
Copy full SHA for 32e9fba

File tree

Expand file treeCollapse file tree

1 file changed

+5
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-10
lines changed
Open diff view settings
Collapse file

‎src/_ttconv.cpp‎

Copy file name to clipboardExpand all lines: src/_ttconv.cpp
+5-10Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
#include <pybind11/pybind11.h>
10+
#include <pybind11/stl.h>
1011
#include "pprdrv.h"
11-
#include <vector>
1212

1313
namespace py = pybind11;
1414
using namespace pybind11::literals;
@@ -40,25 +40,20 @@ static void convert_ttf_to_ps(
4040
const char *filename,
4141
py::object &output,
4242
int fonttype,
43-
py::iterable* glyph_ids)
43+
std::optional<std::vector<int>> glyph_ids_or_none)
4444
{
4545
PythonFileWriter output_(output);
4646

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-
5447
if (fonttype != 3 && fonttype != 42) {
5548
throw py::value_error(
5649
"fonttype must be either 3 (raw Postscript) or 42 (embedded Truetype)");
5750
}
5851

52+
auto glyph_ids = glyph_ids_or_none.value_or(std::vector<int>{});
53+
5954
try
6055
{
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);
6257
}
6358
catch (TTException &e)
6459
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.