summaryrefslogtreecommitdiff
path: root/vcl/source/outdev
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2015-10-21 22:34:08 +0800
committerNorbert Thiebaud <nthiebaud@gmail.com>2015-11-03 20:01:46 +0000
commit281be263619a8e513a26e6a9165d1d77cf6524ea (patch)
tree93b961416e794b100fbc86ac5af80ec3a65428a2 /vcl/source/outdev
parent2b48a5f1550e6f62931c2973086e8970f88f58ee (diff)
tdf#81144 Chinese full-width punctuation does not align properly
Ideographic fullstop and comma in most Chinese fonts are centered, while those in Japanese fonts align closer to the left. Original compression algorithm trimed right side of the punctuation, making fullwidth fullstop or comma in Chinese font visually unbalanced. In worst case, it crowds together with the followed compressed punctuation. This patch fix the situation in the folowing way 1) make compression less stronger. 2) Trim space according to glyph bearing to font height ratio. 3) fix a memory access violation issue Change-Id: Icff215064e6c442fd36eac8e01b01fb6acb27594 Reviewed-on: https://gerrit.libreoffice.org/19517 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'vcl/source/outdev')
-rw-r--r--vcl/source/outdev/font.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index fd7b818ac871..6d641648eb03 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -216,6 +216,8 @@ FontMetric OutputDevice::GetFontMetric() const
aMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::DEVICE_FLAG;
if( pMetric->mbScalableFont )
aMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::SCALABLE_FLAG;
+ if ( pMetric->mbFullstopCentered)
+ aMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::FULLSTOP_CENTERED_FLAG;
aMetric.mpImplMetric->mnAscent = ImplDevicePixelToLogicHeight( pMetric->mnAscent+mnEmphasisAscent );
aMetric.mpImplMetric->mnDescent = ImplDevicePixelToLogicHeight( pMetric->mnDescent+mnEmphasisDescent );
aMetric.mpImplMetric->mnIntLeading = ImplDevicePixelToLogicHeight( pMetric->mnIntLeading+mnEmphasisAscent );
@@ -1744,6 +1746,7 @@ ImplFontMetricData::ImplFontMetricData( const FontSelectPattern& rFontSelData )
, mnMinKashida( 0 )
, meFamilyType(FAMILY_DONTKNOW)
, mbScalableFont(false)
+ , mbFullstopCentered(false)
, mnUnderlineSize( 0 )
, mnUnderlineOffset( 0 )
, mnBUnderlineSize( 0 )
@@ -1788,6 +1791,7 @@ ImplFontMetricData::ImplFontMetricData( const FontSelectPattern& rFontSelData )
}
}
+
void ImplFontMetricData::ImplInitTextLineSize( const OutputDevice* pDev )
{
long nDescent = mnDescent;
@@ -1870,6 +1874,21 @@ void ImplFontMetricData::ImplInitTextLineSize( const OutputDevice* pDev )
mnDStrikeoutSize = n2LineHeight;
mnDStrikeoutOffset1 = nStrikeoutOffset - n2LineDY2 - n2LineHeight;
mnDStrikeoutOffset2 = mnDStrikeoutOffset1 + n2LineDY + n2LineHeight;
+
+ const vcl::Font& rFont ( pDev->GetFont() );
+ bool bCentered = true;
+ if (MsLangId::isCJK(rFont.GetLanguage()))
+ {
+ const OUString sFullstop( sal_Unicode( 0x3001 ) ); // Fullwidth fullstop
+ Rectangle aRect;
+ pDev->GetTextBoundRect( aRect, sFullstop );
+ const sal_uInt16 nH = rFont.GetSize().Height();
+ const sal_uInt16 nB = aRect.Left();
+ // Use 18.75% as a threshold to define a centered fullwidth fullstop.
+ // In general, nB/nH < 5% for most Japanese fonts.
+ bCentered = (nB > (((nH >> 1)+nH)>>3)) ? true : false;
+ }
+ mbFullstopCentered = bCentered ;
}
void ImplFontMetricData::ImplInitAboveTextLineSize()