diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2014-10-06 18:16:16 +1100 |
---|---|---|
committer | Chris Sherlock <chris.sherlock79@gmail.com> | 2014-10-13 09:19:04 +0000 |
commit | f6d61562d41b8a49449d881da66a3d8fa519487f (patch) | |
tree | 15571322cf3bf8475fe2e1c5d1d0ae9fd38f7c1d /vcl | |
parent | bb1d4f8c9a275a20e8795ee36ca3259376746e4f (diff) |
vcl: Make ImplFontCharMap a pImpl and move functions to FontCharMap
To do this, I've made FontCharMap a friend class for ImplFontCharMap,
and have moved the functions directly into FontCharMap. In this patch,
I am attempting to stop the direct use of ImplFontCharMap by anything
other than FontCharMap. However, FontCharMap itself requires a
refcounter, so we will use FontCharMapPtr to access the font character
map.
Change-Id: I509b990a8cbd911c5cc1572c7d24fc5348ca06d9
Reviewed-on: https://gerrit.libreoffice.org/11823
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
Tested-by: Chris Sherlock <chris.sherlock79@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/generic/fontmanager/fontmanager.cxx | 4 | ||||
-rw-r--r-- | vcl/generic/glyphs/gcach_ftyp.cxx | 13 | ||||
-rw-r--r-- | vcl/generic/glyphs/gcach_ftyp.hxx | 4 | ||||
-rw-r--r-- | vcl/generic/print/genpspgraphics.cxx | 6 | ||||
-rw-r--r-- | vcl/headless/svptext.cxx | 6 | ||||
-rw-r--r-- | vcl/inc/generic/genpspgraphics.h | 2 | ||||
-rw-r--r-- | vcl/inc/generic/glyphcache.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/headless/svpgdi.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/impfont.hxx | 24 | ||||
-rw-r--r-- | vcl/inc/quartz/salgdi.h | 8 | ||||
-rw-r--r-- | vcl/inc/salgdi.hxx | 19 | ||||
-rw-r--r-- | vcl/inc/unx/salgdi.h | 7 | ||||
-rw-r--r-- | vcl/inc/win/salgdi.h | 6 | ||||
-rw-r--r-- | vcl/qa/cppunit/fontcharmap.cxx | 12 | ||||
-rw-r--r-- | vcl/quartz/salgdi.cxx | 30 | ||||
-rw-r--r-- | vcl/source/filter/wmf/wmfwr.cxx | 9 | ||||
-rw-r--r-- | vcl/source/gdi/impfont.cxx | 393 | ||||
-rw-r--r-- | vcl/source/outdev/font.cxx | 24 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/salgdi3.cxx | 9 | ||||
-rw-r--r-- | vcl/win/source/gdi/salgdi3.cxx | 40 |
20 files changed, 306 insertions, 317 deletions
diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx index 746d8395b51b..53448c61a752 100644 --- a/vcl/generic/fontmanager/fontmanager.cxx +++ b/vcl/generic/fontmanager/fontmanager.cxx @@ -2088,7 +2088,7 @@ void PrintFontManager::getGlyphWidths( fontID nFont, CmapResult aCmapResult; if( ParseCMAP( pCmapData, nCmapSize, aCmapResult ) ) { - const ImplFontCharMapPtr pCharMap( new ImplFontCharMap(aCmapResult) ); + FontCharMapPtr pCharMap( new FontCharMap(aCmapResult) ); for( sal_uInt32 cOld = 0;;) { // get next unicode covered by font @@ -2105,6 +2105,8 @@ void PrintFontManager::getGlyphWidths( fontID nFont, // update the requested map rUnicodeEnc[ (sal_Unicode)c ] = aGlyphId; } + + pCharMap = 0; } } } diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx b/vcl/generic/glyphs/gcach_ftyp.cxx index 4a8ddd014ded..9e12d5a2be05 100644 --- a/vcl/generic/glyphs/gcach_ftyp.cxx +++ b/vcl/generic/glyphs/gcach_ftyp.cxx @@ -1266,13 +1266,13 @@ bool ServerFont::GetGlyphBitmap8( sal_GlyphId aGlyphId, RawBitmap& rRawBitmap ) // determine unicode ranges in font -const ImplFontCharMapPtr ServerFont::GetImplFontCharMap( void ) const +const FontCharMapPtr ServerFont::GetFontCharMap() const { - const ImplFontCharMapPtr pIFCMap = mpFontInfo->GetImplFontCharMap(); - return pIFCMap; + const FontCharMapPtr pFCMap = mpFontInfo->GetFontCharMap(); + return pFCMap; } -const ImplFontCharMapPtr FtFontInfo::GetImplFontCharMap( void ) +const FontCharMapPtr FtFontInfo::GetFontCharMap() { // check if the charmap is already cached if( mpFontCharMap ) @@ -1283,12 +1283,13 @@ const ImplFontCharMapPtr FtFontInfo::GetImplFontCharMap( void ) bool bOK = GetFontCodeRanges( aCmapResult ); if( bOK ) { - ImplFontCharMapPtr pFontCharMap( new ImplFontCharMap( aCmapResult ) ); + FontCharMapPtr pFontCharMap( new FontCharMap ( aCmapResult ) ); mpFontCharMap = pFontCharMap; } else { - mpFontCharMap = ImplFontCharMap::GetDefaultMap(); + FontCharMapPtr pFontCharMap( new FontCharMap() ); + mpFontCharMap = pFontCharMap; } // mpFontCharMap on either branch now has a refcount of 1 return mpFontCharMap; diff --git a/vcl/generic/glyphs/gcach_ftyp.hxx b/vcl/generic/glyphs/gcach_ftyp.hxx index 803ce072a955..21cd6538bcca 100644 --- a/vcl/generic/glyphs/gcach_ftyp.hxx +++ b/vcl/generic/glyphs/gcach_ftyp.hxx @@ -84,7 +84,7 @@ public: void CacheGlyphIndex( sal_UCS4 cChar, int nGI ) const; bool GetFontCodeRanges( CmapResult& ) const; - const ImplFontCharMapPtr GetImplFontCharMap( void ); + const FontCharMapPtr GetFontCharMap(); private: FT_FaceRec_* maFaceFT; @@ -99,7 +99,7 @@ private: sal_IntPtr mnFontId; ImplDevFontAttributes maDevFontAttributes; - ImplFontCharMapPtr mpFontCharMap; + FontCharMapPtr mpFontCharMap; // cache unicode->glyphid mapping because looking it up is expensive // TODO: change to boost::unordered_multimap when a use case requires a m:n mapping diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx index 759519b3cefa..644e4fdb99a3 100644 --- a/vcl/generic/print/genpspgraphics.cxx +++ b/vcl/generic/print/genpspgraphics.cxx @@ -777,13 +777,13 @@ void GenPspGraphics::DrawServerFontLayout( const ServerFontLayout& rLayout ) DrawPrinterLayout( rLayout, *m_pPrinterGfx, true ); } -const ImplFontCharMapPtr GenPspGraphics::GetImplFontCharMap() const +const FontCharMapPtr GenPspGraphics::GetFontCharMap() const { if( !m_pServerFont[0] ) return NULL; - const ImplFontCharMapPtr pIFCMap = m_pServerFont[0]->GetImplFontCharMap(); - return pIFCMap; + const FontCharMapPtr pFCMap = m_pServerFont[0]->GetFontCharMap(); + return pFCMap; } bool GenPspGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx index 905d78bef9fd..8fc51ced7ddb 100644 --- a/vcl/headless/svptext.cxx +++ b/vcl/headless/svptext.cxx @@ -231,13 +231,13 @@ void SvpSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int nFallbackLe } } -const ImplFontCharMapPtr SvpSalGraphics::GetImplFontCharMap() const +const FontCharMapPtr SvpSalGraphics::GetFontCharMap() const { if( !m_pServerFont[0] ) return NULL; - const ImplFontCharMapPtr pIFCMap = m_pServerFont[0]->GetImplFontCharMap(); - return pIFCMap; + const FontCharMapPtr pFCMap = m_pServerFont[0]->GetFontCharMap(); + return pFCMap; } bool SvpSalGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const diff --git a/vcl/inc/generic/genpspgraphics.h b/vcl/inc/generic/genpspgraphics.h index 66c7f31f3802..2a562c341ff7 100644 --- a/vcl/inc/generic/genpspgraphics.h +++ b/vcl/inc/generic/genpspgraphics.h @@ -89,7 +89,7 @@ public: virtual void SetTextColor( SalColor nSalColor ) SAL_OVERRIDE; virtual sal_uInt16 SetFont( FontSelectPattern*, int nFallbackLevel ) SAL_OVERRIDE; virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) SAL_OVERRIDE; - virtual const ImplFontCharMapPtr GetImplFontCharMap() const SAL_OVERRIDE; + virtual const FontCharMapPtr GetFontCharMap() const SAL_OVERRIDE; virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const SAL_OVERRIDE; virtual void GetDevFontList( PhysicalFontCollection* ) SAL_OVERRIDE; // graphics must drop any cached font info diff --git a/vcl/inc/generic/glyphcache.hxx b/vcl/inc/generic/glyphcache.hxx index 1a3da60118fc..ba44ae8412b3 100644 --- a/vcl/inc/generic/glyphcache.hxx +++ b/vcl/inc/generic/glyphcache.hxx @@ -33,9 +33,9 @@ #include <com/sun/star/i18n/XBreakIterator.hpp> #include <tools/gen.hxx> #include <vcl/dllapi.h> +#include <vcl/metric.hxx> #include <outfont.hxx> -#include <impfont.hxx> #include <sallayout.hxx> class FtFontInfo; @@ -182,7 +182,7 @@ public: const unsigned char* GetTable( const char* pName, sal_uLong* pLength ); int GetEmUnits() const { return maFaceFT->units_per_EM;} const FT_Size_Metrics& GetMetricsFT() const { return maSizeFT->metrics; } - const ImplFontCharMapPtr GetImplFontCharMap() const; + const FontCharMapPtr GetFontCharMap() const; bool GetFontCapabilities(vcl::FontCapabilities &) const; GlyphData& GetGlyphData( sal_GlyphId ); diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index aad4693d35e7..a872d4a2019d 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -23,6 +23,7 @@ #include <basebmp/bitmapdevice.hxx> #include <basebmp/color.hxx> #include <vcl/sysdata.hxx> +#include <vcl/metric.hxx> #include "salgdi.hxx" #include "sallayout.hxx" @@ -156,7 +157,7 @@ public: virtual void SetTextColor( SalColor nSalColor ) SAL_OVERRIDE; virtual sal_uInt16 SetFont( FontSelectPattern*, int nFallbackLevel ) SAL_OVERRIDE; virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) SAL_OVERRIDE; - virtual const ImplFontCharMapPtr GetImplFontCharMap() const SAL_OVERRIDE; + virtual const FontCharMapPtr GetFontCharMap() const SAL_OVERRIDE; virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const SAL_OVERRIDE; virtual void GetDevFontList( PhysicalFontCollection* ) SAL_OVERRIDE; virtual void ClearDevFontCache() SAL_OVERRIDE; diff --git a/vcl/inc/impfont.hxx b/vcl/inc/impfont.hxx index af97677f3999..8efb30b9363f 100644 --- a/vcl/inc/impfont.hxx +++ b/vcl/inc/impfont.hxx @@ -163,34 +163,18 @@ public: explicit ImplFontCharMap( const CmapResult& ); virtual ~ImplFontCharMap(); - static ImplFontCharMapPtr GetDefaultMap( bool bSymbols=false); - - bool IsDefaultMap() const; - bool HasChar( sal_uInt32 ) const; - int CountCharsInRange( sal_uInt32 cMin, sal_uInt32 cMax ) const; - int GetCharCount() const { return mnCharCount;} - - sal_uInt32 GetFirstChar() const { return mpRangeCodes[0];} - sal_uInt32 GetLastChar() const; - - sal_uInt32 GetNextChar( sal_uInt32 ) const; - sal_uInt32 GetPrevChar( sal_uInt32 ) const; - - int GetIndexFromChar( sal_uInt32 ) const; - sal_uInt32 GetCharFromIndex( int ) const; - - int GetGlyphIndex( sal_uInt32 ) const; - private: + friend class FontCharMap; friend void intrusive_ptr_add_ref(ImplFontCharMap* pImplFontCharMap); friend void intrusive_ptr_release(ImplFontCharMap* pImplFontCharMap); - int ImplFindRangeIndex( sal_uInt32 ) const; - // prevent assignment and copy construction explicit ImplFontCharMap( const ImplFontCharMap& ); void operator=( const ImplFontCharMap& ); + static ImplFontCharMapPtr getDefaultMap( bool bSymbols=false); + bool isDefaultMap() const; + private: const sal_uInt32* mpRangeCodes; // pairs of StartCode/(EndCode+1) const int* mpStartGlyphs; // range-specific mapper to glyphs diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 0c58ca7da621..45a12c4ee63b 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -45,6 +45,7 @@ extern "C" { #include "postmac.h" #include <vcl/fontcapabilities.hxx> +#include <vcl/metric.hxx> #include "outfont.hxx" #include "PhysicalFontFace.hxx" @@ -73,7 +74,7 @@ public: CoreTextStyle* CreateTextStyle( const FontSelectPattern& ) const; int GetFontTable( const char pTagName[5], unsigned char* ) const; - const ImplFontCharMapPtr GetImplFontCharMap() const; + const FontCharMapPtr GetFontCharMap() const; bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const; bool HasChar( sal_uInt32 cChar ) const; @@ -85,7 +86,7 @@ protected: private: const sal_IntPtr mnFontId; - mutable ImplFontCharMapPtr mpCharMap; + mutable FontCharMapPtr mpCharMap; mutable vcl::FontCapabilities maFontCapabilities; mutable bool mbOs2Read; // true if OS2-table related info is valid mutable bool mbHasOs2Table; @@ -330,8 +331,7 @@ public: // get the current font's metrics virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) SAL_OVERRIDE; // get the repertoire of the current font - virtual const ImplFontCharMapPtr - GetImplFontCharMap() const SAL_OVERRIDE; + virtual const FontCharMapPtr GetFontCharMap() const SAL_OVERRIDE; virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const SAL_OVERRIDE; // graphics must fill supplied font list virtual void GetDevFontList( PhysicalFontCollection* ) SAL_OVERRIDE; diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index c2752b92447f..b49f9ecd1083 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -20,15 +20,17 @@ #ifndef INCLUDED_VCL_INC_SALGDI_HXX #define INCLUDED_VCL_INC_SALGDI_HXX -#include "tools/solar.h" -#include "vcl/dllapi.h" -#include "vcl/salgtype.hxx" -#include "osl/thread.hxx" -#include "vcl/outdev.hxx" -#include "vcl/salnativewidgets.hxx" +#include <tools/solar.h> +#include <osl/thread.hxx> + +#include <vcl/dllapi.h> +#include <vcl/salgtype.hxx> +#include <vcl/outdev.hxx> +#include <vcl/salnativewidgets.hxx> +#include <vcl/metric.hxx> + #include "salglyphid.hxx" #include "sallayout.hxx" -#include <impfont.hxx> #include <map> @@ -231,8 +233,7 @@ public: virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel = 0 ) = 0; // get the repertoire of the current font - virtual const ImplFontCharMapPtr - GetImplFontCharMap() const = 0; + virtual const FontCharMapPtr GetFontCharMap() const = 0; // get the layout capabilities of the current font virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const = 0; diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index 59af7ffba0f0..d34c5d1a9d27 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -24,8 +24,9 @@ #include <postx.h> #include <tools/rational.hxx> -#include "vcl/salgtype.hxx" -#include "vcl/vclenum.hxx" +#include <vcl/salgtype.hxx> +#include <vcl/vclenum.hxx> +#include <vcl/metric.hxx> #include "salgdi.hxx" #include "sallayout.hxx" @@ -229,7 +230,7 @@ public: virtual void SetTextColor( SalColor nSalColor ) SAL_OVERRIDE; virtual sal_uInt16 SetFont( FontSelectPattern*, int nFallbackLevel ) SAL_OVERRIDE; virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) SAL_OVERRIDE; - virtual const ImplFontCharMapPtr GetImplFontCharMap() const SAL_OVERRIDE; + virtual const FontCharMapPtr GetFontCharMap() const SAL_OVERRIDE; virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const SAL_OVERRIDE; virtual void GetDevFontList( PhysicalFontCollection* ) SAL_OVERRIDE; virtual void ClearDevFontCache() SAL_OVERRIDE; diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index ace973cde206..66c561830e49 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -94,7 +94,7 @@ public: const gr_face* GraphiteFace() const; #endif - const ImplFontCharMapPtr GetImplFontCharMap() const; + FontCharMapPtr GetFontCharMap() const; bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const; const Ucs2SIntMap* GetEncodingVector() const { return mpEncodingVector; } void SetEncodingVector( const Ucs2SIntMap* pNewVec ) const @@ -116,7 +116,7 @@ private: #endif mutable bool mbHasArabicSupport; mutable bool mbFontCapabilitiesRead; - mutable ImplFontCharMapPtr mpUnicodeMap; + mutable FontCharMapPtr mpUnicodeMap; mutable const Ucs2SIntMap* mpEncodingVector; mutable vcl::FontCapabilities maFontCapabilities; @@ -310,7 +310,7 @@ public: // get the current font's metrics virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ); // get the repertoire of the current font - virtual const ImplFontCharMapPtr GetImplFontCharMap() const; + virtual const FontCharMapPtr GetFontCharMap() const; // get the layout capabilities of the current font virtual bool GetFontCapabilities(vcl::FontCapabilities &rGetFontCapabilities) const; // graphics must fill supplied font list diff --git a/vcl/qa/cppunit/fontcharmap.cxx b/vcl/qa/cppunit/fontcharmap.cxx index 2c361580613d..2a88b66764b5 100644 --- a/vcl/qa/cppunit/fontcharmap.cxx +++ b/vcl/qa/cppunit/fontcharmap.cxx @@ -28,17 +28,19 @@ public: void VclFontCharMapTest::testDefaultFontCharMap() { - FontCharMap fcmap; // gets default map + FontCharMapPtr pfcmap( new FontCharMap() ); // gets default map - CPPUNIT_ASSERT( fcmap.IsDefaultMap() ); + CPPUNIT_ASSERT( pfcmap->IsDefaultMap() ); - sal_uInt32 nStartBMPPlane = fcmap.GetFirstChar(); - sal_uInt32 nStartSupBMPPlane = fcmap.GetNextChar(0xD800); - sal_uInt32 nEndBMPPlane = fcmap.GetLastChar(); + sal_uInt32 nStartBMPPlane = pfcmap->GetFirstChar(); + sal_uInt32 nStartSupBMPPlane = pfcmap->GetNextChar(0xD800); + sal_uInt32 nEndBMPPlane = pfcmap->GetLastChar(); CPPUNIT_ASSERT( nStartBMPPlane == 0x0020 ); CPPUNIT_ASSERT( nStartSupBMPPlane == 0xE000 ); CPPUNIT_ASSERT( nEndBMPPlane == 0xFFF0-1 ); + + pfcmap = 0; } CPPUNIT_TEST_SUITE_REGISTRATION(VclFontCharMapTest); diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index b5f5251f99e8..d33e570d564e 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -37,6 +37,9 @@ #include "vcl/sysdata.hxx" #include "vcl/svapp.hxx" +#include "vcl/metric.hxx" + +#include "impfont.hxx" #include "quartz/salgdi.h" #include "quartz/utils.h" @@ -53,7 +56,6 @@ #include "ctfonts.hxx" #include "fontsubset.hxx" -#include "impfont.hxx" #include "sallayout.hxx" #include "sft.hxx" @@ -93,37 +95,38 @@ sal_IntPtr CoreTextFontData::GetFontId() const static unsigned GetUShort( const unsigned char* p ){return((p[0]<<8)+p[1]);} -const ImplFontCharMapPtr CoreTextFontData::GetImplFontCharMap() const +const FontCharMapPtr CoreTextFontData::GetFontCharMap() const { // return the cached charmap if( mpCharMap ) return mpCharMap; // set the default charmap - mpCharMap = ImplFontCharMap::GetDefaultMap(); + FontCharMapPtr pCharMap( new FontCharMap() ); + mpCharMap = pCharMap; // get the CMAP byte size // allocate a buffer for the CMAP raw data const int nBufSize = GetFontTable( "cmap", NULL ); - DBG_ASSERT( (nBufSize > 0), "CoreTextFontData::GetImplFontCharMap : GetFontTable1 failed!\n"); + DBG_ASSERT( (nBufSize > 0), "CoreTextFontData::GetFontCharMap : GetFontTable1 failed!\n"); if( nBufSize <= 0 ) return mpCharMap; // get the CMAP raw data ByteVector aBuffer( nBufSize ); const int nRawLength = GetFontTable( "cmap", &aBuffer[0] ); - DBG_ASSERT( (nRawLength > 0), "CoreTextFontData::GetImplFontCharMap : GetFontTable2 failed!\n"); + DBG_ASSERT( (nRawLength > 0), "CoreTextFontData::GetFontCharMap : GetFontTable2 failed!\n"); if( nRawLength <= 0 ) return mpCharMap; - DBG_ASSERT( (nBufSize==nRawLength), "CoreTextFontData::GetImplFontCharMap : ByteCount mismatch!\n"); + DBG_ASSERT( (nBufSize==nRawLength), "CoreTextFontData::GetFontCharMap : ByteCount mismatch!\n"); // parse the CMAP CmapResult aCmapResult; if( ParseCMAP( &aBuffer[0], nRawLength, aCmapResult ) ) { - ImplFontCharMapPtr pCharMap(new ImplFontCharMap( aCmapResult ) ); + FontCharMapPtr pDefFontCharMap( new FontCharMap(aCmapResult) ); // create the matching charmap - mpCharMap = pCharMap; + mpCharMap = pDefFontCharMap; } return mpCharMap; @@ -485,12 +488,15 @@ SalLayout* AquaSalGraphics::GetTextLayout( ImplLayoutArgs& /*rArgs*/, int /*nFal return pSalLayout; } -const ImplFontCharMapPtr AquaSalGraphics::GetImplFontCharMap() const +const FontCharMapPtr AquaSalGraphics::GetFontCharMap() const { if( !mpFontData ) - return ImplFontCharMap::GetDefaultMap(); + { + FontCharMapPtr pFontCharMap( new FontCharMap() ); + return pFontCharMap; + } - return mpFontData->GetImplFontCharMap(); + return mpFontData->GetFontCharMap(); } bool AquaSalGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const @@ -722,7 +728,7 @@ void AquaSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFontData, bool bV free( (void*)pGlyphMetrics ); } - ImplFontCharMapPtr pMap = mpFontData->GetImplFontCharMap(); + FontCharMapPtr pMap = mpFontData->GetFontCharMap(); DBG_ASSERT( pMap && pMap->GetCharCount(), "no charmap" ); // get unicode<->glyph encoding diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index 2587823356f2..16493cec4005 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -945,15 +945,18 @@ void WMFWriter::SetAllAttr() pVirDev->SetFont(aSrcFont); if ( aDstFont.GetName() != aSrcFont.GetName() ) { - FontCharMap aFontCharMap; - if ( pVirDev->GetFontCharMap( aFontCharMap ) ) + FontCharMapPtr pFontCharMap; + if ( pVirDev->GetFontCharMap( pFontCharMap ) ) { - if ( ( aFontCharMap.GetFirstChar() & 0xff00 ) == 0xf000 ) + if ( ( pFontCharMap->GetFirstChar() & 0xff00 ) == 0xf000 ) aSrcFont.SetCharSet( RTL_TEXTENCODING_SYMBOL ); else if ( aSrcFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 ); } + + pFontCharMap = 0; } + aDstFont = aSrcFont; CreateSelectDeleteFont(aDstFont); } diff --git a/vcl/source/gdi/impfont.cxx b/vcl/source/gdi/impfont.cxx index 1bd7dcd0e4cb..223e9e1fd83b 100644 --- a/vcl/source/gdi/impfont.cxx +++ b/vcl/source/gdi/impfont.cxx @@ -33,6 +33,19 @@ CmapResult::CmapResult( bool bSymbolic, , mbRecoded( false) {} +static ImplFontCharMapPtr pDefaultImplFontCharMap; +static const sal_UCS4 aDefaultUnicodeRanges[] = {0x0020,0xD800, 0xE000,0xFFF0}; +static const sal_UCS4 aDefaultSymbolRanges[] = {0x0020,0x0100, 0xF020,0xF100}; + +ImplFontCharMap::~ImplFontCharMap() +{ + if( isDefaultMap() ) + return; + delete[] mpRangeCodes; + delete[] mpStartGlyphs; + delete[] mpGlyphIds; +} + ImplFontCharMap::ImplFontCharMap( const CmapResult& rCR ) : mpRangeCodes( rCR.mpRangeCodes ) , mpStartGlyphs( rCR.mpStartGlyphs ) @@ -50,26 +63,7 @@ ImplFontCharMap::ImplFontCharMap( const CmapResult& rCR ) } } -static ImplFontCharMapPtr pDefaultImplFontCharMap; -static const sal_UCS4 aDefaultUnicodeRanges[] = {0x0020,0xD800, 0xE000,0xFFF0}; -static const sal_UCS4 aDefaultSymbolRanges[] = {0x0020,0x0100, 0xF020,0xF100}; - -bool ImplFontCharMap::IsDefaultMap() const -{ - const bool bIsDefault = (mpRangeCodes == aDefaultUnicodeRanges) || (mpRangeCodes == aDefaultSymbolRanges); - return bIsDefault; -} - -ImplFontCharMap::~ImplFontCharMap() -{ - if( IsDefaultMap() ) - return; - delete[] mpRangeCodes; - delete[] mpStartGlyphs; - delete[] mpGlyphIds; -} - -ImplFontCharMapPtr ImplFontCharMap::GetDefaultMap( bool bSymbols) +ImplFontCharMapPtr ImplFontCharMap::getDefaultMap( bool bSymbols ) { const sal_UCS4* pRangeCodes = aDefaultUnicodeRanges; int nCodesCount = sizeof(aDefaultUnicodeRanges) / sizeof(*pRangeCodes); @@ -85,173 +79,10 @@ ImplFontCharMapPtr ImplFontCharMap::GetDefaultMap( bool bSymbols) return pDefaultImplFontCharMap; } -int ImplFontCharMap::ImplFindRangeIndex( sal_UCS4 cChar ) const -{ - int nLower = 0; - int nMid = mnRangeCount; - int nUpper = 2 * mnRangeCount - 1; - while( nLower < nUpper ) - { - if( cChar >= mpRangeCodes[ nMid ] ) - nLower = nMid; - else - nUpper = nMid - 1; - nMid = (nLower + nUpper + 1) / 2; - } - - return nMid; -} - -bool ImplFontCharMap::HasChar( sal_UCS4 cChar ) const -{ - bool bHasChar = false; - - if( mpStartGlyphs == NULL ) { // only the char-ranges are known - const int nRange = ImplFindRangeIndex( cChar ); - if( nRange==0 && cChar<mpRangeCodes[0] ) - return false; - bHasChar = ((nRange & 1) == 0); // inside a range - } else { // glyph mapping is available - const int nGlyphIndex = GetGlyphIndex( cChar ); - bHasChar = (nGlyphIndex != 0); // not the notdef-glyph - } - - return bHasChar; -} - -int ImplFontCharMap::GetGlyphIndex( sal_UCS4 cChar ) const -{ - // return -1 if the object doesn't know the glyph ids - if( !mpStartGlyphs ) - return -1; - - // return 0 if the unicode doesn't have a matching glyph - int nRange = ImplFindRangeIndex( cChar ); - // check that we are inside any range - if( (nRange == 0) && (cChar < mpRangeCodes[0]) ) { - // symbol aliasing gives symbol fonts a second chance - const bool bSymbolic = cChar <= 0xFF && (mpRangeCodes[0]>=0xF000) && (mpRangeCodes[1]<=0xF0FF); - if( !bSymbolic ) - return 0; - // check for symbol aliasing (U+F0xx -> U+00xx) - cChar |= 0xF000; - nRange = ImplFindRangeIndex( cChar ); - if( (nRange == 0) && (cChar < mpRangeCodes[0]) ) { - return 0; - } - } - // check that we are inside a range - if( (nRange & 1) != 0 ) - return 0; - - // get glyph index directly or indirectly - int nGlyphIndex = cChar - mpRangeCodes[ nRange ]; - const int nStartIndex = mpStartGlyphs[ nRange/2 ]; - if( nStartIndex >= 0 ) { - // the glyph index can be calculated - nGlyphIndex += nStartIndex; - } else { - // the glyphid array has the glyph index - nGlyphIndex = mpGlyphIds[ nGlyphIndex - nStartIndex]; - } - - return nGlyphIndex; -} - -// returns the number of chars supported by the font, which -// are inside the unicode range from cMin to cMax (inclusive) -int ImplFontCharMap::CountCharsInRange( sal_UCS4 cMin, sal_UCS4 cMax ) const -{ - int nCount = 0; - - // find and adjust range and char count for cMin - int nRangeMin = ImplFindRangeIndex( cMin ); - if( nRangeMin & 1 ) - ++nRangeMin; - else if( cMin > mpRangeCodes[ nRangeMin ] ) - nCount -= cMin - mpRangeCodes[ nRangeMin ]; - - // find and adjust range and char count for cMax - int nRangeMax = ImplFindRangeIndex( cMax ); - if( nRangeMax & 1 ) - --nRangeMax; - else - nCount -= mpRangeCodes[ nRangeMax+1 ] - cMax - 1; - - // count chars in complete ranges between cMin and cMax - for( int i = nRangeMin; i <= nRangeMax; i+=2 ) - nCount += mpRangeCodes[i+1] - mpRangeCodes[i]; - - return nCount; -} - - -sal_UCS4 ImplFontCharMap::GetLastChar() const -{ - return (mpRangeCodes[ 2*mnRangeCount-1 ] - 1); -} - -sal_UCS4 ImplFontCharMap::GetNextChar( sal_UCS4 cChar ) const -{ - if( cChar < GetFirstChar() ) - return GetFirstChar(); - if( cChar >= GetLastChar() ) - return GetLastChar(); - - int nRange = ImplFindRangeIndex( cChar + 1 ); - if( nRange & 1 ) // outside of range? - return mpRangeCodes[ nRange + 1 ]; // => first in next range - return (cChar + 1); -} - -sal_UCS4 ImplFontCharMap::GetPrevChar( sal_UCS4 cChar ) const -{ - if( cChar <= GetFirstChar() ) - return GetFirstChar(); - if( cChar > GetLastChar() ) - return GetLastChar(); - - int nRange = ImplFindRangeIndex( cChar - 1 ); - if( nRange & 1 ) // outside a range? - return (mpRangeCodes[ nRange ] - 1); // => last in prev range - return (cChar - 1); -} - -int ImplFontCharMap::GetIndexFromChar( sal_UCS4 cChar ) const -{ - // TODO: improve linear walk? - int nCharIndex = 0; - const sal_UCS4* pRange = &mpRangeCodes[0]; - for( int i = 0; i < mnRangeCount; ++i ) - { - sal_UCS4 cFirst = *(pRange++); - sal_UCS4 cLast = *(pRange++); - if( cChar >= cLast ) - nCharIndex += cLast - cFirst; - else if( cChar >= cFirst ) - return nCharIndex + (cChar - cFirst); - else - break; - } - - return -1; -} - -sal_UCS4 ImplFontCharMap::GetCharFromIndex( int nCharIndex ) const +bool ImplFontCharMap::isDefaultMap() const { - // TODO: improve linear walk? - const sal_UCS4* pRange = &mpRangeCodes[0]; - for( int i = 0; i < mnRangeCount; ++i ) - { - sal_UCS4 cFirst = *(pRange++); - sal_UCS4 cLast = *(pRange++); - nCharIndex -= cLast - cFirst; - if( nCharIndex < 0 ) - return (cLast + nCharIndex); - } - - // we can only get here with an out-of-bounds charindex - return mpRangeCodes[0]; + const bool bIsDefault = (mpRangeCodes == aDefaultUnicodeRanges) || (mpRangeCodes == aDefaultSymbolRanges); + return bIsDefault; } static unsigned GetUInt( const unsigned char* p ) { return((p[0]<<24)+(p[1]<<16)+(p[2]<<8)+p[3]);} @@ -543,74 +374,218 @@ bool ParseCMAP( const unsigned char* pCmap, int nLength, CmapResult& rResult ) } FontCharMap::FontCharMap() -: mpImplFontCharMap( ImplFontCharMap::GetDefaultMap() ) +: mpImplFontCharMap( ImplFontCharMap::getDefaultMap() ) +{} + +FontCharMap::FontCharMap( ImplFontCharMapPtr pIFCMap ) +: mpImplFontCharMap( pIFCMap ) {} +FontCharMap::FontCharMap( const CmapResult& rCR ) +{ + ImplFontCharMapPtr pImplFontCharMap( new ImplFontCharMap(rCR) ); + mpImplFontCharMap = pImplFontCharMap; + + const sal_UCS4* pRangePtr = mpImplFontCharMap->mpRangeCodes; + for( int i = mpImplFontCharMap->mnRangeCount; --i >= 0; pRangePtr += 2 ) + { + sal_UCS4 cFirst = pRangePtr[0]; + sal_UCS4 cLast = pRangePtr[1]; + mpImplFontCharMap->mnCharCount += cLast - cFirst; + } +} + FontCharMap::~FontCharMap() { mpImplFontCharMap = 0; } -int FontCharMap::GetCharCount() const +FontCharMapPtr FontCharMap::GetDefaultMap( bool bSymbol ) { - return mpImplFontCharMap->GetCharCount(); + FontCharMapPtr pFontCharMap( new FontCharMap( ImplFontCharMap::getDefaultMap( bSymbol ) ) ); + return pFontCharMap; } -int FontCharMap::CountCharsInRange( sal_UCS4 cMin, sal_UCS4 cMax ) const +bool FontCharMap::IsDefaultMap() const { - return mpImplFontCharMap->CountCharsInRange( cMin, cMax ); + return mpImplFontCharMap->isDefaultMap(); } -void FontCharMap::Reset( const ImplFontCharMapPtr pNewMap ) +int FontCharMap::GetCharCount() const { - if( !pNewMap ) - { - mpImplFontCharMap = ImplFontCharMap::GetDefaultMap(); - } - else if( pNewMap != mpImplFontCharMap ) - { - mpImplFontCharMap = pNewMap; - } + return GetCharCount(); } -bool FontCharMap::IsDefaultMap() const +int FontCharMap::CountCharsInRange( sal_UCS4 cMin, sal_UCS4 cMax ) const { - return mpImplFontCharMap->IsDefaultMap(); + int nCount = 0; + + // find and adjust range and char count for cMin + int nRangeMin = findRangeIndex( cMin ); + if( nRangeMin & 1 ) + ++nRangeMin; + else if( cMin > mpImplFontCharMap->mpRangeCodes[ nRangeMin ] ) + nCount -= cMin - mpImplFontCharMap->mpRangeCodes[ nRangeMin ]; + + // find and adjust range and char count for cMax + int nRangeMax = findRangeIndex( cMax ); + if( nRangeMax & 1 ) + --nRangeMax; + else + nCount -= mpImplFontCharMap->mpRangeCodes[ nRangeMax+1 ] - cMax - 1; + + // count chars in complete ranges between cMin and cMax + for( int i = nRangeMin; i <= nRangeMax; i+=2 ) + nCount += mpImplFontCharMap->mpRangeCodes[i+1] - mpImplFontCharMap->mpRangeCodes[i]; + + return nCount; } bool FontCharMap::HasChar( sal_UCS4 cChar ) const { - return mpImplFontCharMap->HasChar( cChar ); + bool bHasChar = false; + + if( mpImplFontCharMap->mpStartGlyphs == NULL ) { // only the char-ranges are known + const int nRange = findRangeIndex( cChar ); + if( nRange==0 && cChar < mpImplFontCharMap->mpRangeCodes[0] ) + return false; + bHasChar = ((nRange & 1) == 0); // inside a range + } else { // glyph mapping is available + const int nGlyphIndex = GetGlyphIndex( cChar ); + bHasChar = (nGlyphIndex != 0); // not the notdef-glyph + } + + return bHasChar; } sal_UCS4 FontCharMap::GetFirstChar() const { - return mpImplFontCharMap->GetFirstChar(); + return mpImplFontCharMap->mpRangeCodes[0]; } sal_UCS4 FontCharMap::GetLastChar() const { - return mpImplFontCharMap->GetLastChar(); + return (mpImplFontCharMap->mpRangeCodes[ 2*mpImplFontCharMap->mnRangeCount-1 ] - 1); } sal_UCS4 FontCharMap::GetNextChar( sal_UCS4 cChar ) const { - return mpImplFontCharMap->GetNextChar( cChar ); + if( cChar < GetFirstChar() ) + return GetFirstChar(); + if( cChar >= GetLastChar() ) + return GetLastChar(); + + int nRange = findRangeIndex( cChar + 1 ); + if( nRange & 1 ) // outside of range? + return mpImplFontCharMap->mpRangeCodes[ nRange + 1 ]; // => first in next range + return (cChar + 1); } sal_UCS4 FontCharMap::GetPrevChar( sal_UCS4 cChar ) const { - return mpImplFontCharMap->GetPrevChar( cChar ); + if( cChar <= GetFirstChar() ) + return GetFirstChar(); + if( cChar > GetLastChar() ) + return GetLastChar(); + + int nRange = findRangeIndex( cChar - 1 ); + if( nRange & 1 ) // outside a range? + return (mpImplFontCharMap->mpRangeCodes[ nRange ] - 1); // => last in prev range + return (cChar - 1); } int FontCharMap::GetIndexFromChar( sal_UCS4 cChar ) const { - return mpImplFontCharMap->GetIndexFromChar( cChar ); + // TODO: improve linear walk? + int nCharIndex = 0; + const sal_UCS4* pRange = &mpImplFontCharMap->mpRangeCodes[0]; + for( int i = 0; i < mpImplFontCharMap->mnRangeCount; ++i ) + { + sal_UCS4 cFirst = *(pRange++); + sal_UCS4 cLast = *(pRange++); + if( cChar >= cLast ) + nCharIndex += cLast - cFirst; + else if( cChar >= cFirst ) + return nCharIndex + (cChar - cFirst); + else + break; + } + + return -1; } sal_UCS4 FontCharMap::GetCharFromIndex( int nIndex ) const { - return mpImplFontCharMap->GetCharFromIndex( nIndex ); + // TODO: improve linear walk? + const sal_UCS4* pRange = &mpImplFontCharMap->mpRangeCodes[0]; + for( int i = 0; i < mpImplFontCharMap->mnRangeCount; ++i ) + { + sal_UCS4 cFirst = *(pRange++); + sal_UCS4 cLast = *(pRange++); + nIndex -= cLast - cFirst; + if( nIndex < 0 ) + return (cLast + nIndex); + } + + // we can only get here with an out-of-bounds charindex + return mpImplFontCharMap->mpRangeCodes[0]; +} + +int FontCharMap::findRangeIndex( sal_UCS4 cChar ) const +{ + int nLower = 0; + int nMid = mpImplFontCharMap->mnRangeCount; + int nUpper = 2 * mpImplFontCharMap->mnRangeCount - 1; + while( nLower < nUpper ) + { + if( cChar >= mpImplFontCharMap->mpRangeCodes[ nMid ] ) + nLower = nMid; + else + nUpper = nMid - 1; + nMid = (nLower + nUpper + 1) / 2; + } + + return nMid; +} + +int FontCharMap::GetGlyphIndex( sal_UCS4 cChar ) const +{ + // return -1 if the object doesn't know the glyph ids + if( !mpImplFontCharMap->mpStartGlyphs ) + return -1; + + // return 0 if the unicode doesn't have a matching glyph + int nRange = findRangeIndex( cChar ); + // check that we are inside any range + if( (nRange == 0) && (cChar < mpImplFontCharMap->mpRangeCodes[0]) ) { + // symbol aliasing gives symbol fonts a second chance + const bool bSymbolic = cChar <= 0xFF && (mpImplFontCharMap->mpRangeCodes[0]>=0xF000) && + (mpImplFontCharMap->mpRangeCodes[1]<=0xF0FF); + if( !bSymbolic ) + return 0; + // check for symbol aliasing (U+F0xx -> U+00xx) + cChar |= 0xF000; + nRange = findRangeIndex( cChar ); + if( (nRange == 0) && (cChar < mpImplFontCharMap->mpRangeCodes[0]) ) { + return 0; + } + } + // check that we are inside a range + if( (nRange & 1) != 0 ) + return 0; + + // get glyph index directly or indirectly + int nGlyphIndex = cChar - mpImplFontCharMap->mpRangeCodes[ nRange ]; + const int nStartIndex = mpImplFontCharMap->mpStartGlyphs[ nRange/2 ]; + if( nStartIndex >= 0 ) { + // the glyph index can be calculated + nGlyphIndex += nStartIndex; + } else { + // the glyphid array has the glyph index + nGlyphIndex = mpImplFontCharMap->mpGlyphIds[ nGlyphIndex - nStartIndex]; + } + + return nGlyphIndex; } // on some systems we have to get the font attributes from the name table diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 0931f79e369e..f6af60cc6476 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -216,10 +216,8 @@ FontMetric OutputDevice::GetFontMetric( const vcl::Font& rFont ) const return aMetric; } -bool OutputDevice::GetFontCharMap( FontCharMap& rFontCharMap ) const +bool OutputDevice::GetFontCharMap( FontCharMapPtr& rFontCharMap ) const { - rFontCharMap.Reset(); - // we need a graphics if( !mpGraphics && !AcquireGraphics() ) return false; @@ -231,10 +229,16 @@ bool OutputDevice::GetFontCharMap( FontCharMap& rFontCharMap ) const if( !mpFontEntry ) return false; - const ImplFontCharMapPtr pNewMap = mpGraphics->GetImplFontCharMap(); - rFontCharMap.Reset( pNewMap ); + FontCharMapPtr pFontCharMap ( mpGraphics->GetFontCharMap() ); + if (!pFontCharMap) + { + FontCharMapPtr pDefaultMap( new FontCharMap() ); + rFontCharMap = pDefaultMap; + } + else + rFontCharMap = pFontCharMap; - if( rFontCharMap.IsDefaultMap() ) + if( rFontCharMap->IsDefaultMap() ) return false; return true; } @@ -2160,8 +2164,8 @@ sal_Int32 OutputDevice::HasGlyphs( const vcl::Font& rTempFont, const OUString& r // to get the map temporarily set font const vcl::Font aOrigFont = GetFont(); const_cast<OutputDevice&>(*this).SetFont( rTempFont ); - FontCharMap aFontCharMap; - bool bRet = GetFontCharMap( aFontCharMap ); + FontCharMapPtr pFontCharMap ( new FontCharMap() ); + bool bRet = GetFontCharMap( pFontCharMap ); const_cast<OutputDevice&>(*this).SetFont( aOrigFont ); // if fontmap is unknown assume it doesn't have the glyphs @@ -2169,9 +2173,11 @@ sal_Int32 OutputDevice::HasGlyphs( const vcl::Font& rTempFont, const OUString& r return nIndex; for( sal_Int32 i = nIndex; nIndex < nEnd; ++i, ++nIndex ) - if( ! aFontCharMap.HasChar( rStr[i] ) ) + if( ! pFontCharMap->HasChar( rStr[i] ) ) return nIndex; + pFontCharMap = 0; + return -1; } diff --git a/vcl/unx/generic/gdi/salgdi3.cxx b/vcl/unx/generic/gdi/salgdi3.cxx index f028597fe1da..3cd42cdd09a9 100644 --- a/vcl/unx/generic/gdi/salgdi3.cxx +++ b/vcl/unx/generic/gdi/salgdi3.cxx @@ -43,12 +43,13 @@ #include <vcl/jobdata.hxx> #include <vcl/printerinfomanager.hxx> #include <vcl/svapp.hxx> +#include <vcl/metric.hxx> #include "fontmanager.hxx" +#include "impfont.hxx" #include "gcach_xpeer.hxx" #include "generic/genpspgraphics.h" #include "generic/printergfx.hxx" -#include "impfont.hxx" #include "outdev.h" #include "PhysicalFontCollection.hxx" #include "PhysicalFontFace.hxx" @@ -431,13 +432,13 @@ void X11SalGraphics::DrawServerFontLayout( const ServerFontLayout& rLayout ) cairo_destroy(cr); } -const ImplFontCharMapPtr X11SalGraphics::GetImplFontCharMap() const +const FontCharMapPtr X11SalGraphics::GetFontCharMap() const { if( !mpServerFont[0] ) return NULL; - const ImplFontCharMapPtr pIFCMap = mpServerFont[0]->GetImplFontCharMap(); - return pIFCMap; + const FontCharMapPtr pFCMap = mpServerFont[0]->GetFontCharMap(); + return pFCMap; } bool X11SalGraphics::GetFontCapabilities(vcl::FontCapabilities &rGetImplFontCapabilities) const diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx index cb5be79ee1b6..f3933d960ab0 100644 --- a/vcl/win/source/gdi/salgdi3.cxx +++ b/vcl/win/source/gdi/salgdi3.cxx @@ -40,6 +40,7 @@ #include <unotools/fontcfg.hxx> #include <vcl/settings.hxx> #include <vcl/sysdata.hxx> +#include <vcl/metric.hxx> #include "fontsubset.hxx" #include "outdev.h" @@ -430,7 +431,7 @@ public: bool FindFontSubstitute( FontSelectPattern&, OUString& rMissingChars ) const; private: HDC mhDC; - bool HasMissingChars( const PhysicalFontFace*, const OUString& rMissingChars ) const; + bool HasMissingChars( PhysicalFontFace*, const OUString& rMissingChars ) const; }; inline WinGlyphFallbackSubstititution::WinGlyphFallbackSubstititution( HDC hDC ) @@ -441,10 +442,10 @@ void ImplGetLogFontFromFontSelect( HDC, const FontSelectPattern*, LOGFONTW&, bool /*bTestVerticalAvail*/ ); // does a font face hold the given missing characters? -bool WinGlyphFallbackSubstititution::HasMissingChars( const PhysicalFontFace* pFace, const OUString& rMissingChars ) const +bool WinGlyphFallbackSubstititution::HasMissingChars( PhysicalFontFace* pFace, const OUString& rMissingChars ) const { - const ImplWinFontData* pWinFont = static_cast<const ImplWinFontData*>(pFace); - ImplFontCharMapPtr pCharMap = pWinFont->GetImplFontCharMap(); + ImplWinFontData* pWinFont = static_cast< ImplWinFontData* >(pFace); + FontCharMapPtr pCharMap = pWinFont->GetFontCharMap(); if( !pCharMap ) { // construct a Size structure as the parameter of constructor of class FontSelectPattern @@ -468,7 +469,7 @@ bool WinGlyphFallbackSubstititution::HasMissingChars( const PhysicalFontFace* pF ::DeleteFont( hNewFont ); // get the new charmap - pCharMap = pWinFont->GetImplFontCharMap(); + pCharMap = pWinFont->GetFontCharMap(); } // avoid fonts with unknown CMAP subtables for glyph fallback @@ -531,10 +532,10 @@ bool WinGlyphFallbackSubstititution::FindFontSubstitute( FontSelectPattern& rFon // first level fallback: // try use the locale specific default fonts defined in VCL.xcu const PhysicalFontCollection* pFontCollection = ImplGetSVData()->maGDIData.mpScreenFontList; - /*const*/ PhysicalFontFamily* pFontFamily = findDevFontListByLocale(*pFontCollection, aLanguageTag); + PhysicalFontFamily* pFontFamily = findDevFontListByLocale(*pFontCollection, aLanguageTag); if( pFontFamily ) { - const PhysicalFontFace* pFace = pFontFamily->FindBestFontFace( rFontSelData ); + PhysicalFontFace* pFace = pFontFamily->FindBestFontFace( rFontSelData ); if( HasMissingChars( pFace, rMissingChars ) ) { rFontSelData.maSearchName = pFontFamily->GetSearchName(); @@ -550,7 +551,7 @@ bool WinGlyphFallbackSubstititution::FindFontSubstitute( FontSelectPattern& rFon rFontSelData.maSearchName ); if( pFontFamily ) { - const PhysicalFontFace* pFace = pFontFamily->FindBestFontFace( rFontSelData ); + PhysicalFontFace* pFace = pFontFamily->FindBestFontFace( rFontSelData ); if( HasMissingChars( pFace, rMissingChars ) ) { rFontSelData.maSearchName = pFontFamily->GetSearchName(); @@ -569,7 +570,7 @@ bool WinGlyphFallbackSubstititution::FindFontSubstitute( FontSelectPattern& rFon bool bFound = false; for( int i = 0; i < nTestFontCount; ++i ) { - const PhysicalFontFace* pFace = pTestFontList->Get( i ); + PhysicalFontFace* pFace = pTestFontList->Get( i ); bFound = HasMissingChars( pFace, rMissingChars ); if( !bFound ) continue; @@ -1224,7 +1225,7 @@ bool ImplWinFontData::IsGSUBstituted( sal_UCS4 cChar ) const return( maGsubTable.find( cChar ) != maGsubTable.end() ); } -const ImplFontCharMapPtr ImplWinFontData::GetImplFontCharMap() const +FontCharMapPtr ImplWinFontData::GetFontCharMap() const { if( !mpUnicodeMap ) return NULL; @@ -1299,13 +1300,15 @@ void ImplWinFontData::ReadCmapTable( HDC hDC ) const aResult.mbSymbolic = bIsSymbolFont; if( aResult.mnRangeCount > 0 ) { - ImplFontCharMapPtr pUnicodeMap( new ImplFontCharMap( aResult ) ); + FontCharMapPtr pUnicodeMap(new FontCharMap(aResult)); mpUnicodeMap = pUnicodeMap; } } if( !mpUnicodeMap ) - mpUnicodeMap = ImplFontCharMap::GetDefaultMap( bIsSymbolFont ); + { + mpUnicodeMap = FontCharMap::GetDefaultMap( bIsSymbolFont ); + } } void ImplWinFontData::GetFontCapabilities( HDC hDC ) const @@ -1699,11 +1702,14 @@ sal_uLong WinSalGraphics::GetKernPairs() return mnFontKernPairCount; } -const ImplFontCharMapPtr WinSalGraphics::GetImplFontCharMap() const +const FontCharMapPtr WinSalGraphics::GetFontCharMap() const { if( !mpWinFontData[0] ) - return ImplFontCharMap::GetDefaultMap(); - return mpWinFontData[0]->GetImplFontCharMap(); + { + FontCharMapPtr pDefFontCharMap( new FontCharMap() ); + return pDefFontCharMap; + } + return mpWinFontData[0]->GetFontCharMap(); } bool WinSalGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const @@ -2482,7 +2488,7 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile, if( aRawCffData.get() ) { pWinFontData->UpdateFromHDC( getHDC() ); - ImplFontCharMapPtr pCharMap = pWinFontData->GetImplFontCharMap(); + FontCharMapPtr pCharMap = pWinFontData->GetFontCharMap(); sal_GlyphId aRealGlyphIds[ 256 ]; for( int i = 0; i < nGlyphCount; ++i ) @@ -2732,7 +2738,7 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont, rUnicodeEnc.clear(); } const ImplWinFontData* pWinFont = static_cast<const ImplWinFontData*>(pFont); - ImplFontCharMapPtr pMap = pWinFont->GetImplFontCharMap(); + FontCharMapPtr pMap = pWinFont->GetFontCharMap(); DBG_ASSERT( pMap && pMap->GetCharCount(), "no map" ); int nCharCount = pMap->GetCharCount(); |