svx/source/customshapes/EnhancedCustomShapeFontWork.cxx |   34 ++++++++++++----
 1 file changed, 27 insertions(+), 7 deletions(-)

New commits:
commit f9ceb96c11dcb262f030966cf44b2dc5ed657144
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sat Jun 18 21:25:27 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sun Jun 19 13:29:12 2022 +0200

    ofz#48122 Timeout
    
    Change-Id: Ia00a8ced550a5d4c84899e6cfb293779216898e8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136093
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx 
b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
index a08e03f146eb..de621c1367e7 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -243,16 +243,36 @@ static void CalculateHorizontalScalingFactor(
 
         if (fScalingFactor < 1.0)
         {
-            // if we have a very large font that will require scaling down to 
a very small value then
-            // skip directly to a small font size
+            // we have a very large font that will require scaling down to a 
very small value.
             if (nFontSize > 128)
             {
-                double nEstimatedFinalFontSize = nFontSize * fScalingFactor;
-                double nOnePercentFontSize = nFontSize / 100.0;
-                if (nEstimatedFinalFontSize < nOnePercentFontSize)
+                // see if it will even be possible at the min size
+                sal_Int32 nOrigFontSize = nFontSize;
+                double fOrigScalingFactor = fScalingFactor;
+
+                nFontSize = 2;
+                pVirDev->Push(vcl::PushFlags::FONT);
+                aFont.SetFontHeight(nFontSize);
+                pVirDev->SetFont(aFont);
+                UpdateScalingMode(rFWData, rOutline2d, bSingleLineMode, 
pVirDev, fScalingFactor);
+                pVirDev->Pop();
+
+                const bool bHopeLess = fScalingFactor < 1.0;
+                // if its hopeless then just continue on with this FontSize of 
2, otherwise
+                // continue to try smaller sizes
+                if (!bHopeLess)
                 {
-                    nFontSize = std::max<int>(16, std::ceil(5 * 
nEstimatedFinalFontSize));
-                    SAL_WARN("svx", "CalculateHorizontalScalingFactor skipping 
direct to: " << nFontSize << " from " << rFontHeight.GetHeight());
+                    nFontSize = nOrigFontSize;
+                    fScalingFactor = fOrigScalingFactor;
+
+                    // skip directly to a small font size
+                    double nEstimatedFinalFontSize = nFontSize * 
fScalingFactor;
+                    double nOnePercentFontSize = nFontSize / 100.0;
+                    if (nEstimatedFinalFontSize < nOnePercentFontSize)
+                    {
+                        nFontSize = std::max<int>(16, std::ceil(5 * 
nEstimatedFinalFontSize));
+                        SAL_WARN("svx", "CalculateHorizontalScalingFactor 
skipping direct to: " << nFontSize << " from " << rFontHeight.GetHeight());
+                    }
                 }
             }
             nFontSize--;

Reply via email to