summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2019-08-28 18:22:25 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2019-09-11 12:38:11 +0200
commit1a224b4d24d650ab2e1f11980ec90b299343d7f4 (patch)
treeeda171aa5d72ed02e308c9a6be6eae6bd74d81e6
parentMove creating HarfBuzz face to PhysicalFontFace (diff)
downloadcore-1a224b4d24d650ab2e1f11980ec90b299343d7f4.tar.gz
core-1a224b4d24d650ab2e1f11980ec90b299343d7f4.zip
Consolidate GetFontCharMap()
All implementations were basically doing the same thing. Move to PhysicalFontFace and use HarfBuzz API to get the raw OpeenType table data. While at make a few other places use that FontCharMap as well instead of parsing the cmap table again. Drop unused HasChar() as well. Change-Id: I06ff4feb61bcfb17291bf3c299caf11fc53afa4d
-rw-r--r--vcl/inc/PhysicalFontFace.hxx5
-rw-r--r--vcl/inc/qt5/Qt5FontFace.hxx3
-rw-r--r--vcl/inc/quartz/salgdi.h3
-rw-r--r--vcl/inc/unx/fontmanager.hxx3
-rw-r--r--vcl/inc/unx/freetype_glyphcache.hxx4
-rw-r--r--vcl/inc/unx/genpspgraphics.h2
-rw-r--r--vcl/inc/unx/glyphcache.hxx1
-rw-r--r--vcl/inc/win/salgdi.h20
-rw-r--r--vcl/qt5/Qt5FontFace.cxx26
-rw-r--r--vcl/qt5/Qt5Graphics_Text.cxx2
-rw-r--r--vcl/quartz/salgdi.cxx41
-rw-r--r--vcl/source/font/PhysicalFontFace.cxx30
-rw-r--r--vcl/unx/generic/fontmanager/fontmanager.cxx43
-rw-r--r--vcl/unx/generic/gdi/cairotextrender.cxx5
-rw-r--r--vcl/unx/generic/glyphs/freetype_glyphcache.cxx34
-rw-r--r--vcl/unx/generic/print/genpspgraphics.cxx14
-rw-r--r--vcl/win/gdi/salfont.cxx69
17 files changed, 67 insertions, 238 deletions
diff --git a/vcl/inc/PhysicalFontFace.hxx b/vcl/inc/PhysicalFontFace.hxx
index d827c7a10987..3992bb91bf41 100644
--- a/vcl/inc/PhysicalFontFace.hxx
+++ b/vcl/inc/PhysicalFontFace.hxx
@@ -25,6 +25,7 @@
#include <salhelper/simplereferenceobject.hxx>
#include <rtl/ref.hxx>
#include <vcl/dllapi.h>
+#include <vcl/outdev.hxx>
#include "fontattributes.hxx"
@@ -68,6 +69,8 @@ public:
sal_Int32 CompareWithSize( const PhysicalFontFace& ) const;
sal_Int32 CompareIgnoreSize( const PhysicalFontFace& ) const;
+ const FontCharMapRef& GetCharMap() const;
+
hb_face_t* GetHbFace() const;
virtual hb_blob_t* GetHbTable(hb_tag_t nTag) const = 0;
@@ -79,6 +82,8 @@ protected:
long mnHeight; // Height (in pixels)
mutable hb_face_t* mpHbFace;
+
+ mutable FontCharMapRef mxCharMap;
};
#endif // INCLUDED_VCL_INC_PHYSICALFONTFACE_HXX
diff --git a/vcl/inc/qt5/Qt5FontFace.hxx b/vcl/inc/qt5/Qt5FontFace.hxx
index 1ecf01545f45..a179438cf2a5 100644
--- a/vcl/inc/qt5/Qt5FontFace.hxx
+++ b/vcl/inc/qt5/Qt5FontFace.hxx
@@ -42,9 +42,7 @@ public:
int GetFontTable(const char pTagName[5], unsigned char*) const;
- const FontCharMapRef& GetFontCharMap() const;
bool GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const;
- bool HasChar(sal_uInt32 cChar) const;
rtl::Reference<LogicalFontInstance>
CreateFontInstance(const FontSelectPattern& rFSD) const override;
@@ -57,7 +55,6 @@ protected:
private:
const QString m_aFontId;
- mutable FontCharMapRef m_xCharMap;
mutable vcl::FontCapabilities m_aFontCapabilities;
mutable bool m_bFontCapabilitiesRead;
};
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 051585648f19..68c9aff47757 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -67,9 +67,7 @@ public:
int GetFontTable( uint32_t nTagCode, unsigned char* ) const;
int GetFontTable( const char pTagName[5], unsigned char* ) const;
- FontCharMapRef GetFontCharMap() const;
bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const;
- bool HasChar( sal_uInt32 cChar ) const;
rtl::Reference<LogicalFontInstance> CreateFontInstance(const FontSelectPattern&) const override;
@@ -77,7 +75,6 @@ public:
private:
const sal_IntPtr mnFontId;
- mutable FontCharMapRef mxCharMap;
mutable vcl::FontCapabilities maFontCapabilities;
mutable bool mbFontCapabilitiesRead;
};
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx
index 3c67adc70d8f..8d388013144a 100644
--- a/vcl/inc/unx/fontmanager.hxx
+++ b/vcl/inc/unx/fontmanager.hxx
@@ -42,6 +42,7 @@ class FontSubsetInfo;
class FontConfigFontOptions;
class FontSelectPattern;
class GenericUnixSalData;
+class PhysicalFontFace;
namespace psp {
class PPDParser;
@@ -271,7 +272,7 @@ public:
sal_Int32* pWidths,
int nGlyphs
);
- void getGlyphWidths( fontID nFont,
+ void getGlyphWidths( const PhysicalFontFace* pFace,
bool bVertical,
std::vector< sal_Int32 >& rWidths,
std::map< sal_Unicode, sal_uInt32 >& rUnicodeEnc );
diff --git a/vcl/inc/unx/freetype_glyphcache.hxx b/vcl/inc/unx/freetype_glyphcache.hxx
index 9873fa38059d..4fe24ffa4f90 100644
--- a/vcl/inc/unx/freetype_glyphcache.hxx
+++ b/vcl/inc/unx/freetype_glyphcache.hxx
@@ -76,8 +76,6 @@ public:
void AnnounceFont( PhysicalFontCollection* );
- const FontCharMapRef& GetFontCharMap();
-
private:
FT_FaceRec_* maFaceFT;
FreetypeFontFile* const mpFontFile;
@@ -86,8 +84,6 @@ private:
int mnRefCount;
sal_IntPtr const mnFontId;
FontAttributes maDevFontAttributes;
-
- FontCharMapRef mxFontCharMap;
};
class FreetypeFontFace : public PhysicalFontFace
diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h
index 73084a4f6a61..44ca12ebc458 100644
--- a/vcl/inc/unx/genpspgraphics.h
+++ b/vcl/inc/unx/genpspgraphics.h
@@ -55,7 +55,7 @@ public:
static void DoFreeEmbedFontData( const void* pData, long nLen );
// helper methods for sharing with X11SalGraphics
- static void DoGetGlyphWidths( psp::fontID aFont,
+ static void DoGetGlyphWidths( const PhysicalFontFace*,
bool bVertical,
std::vector< sal_Int32 >& rWidths,
Ucs2UIntMap& rUnicodeEnc );
diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx
index ccb25cab87e2..c072752db6a7 100644
--- a/vcl/inc/unx/glyphcache.hxx
+++ b/vcl/inc/unx/glyphcache.hxx
@@ -107,7 +107,6 @@ public:
void GetFontMetric(ImplFontMetricDataRef const &) const;
const unsigned char* GetTable( const char* pName, sal_uLong* pLength ) const;
- FontCharMapRef GetFontCharMap() const;
bool GetFontCapabilities(vcl::FontCapabilities &) const;
bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const;
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 503b8f3aa062..9ccd62085a47 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -68,12 +68,9 @@ public:
void SetFontId( sal_IntPtr nId ) { mnId = nId; }
void UpdateFromHDC( HDC ) const;
- bool HasChar( sal_uInt32 cChar ) const;
-
BYTE GetCharSet() const { return meWinCharSet; }
BYTE GetPitchAndFamily() const { return mnPitchAndFamily; }
- FontCharMapRef GetFontCharMap() const;
bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const;
hb_blob_t* GetHbTable(hb_tag_t nTag) const override;
@@ -83,7 +80,6 @@ private:
// some members that are initialized lazily when the font gets selected into a HDC
mutable bool mbFontCapabilitiesRead;
- mutable FontCharMapRef mxUnicodeMap;
mutable vcl::FontCapabilities maFontCapabilities;
BYTE meWinCharSet;
@@ -91,7 +87,6 @@ private:
bool mbAliasSymbolsHigh;
bool mbAliasSymbolsLow;
- void ReadCmapTable( HDC ) const;
void GetFontCapabilities( HDC hDC ) const;
mutable HDC mhDC;
@@ -400,21 +395,6 @@ void ImplGetLogFontFromFontSelect( HDC, const FontSelectPattern&,
#define MAX_64KSALPOINTS ((((sal_uInt16)0xFFFF)-8)/sizeof(POINTS))
-// called extremely often from just one spot => inline
-inline bool WinFontFace::HasChar( sal_uInt32 cChar ) const
-{
- if( mxUnicodeMap->HasChar( cChar ) )
- return true;
- // second chance to allow symbol aliasing
- if( mbAliasSymbolsLow && ((cChar-0xF000) <= 0xFF) )
- cChar -= 0xF000;
- else if( mbAliasSymbolsHigh && (cChar <= 0xFF) )
- cChar += 0xF000;
- else
- return false;
- return mxUnicodeMap->HasChar( cChar );
-}
-
#endif // INCLUDED_VCL_INC_WIN_SALGDI_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5FontFace.cxx b/vcl/qt5/Qt5FontFace.cxx
index 2523f3424284..4c4bbb7ef6de 100644
--- a/vcl/qt5/Qt5FontFace.cxx
+++ b/vcl/qt5/Qt5FontFace.cxx
@@ -26,7 +26,6 @@
#include <Qt5Tools.hxx>
#include <sft.hxx>
-#include <impfontcharmap.hxx>
#include <fontinstance.hxx>
#include <fontselect.hxx>
#include <PhysicalFontCollection.hxx>
@@ -42,8 +41,6 @@ Qt5FontFace::Qt5FontFace(const Qt5FontFace& rSrc)
: PhysicalFontFace(rSrc)
, m_aFontId(rSrc.m_aFontId)
{
- if (rSrc.m_xCharMap.is())
- m_xCharMap = rSrc.m_xCharMap;
}
static FontWeight fromQFontWeight(int nWeight)
@@ -143,29 +140,6 @@ Qt5FontFace::CreateFontInstance(const FontSelectPattern& rFSD) const
return new Qt5Font(*this, rFSD);
}
-const FontCharMapRef& Qt5FontFace::GetFontCharMap() const
-{
- if (m_xCharMap.is())
- return m_xCharMap;
-
- QFont aFont;
- aFont.fromString(m_aFontId);
- QRawFont aRawFont(QRawFont::fromFont(aFont));
- QByteArray aCMapTable = aRawFont.fontTable("cmap");
- if (aCMapTable.isEmpty())
- {
- m_xCharMap = new FontCharMap();
- return m_xCharMap;
- }
-
- CmapResult aCmapResult;
- if (ParseCMAP(reinterpret_cast<const unsigned char*>(aCMapTable.data()), aCMapTable.size(),
- aCmapResult))
- m_xCharMap = new FontCharMap(aCmapResult);
-
- return m_xCharMap;
-}
-
bool Qt5FontFace::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const
{
// read this only once per font
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 85b51b82b1eb..73dd374493e7 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -71,7 +71,7 @@ FontCharMapRef Qt5Graphics::GetFontCharMap() const
{
if (!m_pTextStyle[0])
return FontCharMapRef(new FontCharMap());
- return static_cast<const Qt5FontFace*>(m_pTextStyle[0]->GetFontFace())->GetFontCharMap();
+ return m_pTextStyle[0]->GetFontFace()->GetCharMap();
}
bool Qt5Graphics::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 0d5ecab6a419..fc986eba5806 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -40,7 +40,6 @@
#include <quartz/ctfonts.hxx>
#include <fontsubset.hxx>
#include <impfont.hxx>
-#include <impfontcharmap.hxx>
#include <impfontmetricdata.hxx>
#include <outdev.h>
#include <PhysicalFontCollection.hxx>
@@ -113,44 +112,6 @@ sal_IntPtr CoreTextFontFace::GetFontId() const
return mnFontId;
}
-FontCharMapRef CoreTextFontFace::GetFontCharMap() const
-{
- // return the cached charmap
- if( mxCharMap.is() )
- return mxCharMap;
-
- // set the default charmap
- FontCharMapRef pCharMap( new FontCharMap() );
- mxCharMap = pCharMap;
-
- // get the CMAP byte size
- // allocate a buffer for the CMAP raw data
- const int nBufSize = GetFontTable( "cmap", nullptr );
- SAL_WARN_IF( (nBufSize <= 0), "vcl", "CoreTextFontFace::GetFontCharMap : GetFontTable1 failed!");
- if( nBufSize <= 0 )
- return mxCharMap;
-
- // get the CMAP raw data
- std::vector<unsigned char> aBuffer( nBufSize );
- const int nRawLength = GetFontTable( "cmap", aBuffer.data() );
- SAL_WARN_IF( (nRawLength <= 0), "vcl", "CoreTextFontFace::GetFontCharMap : GetFontTable2 failed!");
- if( nRawLength <= 0 )
- return mxCharMap;
-
- SAL_WARN_IF( (nBufSize!=nRawLength), "vcl", "CoreTextFontFace::GetFontCharMap : ByteCount mismatch!");
-
- // parse the CMAP
- CmapResult aCmapResult;
- if( ParseCMAP( aBuffer.data(), nRawLength, aCmapResult ) )
- {
- FontCharMapRef xDefFontCharMap( new FontCharMap(aCmapResult) );
- // create the matching charmap
- mxCharMap = xDefFontCharMap;
- }
-
- return mxCharMap;
-}
-
bool CoreTextFontFace::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
{
// read this only once per font
@@ -514,7 +475,7 @@ FontCharMapRef AquaSalGraphics::GetFontCharMap() const
return FontCharMapRef( new FontCharMap() );
}
- return static_cast<const CoreTextFontFace*>(mpTextStyle[0]->GetFontFace())->GetFontCharMap();
+ return mpTextStyle[0]->GetFontFace()->GetCharMap();
}
bool AquaSalGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx
index a8ca4dabbfd7..997b1c155160 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -17,12 +17,15 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <vcl/fontcharmap.hxx>
+
#include <sal/types.h>
#include <tools/fontenum.hxx>
#include <unotools/fontdefs.hxx>
#include <fontattributes.hxx>
#include <fontselect.hxx>
+#include <impfontcharmap.hxx>
#include <PhysicalFontFace.hxx>
@@ -218,4 +221,31 @@ hb_face_t* PhysicalFontFace::GetHbFace() const
return mpHbFace;
}
+const FontCharMapRef& PhysicalFontFace::GetCharMap() const
+{
+ if (mxCharMap.is())
+ return mxCharMap;
+
+ // Get the charmap and cache it.
+ CmapResult aCmapResult;
+ aCmapResult.mbSymbolic = IsSymbolFont();
+
+ hb_blob_t* pBlob = hb_face_reference_table(mpHbFace, HB_TAG('c', 'm', 'a', 'p'));
+ const unsigned char* pData = reinterpret_cast<const unsigned char*>(hb_blob_get_data(pBlob, nullptr));
+ size_t nSize = hb_blob_get_length(pBlob);
+ if (nSize > 0 && ParseCMAP(pData, nSize, aCmapResult))
+ {
+ FontCharMapRef xCharMap(new FontCharMap(aCmapResult));
+ mxCharMap = xCharMap;
+ }
+ else
+ {
+ FontCharMapRef xCharMap(new FontCharMap());
+ mxCharMap = xCharMap;
+ }
+ hb_blob_destroy(pBlob);
+
+ return mxCharMap;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
index a4d07ec3bdbe..87c1f2b84c70 100644
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
@@ -27,7 +27,6 @@
#include <unx/fontmanager.hxx>
#include <fontsubset.hxx>
-#include <impfontcharmap.hxx>
#include <svdata.hxx>
#include <unx/geninst.h>
#include <unx/gendata.hxx>
@@ -55,6 +54,8 @@
#include <sft.hxx>
+#include <PhysicalFontFace.hxx>
+
#if OSL_DEBUG_LEVEL > 1
#include <sys/times.h>
#include <stdio.h>
@@ -1104,12 +1105,12 @@ bool PrintFontManager::createFontSubset(
return bSuccess;
}
-void PrintFontManager::getGlyphWidths( fontID nFont,
+void PrintFontManager::getGlyphWidths( const PhysicalFontFace* pFace,
bool bVertical,
std::vector< sal_Int32 >& rWidths,
std::map< sal_Unicode, sal_uInt32 >& rUnicodeEnc )
{
- PrintFont* pFont = getFont( nFont );
+ PrintFont* pFont = getFont(pFace->GetFontId());
if (!pFont)
return;
TrueTypeFont* pTTFont = nullptr;
@@ -1136,32 +1137,22 @@ void PrintFontManager::getGlyphWidths( fontID nFont,
}
// fill the unicode map
- // TODO: isn't this map already available elsewhere in the fontmanager?
- const sal_uInt8* pCmapData = nullptr;
- int nCmapSize = 0;
- if (GetSfntTable(pTTFont, O_cmap, &pCmapData, &nCmapSize))
+ FontCharMapRef xFontCharMap = pFace->GetCharMap();
+ for (sal_uInt32 cOld = 0;;)
{
- CmapResult aCmapResult;
- if (ParseCMAP(pCmapData, nCmapSize, aCmapResult))
- {
- FontCharMapRef xFontCharMap(new FontCharMap(aCmapResult));
- for (sal_uInt32 cOld = 0;;)
- {
- // get next unicode covered by font
- const sal_uInt32 c = xFontCharMap->GetNextChar(cOld);
- if (c == cOld)
- break;
- cOld = c;
+ // get next unicode covered by font
+ const sal_uInt32 c = xFontCharMap->GetNextChar(cOld);
+ if (c == cOld)
+ break;
+ cOld = c;
#if 1 // TODO: remove when sal_Unicode covers all of unicode
- if (c > sal_Unicode(~0))
- break;
+ if (c > sal_Unicode(~0))
+ break;
#endif
- // get the matching glyph index
- const sal_GlyphId aGlyphId = xFontCharMap->GetGlyphIndex(c);
- // update the requested map
- rUnicodeEnc[static_cast<sal_Unicode>(c)] = aGlyphId;
- }
- }
+ // get the matching glyph index
+ const sal_GlyphId aGlyphId = xFontCharMap->GetGlyphIndex(c);
+ // update the requested map
+ rUnicodeEnc[static_cast<sal_Unicode>(c)] = aGlyphId;
}
}
CloseTTFont(pTTFont);
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index 0b24cbf32d63..7a6f44be779a 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -371,7 +371,7 @@ FontCharMapRef CairoTextRender::GetFontCharMap() const
if( !mpFreetypeFont[0] )
return nullptr;
- return mpFreetypeFont[0]->GetFontCharMap();
+ return mpFreetypeFont[0]->GetFontInstance()->GetFontFace()->GetCharMap();
}
bool CairoTextRender::GetFontCapabilities(vcl::FontCapabilities &rGetImplFontCapabilities) const
@@ -546,8 +546,7 @@ void CairoTextRender::GetGlyphWidths( const PhysicalFontFace* pFont,
// export has filtered its list of subsettable fonts (for
// which this method was created). The correct way would
// be to have the GlyphCache search for the PhysicalFontFace pFont
- psp::fontID aFont = pFont->GetFontId();
- GenPspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc );
+ GenPspGraphics::DoGetGlyphWidths(pFont, bVertical, rWidths, rUnicodeEnc);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index 8dbeab94013f..e3402014dac5 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -66,7 +66,6 @@
#include <sys/stat.h>
#include <sys/mman.h>
#include <unx/fontmanager.hxx>
-#include <impfontcharmap.hxx>
#include <impfontcache.hxx>
static FT_Library aLibFT = nullptr;
@@ -708,39 +707,6 @@ bool FreetypeFont::GetAntialiasAdvice() const
return !mpFontInstance->GetFontSelectPattern().mbNonAntialiased && (mnPrioAntiAlias > 0);
}
-// determine unicode ranges in font
-
-FontCharMapRef FreetypeFont::GetFontCharMap() const
-{
- return mpFontInfo->GetFontCharMap();
-}
-
-const FontCharMapRef& FreetypeFontInfo::GetFontCharMap()
-{
- // check if the charmap is already cached
- if( mxFontCharMap.is() )
- return mxFontCharMap;
-
- // get the charmap and cache it
- CmapResult aCmapResult;
- aCmapResult.mbSymbolic = IsSymbolFont();
-
- sal_uLong nLength = 0;
- const unsigned char* pCmap = GetTable("cmap", &nLength);
- if (pCmap && (nLength > 0) && ParseCMAP(pCmap, nLength, aCmapResult))
- {
- FontCharMapRef xFontCharMap( new FontCharMap ( aCmapResult ) );
- mxFontCharMap = xFontCharMap;
- }
- else
- {
- FontCharMapRef xFontCharMap( new FontCharMap() );
- mxFontCharMap = xFontCharMap;
- }
- // mxFontCharMap on either branch now has a refcount of 1
- return mxFontCharMap;
-}
-
bool FreetypeFont::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
{
bool bRet = false;
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index 26c4163893e4..768c6933900a 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -607,7 +607,7 @@ FontCharMapRef GenPspGraphics::GetFontCharMap() const
if( !m_pFreetypeFont[0] )
return nullptr;
- return m_pFreetypeFont[0]->GetFontCharMap();
+ return m_pFreetypeFont[0]->GetFontInstance()->GetFontFace()->GetCharMap();
}
bool GenPspGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
@@ -793,22 +793,16 @@ void GenPspGraphics::GetGlyphWidths( const PhysicalFontFace* pFont,
std::vector< sal_Int32 >& rWidths,
Ucs2UIntMap& rUnicodeEnc )
{
- // in this context the pFont->GetFontId() is a valid PSP
- // font since they are the only ones left after the PDF
- // export has filtered its list of subsettable fonts (for
- // which this method was created). The correct way would
- // be to have the GlyphCache search for the PhysicalFontFace pFont
- psp::fontID aFont = pFont->GetFontId();
- GenPspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc );
+ GenPspGraphics::DoGetGlyphWidths(pFont, bVertical, rWidths, rUnicodeEnc);
}
-void GenPspGraphics::DoGetGlyphWidths( psp::fontID aFont,
+void GenPspGraphics::DoGetGlyphWidths( const PhysicalFontFace* pFont,
bool bVertical,
std::vector< sal_Int32 >& rWidths,
Ucs2UIntMap& rUnicodeEnc )
{
psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
- rMgr.getGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc );
+ rMgr.getGlyphWidths(pFont, bVertical, rWidths, rUnicodeEnc);
}
FontAttributes GenPspGraphics::Info2FontAttributes( const psp::FastPrintFontInfo& rInfo )
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index c87e00fb3405..24432782e951 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -57,7 +57,6 @@
#include <win/saldata.hxx>
#include <win/salgdi.h>
#include <win/winlayout.hxx>
-#include <impfontcharmap.hxx>
#include <impfontmetricdata.hxx>
#include <impglyphitem.hxx>
@@ -174,32 +173,7 @@ private:
bool WinGlyphFallbackSubstititution::HasMissingChars(PhysicalFontFace* pFace, OUString& rMissingChars) const
{
WinFontFace* pWinFont = static_cast< WinFontFace* >(pFace);
- FontCharMapRef xFontCharMap = pWinFont->GetFontCharMap();
- if( !xFontCharMap.is() )
- {
- // construct a Size structure as the parameter of constructor of class FontSelectPattern
- const Size aSize( pFace->GetWidth(), pFace->GetHeight() );
- // create a FontSelectPattern object for getting s LOGFONT
- const FontSelectPattern aFSD( *pFace, aSize, static_cast<float>(aSize.Height()), 0, false );
- // construct log font
- LOGFONTW aLogFont;
- ImplGetLogFontFromFontSelect( mhDC, aFSD, pFace, aLogFont );
-
- // create HFONT from log font
- HFONT hNewFont = ::CreateFontIndirectW( &aLogFont );
- // select the new font into device
- HFONT hOldFont = ::SelectFont( mhDC, hNewFont );
-
- // read CMAP table to update their xFontCharMap
- pWinFont->UpdateFromHDC( mhDC );
-
- // cleanup temporary font
- ::SelectFont( mhDC, hOldFont );
- ::DeleteFont( hNewFont );
-
- // get the new charmap
- xFontCharMap = pWinFont->GetFontCharMap();
- }
+ FontCharMapRef xFontCharMap = pWinFont->GetCharMap();
// avoid fonts with unknown CMAP subtables for glyph fallback
if( !xFontCharMap.is() || xFontCharMap->IsDefaultMap() )
@@ -642,7 +616,6 @@ WinFontFace::WinFontFace( const FontAttributes& rDFS,
WinFontFace::~WinFontFace()
{
- mxUnicodeMap.clear();
}
sal_IntPtr WinFontFace::GetFontId() const
@@ -679,53 +652,19 @@ static DWORD CalcTag( const char p[5]) { return (p[0]+(p[1]<<8)+(p[2]<<16)+(p[3]
void WinFontFace::UpdateFromHDC( HDC hDC ) const
{
// short circuit if already initialized
- if( mxUnicodeMap.is() )
+ if (mhDC != nullptr)
return;
mhDC = hDC;
-
- ReadCmapTable( hDC );
GetFontCapabilities( hDC );
}
-FontCharMapRef WinFontFace::GetFontCharMap() const
-{
- return mxUnicodeMap;
-}
-
bool WinFontFace::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
{
rFontCapabilities = maFontCapabilities;
return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange;
}
-void WinFontFace::ReadCmapTable( HDC hDC ) const
-{
- if( mxUnicodeMap.is() )
- return;
-
- bool bIsSymbolFont = (meWinCharSet == SYMBOL_CHARSET);
- // get the CMAP table from the font which is selected into the DC
- const DWORD nCmapTag = CalcTag( "cmap" );
- const RawFontData aRawFontData( hDC, nCmapTag );
- // parse the CMAP table if available
- if( aRawFontData.get() ) {
- CmapResult aResult;
- ParseCMAP( aRawFontData.get(), aRawFontData.size(), aResult );
- aResult.mbSymbolic = bIsSymbolFont;
- if( aResult.mnRangeCount > 0 )
- {
- FontCharMapRef pUnicodeMap(new FontCharMap(aResult));
- mxUnicodeMap = pUnicodeMap;
- }
- }
-
- if( !mxUnicodeMap.is() )
- {
- mxUnicodeMap = FontCharMap::GetDefaultMap( bIsSymbolFont );
- }
-}
-
void WinFontFace::GetFontCapabilities( HDC hDC ) const
{
// read this only once per font
@@ -1003,7 +942,7 @@ FontCharMapRef WinSalGraphics::GetFontCharMap() const
{
return FontCharMapRef( new FontCharMap() );
}
- return mpWinFontEntry[0]->GetFontFace()->GetFontCharMap();
+ return mpWinFontEntry[0]->GetFontFace()->GetCharMap();
}
bool WinSalGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
@@ -1762,7 +1701,7 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont,
rUnicodeEnc.clear();
}
const WinFontFace* pWinFont = static_cast<const WinFontFace*>(pFont);
- FontCharMapRef xFCMap = pWinFont->GetFontCharMap();
+ FontCharMapRef xFCMap = pWinFont->GetCharMap();
SAL_WARN_IF( !xFCMap.is() || !xFCMap->GetCharCount(), "vcl", "no map" );
int nCharCount = xFCMap->GetCharCount();