Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commite6f2b0c

Browse files
authored
Merge pull request#28603 from anntzer/ttconv-optional
Simplify ttconv python<->C++ conversion using std::optional.
2 parents0eb624d +32e9fba commite6f2b0c

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

‎src/_ttconv.cpp

Lines 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
namespacepy= pybind11;
1414
usingnamespacepybind11::literals;
@@ -40,25 +40,20 @@ static void convert_ttf_to_ps(
4040
constchar *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
PythonFileWriteroutput_(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
throwpy::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)

[8]ページ先頭

©2009-2025 Movatter.jp