/[packages]/cauldron/libreoffice/releases/3.3.1.2/7.mga1/SOURCES/0001-Resolves-rhbz-682621-better-resizing-of-overtall-gly.patch
ViewVC logotype

Contents of /cauldron/libreoffice/releases/3.3.1.2/7.mga1/SOURCES/0001-Resolves-rhbz-682621-better-resizing-of-overtall-gly.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 389214 - (show annotations) (download)
Thu Jan 17 21:30:27 2013 UTC (11 years, 3 months ago) by pterjan
File size: 5173 byte(s)
oops
1 From 39387fda8c027722d7db2a1320a2bebf95efb641 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
3 Date: Wed, 9 Mar 2011 14:22:04 +0000
4 Subject: [PATCH] Resolves: rhbz#682621 better resizing of overtall glyphsubs
5
6 ---
7 vcl/inc/vcl/outdev.hxx | 5 +++
8 vcl/source/gdi/outdev3.cxx | 70 ++++++++++++++++++++++++++++++++++---------
9 2 files changed, 60 insertions(+), 15 deletions(-)
10
11 diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
12 index 251b2e8..859020f 100644
13 --- a/vcl/inc/vcl/outdev.hxx
14 +++ b/vcl/inc/vcl/outdev.hxx
15 @@ -276,6 +276,8 @@ enum OutDevViewType { OUTDEV_VIEWTYPE_DONTKNOW, OUTDEV_VIEWTYPE_PRINTPREVIEW, OU
16
17 class VirtualDevice;
18 class Printer;
19 +class ImplFontSelectData;
20 +class ImplFontMetricData;
21
22 const char* ImplDbgCheckOutputDevice( const void* pObj );
23
24 @@ -563,6 +565,9 @@ public:
25 // Helper for line geometry paint with support for graphic expansion (pattern and fat_to_area)
26 void impPaintLineGeometryWithEvtlExpand(const LineInfo& rInfo, basegfx::B2DPolyPolygon aLinePolyPolygon);
27
28 + SAL_DLLPRIVATE void forceFallbackFontToFit(SalLayout &rFallback, ImplFontEntry &rFallbackFont,
29 + ImplFontSelectData &rFontSelData, int nFallbackLevel,
30 + ImplLayoutArgs& rLayoutArgs, const ImplFontMetricData& rOrigMetric) const;
31 protected:
32 OutputDevice();
33
34 diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
35 index 84a7b5d..7a439f2 100644
36 --- a/vcl/source/gdi/outdev3.cxx
37 +++ b/vcl/source/gdi/outdev3.cxx
38 @@ -6023,6 +6023,58 @@
39 return pSalLayout;
40 }
41
42 +void OutputDevice::forceFallbackFontToFit(SalLayout &rFallback, ImplFontEntry &rFallbackFont,
43 + ImplFontSelectData &rFontSelData, int nFallbackLevel,
44 + ImplLayoutArgs& rLayoutArgs, const ImplFontMetricData& rOrigMetric) const
45 +{
46 + Rectangle aBoundRect;
47 + bool bHaveBounding = false;
48 + Rectangle aRectangle;
49 +
50 + rFallback.AdjustLayout( rLayoutArgs );
51 +
52 + //All we care about here is getting the vertical bounds of this text and
53 + //make sure it will fit inside the available space
54 + Point aPos;
55 + for( int nStart = 0;;)
56 + {
57 + sal_GlyphId nLGlyph;
58 + if( !rFallback.GetNextGlyphs( 1, &nLGlyph, aPos, nStart ) )
59 + break;
60 +
61 + int nFontTag = nFallbackLevel << GF_FONTSHIFT;
62 + nLGlyph |= nFontTag;
63 +
64 + // get bounding rectangle of individual glyph
65 + if( mpGraphics->GetGlyphBoundRect( nLGlyph, aRectangle ) )
66 + {
67 + // merge rectangle
68 + aRectangle += aPos;
69 + aBoundRect.Union( aRectangle );
70 + bHaveBounding = true;
71 + }
72 + }
73 +
74 + //Shrink it down if it won't fit
75 + if (bHaveBounding)
76 + {
77 + long nGlyphsAscent = -aBoundRect.Top();
78 + float fScaleTop = nGlyphsAscent > rOrigMetric.mnAscent ?
79 + rOrigMetric.mnAscent/(float)nGlyphsAscent : 1;
80 + long nGlyphsDescent = aBoundRect.Bottom();
81 + float fScaleBottom = nGlyphsDescent > rOrigMetric.mnDescent ?
82 + rOrigMetric.mnDescent/(float)nGlyphsDescent : 1;
83 + float fScale = fScaleBottom < fScaleTop ? fScaleBottom : fScaleTop;
84 + if (fScale < 1)
85 + {
86 + long nOrigHeight = rFontSelData.mnHeight;
87 + rFontSelData.mnHeight *= fScale;
88 + rFallbackFont.mnSetFontFlags = mpGraphics->SetFont( &rFontSelData, nFallbackLevel );
89 + rFontSelData.mnHeight = nOrigHeight;
90 + }
91 + }
92 +}
93 +
94 // -----------------------------------------------------------------------
95
96 SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLayoutArgs& rLayoutArgs ) const
97 @@ -6102,22 +6154,7 @@
98 }
99 #endif
100
101 - ImplFontMetricData aSubstituteMetric(aFontSelData);
102 pFallbackFont->mnSetFontFlags = mpGraphics->SetFont( &aFontSelData, nFallbackLevel );
103 - mpGraphics->GetFontMetric(&aSubstituteMetric, nFallbackLevel);
104 -
105 - long nOriginalHeight = aOrigMetric.mnAscent + aOrigMetric.mnDescent;
106 - long nSubstituteHeight = aSubstituteMetric.mnAscent + aSubstituteMetric.mnDescent;
107 - //Too tall, shrink it a bit. Need a better calculation to include extra
108 - //factors and any extra wriggle room we might have available ?
109 - if (nSubstituteHeight > nOriginalHeight)
110 - {
111 - float fScale = nOriginalHeight/(float)nSubstituteHeight;
112 - long nOrigHeight = aFontSelData.mnHeight;
113 - aFontSelData.mnHeight *= fScale;
114 - pFallbackFont->mnSetFontFlags = mpGraphics->SetFont( &aFontSelData, nFallbackLevel );
115 - aFontSelData.mnHeight = nOrigHeight;
116 - }
117
118 // create and add glyph fallback layout to multilayout
119 rLayoutArgs.ResetPos();
120 @@ -6126,6 +6163,9 @@
121 {
122 if( pFallback->LayoutText( rLayoutArgs ) )
123 {
124 + forceFallbackFontToFit(*pFallback, *pFallbackFont, aFontSelData,
125 + nFallbackLevel, rLayoutArgs, aOrigMetric);
126 +
127 if( !pMultiSalLayout )
128 pMultiSalLayout = new MultiSalLayout( *pSalLayout );
129 pMultiSalLayout->AddFallback( *pFallback,
130

  ViewVC Help
Powered by ViewVC 1.1.30