external/harfbuzz/UnpackedTarball_harfbuzz.mk |    1 
 external/harfbuzz/tdf159529.patch.0           |   30 --------------------------
 include/vcl/outdev.hxx                        |    6 +++--
 sw/source/core/txtnode/fntcache.cxx           |    4 +--
 vcl/source/outdev/text.cxx                    |   17 ++++++++------
 5 files changed, 16 insertions(+), 42 deletions(-)

New commits:
commit 56c768bb35d99d029c696d8ce17b5098a2ce7daa
Author:     Christian Lohmaier <[email protected]>
AuthorDate: Fri Jul 11 12:45:34 2025 +0200
Commit:     Adolfo Jayme Barrientos <[email protected]>
CommitDate: Sat Jul 12 14:52:49 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]>
    Signed-off-by: Xisco Fauli <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187765
    Reviewed-by: Adolfo Jayme Barrientos <[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;
commit 466e73897ec8d38dc46676eeadfce22e166f1d0b
Author:     Khaled Hosny <[email protected]>
AuthorDate: Fri Jul 11 11:34:43 2025 +0300
Commit:     Adolfo Jayme Barrientos <[email protected]>
CommitDate: Sat Jul 12 14:52:39 2025 +0200

    Don’t calculate text bounds needlessly in OutputDevice::GetTextArray()
    
    Calculating text bounds can be a costly operation (e.g. for fonts with
    CFF table since it has to be calculated from outlines), and leads to
    loading potentially large font tables (which is especially an issue on
    macOS where we copy font table data when loading, unlike other platforms
    where HarfBuzz mmap’s the file). It seems that the text bounds are only
    used in one place, so this change calculates the bounds only when
    requested.
    
    Change-Id: Ib9017a58dda30b4cc07ceec087cbf4ad45d56d00
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187683
    Tested-by: Jenkins
    Reviewed-by: Khaled Hosny <[email protected]>
    Signed-off-by: Xisco Fauli <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187764
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index aeed95955e2e..d29fa9a18a90 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1056,7 +1056,8 @@ public:
                                        sal_Int32 nIndex = 0, sal_Int32 nLen = 
-1,
                                        bool bCaret = false,
                                        vcl::text::TextLayoutCache const* = 
nullptr,
-                                       SalLayoutGlyphs const* const 
pLayoutCache = nullptr) const;
+                                       SalLayoutGlyphs const* const 
pLayoutCache = nullptr,
+                                       bool bBounds = false) const;
 
     void DrawPartialTextArray(const Point& rStartPt, const OUString& rStr, 
KernArraySpan aKernArray,
                               std::span<const sal_Bool> pKashidaAry, sal_Int32 
nIndex,
@@ -1068,7 +1069,8 @@ public:
                                               sal_Int32 nPartIndex, sal_Int32 
nPartLen,
                                               bool bCaret = false,
                                               const 
vcl::text::TextLayoutCache* = nullptr,
-                                              const SalLayoutGlyphs* 
pLayoutCache = nullptr) const;
+                                              const SalLayoutGlyphs* 
pLayoutCache = nullptr,
+                                              bool bBounds = false) const;
 
     SAL_DLLPRIVATE void         GetCaretPositions( const OUString&, KernArray& 
rCaretXArray,
                                               sal_Int32 nIndex, sal_Int32 nLen,
diff --git a/sw/source/core/txtnode/fntcache.cxx 
b/sw/source/core/txtnode/fntcache.cxx
index b84f301944f8..02358cf1b6dd 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -768,14 +768,14 @@ static void GetTextArray(const SwDrawTextInfo& rExtraInf, 
const OutputDevice& rD
         const SalLayoutGlyphs* pLayoutCache = 
SalLayoutGlyphsCache::self()->GetLayoutGlyphs(
             &rDevice, rStr, nContextBegin, nContextLen, nIndex, nIndex + nLen, 
0, layoutCache);
         stMetrics = rDevice.GetPartialTextArray(rStr, &rDXAry, nContextBegin, 
nContextLen, nIndex,
-                                                nLen, bCaret, layoutCache, 
pLayoutCache);
+                                                nLen, bCaret, layoutCache, 
pLayoutCache, true);
     }
     else
     {
         const SalLayoutGlyphs* pLayoutCache = 
SalLayoutGlyphsCache::self()->GetLayoutGlyphs(
             &rDevice, rStr, nIndex, nLen, 0, layoutCache);
         stMetrics
-            = rDevice.GetTextArray(rStr, &rDXAry, nIndex, nLen, bCaret, 
layoutCache, pLayoutCache);
+            = rDevice.GetTextArray(rStr, &rDXAry, nIndex, nLen, bCaret, 
layoutCache, pLayoutCache, true);
     }
 
     if (stMetrics.aBounds.has_value())
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index d16c776d1df4..4aac96d13d1a 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -787,17 +787,17 @@ vcl::TextArrayMetrics
 OutputDevice::GetTextArray(const OUString& rStr, KernArray* pKernArray, 
sal_Int32 nIndex,
                            sal_Int32 nLen, bool bCaret,
                            vcl::text::TextLayoutCache const* const 
pLayoutCache,
-                           SalLayoutGlyphs const* const pSalLayoutCache) const
+                           SalLayoutGlyphs const* const pSalLayoutCache, bool 
bBounds) const
 {
     return GetPartialTextArray(rStr, pKernArray, nIndex, nLen, nIndex, nLen, 
bCaret, pLayoutCache,
-                               pSalLayoutCache);
+                               pSalLayoutCache, bBounds);
 }
 
 vcl::TextArrayMetrics
 OutputDevice::GetPartialTextArray(const OUString& rStr, KernArray* pKernArray, 
sal_Int32 nIndex,
                                   sal_Int32 nLen, sal_Int32 nPartIndex, 
sal_Int32 nPartLen,
                                   bool bCaret, const 
vcl::text::TextLayoutCache* pLayoutCache,
-                                  const SalLayoutGlyphs* pSalLayoutCache) const
+                                  const SalLayoutGlyphs* pSalLayoutCache, bool 
bBounds) const
 {
     if (nIndex >= rStr.getLength())
     {
@@ -901,11 +901,14 @@ OutputDevice::GetPartialTextArray(const OUString& rStr, 
KernArray* pKernArray, s
 
     vcl::TextArrayMetrics stReturnValue;
 
-    basegfx::B2DRectangle stRect;
-    if (pSalLayout->GetBoundRect(stRect))
+    if (bBounds)
     {
-        auto stRect2 = SalLayout::BoundRect2Rectangle(stRect);
-        stReturnValue.aBounds = ImplDevicePixelToLogic(stRect2);
+        basegfx::B2DRectangle stRect;
+        if (pSalLayout->GetBoundRect(stRect))
+        {
+            auto stRect2 = SalLayout::BoundRect2Rectangle(stRect);
+            stReturnValue.aBounds = ImplDevicePixelToLogic(stRect2);
+        }
     }
 
     stReturnValue.nWidth = ImplDevicePixelToLogicWidthDouble(nWidth);

Reply via email to