include/vcl/outdev.hxx | 4 +- vcl/source/gdi/outdev3.cxx | 72 ++------------------------------------------- 2 files changed, 6 insertions(+), 70 deletions(-)
New commits: commit 92ffe57f6bf40ec0f19e2abed24721137c569063 Author: Khaled Hosny <[email protected]> Date: Sat Jun 15 14:24:21 2013 +0200 Donât shrink text from fallback fonts This code is bogus in multiple ways: * It scales text based on ascent or descent, but this makes no sense as those control line height and nothing else, if one is to scale two different fonts to âfitâ together, cap or x height would be more appropriate. This results in some text being ridiculously shrunk. * Not only that, but it is comparing apples to oranges; original font ascent/descent with the bounding box of the fallback glyphs, which results in different scale ratios depending on the shape of the glyphs at hand, which leads to all sorts of funny and irregular text. * Even worse, the PDF export is completely broken in this case; it uses the scaled down glyph widths but the unscaled font size, resulting in cramped unreadable text. Change-Id: Iaa6117ecfdad8388887d9a03b538e7327544ad5e Reviewed-on: https://gerrit.libreoffice.org/4293 Reviewed-by: Bosdonnat Cedric <[email protected]> Tested-by: Bosdonnat Cedric <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index b97f416..688d75d 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -541,9 +541,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 SalLayout* getFallbackFontThatFits(ImplFontEntry &rFallbackFont, + SAL_DLLPRIVATE SalLayout* getFallbackFont(ImplFontEntry &rFallbackFont, FontSelectPattern &rFontSelData, int nFallbackLevel, - ImplLayoutArgs& rLayoutArgs, const ImplFontMetricData& rOrigMetric) const; + ImplLayoutArgs& rLayoutArgs) const; protected: OutputDevice(); diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index 38f1f25..999f703 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -5877,9 +5877,9 @@ SalLayout* OutputDevice::ImplLayout( const OUString& rOrigStr, sal_Int32 nMinInd return pSalLayout; } -SalLayout* OutputDevice::getFallbackFontThatFits(ImplFontEntry &rFallbackFont, +SalLayout* OutputDevice::getFallbackFont(ImplFontEntry &rFallbackFont, FontSelectPattern &rFontSelData, int nFallbackLevel, - ImplLayoutArgs& rLayoutArgs, const ImplFontMetricData& rOrigMetric) const + ImplLayoutArgs& rLayoutArgs) const { rFallbackFont.mnSetFontFlags = mpGraphics->SetFont( &rFontSelData, nFallbackLevel ); @@ -5896,68 +5896,8 @@ SalLayout* OutputDevice::getFallbackFontThatFits(ImplFontEntry &rFallbackFont, return NULL; } - Rectangle aBoundRect; - bool bHaveBounding = false; - Rectangle aRectangle; - pFallback->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( !pFallback->GetNextGlyphs( 1, &nLGlyph, aPos, nStart ) ) - break; - - sal_GlyphId 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; - long nNewHeight = static_cast<int>(static_cast<float>(rFontSelData.mnHeight) * fScale); - - if (nNewHeight == nOrigHeight) - --nNewHeight; - - pFallback->Release(); - - rFontSelData.mnHeight = nNewHeight; - rFallbackFont.mnSetFontFlags = mpGraphics->SetFont( &rFontSelData, nFallbackLevel ); - rFontSelData.mnHeight = nOrigHeight; - - rLayoutArgs.ResetPos(); - pFallback = mpGraphics->GetTextLayout( rLayoutArgs, nFallbackLevel ); - if (pFallback && !pFallback->LayoutText(rLayoutArgs)) - { - pFallback->Release(); - pFallback = NULL; - } - SAL_WARN_IF(!pFallback, "vcl.gdi", "we couldn't layout text with a smaller point size that worked with a bigger one"); - } - } return pFallback; } @@ -5980,10 +5920,6 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay FontSelectPattern aFontSelData = mpFontEntry->maFontSelData; - ImplFontMetricData aOrigMetric( aFontSelData ); - // TODO: use cached metric in fontentry - mpGraphics->GetFontMetric( &aOrigMetric ); - // when device specific font substitution may have been performed for // the originally selected font then make sure that a fallback to that // font is performed first @@ -6018,8 +5954,8 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay } // create and add glyph fallback layout to multilayout - SalLayout* pFallback = getFallbackFontThatFits(*pFallbackFont, aFontSelData, - nFallbackLevel, rLayoutArgs, aOrigMetric); + SalLayout* pFallback = getFallbackFont(*pFallbackFont, aFontSelData, + nFallbackLevel, rLayoutArgs); if (pFallback) { if( !pMultiSalLayout )
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
