vcl/inc/sft.hxx | 16 --------- vcl/source/font/PhysicalFontFace.cxx | 36 +++++++++++++++++++++ vcl/source/fontsubset/sft.cxx | 58 ----------------------------------- 3 files changed, 36 insertions(+), 74 deletions(-)
New commits: commit 054c8aade7cca8b6b482c16c5a80c5772522180c Author: Khaled Hosny <kha...@aliftype.com> AuthorDate: Wed Sep 21 12:29:19 2022 +0200 Commit: خالد حسني <kha...@aliftype.com> CommitDate: Sat Oct 1 08:04:47 2022 +0200 vcl: Move TrueTypeFace where it is used No need to make it module public. Easier to modify it. Change-Id: I119381d463c8f176b355fc7df111011ae518b49d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140821 Tested-by: Jenkins Reviewed-by: خالد حسني <kha...@aliftype.com> diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx index 780dd867d304..dc539ab958ac 100644 --- a/vcl/inc/sft.hxx +++ b/vcl/inc/sft.hxx @@ -453,7 +453,6 @@ constexpr sal_uInt32 T_CFF = 0x43464620; class AbstractTrueTypeFont; class TrueTypeFont; -class TrueTypeFace; /** * @defgroup sft Sun Font Tools Exported Functions @@ -788,21 +787,6 @@ const sal_uInt8* TrueTypeFont::table(sal_uInt32 ord, sal_uInt32& size) const return rTable.pData; } -class VCL_DLLPUBLIC TrueTypeFace final : public AbstractTrueTypeFont -{ - const font::PhysicalFontFace& m_rFace; - mutable std::array<font::RawFontData, NUM_TAGS> m_aTableList; - - static sal_uInt32 TableTag(sal_uInt32); - -public: - TrueTypeFace(const font::PhysicalFontFace&); - ~TrueTypeFace() override; - - bool hasTable(sal_uInt32) const override; - const sal_uInt8* table(sal_uInt32, sal_uInt32&) const override; -}; - } // namespace vcl #endif // INCLUDED_VCL_INC_SFT_HXX diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx index 70738bbad06b..e649f8c7712e 100644 --- a/vcl/source/font/PhysicalFontFace.cxx +++ b/vcl/source/font/PhysicalFontFace.cxx @@ -296,6 +296,42 @@ bool PhysicalFontFace::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilit return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange; } +namespace +{ +class TrueTypeFace final : public AbstractTrueTypeFont +{ + const PhysicalFontFace& m_rFace; + mutable std::array<RawFontData, NUM_TAGS> m_aTableList; + + const RawFontData& table(sal_uInt32 nIdx) const + { + assert(nIdx < NUM_TAGS); + static const uint32_t aTags[NUM_TAGS] = { + T_maxp, T_glyf, T_head, T_loca, T_name, T_hhea, T_hmtx, T_cmap, T_vhea, + T_vmtx, T_OS2, T_post, T_cvt, T_prep, T_fpgm, T_gsub, T_CFF, + }; + if (m_aTableList[nIdx].empty()) + m_aTableList[nIdx] = std::move(m_rFace.GetRawFontData(aTags[nIdx])); + return m_aTableList[nIdx]; + } + +public: + TrueTypeFace(const PhysicalFontFace& rFace) + : AbstractTrueTypeFont(nullptr, rFace.GetFontCharMap()) + , m_rFace(rFace) + { + } + + bool hasTable(sal_uInt32 nIdx) const override { return !table(nIdx).empty(); } + const sal_uInt8* table(sal_uInt32 nIdx, sal_uInt32& nSize) const override + { + auto& rTable = table(nIdx); + nSize = rTable.size(); + return rTable.data(); + } +}; +} + bool PhysicalFontFace::CreateFontSubset(std::vector<sal_uInt8>& rOutBuffer, const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding, const int nGlyphCount, FontSubsetInfo& rInfo) const diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index deb18ff73177..a0961c36542c 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -1211,64 +1211,6 @@ TrueTypeFont::~TrueTypeFont() #endif } -TrueTypeFace::TrueTypeFace(const font::PhysicalFontFace& rFace) - : AbstractTrueTypeFont(nullptr, rFace.GetFontCharMap()) - , m_rFace(rFace) -{ -} - -TrueTypeFace::~TrueTypeFace() -{ -} - -sal_uInt32 TrueTypeFace::TableTag(sal_uInt32 nIdx) -{ - switch (nIdx) - { - case O_cmap: return T_cmap; - case O_cvt: return T_cvt; - case O_fpgm: return T_fpgm; - case O_glyf: return T_glyf; - case O_gsub: return T_gsub; - case O_head: return T_head; - case O_hhea: return T_hhea; - case O_hmtx: return T_hmtx; - case O_loca: return T_loca; - case O_maxp: return T_maxp; - case O_name: return T_name; - case O_post: return T_post; - case O_prep: return T_prep; - case O_vhea: return T_vhea; - case O_vmtx: return T_vmtx; - case O_OS2: return T_OS2; - case O_CFF: return T_CFF; - default: - assert(false); - return 0; - } -} - -bool TrueTypeFace::hasTable(sal_uInt32 nIdx) const -{ - uint32_t nTag = TableTag(nIdx); - if (!nTag) - return false; - if (m_aTableList[nIdx].empty()) - m_aTableList[nIdx] = std::move(m_rFace.GetRawFontData(nTag)); - return !m_aTableList[nIdx].empty(); -} - -const sal_uInt8* TrueTypeFace::table(sal_uInt32 nIdx, sal_uInt32& nSize) const -{ - uint32_t nTag = TableTag(nIdx); - if (!nTag) - return nullptr; - if (m_aTableList[nIdx].empty()) - m_aTableList[nIdx] = std::move(m_rFace.GetRawFontData(nTag)); - nSize = m_aTableList[nIdx].size(); - return reinterpret_cast<const sal_uInt8*>(m_aTableList[nIdx].data()); -} - void CloseTTFont(TrueTypeFont* ttf) { delete ttf; } SFErrCodes AbstractTrueTypeFont::initialize()