Kaydet (Commit) 1f7d7d0f authored tarafından Khaled Hosny's avatar Khaled Hosny

[harfbuzz] Fix text width calculation for real

No more second guessing if text width, we know that information already,
so pass it around instead of trying to re-create it.

Change-Id: I19faacbc309d38753c3c9f7214dfa0bf59cc66b5
üst 2e302f18
......@@ -76,33 +76,9 @@ long ServerFontLayout::GetTextWidth() const
{
long nWidth;
if (bUseHarfBuzz)
{
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;
}
nWidth = GetWidth();
else
{
nWidth = GenericSalLayout::GetTextWidth();
}
return nWidth;
}
......@@ -448,9 +424,6 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
continue;
}
const GlyphMetric& rGM = rFont.GetGlyphMetric(nGlyphIndex);
int nGlyphWidth = rGM.GetCharWidth();
long nGlyphFlags = 0;
if (bRightToLeft)
nGlyphFlags |= GlyphItem::IS_RTL_GLYPH;
......@@ -473,10 +446,7 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
int32_t nYAdvance = pHbPositions[i].y_advance >> 6;
Point aNewPos = Point(aCurrPos.X() + nXOffset, -(aCurrPos.Y() + nYOffset));
GlyphItem aGI(nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nGlyphWidth);
aGI.mnNewWidth = nXAdvance;
const GlyphItem aGI(nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nXAdvance);
rLayout.AppendGlyph(aGI);
aCurrPos.X() += nXAdvance;
......@@ -485,6 +455,7 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
hb_buffer_destroy(pHbBuffer);
}
rLayout.SetWidth(aCurrPos.X());
hb_font_destroy(pHbFont);
......
......@@ -319,6 +319,7 @@ private:
SAL_DLLPRIVATE ServerFontLayout& operator=( const ServerFontLayout& );
bool bUseHarfBuzz;
long mnTextWidth;
public:
ServerFontLayout( ServerFont& );
......@@ -328,6 +329,10 @@ public:
virtual void DrawText( SalGraphics& ) const;
virtual long GetTextWidth() const;
ServerFont& GetServerFont() const { return mrServerFont; }
// used by layout engine
void SetWidth( long nWidth ) { mnTextWidth = nWidth; }
long GetWidth() const { return mnTextWidth; }
};
// =======================================================================
......
......@@ -367,8 +367,6 @@ protected:
bool GetCharWidths( sal_Int32* pCharWidths ) const;
GlyphVector GetGlyphItems() const { return m_GlyphItems; }
private:
GlyphVector m_GlyphItems;
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