From: osa Date: Fri, 27 Mar 2020 13:09:10 +0000 (+0300) Subject: 0031468: Visualization - add public interface to return embedding a single fallback... X-Git-Tag: V7_5_0_beta~237 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=21095f2dc26b1c686254c2923bc03876de6bbb91 0031468: Visualization - add public interface to return embedding a single fallback font --- diff --git a/src/Font/Font_FTFont.cxx b/src/Font/Font_FTFont.cxx index bf2ca11e2a..703d3175a2 100755 --- a/src/Font/Font_FTFont.cxx +++ b/src/Font/Font_FTFont.cxx @@ -21,8 +21,6 @@ #include #include -#include "Font_DejavuSans_Latin_woff.pxx" - #include #include @@ -191,11 +189,8 @@ Handle(Font_FTFont) Font_FTFont::FindAndCreate (const TCollection_AsciiString& t aParams.ToSynthesizeItalic = true; break; } - Handle(NCollection_Buffer) aBuffer = new NCollection_Buffer (Handle(NCollection_BaseAllocator)(), - Font_DejavuSans_Latin_woff_size, - const_cast(Font_DejavuSans_Latin_woff)); Handle(Font_FTFont) aFont = new Font_FTFont(); - if (aFont->Init (aBuffer, "Embed Fallback Font", aParams, 0)) + if (aFont->Init (Font_FontMgr::EmbedFallbackFont(), "Embed Fallback Font", aParams, 0)) { aFont->myFontAspect = aFontAspect; return aFont; @@ -234,10 +229,7 @@ bool Font_FTFont::FindAndInit (const TCollection_AsciiString& theFontName, { aParams.ToSynthesizeItalic = true; } - Handle(NCollection_Buffer) aBuffer = new NCollection_Buffer (Handle(NCollection_BaseAllocator)(), - Font_DejavuSans_Latin_woff_size, - const_cast(Font_DejavuSans_Latin_woff)); - return Init (aBuffer, "Embed Fallback Font", aParams, 0); + return Init (Font_FontMgr::EmbedFallbackFont(), "Embed Fallback Font", aParams, 0); } Release(); return false; diff --git a/src/Font/Font_FontMgr.cxx b/src/Font/Font_FontMgr.cxx index 9d226bbf50..249e674d29 100644 --- a/src/Font/Font_FontMgr.cxx +++ b/src/Font/Font_FontMgr.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +28,8 @@ #include #include +#include "Font_DejavuSans_Latin_woff.pxx" + #include #include FT_FREETYPE_H IMPLEMENT_STANDARD_RTTIEXT(Font_FontMgr,Standard_Transient) @@ -1035,3 +1038,14 @@ Handle(Font_SystemFont) Font_FontMgr::Font_FontMap::Find (const TCollection_Asci } return Handle(Font_SystemFont)(); } + +// ======================================================================= +// function : EmbedFallbackFont +// purpose : +// ======================================================================= +Handle(NCollection_Buffer) Font_FontMgr::EmbedFallbackFont() +{ + return new NCollection_Buffer (Handle(NCollection_BaseAllocator)(), + Font_DejavuSans_Latin_woff_size, + const_cast(Font_DejavuSans_Latin_woff)); +} diff --git a/src/Font/Font_FontMgr.hxx b/src/Font/Font_FontMgr.hxx index 6ee2358af4..410bbf9a5a 100644 --- a/src/Font/Font_FontMgr.hxx +++ b/src/Font/Font_FontMgr.hxx @@ -30,6 +30,7 @@ class Font_SystemFont; class TCollection_HAsciiString; +class NCollection_Buffer; DEFINE_STANDARD_HANDLE(Font_FontMgr, Standard_Transient) @@ -158,6 +159,12 @@ public: //! Clear registry. Can be used for testing purposes. Standard_EXPORT void ClearFontDataBase(); + //! Return DejaVu font as embed a single fallback font. + //! It can be used in cases when there is no own font file. + //! Note: result buffer is readonly and should not be changed, + //! any data modification can lead to unpredictable consequences. + Standard_EXPORT static Handle(NCollection_Buffer) EmbedFallbackFont(); + private: //! Creates empty font manager object