diff options
author | Caolán McNamara <caolanm@redhat.com> | 2010-09-30 16:50:58 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2010-09-30 16:50:58 +0100 |
commit | 5e83d9db0213f17fe8af6ca1ae33e397f83e9d54 (patch) | |
tree | ab78535e0eedf47d1aa0085ad1359b08f9f0619c | |
parent | bf2037d9ad896023f0190180e77cf7afac3a9bdd (diff) |
shrink replacement glyphs when they wouldn't fit on the line
-rw-r--r-- | vcl/inc/vcl/salgdi.hxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/outdev3.cxx | 19 | ||||
-rw-r--r-- | vcl/unx/headless/svpgdi.hxx | 2 | ||||
-rw-r--r-- | vcl/unx/headless/svppspgraphics.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/headless/svppspgraphics.hxx | 2 | ||||
-rw-r--r-- | vcl/unx/headless/svptext.cxx | 9 | ||||
-rw-r--r-- | vcl/unx/inc/pspgraphics.h | 2 | ||||
-rw-r--r-- | vcl/unx/inc/salgdi.h | 2 | ||||
-rw-r--r-- | vcl/unx/source/gdi/pspgraphics.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/source/gdi/salgdi3.cxx | 13 |
10 files changed, 40 insertions, 15 deletions
diff --git a/vcl/inc/vcl/salgdi.hxx b/vcl/inc/vcl/salgdi.hxx index f75817071304..cbe3581bedc4 100644 --- a/vcl/inc/vcl/salgdi.hxx +++ b/vcl/inc/vcl/salgdi.hxx @@ -233,7 +233,7 @@ public: // release the fonts void ReleaseFonts() { SetFont( NULL, 0 ); } // get the current font's metrics - virtual void GetFontMetric( ImplFontMetricData* ) = 0; + virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel = 0 ) = 0; // get kernign pairs of the current font // return only PairCount if (pKernPairs == NULL) diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index bf1cc2728bf1..29e7380848f3 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -6058,6 +6058,10 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay rtl::OUString aMissingCodes = aMissingCodeBuf.makeStringAndClear(); ImplFontSelectData aFontSelData = mpFontEntry->maFontSelData; + + ImplFontMetricData aOrigMetric(aFontSelData); + 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 @@ -6102,7 +6106,22 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay } #endif + 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(); diff --git a/vcl/unx/headless/svpgdi.hxx b/vcl/unx/headless/svpgdi.hxx index ca1af87f8862..1ad9eca9d272 100644 --- a/vcl/unx/headless/svpgdi.hxx +++ b/vcl/unx/headless/svpgdi.hxx @@ -86,7 +86,7 @@ public: virtual void SetTextColor( SalColor nSalColor ); virtual USHORT SetFont( ImplFontSelectData*, int nFallbackLevel ); - virtual void GetFontMetric( ImplFontMetricData* ); + virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ); virtual ULONG GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs ); virtual ImplFontCharMap* GetImplFontCharMap() const; virtual void GetDevFontList( ImplDevFontList* ); diff --git a/vcl/unx/headless/svppspgraphics.cxx b/vcl/unx/headless/svppspgraphics.cxx index 6da09b38023c..86f356031f52 100644 --- a/vcl/unx/headless/svppspgraphics.cxx +++ b/vcl/unx/headless/svppspgraphics.cxx @@ -792,7 +792,7 @@ void PspGraphics::GetDevFontSubstList( OutputDevice* pOutDev ) } } -void PspGraphics::GetFontMetric( ImplFontMetricData *pMetric ) +void PspGraphics::GetFontMetric( ImplFontMetricData *pMetric, int ) { const psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); psp::PrintFontInfo aInfo; diff --git a/vcl/unx/headless/svppspgraphics.hxx b/vcl/unx/headless/svppspgraphics.hxx index 063dff34c3c2..987923eb40ff 100644 --- a/vcl/unx/headless/svppspgraphics.hxx +++ b/vcl/unx/headless/svppspgraphics.hxx @@ -105,7 +105,7 @@ public: virtual void SetTextColor( SalColor nSalColor ); virtual USHORT SetFont( ImplFontSelectData*, int nFallbackLevel ); - virtual void GetFontMetric( ImplFontMetricData* ); + virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ); virtual ULONG GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs ); virtual ImplFontCharMap* GetImplFontCharMap() const; virtual void GetDevFontList( ImplDevFontList* ); diff --git a/vcl/unx/headless/svptext.cxx b/vcl/unx/headless/svptext.cxx index ecb8b11b7e04..34941fc777db 100644 --- a/vcl/unx/headless/svptext.cxx +++ b/vcl/unx/headless/svptext.cxx @@ -240,12 +240,15 @@ USHORT SvpSalGraphics::SetFont( ImplFontSelectData* pIFSD, int nFallbackLevel ) // --------------------------------------------------------------------------- -void SvpSalGraphics::GetFontMetric( ImplFontMetricData* pMetric ) +void SvpSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int nFallbackLevel ) { - if( m_pServerFont[0] != NULL ) + if( nFallbackLevel >= MAX_FALLBACK ) + return; + + if( m_pServerFont[nFallbackLevel] != NULL ) { long rDummyFactor; - m_pServerFont[0]->FetchFontMetric( *pMetric, rDummyFactor ); + m_pServerFont[nFallbackLevel]->FetchFontMetric( *pMetric, rDummyFactor ); } } diff --git a/vcl/unx/inc/pspgraphics.h b/vcl/unx/inc/pspgraphics.h index 4b1ac12116a3..a91029e34580 100644 --- a/vcl/unx/inc/pspgraphics.h +++ b/vcl/unx/inc/pspgraphics.h @@ -102,7 +102,7 @@ public: virtual void SetTextColor( SalColor nSalColor ); virtual USHORT SetFont( ImplFontSelectData*, int nFallbackLevel ); - virtual void GetFontMetric( ImplFontMetricData* ); + virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ); virtual ULONG GetKernPairs( ULONG nMaxPairs, ImplKernPairData* ); virtual ImplFontCharMap* GetImplFontCharMap() const; virtual void GetDevFontList( ImplDevFontList* ); diff --git a/vcl/unx/inc/salgdi.h b/vcl/unx/inc/salgdi.h index 42d9c5592317..33e6be054d48 100644 --- a/vcl/unx/inc/salgdi.h +++ b/vcl/unx/inc/salgdi.h @@ -253,7 +253,7 @@ public: virtual void SetTextColor( SalColor nSalColor ); virtual USHORT SetFont( ImplFontSelectData*, int nFallbackLevel ); - virtual void GetFontMetric( ImplFontMetricData* ); + virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ); virtual ULONG GetKernPairs( ULONG nMaxPairs, ImplKernPairData* ); virtual ImplFontCharMap* GetImplFontCharMap() const; virtual void GetDevFontList( ImplDevFontList* ); diff --git a/vcl/unx/source/gdi/pspgraphics.cxx b/vcl/unx/source/gdi/pspgraphics.cxx index d3eb103b9dd6..220d7bbcae87 100644 --- a/vcl/unx/source/gdi/pspgraphics.cxx +++ b/vcl/unx/source/gdi/pspgraphics.cxx @@ -885,7 +885,7 @@ void PspGraphics::GetDevFontSubstList( OutputDevice* pOutDev ) } } -void PspGraphics::GetFontMetric( ImplFontMetricData *pMetric ) +void PspGraphics::GetFontMetric( ImplFontMetricData *pMetric, int ) { const psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); psp::PrintFontInfo aInfo; diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx index 6e3b2047f900..b5e03fc730ef 100644 --- a/vcl/unx/source/gdi/salgdi3.cxx +++ b/vcl/unx/source/gdi/salgdi3.cxx @@ -1763,16 +1763,19 @@ bool GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize, // ---------------------------------------------------------------------------- void -X11SalGraphics::GetFontMetric( ImplFontMetricData *pMetric ) +X11SalGraphics::GetFontMetric( ImplFontMetricData *pMetric, int nFallbackLevel ) { - if( mpServerFont[0] != NULL ) + if( nFallbackLevel >= MAX_FALLBACK ) + return; + + if( mpServerFont[nFallbackLevel] != NULL ) { long rDummyFactor; - mpServerFont[0]->FetchFontMetric( *pMetric, rDummyFactor ); + mpServerFont[nFallbackLevel]->FetchFontMetric( *pMetric, rDummyFactor ); } - else if( mXFont[0] != NULL ) + else if( mXFont[nFallbackLevel] != NULL ) { - mXFont[0]->ToImplFontMetricData( pMetric ); + mXFont[nFallbackLevel]->ToImplFontMetricData( pMetric ); if ( bFontVertical_ ) pMetric->mnOrientation = 0; } |