Kaydet (Commit) 9cd7f7ad authored tarafından Khaled Hosny's avatar Khaled Hosny

[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
üst fc893070
...@@ -67,6 +67,40 @@ bool ServerFontLayout::LayoutText( ImplLayoutArgs& rArgs ) ...@@ -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 ) void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs )
{ {
GenericSalLayout::AdjustLayout( rArgs ); GenericSalLayout::AdjustLayout( rArgs );
......
...@@ -324,6 +324,7 @@ public: ...@@ -324,6 +324,7 @@ public:
virtual void AdjustLayout( ImplLayoutArgs& ); virtual void AdjustLayout( ImplLayoutArgs& );
virtual void ApplyDXArray( ImplLayoutArgs& ); virtual void ApplyDXArray( ImplLayoutArgs& );
virtual void DrawText( SalGraphics& ) const; virtual void DrawText( SalGraphics& ) const;
virtual long GetTextWidth() const;
ServerFont& GetServerFont() const { return mrServerFont; } ServerFont& GetServerFont() const { return mrServerFont; }
}; };
......
...@@ -367,6 +367,8 @@ protected: ...@@ -367,6 +367,8 @@ protected:
bool GetCharWidths( sal_Int32* pCharWidths ) const; bool GetCharWidths( sal_Int32* pCharWidths ) const;
GlyphVector GetGlyphItems() const { return m_GlyphItems; }
private: private:
GlyphVector m_GlyphItems; GlyphVector m_GlyphItems;
mutable Point maBasePoint; mutable Point maBasePoint;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment