Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/skia/Font.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "common.h"
#include <include/core/SkFontMetrics.h>
#include <include/ports/SkFontMgr_empty.h>
#include <include/ports/SkFontScanner_FreeType.h>
#include <pybind11/stl.h>
#include <pybind11/stl_bind.h>
#include <pybind11/iostream.h>
Expand Down Expand Up @@ -369,6 +370,22 @@ fontarguments
&SkFontArguments::getVariationDesignPosition)
;

py::class_<SkFontScanner> font_scanner(m, "FontScanner");

font_scanner
.def(py::init(&SkFontScanner_Make_FreeType))
.def("scanFile", &SkFontScanner::scanFile,
py::arg("stream"), py::arg("numFaces"))
.def("scanFace", &SkFontScanner::scanFace,
py::arg("stream"), py::arg("faceIndex"), py::arg("numInstances"))
.def("MakeFromData",
[] (const SkFontScanner& self, sk_sp<SkData> data, const SkFontArguments& args) {
std::unique_ptr<SkStreamAsset> stream(new SkMemoryStream(data));
return self.MakeFromStream(std::move(stream), args);
},
py::arg("data"), py::arg("args"))
;

py::class_<SkTypeface, sk_sp<SkTypeface>, SkRefCnt> typeface(
m, "Typeface", R"docstring(
The :py:class:`Typeface` class specifies the typeface and intrinsic style of
Expand Down
4 changes: 4 additions & 0 deletions src/skia/TextBlob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ py::class_<SkTextBlob::Iter::Run>(iter, "Run")

iter
.def(py::init<const SkTextBlob&>())
.def("__iter__",
[] (SkTextBlob::Iter& it) {
return it;
})
.def("__next__",
[] (SkTextBlob::Iter& it) {
SkTextBlob::Iter::Run run;
Expand Down
Loading