File indexing completed on 2026-07-04 08:32:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _Font_SystemFont_HeaderFile
0017 #define _Font_SystemFont_HeaderFile
0018
0019 #include <Font_FontAspect.hxx>
0020 #include <Standard.hxx>
0021 #include <NCollection_DefineAlloc.hxx>
0022 #include <Standard_Transient.hxx>
0023 #include <TCollection_AsciiString.hxx>
0024
0025
0026
0027 class Font_SystemFont : public Standard_Transient
0028 {
0029 DEFINE_STANDARD_RTTIEXT(Font_SystemFont, Standard_Transient)
0030 public:
0031
0032 Standard_EXPORT Font_SystemFont(const TCollection_AsciiString& theFontName);
0033
0034
0035 const TCollection_AsciiString& FontKey() const { return myFontKey; }
0036
0037
0038 const TCollection_AsciiString& FontName() const { return myFontName; }
0039
0040
0041 const TCollection_AsciiString& FontPath(Font_FontAspect theAspect) const
0042 {
0043 return myFilePaths[theAspect != Font_FontAspect_UNDEFINED ? theAspect
0044 : Font_FontAspect_Regular];
0045 }
0046
0047
0048 Standard_Integer FontFaceId(Font_FontAspect theAspect) const
0049 {
0050 return myFaceIds[theAspect != Font_FontAspect_UNDEFINED ? theAspect : Font_FontAspect_Regular];
0051 }
0052
0053
0054 Standard_EXPORT void SetFontPath(Font_FontAspect theAspect,
0055 const TCollection_AsciiString& thePath,
0056 const Standard_Integer theFaceId = 0);
0057
0058
0059 bool HasFontAspect(Font_FontAspect theAspect) const
0060 {
0061 return !myFilePaths[theAspect != Font_FontAspect_UNDEFINED ? theAspect
0062 : Font_FontAspect_Regular]
0063 .IsEmpty();
0064 }
0065
0066
0067 const TCollection_AsciiString& FontPathAny(Font_FontAspect theAspect,
0068 bool& theToSynthesizeItalic,
0069 Standard_Integer& theFaceId) const
0070 {
0071 const Font_FontAspect anAspect =
0072 theAspect != Font_FontAspect_UNDEFINED ? theAspect : Font_FontAspect_Regular;
0073 const TCollection_AsciiString& aPath = myFilePaths[anAspect];
0074 theFaceId = myFaceIds[anAspect];
0075 if (!aPath.IsEmpty())
0076 {
0077 return aPath;
0078 }
0079
0080 if (theAspect == Font_FontAspect_Italic || theAspect == Font_FontAspect_BoldItalic)
0081 {
0082 if (theAspect == Font_FontAspect_BoldItalic && !myFilePaths[Font_FontAspect_Bold].IsEmpty())
0083 {
0084 theToSynthesizeItalic = true;
0085 theFaceId = myFaceIds[Font_FontAspect_Bold];
0086 return myFilePaths[Font_FontAspect_Bold];
0087 }
0088 else if (!myFilePaths[Font_FontAspect_Regular].IsEmpty())
0089 {
0090 theToSynthesizeItalic = true;
0091 theFaceId = myFaceIds[Font_FontAspect_Regular];
0092 return myFilePaths[Font_FontAspect_Regular];
0093 }
0094 }
0095
0096 if (!myFilePaths[Font_FontAspect_Regular].IsEmpty())
0097 {
0098 theFaceId = myFaceIds[Font_FontAspect_Regular];
0099 return myFilePaths[Font_FontAspect_Regular];
0100 }
0101
0102 for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter)
0103 {
0104 if (!myFilePaths[anAspectIter].IsEmpty())
0105 {
0106 theFaceId = myFaceIds[anAspectIter];
0107 return myFilePaths[anAspectIter];
0108 }
0109 }
0110 theFaceId = myFaceIds[Font_FontAspect_Regular];
0111 return myFilePaths[Font_FontAspect_Regular];
0112 }
0113
0114
0115 Standard_EXPORT Standard_Boolean IsEqual(const Handle(Font_SystemFont)& theOtherFont) const;
0116
0117
0118
0119
0120 Standard_Boolean IsSingleStrokeFont() const { return myIsSingleLine; }
0121
0122
0123 void SetSingleStrokeFont(Standard_Boolean theIsSingleLine) { myIsSingleLine = theIsSingleLine; }
0124
0125
0126 Standard_EXPORT TCollection_AsciiString ToString() const;
0127
0128 public:
0129 bool operator==(const Font_SystemFont& theFont) const
0130 {
0131 return myFontKey.IsEqual(theFont.FontKey());
0132 }
0133
0134 private:
0135 TCollection_AsciiString myFilePaths[Font_FontAspect_NB];
0136 Standard_Integer myFaceIds[Font_FontAspect_NB];
0137 TCollection_AsciiString myFontKey;
0138 TCollection_AsciiString myFontName;
0139 Standard_Boolean myIsSingleLine;
0140 };
0141
0142 namespace std
0143 {
0144 template <>
0145 struct hash<Handle(Font_SystemFont)>
0146 {
0147 size_t operator()(const Handle(Font_SystemFont)& theLink) const noexcept
0148 {
0149 if (theLink.IsNull())
0150 return 0;
0151 return std::hash<TCollection_AsciiString>{}(theLink->FontKey());
0152 }
0153 };
0154 };
0155
0156 DEFINE_STANDARD_HANDLE(Font_SystemFont, Standard_Transient)
0157
0158 #endif