diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2013-04-27 14:47:29 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2013-04-29 12:45:39 +0200 |
commit | 9cd7f7aded9ba171bf91a8223e6e8a868aedd792 (patch) | |
tree | 8278a59d00c192e6627cc8dc81128ce16d00d714 /vcl/generic | |
parent | fc893070c9255637950ac9844c1ad519b0115bd8 (diff) |
[harfbuzz] Fix text width calculation
GenericSalLayout::GetTextWidth() uses GlyphItem's mnNewWidth when
calculating text width, and though this seems logical (it is after all
the actual with the glyph is contributing to the all over advance
width), it results in shorter width calculation whenever glyph width
adjustment is involved, no idea why!
The #ifdef is there so that the ICU code path is not changed in anyway,
but all of this should be merged into GenericSalLayout when ICU is
gone.
Change-Id: I7cbde1675b78e87c142513eb52a13ee5fdc60617
Diffstat (limited to 'vcl/generic')
-rw-r--r-- | vcl/generic/glyphs/gcach_layout.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx index abd9adffd947..22cb8f77fdb7 100644 --- a/vcl/generic/glyphs/gcach_layout.cxx +++ b/vcl/generic/glyphs/gcach_layout.cxx @@ -67,6 +67,40 @@ bool ServerFontLayout::LayoutText( ImplLayoutArgs& rArgs ) } // ----------------------------------------------------------------------- +long ServerFontLayout::GetTextWidth() const +{ + long nWidth; +#if ENABLE_HARFBUZZ + const char* pUseHarfBuzz = getenv("SAL_USE_HARFBUZZ"); + if (pUseHarfBuzz) { + GlyphVector aGlyphItems = GenericSalLayout::GetGlyphItems(); + + if( aGlyphItems.empty() ) + return 0; + + // initialize the extent + long nMinPos = 0; + long nMaxPos = 0; + + for( GlyphVector::const_iterator pG = aGlyphItems.begin(), end = aGlyphItems.end(); pG != end ; ++pG ) + { + // update the text extent with the glyph extent + long nXPos = pG->maLinearPos.X(); + if( nMinPos > nXPos ) + nMinPos = nXPos; + nXPos += pG->mnOrigWidth; + if( nMaxPos < nXPos ) + nMaxPos = nXPos; + } + + nWidth = nMaxPos - nMinPos; + } + else +#endif + nWidth = GenericSalLayout::GetTextWidth(); + return nWidth; +} + void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs ) { GenericSalLayout::AdjustLayout( rArgs ); |