diff options
author | Khaled Hosny <khaled@aliftype.com> | 2022-10-01 07:06:16 +0200 |
---|---|---|
committer | خالد حسني <khaled@aliftype.com> | 2022-10-01 13:08:52 +0200 |
commit | caa10a1f80da856debf4f397503f27c86199208f (patch) | |
tree | 536777e57f50fb416743ed6a05f909daa57b3dda /vcl/source | |
parent | dd8775b051b40309d7d7e5730a3c5304d931f594 (diff) |
vcl: Use a hb_face_t wrapper in TrueTypeFace
We don’t need full access to PhysicalFontFace. This will be needed when
we use hb-subset API for instantiating variable fonts.
Change-Id: I2578525cd54167d01cd2748d5ac1900c607867a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140823
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@aliftype.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/font/PhysicalFontFace.cxx | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx index e649f8c7712e..fb54daf3da04 100644 --- a/vcl/source/font/PhysicalFontFace.cxx +++ b/vcl/source/font/PhysicalFontFace.cxx @@ -298,9 +298,33 @@ bool PhysicalFontFace::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilit namespace { +class RawFace +{ +public: + RawFace(hb_face_t* pFace) + : mpFace(hb_face_reference(pFace)) + { + } + + RawFace(const RawFace& rOther) + : mpFace(hb_face_reference(rOther.mpFace)) + { + } + + ~RawFace() { hb_face_destroy(mpFace); } + + RawFontData GetTable(uint32_t nTag) const + { + return RawFontData(hb_face_reference_table(mpFace, nTag)); + } + +private: + hb_face_t* mpFace; +}; + class TrueTypeFace final : public AbstractTrueTypeFont { - const PhysicalFontFace& m_rFace; + const RawFace m_aFace; mutable std::array<RawFontData, NUM_TAGS> m_aTableList; const RawFontData& table(sal_uInt32 nIdx) const @@ -311,14 +335,14 @@ class TrueTypeFace final : public AbstractTrueTypeFont 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])); + m_aTableList[nIdx] = std::move(m_aFace.GetTable(aTags[nIdx])); return m_aTableList[nIdx]; } public: - TrueTypeFace(const PhysicalFontFace& rFace) - : AbstractTrueTypeFont(nullptr, rFace.GetFontCharMap()) - , m_rFace(rFace) + TrueTypeFace(const RawFace aFace, const FontCharMapRef rCharMap) + : AbstractTrueTypeFont(nullptr, rCharMap) + , m_aFace(std::move(aFace)) { } @@ -344,7 +368,7 @@ bool PhysicalFontFace::CreateFontSubset(std::vector<sal_uInt8>& rOutBuffer, nGlyphCount, rInfo); // Prepare data for font subsetter. - TrueTypeFace aSftFont(*this); + TrueTypeFace aSftFont(RawFace(GetHbFace()), GetFontCharMap()); if (aSftFont.initialize() != SFErrCodes::Ok) return false; |