summaryrefslogtreecommitdiffstats
path: root/vcl
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2013-05-06 16:54:53 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2013-05-06 17:22:30 +0200
commitf0393d7ff69011a16b100541ef18e5090544e4a1 (patch)
tree86c254a7dcc0e45852bb3c98cf5575ec1fef0ebb /vcl
parentRemove unused variables (diff)
downloadcore-f0393d7ff69011a16b100541ef18e5090544e4a1.tar.gz
core-f0393d7ff69011a16b100541ef18e5090544e4a1.zip
[harfbuzz] Fix text width calculation, 3rd try
It turns out storing the width in the layout is not so good idea, because in some mysterious cases when font fallback is involved we call GetTextWidth() without calling LayoutText() first, and we return the width of the previous text run. It seems all I needed is to pass down the X offset with the glyph item, and take it into account when calculating the width. Change-Id: Idbdb6bba00573fb6ca773701757d667e21ac0912
Diffstat (limited to 'vcl')
-rw-r--r--vcl/generic/glyphs/gcach_layout.cxx14
-rw-r--r--vcl/inc/generic/glyphcache.hxx6
-rw-r--r--vcl/inc/sallayout.hxx11
-rw-r--r--vcl/source/gdi/sallayout.cxx2
4 files changed, 13 insertions, 20 deletions
diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx
index cb6c1953a74a..935a0e5180d7 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -72,17 +72,6 @@ bool ServerFontLayout::LayoutText( ImplLayoutArgs& rArgs )
}
// -----------------------------------------------------------------------
-long ServerFontLayout::GetTextWidth() const
-{
- long nWidth;
- if (bUseHarfBuzz)
- nWidth = GetWidth();
- else
- nWidth = GenericSalLayout::GetTextWidth();
-
- return nWidth;
-}
-
void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs )
{
GenericSalLayout::AdjustLayout( rArgs );
@@ -524,7 +513,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));
- const GlyphItem aGI(nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nXAdvance);
+ const GlyphItem aGI(nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nXAdvance, nXOffset);
rLayout.AppendGlyph(aGI);
aCurrPos.X() += nXAdvance;
@@ -533,7 +522,6 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
hb_buffer_destroy(pHbBuffer);
}
- rLayout.SetWidth(aCurrPos.X());
hb_font_destroy(pHbFont);
diff --git a/vcl/inc/generic/glyphcache.hxx b/vcl/inc/generic/glyphcache.hxx
index 5345360d8c52..e03e03485ee4 100644
--- a/vcl/inc/generic/glyphcache.hxx
+++ b/vcl/inc/generic/glyphcache.hxx
@@ -317,7 +317,6 @@ private:
SAL_DLLPRIVATE ServerFontLayout& operator=( const ServerFontLayout& );
bool bUseHarfBuzz;
- long mnTextWidth;
public:
ServerFontLayout( ServerFont& );
@@ -325,12 +324,7 @@ public:
virtual void AdjustLayout( ImplLayoutArgs& );
virtual void ApplyDXArray( ImplLayoutArgs& );
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; }
};
// =======================================================================
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 5d99acb768df..6b25f5bae386 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -310,6 +310,7 @@ struct GlyphItem
int mnCharPos; // index in string
int mnOrigWidth; // original glyph width
int mnNewWidth; // width after adjustments
+ int mnXOffset;
sal_GlyphId mnGlyphIndex;
Point maLinearPos; // absolute position of non rotated string
@@ -320,9 +321,19 @@ public:
long nFlags, int nOrigWidth )
: mnFlags(nFlags), mnCharPos(nCharPos),
mnOrigWidth(nOrigWidth), mnNewWidth(nOrigWidth),
+ mnXOffset(0),
mnGlyphIndex(nGlyphIndex), maLinearPos(rLinearPos)
{}
+ GlyphItem( int nCharPos, sal_GlyphId nGlyphIndex, const Point& rLinearPos,
+ long nFlags, int nOrigWidth, int nXOffset )
+ : mnFlags(nFlags), mnCharPos(nCharPos),
+ mnOrigWidth(nOrigWidth), mnNewWidth(nOrigWidth),
+ mnXOffset(nXOffset),
+ mnGlyphIndex(nGlyphIndex), maLinearPos(rLinearPos)
+ {}
+
+
enum{ FALLBACK_MASK=0xFF, IS_IN_CLUSTER=0x100, IS_RTL_GLYPH=0x200, IS_DIACRITIC=0x400 };
bool IsClusterStart() const { return ((mnFlags & IS_IN_CLUSTER) == 0); }
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index e90f7820f7e4..6955679350ad 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -996,7 +996,7 @@ long GenericSalLayout::GetTextWidth() const
long nXPos = pG->maLinearPos.X();
if( nMinPos > nXPos )
nMinPos = nXPos;
- nXPos += pG->mnNewWidth;
+ nXPos += pG->mnNewWidth - pG->mnXOffset;
if( nMaxPos < nXPos )
nMaxPos = nXPos;
}