summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2015-11-21 23:14:18 +0800
committerMark Hung <marklh9@gmail.com>2015-12-19 12:38:46 +0000
commite32fd5e8671b787dfc6795f3109c616974fe2594 (patch)
treebaa98cc3a936549bd3316923de5529cf5c82c4b1
parentdd258f168f7e5952a71d84a2564c3d5162a613c8 (diff)
tdf#83755 correct non-printing character position
Bullet of non-monospace font that is used as non-printing character to indicate space might be wider than the space. Drawing the bullet over the space make the bullet too close to next character. Shift the bullet accordingly so that bullet is centered with original space. Change-Id: I0d8d721041e8a475546fe25fb01bee374fc3e499 Reviewed-on: https://gerrit.libreoffice.org/20112 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mark Hung <marklh9@gmail.com>
-rw-r--r--include/vcl/metric.hxx1
-rw-r--r--sw/source/core/txtnode/fntcache.cxx22
-rw-r--r--vcl/inc/impfont.hxx2
-rw-r--r--vcl/inc/outfont.hxx1
-rw-r--r--vcl/source/gdi/metric.cxx6
-rw-r--r--vcl/source/outdev/font.cxx5
6 files changed, 37 insertions, 0 deletions
diff --git a/include/vcl/metric.hxx b/include/vcl/metric.hxx
index ddf27eb85455..fd3759a76eba 100644
--- a/include/vcl/metric.hxx
+++ b/include/vcl/metric.hxx
@@ -73,6 +73,7 @@ public:
long GetLineHeight() const;
long GetSlant() const;
bool IsFullstopCentered() const;
+ long GetBulletOffset() const;
FontMetric& operator=( const FontMetric& rMetric );
bool operator==( const FontMetric& rMetric ) const;
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index f8189328cff6..1b5ebbde0ade 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -1781,6 +1781,28 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
pTmpFont->SetOverline(UNDERLINE_NONE);
pTmpFont->SetStrikeout(STRIKEOUT_NONE);
rInf.GetOut().SetFont( *pTmpFont );
+ long nShift = rInf.GetOut( ).GetFontMetric( ).GetBulletOffset( );
+ if ( nShift )
+ {
+ long nAdd = 0;
+
+ if (aBulletOverlay.getLength() > nTmpIdx &&
+ aBulletOverlay[ nTmpIdx ] == CH_BULLET )
+ {
+ if (bSwitchH2V)
+ aTextOriginPos.Y() += nShift ;
+ else
+ aTextOriginPos.X() += nShift ;
+ nAdd = nShift ;
+ }
+ for( sal_Int32 i = 1 ; i < nLen ; ++i )
+ {
+ if ( aBulletOverlay[ i + nTmpIdx ] == CH_BULLET )
+ pKernArray [ i - 1 ] += nShift ;
+ if ( nAdd )
+ pKernArray [ i - 1 ] -= nAdd;
+ }
+ }
rInf.GetOut().DrawTextArray( aTextOriginPos, aBulletOverlay, pKernArray + nOffs,
nTmpIdx + nOffs , nLen - nOffs );
pTmpFont->SetColor( aPreviousColor );
diff --git a/vcl/inc/impfont.hxx b/vcl/inc/impfont.hxx
index ab2bd21ffe0d..1ed1e41560c9 100644
--- a/vcl/inc/impfont.hxx
+++ b/vcl/inc/impfont.hxx
@@ -100,6 +100,7 @@ private:
long mnExtLeading; // External Leading
long mnLineHeight; // Ascent+Descent+EmphasisMark
long mnSlant; // Slant
+ long mnBulletOffset;// Offset for non-priting character
sal_uInt16 mnMiscFlags; // Misc Flags
sal_uInt32 mnRefCount; // Reference Counter
@@ -118,6 +119,7 @@ public:
long GetSlant() const { return mnSlant; }
bool IsFullstopCentered() const { return ((mnMiscFlags & FULLSTOP_CENTERED_FLAG ) != 0); }
+ long GetBulletOffset() const { return mnBulletOffset; }
bool IsScalable() const { return ((mnMiscFlags & SCALABLE_FLAG) != 0); }
bool operator==( const ImplFontMetric& ) const;
diff --git a/vcl/inc/outfont.hxx b/vcl/inc/outfont.hxx
index 8eef436fa757..d34473b9cc21 100644
--- a/vcl/inc/outfont.hxx
+++ b/vcl/inc/outfont.hxx
@@ -176,6 +176,7 @@ public: // TODO: hide members behind accessor methods
bool mbTrueTypeFont;
bool mbKernableFont;
bool mbFullstopCentered;
+ long mnBulletOffset; // Offset to position non-print character
// font metrics that are usually derived from the measurements
long mnUnderlineSize; // Lineheight of Underline
diff --git a/vcl/source/gdi/metric.cxx b/vcl/source/gdi/metric.cxx
index 05630c63f895..bf671af3321a 100644
--- a/vcl/source/gdi/metric.cxx
+++ b/vcl/source/gdi/metric.cxx
@@ -32,6 +32,7 @@ ImplFontMetric::ImplFontMetric()
mnExtLeading( 0 ),
mnLineHeight( 0 ),
mnSlant( 0 ),
+ mnBulletOffset( 0 ),
mnMiscFlags( 0 ),
mnRefCount( 1 )
{}
@@ -156,6 +157,11 @@ bool FontMetric::IsFullstopCentered() const
return mpImplMetric->IsFullstopCentered();
}
+long FontMetric::GetBulletOffset() const
+{
+ return mpImplMetric->GetBulletOffset();
+}
+
FontMetric& FontMetric::operator =( const FontMetric& rMetric )
{
vcl::FontInfo::operator=( rMetric );
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index f2885f0813e8..d8c9ce2074ec 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -218,6 +218,7 @@ FontMetric OutputDevice::GetFontMetric() const
aMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::SCALABLE_FLAG;
if ( pMetric->mbFullstopCentered)
aMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::FULLSTOP_CENTERED_FLAG;
+ aMetric.mpImplMetric->mnBulletOffset= pMetric->mnBulletOffset;
aMetric.mpImplMetric->mnAscent = ImplDevicePixelToLogicHeight( pMetric->mnAscent+mnEmphasisAscent );
aMetric.mpImplMetric->mnDescent = ImplDevicePixelToLogicHeight( pMetric->mnDescent+mnEmphasisDescent );
aMetric.mpImplMetric->mnIntLeading = ImplDevicePixelToLogicHeight( pMetric->mnIntLeading+mnEmphasisAscent );
@@ -1752,6 +1753,7 @@ ImplFontMetricData::ImplFontMetricData( const FontSelectPattern& rFontSelData )
, mbScalableFont(false)
, mbTrueTypeFont(false)
, mbFullstopCentered(false)
+ , mnBulletOffset( 0 )
, mnUnderlineSize( 0 )
, mnUnderlineOffset( 0 )
, mnBUnderlineSize( 0 )
@@ -1894,6 +1896,9 @@ void ImplFontMetricData::ImplInitTextLineSize( const OutputDevice* pDev )
bCentered = nB > (((nH >> 1)+nH)>>3);
}
mbFullstopCentered = bCentered ;
+
+ mnBulletOffset = ( pDev->GetTextWidth( OUString( sal_Unicode( 0x20 ) ) ) - pDev->GetTextWidth( OUString( sal_Unicode( 0xb7 ) ) ) ) >> 1 ;
+
}
void ImplFontMetricData::ImplInitAboveTextLineSize()