summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-09-05 09:06:55 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-09-05 10:04:38 +0100
commit5c3dc6791c8737b24d5b8211bf7330caff47b62b (patch)
treefb181ddc54109831ca7c277c5c74fa118b5d9519 /vcl
parent7a7a2c5495e9e03181843c327a0c28fd6e5e88bd (diff)
should be able to remove SimpleLayoutEngine now
Change-Id: I74d2cb7c47ec04f4276755fa1bd74779842c7832
Diffstat (limited to 'vcl')
-rw-r--r--vcl/generic/glyphs/gcach_layout.cxx83
-rw-r--r--vcl/inc/generic/glyphcache.hxx2
2 files changed, 9 insertions, 76 deletions
diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx
index cd6b96cb6a49..774f0f8d56c4 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -42,8 +42,6 @@
#include <unicode/uscript.h>
#include <unicode/ubidi.h>
-namespace { struct SimpleLayoutEngine : public rtl::Static< ServerFontLayoutEngine, SimpleLayoutEngine > {}; }
-
// =======================================================================
// layout implementation for ServerFont
// =======================================================================
@@ -62,10 +60,8 @@ void ServerFontLayout::DrawText( SalGraphics& rSalGraphics ) const
bool ServerFontLayout::LayoutText( ImplLayoutArgs& rArgs )
{
ServerFontLayoutEngine* pLE = mrServerFont.GetLayoutEngine();
- if( !pLE )
- pLE = &SimpleLayoutEngine::get();
-
- bool bRet = (*pLE)( *this, rArgs );
+ assert(pLE);
+ bool bRet = pLE ? pLE->layout(*this, rArgs) : false;
return bRet;
}
@@ -95,68 +91,6 @@ void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs )
}
// =======================================================================
-
-bool ServerFontLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rArgs )
-{
- ServerFont& rFont = rLayout.GetServerFont();
-
- Point aNewPos( 0, 0 );
- int nOldGlyphId = -1;
- int nGlyphWidth = 0;
- GlyphItem aPrevItem;
- bool bRightToLeft;
-
- rLayout.Reserve(rArgs.mnLength);
- for( int nCharPos = -1; rArgs.GetNextPos( &nCharPos, &bRightToLeft ); )
- {
- sal_UCS4 cChar = rArgs.mpStr[ nCharPos ];
- if( (cChar >= 0xD800) && (cChar <= 0xDFFF) )
- {
- if( cChar >= 0xDC00 ) // this part of a surrogate pair was already processed
- continue;
- cChar = 0x10000 + ((cChar - 0xD800) << 10)
- + (rArgs.mpStr[ nCharPos+1 ] - 0xDC00);
- }
-
- if( bRightToLeft )
- cChar = GetMirroredChar( cChar );
- int nGlyphIndex = rFont.GetGlyphIndex( cChar );
- // when glyph fallback is needed update LayoutArgs
- if( !nGlyphIndex ) {
- rArgs.NeedFallback( nCharPos, bRightToLeft );
- if( cChar >= 0x10000 ) // handle surrogate pairs
- rArgs.NeedFallback( nCharPos+1, bRightToLeft );
- }
-
- // apply pair kerning to prev glyph if requested
- if( SAL_LAYOUT_KERNING_PAIRS & rArgs.mnFlags )
- {
- int nKernValue = rFont.GetGlyphKernValue( nOldGlyphId, nGlyphIndex );
- nGlyphWidth += nKernValue;
- aPrevItem.mnNewWidth = nGlyphWidth;
- }
-
- // finish previous glyph
- if( nOldGlyphId >= 0 )
- rLayout.AppendGlyph( aPrevItem );
- aNewPos.X() += nGlyphWidth;
-
- // prepare GlyphItem for appending it in next round
- nOldGlyphId = nGlyphIndex;
- const GlyphMetric& rGM = rFont.GetGlyphMetric( nGlyphIndex );
- nGlyphWidth = rGM.GetCharWidth();
- int nGlyphFlags = bRightToLeft ? GlyphItem::IS_RTL_GLYPH : 0;
- aPrevItem = GlyphItem( nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nGlyphWidth );
- }
-
- // append last glyph item if any
- if( nOldGlyphId >= 0 )
- rLayout.AppendGlyph( aPrevItem );
-
- return true;
-}
-
-// =======================================================================
// bridge to ICU LayoutEngine
// =======================================================================
@@ -215,7 +149,7 @@ const void* IcuFontFromServerFont::getFontTable( LETag nICUTableTag ) const
"vcl",
"font( h=" << mrServerFont.GetFontSelData().mnHeight << ", \""
<< mrServerFont.GetFontFileName()->getStr() << "\" )");
- return (const void*)pBuffer;
+ return pBuffer;
}
// -----------------------------------------------------------------------
@@ -347,7 +281,7 @@ public:
IcuLayoutEngine( ServerFont& );
virtual ~IcuLayoutEngine();
- virtual bool operator()( ServerFontLayout&, ImplLayoutArgs& );
+ virtual bool layout( ServerFontLayout&, ImplLayoutArgs& );
};
// -----------------------------------------------------------------------
@@ -362,8 +296,7 @@ IcuLayoutEngine::IcuLayoutEngine( ServerFont& rServerFont )
IcuLayoutEngine::~IcuLayoutEngine()
{
- if( mpIcuLE )
- delete mpIcuLE;
+ delete mpIcuLE;
}
// -----------------------------------------------------------------------
@@ -376,7 +309,7 @@ static bool lcl_CharIsJoiner(sal_Unicode cChar)
//See https://bugs.freedesktop.org/show_bug.cgi?id=31016
#define ARABIC_BANDAID
-bool IcuLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rArgs )
+bool IcuLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
{
LEUnicode* pIcuChars;
if( sizeof(LEUnicode) == sizeof(*rArgs.mpStr) )
@@ -643,8 +576,8 @@ bool IcuLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rAr
ServerFontLayoutEngine* ServerFont::GetLayoutEngine()
{
// find best layout engine for font, platform, script and language
- if( !mpLayoutEngine && FT_IS_SFNT( maFaceFT ) )
- mpLayoutEngine = new IcuLayoutEngine( *this );
+ if (!mpLayoutEngine)
+ mpLayoutEngine = new IcuLayoutEngine(*this);
return mpLayoutEngine;
}
diff --git a/vcl/inc/generic/glyphcache.hxx b/vcl/inc/generic/glyphcache.hxx
index 43189790d605..6c6ca43a10c9 100644
--- a/vcl/inc/generic/glyphcache.hxx
+++ b/vcl/inc/generic/glyphcache.hxx
@@ -340,7 +340,7 @@ class ServerFontLayoutEngine
{
public:
virtual ~ServerFontLayoutEngine() {}
- virtual bool operator()( ServerFontLayout&, ImplLayoutArgs& );
+ virtual bool layout(ServerFontLayout&, ImplLayoutArgs&) = 0;
};
// =======================================================================