diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-12-26 15:14:31 +0000 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2018-05-08 00:55:27 +0200 |
commit | bdccb7e9991d83029eb2f2f11327b54534a00db8 (patch) | |
tree | c32e95c49849647dc72c1071f375f3d2b67d8d7a /vcl/inc/fontinstance.hxx | |
parent | 9615e45d2e2bac79c252a018846e4f20012cfa34 (diff) |
Refactor CommonSalLayout font handling
Moves all platform specific code from CommonSalLayout into the
platform specific plugins. This way the vcl library won't depend
on the Qt5 libraries and the Qt5Font header can be moved into the
qt5 VCL plugin.
While at it, switch the CommonSalLayouts font reference from the
FontSelectPattern to the LogicalFontInstance and also add the
harfbuzz font handling to the instance.
Change-Id: Ida910b8d88837ea949a2f84394ccc0cfae153060
Reviewed-on: https://gerrit.libreoffice.org/47408
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
Diffstat (limited to 'vcl/inc/fontinstance.hxx')
-rw-r--r-- | vcl/inc/fontinstance.hxx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx index c37ada563fb0..8bd6584c6154 100644 --- a/vcl/inc/fontinstance.hxx +++ b/vcl/inc/fontinstance.hxx @@ -26,6 +26,8 @@ #include <unordered_map> #include <memory> +#include <hb-ot.h> + class ConvertChar; class ImplFontCache; class PhysicalFontFace; @@ -57,13 +59,25 @@ public: // TODO: make data members private void Acquire(); void Release(); + inline hb_font_t* GetHbFont(); + void SetAverageWidthFactor(double nFactor) { m_nAveWidthFactor = nFactor; } + double GetAverageWidthFactor() const { return m_nAveWidthFactor; } const FontSelectPattern& GetFontSelectPattern() const { return m_aFontSelData; } + const PhysicalFontFace* GetFontFace() const { return m_pFontFace; } const ImplFontCache* GetFontCache() const { return mpFontCache; } + void GetScale(double* nXScale, double* nYScale); + static inline void DecodeOpenTypeTag(const uint32_t nTableTag, char* pTagName); + protected: explicit LogicalFontInstance(const PhysicalFontFace&, const FontSelectPattern&); + // Takes ownership of pHbFace. + hb_font_t* InitHbFont(hb_face_t* pHbFace) const; + virtual hb_font_t* ImplInitHbFont() { assert(false); return nullptr; } + inline void ReleaseHbFont(); + private: // cache of Unicode characters and replacement font names // TODO: a fallback map can be shared with many other ImplFontEntries @@ -73,9 +87,35 @@ private: ImplFontCache * mpFontCache; sal_uInt32 mnRefCount; const FontSelectPattern m_aFontSelData; + hb_font_t* m_pHbFont; + double m_nAveWidthFactor; const PhysicalFontFace* m_pFontFace; }; +inline hb_font_t* LogicalFontInstance::GetHbFont() +{ + if (!m_pHbFont) + m_pHbFont = ImplInitHbFont(); + return m_pHbFont; +} + +inline void LogicalFontInstance::ReleaseHbFont() +{ + if (!m_pHbFont) + return; + hb_font_destroy(m_pHbFont); + m_pHbFont = nullptr; +} + +inline void LogicalFontInstance::DecodeOpenTypeTag(const uint32_t nTableTag, char* pTagName) +{ + pTagName[0] = static_cast<char>(nTableTag >> 24); + pTagName[1] = static_cast<char>(nTableTag >> 16); + pTagName[2] = static_cast<char>(nTableTag >> 8); + pTagName[3] = static_cast<char>(nTableTag); + pTagName[4] = 0; +} + #endif // INCLUDED_VCL_INC_FONTINSTANCE_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |