external/harfbuzz/UnpackedTarball_harfbuzz.mk | 1 external/harfbuzz/tdf159529.patch.0 | 30 -------------------------- vcl/quartz/CoreTextFont.cxx | 28 +++++++++++++++++------- 3 files changed, 20 insertions(+), 39 deletions(-)
New commits: commit 5dd3bc47556d95c862b9c889537730ef41fa257e Author: Patrick Luby <[email protected]> AuthorDate: Fri Jul 11 18:18:45 2025 -0400 Commit: Khaled Hosny <[email protected]> CommitDate: Sat Jul 12 09:44:58 2025 +0200 tdf#159529 Use macOS font table memory directly instead of copying Per Apple's documentation, the CFDataRef returned by the CTFontCopyTable() function is "A retained reference to the font table data as a CFDataRef object. The table data is not actually copied; however, the data reference must be released." So, instead of making a copy of the CFDataRef's data, just use the CFDataRef's data pointer for the HarfBuzz blob and release the CFDataRef in the blob's destroy function. Change-Id: Ia670d036b20ca268b203eedcb1abbaad471d5384 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187761 Reviewed-by: Khaled Hosny <[email protected]> Tested-by: Jenkins diff --git a/vcl/quartz/CoreTextFont.cxx b/vcl/quartz/CoreTextFont.cxx index 6248a255c64e..5e6fda77bc24 100644 --- a/vcl/quartz/CoreTextFont.cxx +++ b/vcl/quartz/CoreTextFont.cxx @@ -142,6 +142,13 @@ static void MyCGPathApplierFunc(void* pData, const CGPathElement* pElement) } } +static void MyDestroyCFDataRef(void* pUserData) +{ + CFDataRef pData = static_cast<CFDataRef>(pUserData); + if (pData) + CFRelease(pData); +} + bool CoreTextFont::GetGlyphOutline(sal_GlyphId nId, basegfx::B2DPolyPolygon& rResult, bool) const { rResult.clear(); @@ -216,15 +223,20 @@ hb_blob_t* CoreTextFontFace::GetHbTable(hb_tag_t nTag) const const CFIndex nLength = pData ? CFDataGetLength(pData) : 0; if (nLength > 0) { - auto pBuffer = new UInt8[nLength]; - const CFRange aRange = CFRangeMake(0, nLength); - CFDataGetBytes(pData, aRange, pBuffer); - - pBlob = hb_blob_create(reinterpret_cast<const char*>(pBuffer), nLength, - HB_MEMORY_MODE_READONLY, pBuffer, - [](void* data) { delete[] static_cast<UInt8*>(data); }); + // tdf#159529 Use macOS font table memory directly instead of copying + // Per Apple's documentation, the CFDataRef returned by the + // CTFontCopyTable() function is "A retained reference to the + // font table data as a CFDataRef object. The table data is not + // actually copied; however, the data reference must be released." + // So, instead of making a copy of the CFDataRef's data, just use + // the CFDataRef's data pointer for the HarfBuzz blob and release + // the CFDataRef in the blob's destroy function. + pBlob = hb_blob_create(reinterpret_cast<const char*>(CFDataGetBytePtr(pData)), nLength, + HB_MEMORY_MODE_READONLY, + const_cast<void*>(static_cast<CFTypeRef>(pData)), + MyDestroyCFDataRef); } - if (pData) + else if (pData) CFRelease(pData); } commit bd406000424d9db4a6c6cf38ed19fcdfd90f2d89 Author: Christian Lohmaier <[email protected]> AuthorDate: Fri Jul 11 12:45:34 2025 +0200 Commit: Khaled Hosny <[email protected]> CommitDate: Sat Jul 12 09:44:44 2025 +0200 Revert "tdf#159529 clear hb_ot_face_t data after fetching 'sbix' and 'glyf' tables" This reverts commit af47a78e11d4819bb4b1ae1a1277babd10d815b7. Reason for revert: seems to cause regression/crash tdf#167455 after the update to harfbuzz 11.2 See also https://github.com/harfbuzz/harfbuzz/issues/5386 that confirms the crash to be related to the patch Change-Id: I359f716afbc8d94fbdb25e600827ac3c41c2ae0c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187698 Tested-by: Jenkins Reviewed-by: Patrick Luby <[email protected]> Reviewed-by: Khaled Hosny <[email protected]> diff --git a/external/harfbuzz/UnpackedTarball_harfbuzz.mk b/external/harfbuzz/UnpackedTarball_harfbuzz.mk index 49b5ee65f05c..b3b63944d0dc 100644 --- a/external/harfbuzz/UnpackedTarball_harfbuzz.mk +++ b/external/harfbuzz/UnpackedTarball_harfbuzz.mk @@ -16,7 +16,6 @@ $(eval $(call gb_UnpackedTarball_update_autoconf_configs,harfbuzz)) $(eval $(call gb_UnpackedTarball_set_patchlevel,harfbuzz,0)) $(eval $(call gb_UnpackedTarball_add_patches,harfbuzz, \ - external/harfbuzz/tdf159529.patch.0 \ external/harfbuzz/harfbuzz_visibility.patch.1 \ )) diff --git a/external/harfbuzz/tdf159529.patch.0 b/external/harfbuzz/tdf159529.patch.0 deleted file mode 100644 index e65a579466eb..000000000000 --- a/external/harfbuzz/tdf159529.patch.0 +++ /dev/null @@ -1,30 +0,0 @@ ---- ./src/hb-ot-font.cc 2023-11-11 09:08:45 -+++ ./src/hb-ot-font.cc 2024-02-20 18:53:55 -@@ -413,7 +413,12 @@ - const hb_ot_face_t *ot_face = ot_font->ot_face; - - #if !defined(HB_NO_OT_FONT_BITMAP) && !defined(HB_NO_COLOR) -- if (ot_face->sbix->get_extents (font, glyph, extents)) return true; -+ /* tdf#159529 clear the hb_ot_face_t's data after fetching 'sbix' table -+ * The 'sbix' table can be very large for color emoji fonts so clear any -+ * cached data in hb_ot_face_t after fetching that table's extents. */ -+ bool sbixResult = ot_face->sbix->get_extents (font, glyph, extents); -+ const_cast<hb_ot_face_t*>(ot_face)->sbix.fini (); -+ if (sbixResult) return true; - if (ot_face->CBDT->get_extents (font, glyph, extents)) return true; - #endif - #if !defined(HB_NO_COLOR) && !defined(HB_NO_PAINT) -@@ -422,7 +427,12 @@ - #ifndef HB_NO_VAR_COMPOSITES - if (ot_face->VARC->get_extents (font, glyph, extents)) return true; - #endif -- if (ot_face->glyf->get_extents (font, glyph, extents)) return true; -+ /* tdf#159529 clear the hb_ot_face_t's data after fetching 'glyf' table -+ * The 'glyf' table can be very large for color emoji fonts so clear any -+ * cached data in hb_ot_face_t after fetching that table's extents. */ -+ bool glyfResult = ot_face->glyf->get_extents (font, glyph, extents); -+ const_cast<hb_ot_face_t*>(ot_face)->glyf.fini (); -+ if (glyfResult) return true; - #ifndef HB_NO_OT_FONT_CFF - if (ot_face->cff2->get_extents (font, glyph, extents)) return true; - if (ot_face->cff1->get_extents (font, glyph, extents)) return true;
