summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2019-04-28 15:05:35 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2019-04-28 19:18:56 +0200
commit9c1c18f42bbb1f54c39202329088d50d2839ceb9 (patch)
tree44772499cb5032287a0ca03b331dad83dbaf25de /vcl
parenta7c2f1580e928d13d02d778639a0f26de728b5be (diff)
Move lcl_CalcAsianKerning near its only user
This function is just used by ApplyAsianKerning, so move it there. While at it drop the unused constant boolean. Same for the comment referencing ImplCalcKerning, which is long gone since a huge merge in commit 2f382d6c2579 ("MWS_SRX644: migrate branch mws_srx644 -> HEAD"). Also "const int"ify ApplyAsianKerning. No need for long, as the lcl_CalcAsianKerning just returns int in the range [-2,+2]. Change-Id: I9b1b3351ab71219c8e2ee49ce441f5222e5c1c4b Reviewed-on: https://gerrit.libreoffice.org/71476 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/sallayout.cxx97
1 files changed, 47 insertions, 50 deletions
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index fc0a765e2af7..17e6f7f38b35 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -590,47 +590,6 @@ Point SalLayout::GetDrawPosition( const Point& rRelative ) const
return aPos;
}
-// returns asian kerning values in quarter of character width units
-// to enable automatic halfwidth substitution for fullwidth punctuation
-// return value is negative for l, positive for r, zero for neutral
-
-// If the range doesn't match in 0x3000 and 0x30FB, please change
-// also ImplCalcKerning.
-
-static int lcl_CalcAsianKerning( sal_UCS4 c, bool bLeft, bool /*TODO:? bVertical*/ )
-{
- // http://www.asahi-net.or.jp/~sd5a-ucd/freetexts/jis/x4051/1995/appendix.html
- static const signed char nTable[0x30] =
- {
- 0, -2, -2, 0, 0, 0, 0, 0, +2, -2, +2, -2, +2, -2, +2, -2,
- +2, -2, 0, 0, +2, -2, +2, -2, 0, 0, 0, 0, 0, +2, -2, -2,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -2, +2, +2, -2, -2
- };
-
- int nResult = 0;
- if( (c >= 0x3000) && (c < 0x3030) )
- nResult = nTable[ c - 0x3000 ];
- else switch( c )
- {
- case 0x30FB:
- nResult = bLeft ? -1 : +1; // 25% left/right/top/bottom
- break;
- case 0x2019: case 0x201D:
- case 0xFF01: case 0xFF09: case 0xFF0C:
- case 0xFF1A: case 0xFF1B:
- nResult = -2;
- break;
- case 0x2018: case 0x201C:
- case 0xFF08:
- nResult = +2;
- break;
- default:
- break;
- }
-
- return nResult;
-}
-
bool SalLayout::GetOutline(basegfx::B2DPolyPolygonVector& rVector) const
{
bool bAllOk = true;
@@ -800,15 +759,55 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth )
}
}
+// returns asian kerning values in quarter of character width units
+// to enable automatic halfwidth substitution for fullwidth punctuation
+// return value is negative for l, positive for r, zero for neutral
+// TODO: handle vertical layout as proposed in commit 43bf2ad49c2b3989bbbe893e4fee2e032a3920f5?
+static int lcl_CalcAsianKerning(sal_UCS4 c, bool bLeft)
+{
+ // http://www.asahi-net.or.jp/~sd5a-ucd/freetexts/jis/x4051/1995/appendix.html
+ static const signed char nTable[0x30] =
+ {
+ 0, -2, -2, 0, 0, 0, 0, 0, +2, -2, +2, -2, +2, -2, +2, -2,
+ +2, -2, 0, 0, +2, -2, +2, -2, 0, 0, 0, 0, 0, +2, -2, -2,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -2, +2, +2, -2, -2
+ };
+
+ int nResult = 0;
+ if( (c >= 0x3000) && (c < 0x3030) )
+ nResult = nTable[ c - 0x3000 ];
+ else switch( c )
+ {
+ case 0x30FB:
+ nResult = bLeft ? -1 : +1; // 25% left/right/top/bottom
+ break;
+ case 0x2019: case 0x201D:
+ case 0xFF01: case 0xFF09: case 0xFF0C:
+ case 0xFF1A: case 0xFF1B:
+ nResult = -2;
+ break;
+ case 0x2018: case 0x201C:
+ case 0xFF08:
+ nResult = +2;
+ break;
+ default:
+ break;
+ }
+
+ return nResult;
+}
+
void GenericSalLayout::ApplyAsianKerning(const OUString& rStr)
{
const int nLength = rStr.getLength();
long nOffset = 0;
- for( std::vector<GlyphItem>::iterator pGlyphIter = m_GlyphItems.Impl()->begin(), pGlyphIterEnd = m_GlyphItems.Impl()->end(); pGlyphIter != pGlyphIterEnd; ++pGlyphIter )
+ for (std::vector<GlyphItem>::iterator pGlyphIter = m_GlyphItems.Impl()->begin(),
+ pGlyphIterEnd = m_GlyphItems.Impl()->end();
+ pGlyphIter != pGlyphIterEnd; ++pGlyphIter)
{
const int n = pGlyphIter->m_nCharPos;
- if( n < nLength - 1)
+ if (n < nLength - 1)
{
// ignore code ranges that are not affected by asian punctuation compression
const sal_Unicode cHere = rStr[n];
@@ -819,16 +818,14 @@ void GenericSalLayout::ApplyAsianKerning(const OUString& rStr)
continue;
// calculate compression values
- const bool bVertical = false;
- long nKernFirst = +lcl_CalcAsianKerning( cHere, true, bVertical );
- long nKernNext = -lcl_CalcAsianKerning( cNext, false, bVertical );
+ const int nKernFirst = +lcl_CalcAsianKerning(cHere, true);
+ const int nKernNext = -lcl_CalcAsianKerning(cNext, false);
// apply punctuation compression to logical glyph widths
- long nDelta = (nKernFirst < nKernNext) ? nKernFirst : nKernNext;
+ int nDelta = (nKernFirst < nKernNext) ? nKernFirst : nKernNext;
if( nDelta<0 && nKernFirst!=0 && nKernNext!=0 )
{
- int nGlyphWidth = pGlyphIter->m_nOrigWidth;
- nDelta = (nDelta * nGlyphWidth + 2) / 4;
+ nDelta = (nDelta * pGlyphIter->m_nOrigWidth + 2) / 4;
if( pGlyphIter+1 == pGlyphIterEnd )
pGlyphIter->m_nNewWidth += nDelta;
nOffset += nDelta;
@@ -837,7 +834,7 @@ void GenericSalLayout::ApplyAsianKerning(const OUString& rStr)
// adjust the glyph positions to the new glyph widths
if( pGlyphIter+1 != pGlyphIterEnd )
- pGlyphIter->m_aLinearPos.AdjustX(nOffset );
+ pGlyphIter->m_aLinearPos.AdjustX(nOffset);
}
}