vcl: tdf#138325 pass PostScript name down to CreateCFFfontSubset()
If we don’t pass the name from the caller, it will try to read it from
the CFF table but some fonts has CFF table without a PostScript name so
we end up with a dummy value.
Change-Id: Ie7c46cdf5542ce83a57b60dee35dbb704a898f18
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140220
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@aliftype.com>
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 55464aa..c1d2c5c 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -628,6 +628,7 @@ class TrueTypeFace;
VCL_DLLPUBLIC bool CreateCFFfontSubset(const unsigned char* pFontBytes,
int nByteLength,
std::vector<sal_uInt8>& rOutBuffer,
const OUString& rPSName,
const sal_GlyphId* pGlyphIds,
const sal_uInt8* pEncoding,
int nGlyphCount, FontSubsetInfo& rInfo);
diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx
index d210304..411f2d5 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -293,7 +293,8 @@ bool PhysicalFontFace::CreateFontSubset(std::vector<sal_uInt8>& rOutBuffer,
// Shortcut for CFF-subsetting.
auto aData = GetRawFontData(T_CFF);
if (!aData.empty())
return CreateCFFfontSubset(aData.data(), aData.size(), rOutBuffer, pGlyphIds, pEncoding,
return CreateCFFfontSubset(aData.data(), aData.size(), rOutBuffer,
GetName(NAME_ID_POSTSCRIPT_NAME), pGlyphIds, pEncoding,
nGlyphCount, rInfo);
// Prepare data for font subsetter.
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index de2461d..892366e 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1914,8 +1914,8 @@ bool CreateTTFfontSubset(vcl::AbstractTrueTypeFont& rTTF, std::vector<sal_uInt8>
}
bool CreateCFFfontSubset(const unsigned char* pFontBytes, int nByteLength,
std::vector<sal_uInt8>& rOutBuffer, const sal_GlyphId* pGlyphIds,
const sal_uInt8* pEncoding, int nGlyphCount,
std::vector<sal_uInt8>& rOutBuffer, const OUString& rPSName,
const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding, int nGlyphCount,
FontSubsetInfo& rInfo)
{
utl::TempFile aTempFile;
@@ -1926,8 +1926,8 @@ bool CreateCFFfontSubset(const unsigned char* pFontBytes, int nByteLength,
return false;
rInfo.LoadFont(FontType::CFF_FONT, pFontBytes, nByteLength);
bool bRet = rInfo.CreateFontSubset(FontType::TYPE1_PFB, pOutFile, nullptr, pGlyphIds, pEncoding,
nGlyphCount);
bool bRet = rInfo.CreateFontSubset(FontType::TYPE1_PFB, pOutFile, rPSName.toUtf8().getStr(),
pGlyphIds, pEncoding, nGlyphCount);
fclose(pOutFile);
if (bRet)