summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@aliftype.com>2022-12-05 22:07:29 +0200
committerخالد حسني <khaled@aliftype.com>2022-12-06 04:24:42 +0000
commit1d5a02d12eacadb708c18e70db747e80ab8817a9 (patch)
tree286cbb19389fe7b19cfc2e4eaaeca0236de87e5a /vcl
parent7415ce2b9795a78f836bc5e5bffb4b56eee26b21 (diff)
Simplify PhysicalFontFace::CreateFontSubset() a bit
Hide the logic inside fontsubset and don’t leak it to the caller. Change-Id: Ibc845e0051eaeb64e8de42f80d4d404fd6a3880e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143686 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/sft.hxx10
-rw-r--r--vcl/source/font/PhysicalFontFace.cxx11
-rw-r--r--vcl/source/fontsubset/sft.cxx24
3 files changed, 20 insertions, 25 deletions
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 52d9c3db014d..b5fc71b44530 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -611,17 +611,7 @@ class TrueTypeFont;
std::vector<sal_uInt8>& rOutBuffer,
const sal_GlyphId* pGlyphIds,
const sal_uInt8* pEncoding,
- int nGlyphCount);
-
- VCL_DLLPUBLIC bool CreateCFFfontSubset(const unsigned char* pFontBytes,
- int nByteLength,
- std::vector<sal_uInt8>& rOutBuffer,
- const sal_GlyphId* pGlyphIds,
- const sal_uInt8* pEncoding,
int nGlyphCount, FontSubsetInfo& rInfo);
-
- VCL_DLLPUBLIC void FillFontSubsetInfo(AbstractTrueTypeFont *ttf,
- FontSubsetInfo& rInfo);
/**
* Generates a new PostScript Type42 font and dumps it to <b>outf</b> file.
* This function substitutes glyph 0 for all glyphIDs that are not found in the font.
diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx
index 72c0a86802c8..aa9a9327f708 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -363,17 +363,8 @@ bool PhysicalFontFace::CreateFontSubset(std::vector<sal_uInt8>& rOutBuffer,
if (aSftFont.initialize() != SFErrCodes::Ok)
return false;
- // Get details about the subset font.
- FillFontSubsetInfo(&aSftFont, rInfo);
-
- // Shortcut for CFF-subsetting.
- auto aData = GetRawFontData(T_CFF);
- if (!aData.empty())
- return CreateCFFfontSubset(aData.data(), aData.size(), rOutBuffer, pGlyphIds, pEncoding,
- nGlyphCount, rInfo);
-
// write subset into destination file
- return CreateTTFfontSubset(aSftFont, rOutBuffer, pGlyphIds, pEncoding, nGlyphCount);
+ return CreateTTFfontSubset(aSftFont, rOutBuffer, pGlyphIds, pEncoding, nGlyphCount, rInfo);
}
bool PhysicalFontFace::HasColorLayers() const
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 205be4f8ce26..ee2e0de65dbc 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1809,10 +1809,24 @@ SFErrCodes CreateTTFromTTGlyphs(AbstractTrueTypeFont *ttf,
return res;
}
+static void FillFontSubsetInfo(AbstractTrueTypeFont*, FontSubsetInfo&);
+static bool CreateCFFfontSubset(const unsigned char*, int, std::vector<sal_uInt8>&,
+ const sal_GlyphId*, const sal_uInt8*, int, FontSubsetInfo&);
+
bool CreateTTFfontSubset(vcl::AbstractTrueTypeFont& rTTF, std::vector<sal_uInt8>& rOutBuffer,
const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding,
- const int nOrigGlyphCount)
+ const int nOrigGlyphCount, FontSubsetInfo& rInfo)
{
+ // Get details about the subset font.
+ FillFontSubsetInfo(&rTTF, rInfo);
+
+ // Shortcut for CFF-subsetting.
+ sal_uInt32 nCFF;
+ const sal_uInt8* pCFF = rTTF.table(O_CFF, nCFF);
+ if (nCFF)
+ return CreateCFFfontSubset(pCFF, nCFF, rOutBuffer, pGlyphIds, pEncoding,
+ nOrigGlyphCount, rInfo);
+
// Multiple questions:
// - Why is there a glyph limit?
// MacOS used to handle 257 glyphs...
@@ -1867,9 +1881,9 @@ bool CreateTTFfontSubset(vcl::AbstractTrueTypeFont& rTTF, std::vector<sal_uInt8>
== vcl::SFErrCodes::Ok);
}
-bool CreateCFFfontSubset(const unsigned char* pFontBytes, int nByteLength,
- std::vector<sal_uInt8>& rOutBuffer, const sal_GlyphId* pGlyphIds,
- const sal_uInt8* pEncoding, int nGlyphCount, FontSubsetInfo& rInfo)
+static bool CreateCFFfontSubset(const unsigned char* pFontBytes, int nByteLength,
+ std::vector<sal_uInt8>& rOutBuffer, const sal_GlyphId* pGlyphIds,
+ const sal_uInt8* pEncoding, int nGlyphCount, FontSubsetInfo& rInfo)
{
utl::TempFileFast aTempFile;
SvStream* pStream = aTempFile.GetStream(StreamMode::READWRITE);
@@ -2245,7 +2259,7 @@ void GetTTGlobalFontInfo(AbstractTrueTypeFont *ttf, TTGlobalFontInfo *info)
}
}
-void FillFontSubsetInfo(AbstractTrueTypeFont *ttf, FontSubsetInfo& rInfo)
+static void FillFontSubsetInfo(AbstractTrueTypeFont *ttf, FontSubsetInfo& rInfo)
{
TTGlobalFontInfo aTTInfo;
GetTTGlobalFontInfo(ttf, &aTTInfo);