Skip to content

Commit 1a2b1e4

Browse files
committed
Enable GetStringWidths
1 parent 32fe5c6 commit 1a2b1e4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

bindings/interface/Font.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,12 @@ py::class_<BFont>(m, "BFont")
210210
.def("StringWidth", py::overload_cast<const char *>(&BFont::StringWidth, py::const_), "", py::arg("string"))
211211
.def("StringWidth", py::overload_cast<const char *, int32>(&BFont::StringWidth, py::const_), "", py::arg("string"), py::arg("length"))
212212
//.def("GetStringWidths", &BFont::GetStringWidths, "", py::arg("stringArray"), py::arg("lengthArray"), py::arg("numStrings"), py::arg("widthArray"))
213-
213+
.def("GetStringWidths", [](BFont& self, std::vector<const char *> stringArray, std::vector<int32> lengthArray){
214+
std::vector<float> widthArray;
215+
widthArray.resize(stringArray.size());
216+
self.GetStringWidths(stringArray.data(),lengthArray.data(),stringArray.size(),widthArray.data());
217+
return widthArray;
218+
},"", py::arg("stringArray"), py::arg("lengthArray"))
214219
//.def("GetEscapements", py::overload_cast<const char, int, float>(&BFont::GetEscapements,py::const_), "", py::arg("charArray"), py::arg("numChars"), py::arg("escapementArray"))
215220
.def("GetEscapements", [](BFont& self, const std::string& charArray, std::vector<float>& escapementArray) {
216221
// TODO: this function does not return the escapement array, or returns it empty, DON'T WORK

0 commit comments

Comments
 (0)