Strip down GetEmbedFontData to what is really used
The only remaining user is EmbeddedFontsHelper, and it just needs the
raw font data.
Change-Id: Ia15c59158b5c9e44d0936463553303a3c8b6e0f5
Reviewed-on: https://gerrit.libreoffice.org/31374
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx
index 2d44659..63a10f5 100644
--- a/vcl/headless/svptext.cxx
+++ b/vcl/headless/svptext.cxx
@@ -73,15 +73,9 @@ bool SvpSalGraphics::CreateFontSubset(
return m_aTextRenderImpl.CreateFontSubset(rToFile, pFont, pGlyphIds, pEncoding, pWidths, nGlyphCount, rInfo);
}
const void* SvpSalGraphics::GetEmbedFontData(
const PhysicalFontFace* pFont,
const sal_Ucs* pUnicodes,
sal_Int32* pWidths,
size_t nLen,
FontSubsetInfo& rInfo,
long* pDataLen)
const void* SvpSalGraphics::GetEmbedFontData(const PhysicalFontFace* pFont, long* pDataLen)
{
return m_aTextRenderImpl.GetEmbedFontData(pFont, pUnicodes, pWidths, nLen, rInfo, pDataLen);
return m_aTextRenderImpl.GetEmbedFontData(pFont, pDataLen);
}
void SvpSalGraphics::FreeEmbedFontData( const void* pData, long nLen )
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index bcd4ac6..ad6e4bf 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -153,12 +153,7 @@ public:
int nGlyphs,
FontSubsetInfo& rInfo
) override;
virtual const void* GetEmbedFontData( const PhysicalFontFace*,
const sal_Ucs* pUnicodes,
sal_Int32* pWidths,
size_t nLen,
FontSubsetInfo& rInfo,
long* pDataLen ) override;
virtual const void* GetEmbedFontData(const PhysicalFontFace*, long* pDataLen) override;
virtual void FreeEmbedFontData( const void* pData, long nDataLen ) override;
virtual void GetGlyphWidths( const PhysicalFontFace*,
bool bVertical,
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index f752fd2..382641e 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -365,16 +365,8 @@ public:
// GetEmbedFontData: gets the font data for a font marked
// embeddable by GetDevFontList or NULL in case of error
// parameters: pFont: describes the font in question
// pWidths: the widths of all glyphs from char code 0 to 255
// pWidths MUST support at least 256 members;
// rInfo: additional outgoing information
// pDataLen: out parameter, contains the byte length of the returned buffer
virtual const void* GetEmbedFontData( const PhysicalFontFace*,
const sal_Ucs* pUnicodes,
sal_Int32* pWidths,
size_t nLen,
FontSubsetInfo& rInfo,
long* pDataLen ) override;
virtual const void* GetEmbedFontData(const PhysicalFontFace*, long* pDataLen) override;
// frees the font data again
virtual void FreeEmbedFontData( const void* pData, long nDataLen ) override;
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index e7382be..13e5e71 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -175,23 +175,13 @@ public:
// GetEmbedFontData: gets the font data for a font marked
// embeddable by GetDevFontList or NULL in case of error
// parameters: pFont: describes the font in question
// pUnicodes: contains the Unicodes assigned to code points 0 to 255
// pWidths: the widths of all glyphs from char code 0 to 255
// nLen: the number of elements in each of pWidths and pUnicodes
// rInfo: additional outgoing information
// pDataLen: out parameter, contains the byte length of the returned buffer
virtual const void* GetEmbedFontData(
const PhysicalFontFace* pFont,
const sal_Ucs* pUnicodes,
sal_Int32* pWidths,
size_t nLen,
FontSubsetInfo& rInfo,
long* pDataLen ) = 0;
virtual const void* GetEmbedFontData(const PhysicalFontFace* pFont, long* pDataLen) = 0;
// free the font data again
virtual void FreeEmbedFontData( const void* pData, long nDataLen ) = 0;
// get the same widths as in CreateFontSubset and GetEmbedFontData
// get the same widths as in CreateFontSubset
// in case of an embeddable font also fill the mapping
// between unicode and glyph id
// leave widths vector and mapping untouched in case of failure
diff --git a/vcl/inc/textrender.hxx b/vcl/inc/textrender.hxx
index 694fa7b..9417345 100644
--- a/vcl/inc/textrender.hxx
+++ b/vcl/inc/textrender.hxx
@@ -51,14 +51,7 @@ public:
int nGlyphs,
FontSubsetInfo& rInfo) = 0;
virtual const void* GetEmbedFontData(
const PhysicalFontFace*,
const sal_Ucs* pUnicodes,
sal_Int32* pWidths,
size_t nLen,
FontSubsetInfo& rInfo,
long* pDataLen ) = 0;
virtual const void* GetEmbedFontData(const PhysicalFontFace*, long* pDataLen) = 0;
virtual void FreeEmbedFontData( const void* pData, long nDataLen ) = 0;
virtual void GetGlyphWidths(
const PhysicalFontFace*,
diff --git a/vcl/inc/unx/cairotextrender.hxx b/vcl/inc/unx/cairotextrender.hxx
index a8a0d6d5..5fab64a 100644
--- a/vcl/inc/unx/cairotextrender.hxx
+++ b/vcl/inc/unx/cairotextrender.hxx
@@ -67,14 +67,7 @@ public:
int nGlyphs,
FontSubsetInfo& rInfo) override;
virtual const void* GetEmbedFontData(
const PhysicalFontFace*,
const sal_Ucs* pUnicodes,
sal_Int32* pWidths,
size_t nLen,
FontSubsetInfo& rInfo,
long* pDataLen ) override;
virtual const void* GetEmbedFontData(const PhysicalFontFace*, long* pDataLen) override;
virtual void FreeEmbedFontData( const void* pData, long nDataLen ) override;
virtual void GetGlyphWidths(
const PhysicalFontFace*,
diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h
index 97e759e..71bd81f 100644
--- a/vcl/inc/unx/genpspgraphics.h
+++ b/vcl/inc/unx/genpspgraphics.h
@@ -56,9 +56,7 @@ public:
SalInfoPrinter* pInfoPrinter );
// helper methods
static const void * DoGetEmbedFontData ( psp::fontID aFont, const sal_Ucs* pUnicodes,
sal_Int32* pWidths, size_t nLen, FontSubsetInfo& rInfo,
long* pDataLen );
static const void * DoGetEmbedFontData(psp::fontID aFont, long* pDataLen);
static void DoFreeEmbedFontData( const void* pData, long nLen );
// helper methods for sharing with X11SalGraphics
@@ -111,12 +109,7 @@ public:
sal_Int32* pWidths,
int nGlyphs,
FontSubsetInfo& rInfo ) override;
virtual const void* GetEmbedFontData( const PhysicalFontFace*,
const sal_Ucs* pUnicodes,
sal_Int32* pWidths,
size_t nLen,
FontSubsetInfo& rInfo,
long* pDataLen ) override;
virtual const void* GetEmbedFontData(const PhysicalFontFace*, long* pDataLen) override;
virtual void FreeEmbedFontData( const void* pData, long nDataLen ) override;
virtual void GetGlyphWidths( const PhysicalFontFace*,
bool bVertical,
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 2a64ebf..27b0c84 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -131,14 +131,7 @@ public:
int nGlyphs,
FontSubsetInfo& rInfo ) override;
virtual const void* GetEmbedFontData(
const PhysicalFontFace*,
const sal_Ucs* pUnicodes,
sal_Int32* pWidths,
size_t nLen,
FontSubsetInfo& rInfo,
long* pDataLen ) override;
virtual const void* GetEmbedFontData(const PhysicalFontFace*, long* pDataLen) override;
virtual void FreeEmbedFontData( const void* pData, long nDataLen ) override;
virtual void GetGlyphWidths(
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index a07af12..8471699 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -393,16 +393,8 @@ public:
// GetEmbedFontData: gets the font data for a font marked
// embeddable by GetDevFontList or NULL in case of error
// parameters: pFont: describes the font in question
// pWidths: the widths of all glyphs from char code 0 to 255
// pWidths MUST support at least 256 members;
// rInfo: additional outgoing information
// pDataLen: out parameter, contains the byte length of the returned buffer
virtual const void* GetEmbedFontData( const PhysicalFontFace*,
const sal_Ucs* pUnicodes,
sal_Int32* pWidths,
size_t nLen,
FontSubsetInfo& rInfo,
long* pDataLen ) override;
virtual const void* GetEmbedFontData(const PhysicalFontFace*, long* pDataLen) override;
// frees the font data again
virtual void FreeEmbedFontData( const void* pData, long nDataLen ) override;
virtual void GetGlyphWidths( const PhysicalFontFace*,
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index e57fd95..4a363b3 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -840,12 +840,7 @@ void AquaSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFontData, bool bV
::CloseTTFont( pSftFont );
}
const void* AquaSalGraphics::GetEmbedFontData( const PhysicalFontFace*,
const sal_Ucs* /*pUnicodes*/,
sal_Int32* /*pWidths*/,
size_t /*nLen*/,
FontSubsetInfo&,
long* /*pDataLen*/ )
const void* AquaSalGraphics::GetEmbedFontData(const PhysicalFontFace*, long* /*pDataLen*/)
{
return nullptr;
}
diff --git a/vcl/source/gdi/embeddedfontshelper.cxx b/vcl/source/gdi/embeddedfontshelper.cxx
index b39136d..5e4e242 100644
--- a/vcl/source/gdi/embeddedfontshelper.cxx
+++ b/vcl/source/gdi/embeddedfontshelper.cxx
@@ -261,9 +261,8 @@ OUString EmbeddedFontsHelper::fontFileUrl( const OUString& familyName, FontFamil
}
if( selected != nullptr )
{
FontSubsetInfo info;
long size;
if( const void* data = graphics->GetEmbedFontData( selected, nullptr, nullptr, 0, info, &size ))
if (const void* data = graphics->GetEmbedFontData(selected, &size))
{
if( sufficientTTFRights( data, size, rights ))
{
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index 8607530..de3dc4b 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -536,7 +536,7 @@ bool CairoTextRender::CreateFontSubset(
return bSuccess;
}
const void* CairoTextRender::GetEmbedFontData( const PhysicalFontFace* pFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, size_t nLen, FontSubsetInfo& rInfo, long* pDataLen )
const void* CairoTextRender::GetEmbedFontData(const PhysicalFontFace* pFont, long* pDataLen)
{
// in this context the pFont->GetFontId() is a valid PSP
// font since they are the only ones left after the PDF
@@ -544,7 +544,7 @@ const void* CairoTextRender::GetEmbedFontData( const PhysicalFontFace* pFont, co
// which this method was created). The correct way would
// be to have the GlyphCache search for the PhysicalFontFace pFont
psp::fontID aFont = pFont->GetFontId();
return GenPspGraphics::DoGetEmbedFontData( aFont, pUnicodes, pWidths, nLen, rInfo, pDataLen );
return GenPspGraphics::DoGetEmbedFontData(aFont, pDataLen);
}
void CairoTextRender::FreeEmbedFontData( const void* pData, long nLen )
diff --git a/vcl/unx/generic/gdi/font.cxx b/vcl/unx/generic/gdi/font.cxx
index 937fa2b..8379c0c 100644
--- a/vcl/unx/generic/gdi/font.cxx
+++ b/vcl/unx/generic/gdi/font.cxx
@@ -141,9 +141,9 @@ bool X11SalGraphics::CreateFontSubset(
pGlyphIds, pEncoding, pWidths, nGlyphCount, rInfo);
}
const void* X11SalGraphics::GetEmbedFontData( const PhysicalFontFace* pFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, size_t nLen, FontSubsetInfo& rInfo, long* pDataLen )
const void* X11SalGraphics::GetEmbedFontData(const PhysicalFontFace* pFont, long* pDataLen)
{
return mxTextRenderImpl->GetEmbedFontData(pFont, pUnicodes, pWidths, nLen, rInfo, pDataLen);
return mxTextRenderImpl->GetEmbedFontData(pFont, pDataLen);
}
void X11SalGraphics::FreeEmbedFontData( const void* pData, long nLen )
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index d1dbbf4..cebc0eb 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -1039,27 +1039,11 @@ void GenPspGraphics::DoFreeEmbedFontData( const void* pData, long nLen )
munmap( const_cast<void *>(pData), nLen );
}
const void* GenPspGraphics::DoGetEmbedFontData( psp::fontID aFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, size_t nLen, FontSubsetInfo& rInfo, long* pDataLen )
const void* GenPspGraphics::DoGetEmbedFontData(psp::fontID aFont, long* pDataLen)
{
psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
psp::PrintFontInfo aFontInfo;
if( ! rMgr.getFontInfo( aFont, aFontInfo ) )
return nullptr;
// fill in font info
rInfo.m_nAscent = aFontInfo.m_nAscend;
rInfo.m_nDescent = aFontInfo.m_nDescend;
rInfo.m_aPSName = rMgr.getPSName( aFont );
int xMin, yMin, xMax, yMax;
rMgr.getFontBoundingBox( aFont, xMin, yMin, xMax, yMax );
std::vector<psp::CharacterMetric> aMetrics(nLen);
if (!rMgr.getMetrics(aFont, pUnicodes, nLen, aMetrics.data()))
return nullptr;
OString aSysPath = rMgr.getFontFileSysPath( aFont );
int fd = open( aSysPath.getStr(), O_RDONLY );
@@ -1077,14 +1061,6 @@ const void* GenPspGraphics::DoGetEmbedFontData( psp::fontID aFont, const sal_Ucs
return nullptr;
*pDataLen = aStat.st_size;
rInfo.m_aFontBBox = Rectangle( Point( xMin, yMin ), Size( xMax-xMin, yMax-yMin ) );
rInfo.m_nCapHeight = yMax; // Well ...
for (size_t i = 0; i < nLen; ++i)
pWidths[i] = (aMetrics[i].width > 0 ? aMetrics[i].width : 0);
rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF;
return pFile;
}
@@ -1093,7 +1069,7 @@ void GenPspGraphics::FreeEmbedFontData( const void* pData, long nLen )
DoFreeEmbedFontData( pData, nLen );
}
const void* GenPspGraphics::GetEmbedFontData( const PhysicalFontFace* pFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, size_t nLen, FontSubsetInfo& rInfo, long* pDataLen )
const void* GenPspGraphics::GetEmbedFontData(const PhysicalFontFace* pFont, long* pDataLen)
{
// in this context the pFont->GetFontId() is a valid PSP
// font since they are the only ones left after the PDF
@@ -1101,7 +1077,7 @@ const void* GenPspGraphics::GetEmbedFontData( const PhysicalFontFace* pFont, con
// which this method was created). The correct way would
// be to have the GlyphCache search for the PhysicalFontFace pFont
psp::fontID aFont = pFont->GetFontId();
return DoGetEmbedFontData(aFont, pUnicodes, pWidths, nLen, rInfo, pDataLen);
return DoGetEmbedFontData(aFont, pDataLen);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 7f7f681..5d1e6bc 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -1903,15 +1903,12 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile,
return (nRC == SF_OK);
}
const void* WinSalGraphics::GetEmbedFontData( const PhysicalFontFace* pFont,
const sal_Unicode* pUnicodes, sal_Int32* pCharWidths, size_t nLen,
FontSubsetInfo& rInfo, long* pDataLen )
const void* WinSalGraphics::GetEmbedFontData(const PhysicalFontFace* pFont, long* pDataLen)
{
// create matching FontSelectPattern
// we need just enough to get to the font file data
FontSelectPattern aIFSD( *pFont, Size(0,1000), 1000.0, 0, false );
// TODO: much better solution: move SetFont and restoration of old font to caller
ScopedFont aOldFont(*this);
SetFont( &aIFSD, 0 );
@@ -1921,39 +1918,6 @@ const void* WinSalGraphics::GetEmbedFontData( const PhysicalFontFace* pFont,
if( !aRawFontData.get() )
return nullptr;
// get important font properties
TEXTMETRICA aTm;
if( !::GetTextMetricsA( getHDC(), &aTm ) )
*pDataLen = 0;
const bool bPFA = (*aRawFontData.get() < 0x80);
rInfo.m_nFontType = bPFA ? FontSubsetInfo::TYPE1_PFA : FontSubsetInfo::TYPE1_PFB;
WCHAR aFaceName[64];
sal_Int32 nFNLen = ::GetTextFaceW( getHDC(), 64, aFaceName );
// #i59854# strip eventual null byte
while( nFNLen > 0 && aFaceName[nFNLen-1] == 0 )
nFNLen--;
if( nFNLen == 0 )
*pDataLen = 0;
rInfo.m_aPSName = OUString(reinterpret_cast<const sal_Unicode*>(aFaceName), nFNLen);
rInfo.m_nAscent = +aTm.tmAscent;
rInfo.m_nDescent = -aTm.tmDescent;
rInfo.m_aFontBBox = Rectangle( Point( -aTm.tmOverhang, -aTm.tmDescent ),
Point( aTm.tmMaxCharWidth, aTm.tmAscent+aTm.tmExternalLeading ) );
rInfo.m_nCapHeight = aTm.tmAscent; // Well ...
// get individual character widths
for (size_t i = 0; i < nLen; ++i)
{
int nCharWidth = 0;
const sal_Unicode cChar = pUnicodes[i];
if( !::GetCharWidth32W( getHDC(), cChar, cChar, &nCharWidth ) )
*pDataLen = 0;
pCharWidths[i] = nCharWidth;
}
if( !*pDataLen )
return nullptr;
const unsigned char* pData = aRawFontData.steal();
return pData;
}