File indexing completed on 2025-01-18 10:05:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _StdPrs_BRepFont_H__
0016 #define _StdPrs_BRepFont_H__
0017
0018 #include <Adaptor3d_CurveOnSurface.hxx>
0019 #include <BRep_Builder.hxx>
0020 #include <Font_FTFont.hxx>
0021 #include <Font_TextFormatter.hxx>
0022 #include <Geom2dAdaptor_Curve.hxx>
0023 #include <Geom2dConvert_CompCurveToBSplineCurve.hxx>
0024 #include <NCollection_DataMap.hxx>
0025 #include <NCollection_String.hxx>
0026 #include <Standard_Mutex.hxx>
0027 #include <TColgp_Array1OfPnt2d.hxx>
0028 #include <TopoDS_Shape.hxx>
0029 #include <TopTools_SequenceOfShape.hxx>
0030
0031 DEFINE_STANDARD_HANDLE(StdPrs_BRepFont, Standard_Transient)
0032
0033
0034
0035
0036
0037
0038
0039
0040 class StdPrs_BRepFont : public Standard_Transient
0041 {
0042 DEFINE_STANDARD_RTTIEXT(StdPrs_BRepFont, Standard_Transient)
0043 public:
0044
0045
0046
0047
0048
0049
0050
0051 Standard_EXPORT static Handle(StdPrs_BRepFont) FindAndCreate (const TCollection_AsciiString& theFontName,
0052 const Font_FontAspect theFontAspect,
0053 const Standard_Real theSize,
0054 const Font_StrictLevel theStrictLevel = Font_StrictLevel_Any);
0055
0056
0057 Standard_EXPORT StdPrs_BRepFont();
0058
0059
0060
0061
0062
0063 Standard_EXPORT StdPrs_BRepFont (const NCollection_String& theFontPath,
0064 const Standard_Real theSize,
0065 const Standard_Integer theFaceId = 0);
0066
0067
0068
0069
0070
0071
0072 Standard_EXPORT StdPrs_BRepFont (const NCollection_String& theFontName,
0073 const Font_FontAspect theFontAspect,
0074 const Standard_Real theSize,
0075 const Font_StrictLevel theStrictLevel = Font_StrictLevel_Any);
0076
0077
0078 Standard_EXPORT virtual void Release();
0079
0080
0081
0082
0083
0084
0085 Standard_EXPORT bool Init (const NCollection_String& theFontPath,
0086 const Standard_Real theSize,
0087 const Standard_Integer theFaceId);
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 Standard_EXPORT bool FindAndInit (const TCollection_AsciiString& theFontName,
0100 const Font_FontAspect theFontAspect,
0101 const Standard_Real theSize,
0102 const Font_StrictLevel theStrictLevel = Font_StrictLevel_Any);
0103
0104
0105 const Handle(Font_FTFont)& FTFont() const { return myFTFont; }
0106
0107
0108
0109
0110 Standard_EXPORT TopoDS_Shape RenderGlyph (const Standard_Utf32Char& theChar);
0111
0112
0113
0114
0115
0116
0117
0118 Standard_EXPORT void SetCompositeCurveMode (const Standard_Boolean theToConcatenate);
0119
0120
0121
0122 void SetWidthScaling (const float theScaleFactor)
0123 {
0124 myFTFont->SetWidthScaling (theScaleFactor);
0125 }
0126
0127 public:
0128
0129
0130 Standard_Real Ascender() const
0131 {
0132 return myScaleUnits * Standard_Real(myFTFont->Ascender());
0133 }
0134
0135
0136 Standard_Real Descender() const
0137 {
0138 return myScaleUnits * Standard_Real(myFTFont->Descender());
0139 }
0140
0141
0142 Standard_Real LineSpacing() const
0143 {
0144 return myScaleUnits * Standard_Real(myFTFont->LineSpacing());
0145 }
0146
0147
0148 Standard_Real PointSize() const
0149 {
0150 return myScaleUnits * Standard_Real(myFTFont->PointSize());
0151 }
0152
0153
0154
0155 Standard_Real AdvanceX (const Standard_Utf32Char theUCharNext)
0156 {
0157 return myScaleUnits * Standard_Real(myFTFont->AdvanceX (theUCharNext));
0158 }
0159
0160
0161
0162 Standard_Real AdvanceX (const Standard_Utf32Char theUChar,
0163 const Standard_Utf32Char theUCharNext)
0164 {
0165 return myScaleUnits * Standard_Real(myFTFont->AdvanceX (theUChar, theUCharNext));
0166 }
0167
0168
0169
0170 Standard_Real AdvanceY (const Standard_Utf32Char theUCharNext)
0171 {
0172 return myScaleUnits * Standard_Real(myFTFont->AdvanceY (theUCharNext));
0173 }
0174
0175
0176
0177 Standard_Real AdvanceY (const Standard_Utf32Char theUChar,
0178 const Standard_Utf32Char theUCharNext)
0179 {
0180 return myScaleUnits * Standard_Real(myFTFont->AdvanceY (theUChar, theUCharNext));
0181 }
0182
0183
0184 Standard_Real Scale() const
0185 {
0186 return myScaleUnits;
0187 }
0188
0189
0190 Standard_Mutex& Mutex()
0191 {
0192 return myMutex;
0193 }
0194
0195 public:
0196
0197
0198
0199 bool Init (const NCollection_String& theFontName,
0200 const Font_FontAspect theFontAspect,
0201 const Standard_Real theSize)
0202 {
0203 return FindAndInit (theFontName.ToCString(), theFontAspect, theSize, Font_StrictLevel_Any);
0204 }
0205
0206 protected:
0207
0208
0209
0210
0211
0212 Standard_EXPORT Standard_Boolean renderGlyph (const Standard_Utf32Char theChar,
0213 TopoDS_Shape& theShape);
0214
0215 private:
0216
0217
0218 void init();
0219
0220
0221 bool to3d (const Handle(Geom2d_Curve)& theCurve2d,
0222 const GeomAbs_Shape theContinuity,
0223 Handle(Geom_Curve)& theCurve3d);
0224
0225
0226
0227 Standard_Boolean buildFaces (const NCollection_Sequence<TopoDS_Wire>& theWires,
0228 TopoDS_Shape& theRes);
0229
0230 protected:
0231
0232 Handle(Font_FTFont) myFTFont;
0233 NCollection_DataMap<Standard_Utf32Char, TopoDS_Shape>
0234 myCache;
0235 Standard_Mutex myMutex;
0236 Handle(Geom_Surface) mySurface;
0237 Standard_Real myPrecision;
0238 Standard_Real myScaleUnits;
0239 Standard_Boolean myIsCompositeCurve;
0240
0241 protected:
0242
0243 Adaptor3d_CurveOnSurface myCurvOnSurf;
0244 Handle(Geom2dAdaptor_Curve) myCurve2dAdaptor;
0245 Geom2dConvert_CompCurveToBSplineCurve myConcatMaker;
0246 TColgp_Array1OfPnt2d my3Poles;
0247 TColgp_Array1OfPnt2d my4Poles;
0248 BRep_Builder myBuilder;
0249
0250 };
0251
0252 #endif