From 9a90a4524e99eb594202762ce206d567c19bae61 Mon Sep 17 00:00:00 2001 From: kgv Date: Wed, 13 Nov 2019 14:31:48 +0300 Subject: [PATCH] 0031159: Visualization - Font_FontMgr skips sub-faces within .ttc font collections Font_SystemFont now defines Face Id in addition to file path. Font_FontMgr::CheckFont() has been extended to return the list of Faces from font collections. --- src/Font/Font_BRepFont.cxx | 10 ++- src/Font/Font_BRepFont.hxx | 8 +- src/Font/Font_FTFont.cxx | 26 +++--- src/Font/Font_FTFont.hxx | 12 ++- src/Font/Font_FontMgr.cxx | 92 ++++++++++++++------ src/Font/Font_FontMgr.hxx | 19 +++- src/Font/Font_SystemFont.cxx | 9 +- src/Font/Font_SystemFont.hxx | 22 ++++- src/ViewerTest/ViewerTest_ObjectCommands.cxx | 6 +- 9 files changed, 151 insertions(+), 53 deletions(-) diff --git a/src/Font/Font_BRepFont.cxx b/src/Font/Font_BRepFont.cxx index 2e2779aa1e..ef75e1cfc5 100755 --- a/src/Font/Font_BRepFont.cxx +++ b/src/Font/Font_BRepFont.cxx @@ -147,7 +147,8 @@ void Font_BRepFont::init() // purpose : // ======================================================================= Font_BRepFont::Font_BRepFont (const NCollection_String& theFontPath, - const Standard_Real theSize) + const Standard_Real theSize, + const Standard_Integer theFaceId) : myPrecision (Precision::Confusion()), myScaleUnits (1.0), myIsCompositeCurve (Standard_False), @@ -161,7 +162,7 @@ Font_BRepFont::Font_BRepFont (const NCollection_String& theFontPath, } myScaleUnits = getScale (theSize); - Font_FTFont::Init (theFontPath.ToCString(), THE_FONT_PARAMS); + Font_FTFont::Init (theFontPath.ToCString(), THE_FONT_PARAMS, theFaceId); } // ======================================================================= @@ -216,7 +217,8 @@ void Font_BRepFont::SetCompositeCurveMode (const Standard_Boolean theToConcatena // purpose : // ======================================================================= bool Font_BRepFont::Init (const NCollection_String& theFontPath, - const Standard_Real theSize) + const Standard_Real theSize, + const Standard_Integer theFaceId) { if (theSize <= myPrecision * 100.0) { @@ -224,7 +226,7 @@ bool Font_BRepFont::Init (const NCollection_String& theFontPath, } myScaleUnits = getScale (theSize); - return Font_FTFont::Init (theFontPath.ToCString(), THE_FONT_PARAMS); + return Font_FTFont::Init (theFontPath.ToCString(), THE_FONT_PARAMS, theFaceId); } // ======================================================================= diff --git a/src/Font/Font_BRepFont.hxx b/src/Font/Font_BRepFont.hxx index 52e193ec0e..d143038a3a 100755 --- a/src/Font/Font_BRepFont.hxx +++ b/src/Font/Font_BRepFont.hxx @@ -52,8 +52,10 @@ public: //! Constructor with initialization. //! @param theFontPath FULL path to the font //! @param theSize the face size in model units + //! @param theFaceId face id within the file (0 by default) Standard_EXPORT Font_BRepFont (const NCollection_String& theFontPath, - const Standard_Real theSize); + const Standard_Real theSize, + const Standard_Integer theFaceId = 0); //! Constructor with initialization. //! @param theFontName the font name @@ -71,9 +73,11 @@ public: //! Initialize the font. //! @param theFontPath FULL path to the font //! @param theSize the face size in model units + //! @param theFaceId face id within the file (0 by default) //! @return true on success Standard_EXPORT bool Init (const NCollection_String& theFontPath, - const Standard_Real theSize); + const Standard_Real theSize, + const Standard_Integer theFaceId); //! Find (using Font_FontMgr) and initialize the font from the given name. //! Please take into account that size is specified NOT in typography points (pt.). diff --git a/src/Font/Font_FTFont.cxx b/src/Font/Font_FTFont.cxx index 0b708bbe83..bf2ca11e2a 100755 --- a/src/Font/Font_FTFont.cxx +++ b/src/Font/Font_FTFont.cxx @@ -83,7 +83,8 @@ void Font_FTFont::Release() // ======================================================================= bool Font_FTFont::Init (const Handle(NCollection_Buffer)& theData, const TCollection_AsciiString& theFileName, - const Font_FTFontParams& theParams) + const Font_FTFontParams& theParams, + const Standard_Integer theFaceId) { Release(); myBuffer = theData; @@ -98,7 +99,7 @@ bool Font_FTFont::Init (const Handle(NCollection_Buffer)& theData, if (!theData.IsNull()) { - if (FT_New_Memory_Face (myFTLib->Instance(), theData->Data(), (FT_Long )theData->Size(), 0, &myFTFace) != 0) + if (FT_New_Memory_Face (myFTLib->Instance(), theData->Data(), (FT_Long )theData->Size(), (FT_Long )theFaceId, &myFTFace) != 0) { Message::DefaultMessenger()->Send (TCollection_AsciiString("Font '") + myFontPath + "' failed to load from memory", Message_Trace); Release(); @@ -107,7 +108,7 @@ bool Font_FTFont::Init (const Handle(NCollection_Buffer)& theData, } else { - if (FT_New_Face (myFTLib->Instance(), myFontPath.ToCString(), 0, &myFTFace) != 0) + if (FT_New_Face (myFTLib->Instance(), myFontPath.ToCString(), (FT_Long )theFaceId, &myFTFace) != 0) { //Message::DefaultMessenger()->Send (TCollection_AsciiString("Font '") + myFontPath + "' failed to load from file", Message_Trace); Release(); @@ -166,9 +167,10 @@ Handle(Font_FTFont) Font_FTFont::FindAndCreate (const TCollection_AsciiString& t aParams.IsSingleStrokeFont = true; } - const TCollection_AsciiString& aPath = aRequestedFont->FontPathAny (aFontAspect, aParams.ToSynthesizeItalic); + Standard_Integer aFaceId = 0; + const TCollection_AsciiString& aPath = aRequestedFont->FontPathAny (aFontAspect, aParams.ToSynthesizeItalic, aFaceId); Handle(Font_FTFont) aFont = new Font_FTFont(); - if (aFont->Init (aPath, aParams)) + if (aFont->Init (aPath, aParams, aFaceId)) { aFont->myFontAspect = aFontAspect; return aFont; @@ -193,7 +195,7 @@ Handle(Font_FTFont) Font_FTFont::FindAndCreate (const TCollection_AsciiString& t 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)) + if (aFont->Init (aBuffer, "Embed Fallback Font", aParams, 0)) { aFont->myFontAspect = aFontAspect; return aFont; @@ -221,8 +223,9 @@ bool Font_FTFont::FindAndInit (const TCollection_AsciiString& theFontName, aParams.IsSingleStrokeFont = true; } - const TCollection_AsciiString& aPath = aRequestedFont->FontPathAny (myFontAspect, aParams.ToSynthesizeItalic); - return Init (aPath, aParams); + Standard_Integer aFaceId = 0; + const TCollection_AsciiString& aPath = aRequestedFont->FontPathAny (myFontAspect, aParams.ToSynthesizeItalic, aFaceId); + return Init (aPath, aParams, aFaceId); } else if (theStrictLevel == Font_StrictLevel_Any) { @@ -234,7 +237,7 @@ bool Font_FTFont::FindAndInit (const TCollection_AsciiString& theFontName, 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); + return Init (aBuffer, "Embed Fallback Font", aParams, 0); } Release(); return false; @@ -260,8 +263,9 @@ bool Font_FTFont::findAndInitFallback (Font_UnicodeSubset theSubset) Font_FTFontParams aParams = myFontParams; aParams.IsSingleStrokeFont = aRequestedFont->IsSingleStrokeFont(); - const TCollection_AsciiString& aPath = aRequestedFont->FontPathAny (myFontAspect, aParams.ToSynthesizeItalic); - if (myFallbackFaces[theSubset]->Init (aPath, aParams)) + Standard_Integer aFaceId = 0; + const TCollection_AsciiString& aPath = aRequestedFont->FontPathAny (myFontAspect, aParams.ToSynthesizeItalic, aFaceId); + if (myFallbackFaces[theSubset]->Init (aPath, aParams, aFaceId)) { Message::DefaultMessenger()->Send (TCollection_AsciiString ("Font_FTFont, using fallback font '") + aRequestedFont->FontName() + "'" + " for symbols unsupported by '" + myFTFace->family_name + "'", Message_Trace); diff --git a/src/Font/Font_FTFont.hxx b/src/Font/Font_FTFont.hxx index 4ba5743f62..b5755a3325 100755 --- a/src/Font/Font_FTFont.hxx +++ b/src/Font/Font_FTFont.hxx @@ -155,11 +155,13 @@ public: //! Initialize the font from the given file path. //! @param theFontPath path to the font //! @param theParams initialization parameters + //! @param theFaceId face id within the file (0 by default) //! @return true on success bool Init (const TCollection_AsciiString& theFontPath, - const Font_FTFontParams& theParams) + const Font_FTFontParams& theParams, + const Standard_Integer theFaceId = 0) { - return Init (Handle(NCollection_Buffer)(), theFontPath, theParams); + return Init (Handle(NCollection_Buffer)(), theFontPath, theParams, theFaceId); } //! Initialize the font from the given file path or memory buffer. @@ -167,10 +169,12 @@ public: //! when NULL, function will attempt to open theFileName file //! @param theFileName optional path to the font //! @param theParams initialization parameters + //! @param theFaceId face id within the file (0 by default) //! @return true on success Standard_EXPORT bool Init (const Handle(NCollection_Buffer)& theData, const TCollection_AsciiString& theFileName, - const Font_FTFontParams& theParams); + const Font_FTFontParams& theParams, + const Standard_Integer theFaceId = 0); //! Find (using Font_FontMgr) and initialize the font from the given name. //! @param theFontName the font name @@ -290,7 +294,7 @@ public: Font_FTFontParams aParams; aParams.PointSize = thePointSize; aParams.Resolution = theResolution; - return Init (theFontPath.ToCString(), aParams); + return Init (theFontPath.ToCString(), aParams, 0); } //! Initialize the font. diff --git a/src/Font/Font_FontMgr.cxx b/src/Font/Font_FontMgr.cxx index 86d239d8ba..d1ad58bf96 100644 --- a/src/Font/Font_FontMgr.cxx +++ b/src/Font/Font_FontMgr.cxx @@ -139,24 +139,29 @@ IMPLEMENT_STANDARD_RTTIEXT(Font_FontMgr,Standard_Transient) #endif -// ======================================================================= -// function : checkFont -// purpose : -// ======================================================================= -static Handle(Font_SystemFont) checkFont (const Handle(Font_FTLibrary)& theFTLib, - const Standard_CString theFontPath) +//! Retrieve font information. +//! @param theFonts [out] list of validated fonts +//! @param theFTLib [in] font library +//! @param theFontPath [in] path to the file +//! @param theFaceId [in] face id, or -1 to load all faces within the file +//! @return TRUE if at least one font face has been detected +static bool checkFont (NCollection_Sequence& theFonts, + const Handle(Font_FTLibrary)& theFTLib, + const TCollection_AsciiString& theFontPath, + FT_Long theFaceId = -1) { + const FT_Long aFaceId = theFaceId != -1 ? theFaceId : 0; FT_Face aFontFace; - FT_Error aFaceError = FT_New_Face (theFTLib->Instance(), theFontPath, 0, &aFontFace); + FT_Error aFaceError = FT_New_Face (theFTLib->Instance(), theFontPath.ToCString(), aFaceId, &aFontFace); if (aFaceError != FT_Err_Ok) { - return Handle(Font_SystemFont)(); + return false; } if (aFontFace->family_name == NULL // skip broken fonts (error in FreeType?) || FT_Select_Charmap (aFontFace, ft_encoding_unicode) != 0) // Font_FTFont supports only UNICODE fonts { FT_Done_Face (aFontFace); - return Handle(Font_SystemFont)(); + return false; } // FreeType decomposes font definition into Family Name and Style Name, @@ -253,12 +258,30 @@ static Handle(Font_SystemFont) checkFont (const Handle(Font_FTLibrary)& theFTLib } Handle(Font_SystemFont) aResult = new Font_SystemFont (aFamily); - aResult->SetFontPath (anAspect, theFontPath); + aResult->SetFontPath (anAspect, theFontPath, (Standard_Integer )aFaceId); // automatically identify some known single-line fonts aResult->SetSingleStrokeFont (aResult->FontKey().StartsWith ("olf ")); + theFonts.Append (aResult); + + if (theFaceId < aFontFace->num_faces) + { + const FT_Long aNbInstances = aFontFace->style_flags >> 16; + for (FT_Long anInstIter = 1; anInstIter < aNbInstances; ++anInstIter) + { + const FT_Long aSubFaceId = aFaceId + (anInstIter << 16); + checkFont (theFonts, theFTLib, theFontPath, aSubFaceId); + } + } + if (theFaceId == -1) + { + for (FT_Long aFaceIter = 1; aFaceIter < aFontFace->num_faces; ++aFaceIter) + { + checkFont (theFonts, theFTLib, theFontPath, aFaceIter); + } + } FT_Done_Face (aFontFace); - return aResult; + return true; } // ======================================================================= @@ -421,6 +444,17 @@ Font_FontMgr::Font_FontMgr() InitFontDataBase(); } +// ======================================================================= +// function : CheckFont +// purpose : +// ======================================================================= +Standard_Boolean Font_FontMgr::CheckFont (NCollection_Sequence& theFonts, + const TCollection_AsciiString& theFontPath) const +{ + Handle(Font_FTLibrary) aFtLibrary = new Font_FTLibrary(); + return checkFont (theFonts, aFtLibrary, theFontPath, 0); +} + // ======================================================================= // function : CheckFont // purpose : @@ -428,7 +462,10 @@ Font_FontMgr::Font_FontMgr() Handle(Font_SystemFont) Font_FontMgr::CheckFont (Standard_CString theFontPath) const { Handle(Font_FTLibrary) aFtLibrary = new Font_FTLibrary(); - return checkFont (aFtLibrary, theFontPath); + NCollection_Sequence aFonts; + return checkFont (aFonts, aFtLibrary, theFontPath, 0) + ? aFonts.First() + : Handle(Font_SystemFont)(); } // ======================================================================= @@ -453,14 +490,17 @@ Standard_Boolean Font_FontMgr::RegisterFont (const Handle(Font_SystemFont)& theF Handle(Font_SystemFont) anOldFont = myFontMap.FindKey (anOldIndex); for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter) { - if (anOldFont->FontPath ((Font_FontAspect )anAspectIter).IsEqual (theFont->FontPath ((Font_FontAspect )anAspectIter))) + if (anOldFont->FontPath ((Font_FontAspect )anAspectIter).IsEqual (theFont->FontPath ((Font_FontAspect )anAspectIter)) + && anOldFont->FontFaceId ((Font_FontAspect )anAspectIter) == theFont->FontFaceId ((Font_FontAspect )anAspectIter)) { continue; } else if (theToOverride || !anOldFont->HasFontAspect ((Font_FontAspect )anAspectIter)) { - anOldFont->SetFontPath ((Font_FontAspect )anAspectIter, theFont->FontPath ((Font_FontAspect )anAspectIter)); + anOldFont->SetFontPath ((Font_FontAspect )anAspectIter, + theFont->FontPath ((Font_FontAspect )anAspectIter), + theFont->FontFaceId ((Font_FontAspect )anAspectIter)); } else if (theFont->HasFontAspect ((Font_FontAspect )anAspectIter)) { @@ -487,6 +527,7 @@ void Font_FontMgr::InitFontDataBase() { myFontMap.Clear(); Handle(Font_FTLibrary) aFtLibrary = new Font_FTLibrary(); + NCollection_Sequence aFonts; #if defined(OCCT_UWP) // system font files are not accessible @@ -548,10 +589,9 @@ void Font_FontMgr::InitFontDataBase() aFontExtension.LowerCase(); if (aSupportedExtensions.Contains (aFontExtension)) { - if (Handle(Font_SystemFont) aNewFont = checkFont (aFtLibrary, aFontPath.ToCString())) - { - RegisterFont (aNewFont, false); - } + aFonts.Clear(); + checkFont (aFonts, aFtLibrary, aFontPath.ToCString()); + RegisterFonts (aFonts, false); } } } @@ -680,10 +720,9 @@ void Font_FontMgr::InitFontDataBase() aFontFilePath.SystemName (aFontFileName); aFontFileName = anIter.Value() + "/" + aFontFileName; - if (Handle(Font_SystemFont) aNewFont = checkFont (aFtLibrary, aFontFileName.ToCString())) - { - RegisterFont (aNewFont, false); - } + aFonts.Clear(); + checkFont (aFonts, aFtLibrary, aFontFileName); + RegisterFonts (aFonts, false); } #if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__) @@ -738,9 +777,12 @@ void Font_FontMgr::InitFontDataBase() } TCollection_AsciiString aFontFileName (aLine.SubString (1, anEndOfFileName)); aFontPath.AssignCat (aFontFileName); - if (Handle(Font_SystemFont) aNewFont = checkFont (aFtLibrary, aFontPath.ToCString())) + + aFonts.Clear(); + if (checkFont (aFonts, aFtLibrary, aFontPath)) { - RegisterFont (aNewFont, false); + RegisterFonts (aFonts, false); + const Handle(Font_SystemFont)& aNewFont = aFonts.First(); if (!aXLFD.IsEmpty() && aXLFD.Search ("-0-0-0-0-") != -1) // ignore non-resizable fonts { @@ -763,7 +805,7 @@ void Font_FontMgr::InitFontDataBase() } Handle(Font_SystemFont) aNewFontFromXLFD = new Font_SystemFont (anXName); - aNewFontFromXLFD->SetFontPath (anXAspect, aFontPath); + aNewFontFromXLFD->SetFontPath (anXAspect, aFontPath, 0); if (!aNewFont->IsEqual (aNewFontFromXLFD)) { RegisterFont (aNewFontFromXLFD, false); diff --git a/src/Font/Font_FontMgr.hxx b/src/Font/Font_FontMgr.hxx index 4277a8b59c..6ee2358af4 100644 --- a/src/Font/Font_FontMgr.hxx +++ b/src/Font/Font_FontMgr.hxx @@ -120,13 +120,30 @@ public: Standard_EXPORT Handle(Font_SystemFont) FindFallbackFont (Font_UnicodeSubset theSubset, Font_FontAspect theFontAspect) const; + //! Read font file and retrieve information from it (the list of font faces). + Standard_EXPORT Standard_Boolean CheckFont (NCollection_Sequence& theFonts, + const TCollection_AsciiString& theFontPath) const; + //! Read font file and retrieve information from it. Standard_EXPORT Handle(Font_SystemFont) CheckFont (const Standard_CString theFontPath) const; //! Register new font. //! If there is existing entity with the same name and properties but different path //! then font will be overridden or ignored depending on theToOverride flag. - Standard_EXPORT Standard_Boolean RegisterFont (const Handle(Font_SystemFont)& theFont, const Standard_Boolean theToOverride); + Standard_EXPORT Standard_Boolean RegisterFont (const Handle(Font_SystemFont)& theFont, + const Standard_Boolean theToOverride); + + //! Register new fonts. + Standard_Boolean RegisterFonts (const NCollection_Sequence& theFonts, + const Standard_Boolean theToOverride) + { + Standard_Boolean isRegistered = Standard_False; + for (NCollection_Sequence::Iterator aFontIter (theFonts); aFontIter.More(); aFontIter.Next()) + { + isRegistered = RegisterFont (aFontIter.Value(), theToOverride) || isRegistered; + } + return isRegistered; + } //! Return flag for tracing font aliases usage via Message_Trace messages; TRUE by default. Standard_Boolean ToTraceAliases() const { return myToTraceAliases; } diff --git a/src/Font/Font_SystemFont.cxx b/src/Font/Font_SystemFont.cxx index fd37e90758..323bf61760 100644 --- a/src/Font/Font_SystemFont.cxx +++ b/src/Font/Font_SystemFont.cxx @@ -29,6 +29,7 @@ Font_SystemFont::Font_SystemFont (const TCollection_AsciiString& theFontName) myFontName (theFontName), myIsSingleLine (Standard_False) { + memset (myFaceIds, 0, sizeof(myFaceIds)); if (theFontName.IsEmpty()) { throw Standard_ProgramError ("Font_SystemFont constructor called with empty font name"); } myFontKey.LowerCase(); } @@ -38,10 +39,12 @@ Font_SystemFont::Font_SystemFont (const TCollection_AsciiString& theFontName) // purpose : // ======================================================================= void Font_SystemFont::SetFontPath (Font_FontAspect theAspect, - const TCollection_AsciiString& thePath) + const TCollection_AsciiString& thePath, + const Standard_Integer theFaceId) { if (theAspect == Font_FontAspect_UNDEFINED) { throw Standard_ProgramError ("Font_SystemFont::SetFontPath() called with UNDEFINED aspect"); } myFilePaths[theAspect] = thePath; + myFaceIds [theAspect] = theFaceId; } // ======================================================================= @@ -102,6 +105,10 @@ TCollection_AsciiString Font_SystemFont::ToString() const isFirstAspect = false; } aDesc += FontPath ((Font_FontAspect )anAspectIter); + if (FontFaceId ((Font_FontAspect )anAspectIter) != 0) + { + aDesc = aDesc + "," + FontFaceId ((Font_FontAspect )anAspectIter); + } } aDesc += "]"; return aDesc; diff --git a/src/Font/Font_SystemFont.hxx b/src/Font/Font_SystemFont.hxx index c78048998a..b7ab594504 100644 --- a/src/Font/Font_SystemFont.hxx +++ b/src/Font/Font_SystemFont.hxx @@ -43,9 +43,16 @@ public: return myFilePaths[theAspect != Font_FontAspect_UNDEFINED ? theAspect : Font_FontAspect_Regular]; } + //! Returns font file path. + Standard_Integer FontFaceId (Font_FontAspect theAspect) const + { + return myFaceIds[theAspect != Font_FontAspect_UNDEFINED ? theAspect : Font_FontAspect_Regular]; + } + //! Sets font file path for specific aspect. Standard_EXPORT void SetFontPath (Font_FontAspect theAspect, - const TCollection_AsciiString& thePath); + const TCollection_AsciiString& thePath, + const Standard_Integer theFaceId = 0); //! Returns TRUE if dedicated file for specified font aspect has been defined. bool HasFontAspect (Font_FontAspect theAspect) const @@ -55,9 +62,12 @@ public: //! Returns any defined font file path. const TCollection_AsciiString& FontPathAny (Font_FontAspect theAspect, - bool& theToSynthesizeItalic) const + bool& theToSynthesizeItalic, + Standard_Integer& theFaceId) const { - const TCollection_AsciiString& aPath = myFilePaths[theAspect != Font_FontAspect_UNDEFINED ? theAspect : Font_FontAspect_Regular]; + const Font_FontAspect anAspect = theAspect != Font_FontAspect_UNDEFINED ? theAspect : Font_FontAspect_Regular; + const TCollection_AsciiString& aPath = myFilePaths[anAspect]; + theFaceId = myFaceIds[anAspect]; if (!aPath.IsEmpty()) { return aPath; @@ -70,17 +80,20 @@ public: && !myFilePaths[Font_FontAspect_Bold].IsEmpty()) { theToSynthesizeItalic = true; + theFaceId = myFaceIds[Font_FontAspect_Bold]; return myFilePaths[Font_FontAspect_Bold]; } else if (!myFilePaths[Font_FontAspect_Regular].IsEmpty()) { theToSynthesizeItalic = true; + theFaceId = myFaceIds[Font_FontAspect_Regular]; return myFilePaths[Font_FontAspect_Regular]; } } if (!myFilePaths[Font_FontAspect_Regular].IsEmpty()) { + theFaceId = myFaceIds[Font_FontAspect_Regular]; return myFilePaths[Font_FontAspect_Regular]; } @@ -88,9 +101,11 @@ public: { if (!myFilePaths[anAspectIter].IsEmpty()) { + theFaceId = myFaceIds[anAspectIter]; return myFilePaths[anAspectIter]; } } + theFaceId = myFaceIds[Font_FontAspect_Regular]; return myFilePaths[Font_FontAspect_Regular]; } @@ -128,6 +143,7 @@ public: private: TCollection_AsciiString myFilePaths[Font_FontAspect_NB]; //!< paths to the font file + Standard_Integer myFaceIds [Font_FontAspect_NB]; //!< face ids per font file TCollection_AsciiString myFontKey; //!< font family name, lower cased TCollection_AsciiString myFontName; //!< font family name Standard_Boolean myIsSingleLine; //!< single stroke font flag, FALSE by default diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index 0ff7df480b..d2007a95cc 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -5645,13 +5645,15 @@ static int VFont (Draw_Interpretor& theDI, Handle(Font_SystemFont) aFont2 = new Font_SystemFont (aName); if (aFontAspect != Font_FontAspect_UNDEFINED) { - aFont2->SetFontPath (aFontAspect, aFontPath); + aFont2->SetFontPath (aFontAspect, aFontPath, 0); } else { for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter) { - aFont2->SetFontPath ((Font_FontAspect )anAspectIter, aFont->FontPath ((Font_FontAspect )anAspectIter)); + aFont2->SetFontPath ((Font_FontAspect )anAspectIter, + aFont->FontPath ((Font_FontAspect )anAspectIter), + aFont->FontFaceId ((Font_FontAspect )anAspectIter)); } } aFont = aFont2;