[Libreoffice-commits] core.git: include/vcl sw/source vcl/inc vcl/source
Mark Hung
marklh9 at gmail.com
Sat Dec 19 04:39:16 PST 2015
include/vcl/metric.hxx | 1 +
sw/source/core/txtnode/fntcache.cxx | 22 ++++++++++++++++++++++
vcl/inc/impfont.hxx | 2 ++
vcl/inc/outfont.hxx | 1 +
vcl/source/gdi/metric.cxx | 6 ++++++
vcl/source/outdev/font.cxx | 5 +++++
6 files changed, 37 insertions(+)
New commits:
commit e32fd5e8671b787dfc6795f3109c616974fe2594
Author: Mark Hung <marklh9 at gmail.com>
Date: Sat Nov 21 23:14:18 2015 +0800
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 at libreoffice.org>
Reviewed-by: Mark Hung <marklh9 at gmail.com>
diff --git a/include/vcl/metric.hxx b/include/vcl/metric.hxx
index ddf27eb..fd3759a 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 f818932..1b5ebbd 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 ab2bd21..1ed1e41 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 8eef436..d34473b 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 05630c6..bf671af 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 f2885f0..d8c9ce2 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()
More information about the Libreoffice-commits
mailing list