[libreoffice] Resolves: rhbz#682621 better resizing of overtall glyphsubs

Caolan McNamara caolanm at fedoraproject.org
Wed Mar 9 15:39:31 UTC 2011


commit 85db558ee3c850f1b6c28e7837e5d86b4acad8b3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 9 15:39:22 2011 +0000

    Resolves: rhbz#682621 better resizing of overtall glyphsubs

 ...bz-682621-better-resizing-of-overtall-gly.patch |  132 ++++++++++++++++++++
 libreoffice.spec                                   |    7 +-
 2 files changed, 138 insertions(+), 1 deletions(-)
---
diff --git a/0001-Resolves-rhbz-682621-better-resizing-of-overtall-gly.patch b/0001-Resolves-rhbz-682621-better-resizing-of-overtall-gly.patch
new file mode 100644
index 0000000..0f79d89
--- /dev/null
+++ b/0001-Resolves-rhbz-682621-better-resizing-of-overtall-gly.patch
@@ -0,0 +1,132 @@
+From 39387fda8c027722d7db2a1320a2bebf95efb641 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm at redhat.com>
+Date: Wed, 9 Mar 2011 14:22:04 +0000
+Subject: [PATCH] Resolves: rhbz#682621 better resizing of overtall glyphsubs
+
+---
+ vcl/inc/vcl/outdev.hxx     |    5 +++
+ vcl/source/gdi/outdev3.cxx |   70 ++++++++++++++++++++++++++++++++++---------
+ 2 files changed, 60 insertions(+), 15 deletions(-)
+
+diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
+index 251b2e8..859020f 100644
+--- a/vcl/inc/vcl/outdev.hxx
++++ b/vcl/inc/vcl/outdev.hxx
+@@ -276,6 +276,8 @@ enum OutDevViewType { OUTDEV_VIEWTYPE_DONTKNOW, OUTDEV_VIEWTYPE_PRINTPREVIEW, OU
+ 
+ class VirtualDevice;
+ class Printer;
++class ImplFontSelectData;
++class ImplFontMetricData;
+ 
+ const char* ImplDbgCheckOutputDevice( const void* pObj );
+ 
+@@ -563,6 +565,9 @@ public:
+     // Helper for line geometry paint with support for graphic expansion (pattern and fat_to_area)
+     void impPaintLineGeometryWithEvtlExpand(const LineInfo& rInfo, basegfx::B2DPolyPolygon aLinePolyPolygon);
+ 
++    SAL_DLLPRIVATE void forceFallbackFontToFit(SalLayout &rFallback, ImplFontEntry &rFallbackFont,
++        ImplFontSelectData &rFontSelData, int nFallbackLevel,
++        ImplLayoutArgs& rLayoutArgs, const ImplFontMetricData& rOrigMetric) const;
+ protected:
+                         OutputDevice();
+ 
+diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
+index 84a7b5d..7a439f2 100644
+--- a/vcl/source/gdi/outdev3.cxx
++++ b/vcl/source/gdi/outdev3.cxx
+@@ -6015,6 +6015,58 @@ SalLayout* OutputDevice::ImplLayout( const String& rOrigStr,
+     return pSalLayout;
+ }
+ 
++void OutputDevice::forceFallbackFontToFit(SalLayout &rFallback, ImplFontEntry &rFallbackFont,
++    ImplFontSelectData &rFontSelData, int nFallbackLevel,
++    ImplLayoutArgs& rLayoutArgs, const ImplFontMetricData& rOrigMetric) const
++{
++    Rectangle aBoundRect;
++    bool bHaveBounding = false;
++    Rectangle aRectangle;
++
++    rFallback.AdjustLayout( rLayoutArgs );
++
++    //All we care about here is getting the vertical bounds of this text and
++    //make sure it will fit inside the available space
++    Point aPos;
++    for( int nStart = 0;;)
++    {
++        sal_GlyphId nLGlyph;
++        if( !rFallback.GetNextGlyphs( 1, &nLGlyph, aPos, nStart ) )
++            break;
++
++        int nFontTag = nFallbackLevel << GF_FONTSHIFT;
++        nLGlyph |= nFontTag;
++
++        // get bounding rectangle of individual glyph
++        if( mpGraphics->GetGlyphBoundRect( nLGlyph, aRectangle ) )
++        {
++            // merge rectangle
++            aRectangle += aPos;
++            aBoundRect.Union( aRectangle );
++            bHaveBounding = true;
++        }
++    }
++
++    //Shrink it down if it won't fit
++    if (bHaveBounding)
++    {
++        long  nGlyphsAscent = -aBoundRect.Top();
++        float fScaleTop = nGlyphsAscent > rOrigMetric.mnAscent ?
++            rOrigMetric.mnAscent/(float)nGlyphsAscent : 1;
++        long  nGlyphsDescent = aBoundRect.Bottom();
++        float fScaleBottom = nGlyphsDescent > rOrigMetric.mnDescent ?
++            rOrigMetric.mnDescent/(float)nGlyphsDescent : 1;
++        float fScale = fScaleBottom < fScaleTop ? fScaleBottom : fScaleTop;
++        if (fScale < 1)
++        {
++            long nOrigHeight = rFontSelData.mnHeight;
++            rFontSelData.mnHeight *= fScale;
++            rFallbackFont.mnSetFontFlags = mpGraphics->SetFont( &rFontSelData, nFallbackLevel );
++            rFontSelData.mnHeight = nOrigHeight;
++        }
++    }
++}
++
+ // -----------------------------------------------------------------------
+ 
+ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLayoutArgs& rLayoutArgs ) const
+@@ -6072,22 +6124,7 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay
+             }
+         }
+ 
+-        ImplFontMetricData aSubstituteMetric(aFontSelData);
+         pFallbackFont->mnSetFontFlags = mpGraphics->SetFont( &aFontSelData, nFallbackLevel );
+-        mpGraphics->GetFontMetric(&aSubstituteMetric, nFallbackLevel);
+-
+-        long nOriginalHeight = aOrigMetric.mnAscent + aOrigMetric.mnDescent;
+-        long nSubstituteHeight = aSubstituteMetric.mnAscent + aSubstituteMetric.mnDescent;
+-        //Too tall, shrink it a bit. Need a better calculation to include extra
+-        //factors and any extra wriggle room we might have available ?
+-        if (nSubstituteHeight > nOriginalHeight)
+-        {
+-            float fScale = nOriginalHeight/(float)nSubstituteHeight;
+-            long nOrigHeight = aFontSelData.mnHeight;
+-            aFontSelData.mnHeight *= fScale;
+-            pFallbackFont->mnSetFontFlags = mpGraphics->SetFont( &aFontSelData, nFallbackLevel );
+-            aFontSelData.mnHeight = nOrigHeight;
+-        }
+ 
+         // create and add glyph fallback layout to multilayout
+         rLayoutArgs.ResetPos();
+@@ -6096,6 +6133,9 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay
+         {
+             if( pFallback->LayoutText( rLayoutArgs ) )
+             {
++                forceFallbackFontToFit(*pFallback, *pFallbackFont, aFontSelData,
++                    nFallbackLevel, rLayoutArgs, aOrigMetric);
++
+                 if( !pMultiSalLayout )
+                     pMultiSalLayout = new MultiSalLayout( *pSalLayout );
+                 pMultiSalLayout->AddFallback( *pFallback,
+-- 
+1.7.4.1
+
diff --git a/libreoffice.spec b/libreoffice.spec
index 2d78cf5..80929b7 100644
--- a/libreoffice.spec
+++ b/libreoffice.spec
@@ -28,7 +28,7 @@
 Summary:        Free Software Productivity Suite
 Name:           libreoffice
 Version:        3.3.1.2
-Release:        5%{?dist}
+Release:        6%{?dist}
 License:        LGPLv3 and LGPLv2+ and BSD and (MPLv1.1 or GPLv2 or LGPLv2 or Netscape) and (CDDL or GPLv2) and Public Domain
 Group:          Applications/Productivity
 URL:            http://www.documentfoundation.org/develop
@@ -120,6 +120,7 @@ Patch32: 0001-Resolves-rhbz-672818-bandaid-for-crash-in-SwTxtNode-.patch
 Patch33: 0001-valgrind-don-t-leave-an-evil-thread-running-after-ma.patch
 Patch34: 0001-install-high-resolution-icons.patch
 Patch35: 0001-Resolves-rhbz-682716-pa-IN-isn-t-handled-by-fontconf.patch
+Patch36: 0001-Resolves-rhbz-682621-better-resizing-of-overtall-gly.patch
 
 %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
 %define instdir %{_libdir}
@@ -758,6 +759,7 @@ mv -f redhat.soc extras/source/palettes/standard.soc
 %patch33 -p1 -b .valgrind-don-t-leave-an-evil-thread-running-after-ma.patch
 %patch34 -p1 -b .install-high-resolution-icons.patch
 %patch35 -p1 -b .rhbz682716-pa-IN-isn-t-handled-by-fontconf.patch
+%patch36 -p1 -b .rhbz682621-better-resizing-of-overtall-gly.patch
 touch scripting/source/pyprov/delzip
 touch scripting/util/provider/beanshell/delzip
 touch scripting/util/provider/javascript/delzip
@@ -2103,6 +2105,9 @@ update-desktop-database %{_datadir}/applications &> /dev/null || :
 %{basisinstdir}/program/kde-open-url
 
 %changelog
+* Wed Mar 09 2011 Caolán McNamara <caolanm at redhat.com> 3.3.1.2-6
+- Resolves: rhbz#682621 better resizing of overtall glyphsubs
+
 * Tue Mar 08 2011 Caolán McNamara <caolanm at redhat.com> 3.3.1.2-5
 - Resolves: rhbz#682716 pa-IN isn't handled well by fontconfig
 


More information about the scm-commits mailing list