Kaydet (Commit) e32fd5e8 authored tarafından Mark Hung's avatar Mark Hung

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/20112Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMark Hung <marklh9@gmail.com>
üst dd258f16
......@@ -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;
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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
......
......@@ -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 );
......
......@@ -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()
......
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