From 63fc5b3800b57decdcfe03da88784e4c7a03a0ff Mon Sep 17 00:00:00 2001 From: Mcratt Date: Fri, 20 Dec 2024 10:51:11 +0800 Subject: [PATCH] add blob.length property --- src/uharfbuzz/_harfbuzz.pyx | 3 +++ tests/test_uharfbuzz.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/uharfbuzz/_harfbuzz.pyx b/src/uharfbuzz/_harfbuzz.pyx index a386b98..e75360f 100644 --- a/src/uharfbuzz/_harfbuzz.pyx +++ b/src/uharfbuzz/_harfbuzz.pyx @@ -429,6 +429,9 @@ cdef class Blob: def data(self) -> bytes: return self._data + @property + def length(self) -> int: + return hb_blob_get_length(self._hb_blob) class OTVarAxisFlags(IntFlag): HIDDEN = HB_OT_VAR_AXIS_FLAG_HIDDEN diff --git a/tests/test_uharfbuzz.py b/tests/test_uharfbuzz.py index e7d7a90..66e7ef9 100644 --- a/tests/test_uharfbuzz.py +++ b/tests/test_uharfbuzz.py @@ -226,6 +226,9 @@ def test_from_file_path_fail(self): with pytest.raises(hb.HarfBuzzError, match="Failed to open: DOES-NOT-EXIST"): blob = hb.Blob.from_file_path("DOES-NOT-EXIST") + def test_length(self, blankfont): + face = blankfont.face + assert face.blob.length == 1892 class TestFace: def test_properties(self, blankfont):