// This file is generated by WOK (CPPExt). // Please do not edit this file; modify original file instead. // The copyright and license terms as defined for the original file apply to // this header file considered to be the "object code" form of the original source. #ifndef _MFT_FontManager_HeaderFile #define _MFT_FontManager_HeaderFile #ifndef _Standard_HeaderFile #include #endif #ifndef _Standard_DefineHandle_HeaderFile #include #endif #ifndef _Handle_MFT_FontManager_HeaderFile #include #endif #ifndef _TCollection_AsciiString_HeaderFile #include #endif #ifndef _OSD_OpenMode_HeaderFile #include #endif #ifndef _MFT_FileHandle_HeaderFile #include #endif #ifndef _Standard_Boolean_HeaderFile #include #endif #ifndef _Standard_ShortReal_HeaderFile #include #endif #ifndef _Standard_Integer_HeaderFile #include #endif #ifndef _MFT_FileRecord_HeaderFile #include #endif #ifndef _MMgt_TShared_HeaderFile #include #endif #ifndef _Standard_CString_HeaderFile #include #endif #ifndef _Standard_Character_HeaderFile #include #endif #ifndef _Standard_ExtCharacter_HeaderFile #include #endif #ifndef _MFT_TypeOfCommand_HeaderFile #include #endif #ifndef _Standard_Real_HeaderFile #include #endif #ifndef _Quantity_PlaneAngle_HeaderFile #include #endif #ifndef _Quantity_Length_HeaderFile #include #endif #ifndef _Quantity_Factor_HeaderFile #include #endif #ifndef _Handle_MFT_TextManager_HeaderFile #include #endif #ifndef _Standard_ExtString_HeaderFile #include #endif #ifndef _Standard_Address_HeaderFile #include #endif #ifndef _MFT_FilePosition_HeaderFile #include #endif #ifndef _MFT_CommandDescriptor_HeaderFile #include #endif #ifndef _MFT_TypeOfValue_HeaderFile #include #endif class MFT_FontManagerDefinitionError; class MFT_FontManagerError; class Standard_OutOfRange; class Standard_OutOfMemory; class Standard_TypeMismatch; class Aspect_FontStyle; class MFT_TextManager; class TCollection_AsciiString; //! This class permits to manage MDTV fonts.
//! Warning: A FontManager is associated to a xxx.mft font file
//! The coordinates of the outline vectors of each character
//! must be given in the space defined by the font bounding box
class MFT_FontManager : public MMgt_TShared { public: //! Gives access to the font associated
//! to the file $CSF_MDTVFontDirectory/.mft
//! in ReadOnly access mode.
//! Warning: If the symbol CSF_MDTVFontDirectory is not defined
//! try to reads or writes in $PWD directory.
//! Example: myFontManager = new MFT_FontManager("Helvetica-Bold")
//! permits to access to the file
//! $CSF_MDTVFontDirectory/"helvetica-bold.mft"
//! Trigger: If the font file don't exist or if the file
//! don't have an MFT signature.
Standard_EXPORT MFT_FontManager(const Standard_CString anAliasName); //! Gives access to the font associated
//! to the file $CSF_MDTVFontDirectory/.mft
//! with the open mode and the composite
//! flag .
//! Example: The flag must be sets to TRUE for KANJI extended fonts.
//! Warning: If the symbol CSF_MDTVFontDirectory is not defined
//! try to reads or writes in $PWD directory.
//! Trigger: If is ReadOnly or ReadWrite and
//! the font file don't exist or if the file
//! don't have an MFT signature.
Standard_EXPORT MFT_FontManager(const Aspect_FontStyle& aFont,const OSD_OpenMode aFileMode = OSD_ReadOnly,const Standard_Boolean isComposite = Standard_False); //! Save the font file when the open mode is
//! Write or ReadWrite and Close it in all the case.
Standard_EXPORT void Destroy() ; ~MFT_FontManager() { Destroy(); } //! Updates the font name.
//! Trigger: If the font file is not opened
//! in WriteOnly or ReadWrite mode
Standard_EXPORT void SetFont(const Aspect_FontStyle& aFont) ; //! Defines and Enable the char for writing.
//! Trigger: If the font file is not opened
//! in WriteOnly or ReadWrite mode
//! or the char is already defined.
Standard_EXPORT void SetChar(const Standard_Character aChar) ; //! Defines and Enable the accent char for writing.
//! Trigger: If the font file is not opened
//! in WriteOnly or ReadWrite mode
//! or the char is already defined.
Standard_EXPORT void SetAccentChar(const Standard_Character aChar) ; //! Defines and Enable the char for writing.
//! This char being current for adding command.
//! Warning: The char must have an UNICODE UCS2 encoding.
//! Trigger: If the font file is not opened
//! in WriteOnly or ReadWrite mode
//! or if the font is not a composite font.
Standard_EXPORT void SetChar(const Standard_ExtCharacter aChar) ; //! Changes the default encoding of the char position
//! .
//! Example: SetEncoding(233,"eacute")
//! change the default encoding of the char position 233
//! from "Oslash" to "eacute".
//! Trigger - If the font file is not opened
//! in WriteOnly or ReadWrite mode.
//! or if the char encoding is not defined.
Standard_EXPORT void SetEncoding(const Standard_Integer aPosition,const Standard_CString anEncoding) ; //! Remove the definition of the char
//! Trigger - If the font file is not opened
//! in WriteOnly or ReadWrite mode.
Standard_EXPORT void DelChar(const Standard_Character aChar) ; //! Remove the definition of the char
//! This char being current for adding command.
//! Trigger - If the font file is not opened
//! in WriteOnly or ReadWrite mode
//! or if the font is not a composite font.
Standard_EXPORT void DelChar(const Standard_ExtCharacter aChar) ; //! Adds the command of
//! to describe the current char.
//! This command being current for adding parameters if any.
//!---Purpose Trigger - If the font file is not opened
//! in WriteOnly or ReadWrite mode
//! or if a current char don't have being defined.
//! Warning: the last command of the char descriptor
//! must have a type MFC_TOC_ENDCHAR.
Standard_EXPORT void AddCommand(const MFT_TypeOfCommand aCommand) ; //! Adds the integer parameter to fill
//! the current command.
//! Trigger - If the font file is not opened
//! in WriteOnly or ReadWrite mode
//! or if a current command don't have being defined,
//! or if the number of values is > MaxCommandValues()
Standard_EXPORT void AddValue(const Standard_Integer aValue) ; //! Adds the float parameter to fill
//! the current command.
//! Trigger - If the font file is not opened
//! in WriteOnly or ReadWrite mode
//! or if a current command don't have being defined
//! or if the number of values is > MaxCommandValues()
Standard_EXPORT void AddValue(const Standard_Real aValue) ; //! Adds the string parameter to fill
//! the current command.
//! Trigger - If the font file is not opened
//! in WriteOnly or ReadWrite mode
//! or if a current command don't have being defined,
//! or if the number of values is > MaxCommandValues()
//! Warning: The max length of a string must be < MaxCommandValues()*4-1
Standard_EXPORT void AddValue(const Standard_CString aValue) ; //! Sets the bounding box of the font.
//! Trigger - If the font file is not opened
//! in WriteOnly or ReadWrite mode
//! or if the bounding box has a wrong value.
//! Warning: The bounding box coordinates default are :
//! 0,0,1000,1000
Standard_EXPORT void SetBoundingBox(const Standard_Integer aMinX = 0,const Standard_Integer aMinY = 0,const Standard_Integer aMaxX = 1000,const Standard_Integer aMaxY = 1000) ; //! Sets the font matrix.
//! Trigger - If the font file is not opened
//! in WriteOnly or ReadWrite mode
//! Warning: The font matrix default are :
//! 0.001,0,0,0.001,0,0
Standard_EXPORT void SetFontMatrix(const Standard_Real M1 = 0.001,const Standard_Real M2 = 0.0,const Standard_Real M3 = 0.0,const Standard_Real M4 = 0.001,const Standard_Real M5 = 0.0,const Standard_Real M6 = 0.0) ; //! Sets the paint type of the font.
//! Trigger - If the font file is not opened
//! in WriteOnly or ReadWrite mode
//! or if the value is not a Type 1 font value.
//! Warning: The paint type must be one of Type 1 font
//! value 0 for FILL , 1 for STROKE or 2 for OUTLINE.
Standard_EXPORT void SetPaintType(const Standard_Integer aValue = 0) ; //! Sets the fixed pitch flag of the font
//! as TRUE if the font must have an fixed char width
//! or FALSE if the font must have a proportionnal char width.
//! Trigger - If the font file is not opened
//! in WriteOnly or ReadWrite mode
Standard_EXPORT void SetFixedPitch(const Standard_Boolean aFlag = Standard_False) ; //! Sets the italic angle of the font given in RAD
//! clock-wise from vertical.
//! Trigger - If the font file is not opened
//! in WriteOnly or ReadWrite mode
Standard_EXPORT void SetItalicAngle(const Quantity_PlaneAngle anAngle = 0.0) ; //! Computes the bounding box of the font from the
//! min-max of all chars of the font.
//! Warning: this must be call after all characters has been defined.
//! Trigger - If the font file is not opened
//! in WriteOnly or ReadWrite mode.
Standard_EXPORT void ComputeBoundingBox() ; //! Sets the current font attributes.
//! : the maximum width of one character.
//! : the maximum height of one character
//! according to the parameter.
//! : the slant of one character given in RAD
//! clock-wise from vertical.
//! : the relative interpolator precision is
//! the maximum flatness error deflection for the curves.
//! : if TRUE the font height is apply only
//! on the ascent component of the characters;
//! if FALSE the font height is apply both
//! on the ascent and descent components of the characters.
Standard_EXPORT void SetFontAttribs(const Quantity_Length aWidth,const Quantity_Length aHeight,const Quantity_PlaneAngle aSlant = 0.0,const Quantity_Factor aPrecision = 0.02,const Standard_Boolean aCapsHeight = Standard_False) ; //! Drawn an ANSI text
//! : the draw manager to call for each vertex of the string.
//! : the string to interpret
//! , : the position of the text
//! : the orientation angle in RAD from horizontal.
Standard_EXPORT void DrawText(const Handle(MFT_TextManager)& aTextManager,const Standard_CString aString,const Quantity_Length anX,const Quantity_Length anY,const Quantity_PlaneAngle anOrientation = 0.0) ; //! Drawn an EXTENDED text
//! : the draw manager to call for each vertex of the string.
//! : the string to interpret
//! , : the position of the text
//! : the orientation angle in RAD from horizontal.
//! Trigger - If the font is not a composite font and
//! the string is not ASCII.
Standard_EXPORT void DrawText(const Handle(MFT_TextManager)& aTextManager,const Standard_ExtString aString,const Quantity_Length anX,const Quantity_Length anY,const Quantity_PlaneAngle anOrientation = 0.0) ; //! Retrieves the bounding box of the font.
Standard_EXPORT void BoundingBox(Standard_Integer& aMinX,Standard_Integer& aMinY,Standard_Integer& aMaxX,Standard_Integer& aMaxY) const; //! Retrieves the bounding box of a character.
//! Trigger - If the position is < 0 or > MaxCharPosition().
Standard_EXPORT void CharBoundingBox(const Standard_Integer aPosition,Standard_Integer& aMinX,Standard_Integer& aMinY,Standard_Integer& aMaxX,Standard_Integer& aMaxY) ; //! Retrieves the paint type of the font.
Standard_EXPORT Standard_Integer PaintType() const; //! Retrieves the fixed pitch flag of the font
Standard_EXPORT Standard_Boolean FixedPitch() const; //! Retrieves the italic angle of the font
Standard_EXPORT Quantity_PlaneAngle ItalicAngle() const; //! Runs the interpretor with the current attributes setting
//! (font and text attributes)
//! and returns :
//! The max char width of the font CharSet .
//! The max char height of the font CharSet .
//! The max char descent value below the baseline
//! The slant angle of the font
//! The interpolator precision of the font
//! The caps height flag
//! The FULL font name.
Standard_EXPORT Standard_CString FontAttribs(Quantity_Length& aWidth,Quantity_Length& aHeight,Quantity_Length& aDescent,Quantity_PlaneAngle& aSlant,Quantity_Factor& aPrecision,Standard_Boolean& aCapsHeight) ; //! Runs the interpretor on the ASCII text
//! with the current font attributes setting and returns :
//! The string width .
//! The string ascent .
//! The string left bearing value from the origine
//! The string descent value below the baseline
Standard_EXPORT void TextSize(const Standard_CString aString,Quantity_Length& aWidth,Quantity_Length& anAscent,Quantity_Length& aLbearing,Quantity_Length& aDescent) ; //! Runs the interpretor on the EXTENDED text
//! with the current font attributes setting and returns :
//! The string width .
//! The string ascent .
//! The string left bearing value from the origine
//! The string descent value below the baseline
//! Trigger - If the font is not a composite font and
//! the string is not ASCII.
Standard_EXPORT void TextSize(const Standard_ExtString aString,Quantity_Length& aWidth,Quantity_Length& anAscent,Quantity_Length& aLbearing,Quantity_Length& aDescent) ; //! Runs the interpretor with the current attributes setting
//! (font attributes)
//! and returns :
//! The char width .
//! The char left bearing .
//! The char right bearing .
//! The char ascent .
//! The char descent value below the baseline
//! And returns TRUE if the character is defined.
Standard_EXPORT Standard_Boolean CharSize(const Standard_Character aChar,Quantity_Length& aWidth,Quantity_Length& aLbearing,Quantity_Length& aRbearing,Quantity_Length& anAscent,Quantity_Length& aDescent) ; //! Runs the interpretor with the current attributes setting
//! (font attributes)
//! and returns :
//! The extended char width .
//! The extended char left bearing .
//! The extended char right bearing .
//! The extended char ascent .
//! The extended char descent value below the baseline
//! And returns TRUE if the character is defined.
//! Trigger - If the font is not a composite font and
//! the char is not ASCII.
Standard_EXPORT Standard_Boolean CharSize(const Standard_ExtCharacter aChar,Quantity_Length& aWidth,Quantity_Length& aLbearing,Quantity_Length& aRbearing,Quantity_Length& anAscent,Quantity_Length& aDescent) ; //! Retrieves the font descriptor of this font
Standard_EXPORT Aspect_FontStyle Font() const; //! Returns TRUE if the font is composite.
//! Example: KANJI fonts returns TRUE.
Standard_EXPORT Standard_Boolean IsComposite() const; //! Returns TRUE if the font
//! $CSF_MDTVFontDirectory/.mft does exist.
Standard_EXPORT static Standard_Boolean IsKnown(const Standard_CString anAliasName) ; //! Retrieves the font descriptor from an existing font
//! Trigger - If the font does not exist.
Standard_EXPORT static Aspect_FontStyle Font(const Standard_CString anAliasName) ; //! Returns the MFT font number available
//! in the directory $CSF_MDTVFontDirectory
//! according to the filter :
//! "-foundry-family-weight-slant-swidth-adstyl-pixelsize-pointsize-
//! resx-resy-spacing-avdWidth-registry-encoding"
//! Examples: number = MFT_FontMAnager::FontNumber("-euclid3");
//! returns only the euclid3 fonts.
//! number = MFT_FontMAnager::FontNumber(
//! "-*-*-*-*-*-*-*-*-*-*-*-*-japanese");
//! returns only the japanese fonts.
Standard_EXPORT static Standard_Integer FontNumber(const Standard_CString aFilter = "*") ; //! Retrieves the font descriptor of index
//! from the directory $CSF_MDTVFontDirectory
//! Trigger - If the font rank is < 1 or > FontNumber().
Standard_EXPORT static Aspect_FontStyle Font(const Standard_Integer aRank) ; //! Returns the max values of any defined command
Standard_EXPORT static Standard_Integer MaxCommandValues() ; //! Returns the encoding of the char position
//! .
//! Trigger - If the char is not defined
Standard_EXPORT Standard_CString Encoding(const Standard_Integer aPosition) ; //! Returns the char position
//! from the encoding .
//! Trigger - If the char is not defined
Standard_EXPORT Standard_Integer Encoding(const Standard_CString anEncoding) ; //! Dumps the font descriptor of all characters.
Standard_EXPORT void Dump() ; //! Dumps the font descriptor of the character .
Standard_EXPORT void Dump(const Standard_Character aChar) ; //! Dumps the font descriptor of the extended character .
//! Trigger - If the font is not a composite font.
Standard_EXPORT void Dump(const Standard_ExtCharacter aChar) ; //! Saves the entire MFT font in an ASCII format
//! readable by the Restore() method.
//! to the file $CSF_MDTVFontDirectory/.dat
//! And returns TRUE if the file have been saves correctly.
Standard_EXPORT Standard_Boolean Save() ; //! Restores the entire MFT font
//! from the file $CSF_MDTVFontDirectory/.dat
//! And returns TRUE if the file have been restores correctly.
Standard_EXPORT static Standard_Boolean Restore(const Standard_CString anAliasName) ; //! Returns the Underline descent position from the origin
//! of the text according to the current font attributes.
Standard_EXPORT Quantity_Length UnderlinePosition() const; DEFINE_STANDARD_RTTI(MFT_FontManager) protected: private: //! Open the file ,load and verify the header
//! and returns a file handle >= 0
Standard_EXPORT static MFT_FileHandle Open(const TCollection_AsciiString& aFileName,const OSD_OpenMode aFileMode) ; //! Close the file.
//! Returns TRUE if the file was successfully closed.
Standard_EXPORT static Standard_Boolean Close(const MFT_FileHandle& aFileHandle) ; //! Saves updated records and Close this file.
//! Returns TRUE if the file was successfully closed.
Standard_EXPORT Standard_Boolean Close() ; //! Reads a record from the file.
//! Returns TRUE if the file was successfully read.
Standard_EXPORT static Standard_Boolean Read(MFT_FileRecord& aRecord) ; //! Writes a record to the file.
//! Returns TRUE if the file was successfully written.
Standard_EXPORT static Standard_Boolean Write(MFT_FileRecord& aRecord) ; //! Locates an information from the file record.
//! and returns the info address.
//! Warning: May read or write the current record
//! from/to the file and reload an other record
//! according the file position info.
Standard_EXPORT static Standard_Address Locate(MFT_FileRecord& aRecord,const MFT_FilePosition& aFilePosition) ; //! Computes the full path of the font file name
//! $CSF_MDTVFontDirectory/
Standard_EXPORT static Standard_CString Path(const TCollection_AsciiString& aFileName,const Standard_CString anExtension = ".mft") ; //! Returns the max position of any defined char
//! in the header of the file according with the
//! type of the font.
Standard_EXPORT Standard_Integer MaxCharPosition() const; //! Sets the text attributes.
//! : the string to interpret
//! : the orientation angle in RAD from horizontal.
Standard_EXPORT void SetTextAttribs(const Standard_CString aString,const Quantity_PlaneAngle anOrientation = 0.0) ; //! Sets the extended text attributes.
//! : the string to interpret
//! : the orientation angle in RAD from horizontal.
//! Trigger - If the font is not a composite font and
//! the string is not ASCII.
Standard_EXPORT void SetTextAttribs(const Standard_ExtString aString,const Quantity_PlaneAngle anOrientation = 0.0) ; //! Returns TRUE if the char at position is defined
//! in the header of the file.
//! Trigger - If the position is < 0 or > MaxCharPosition().
Standard_EXPORT Standard_Boolean IsDefinedChar(const Standard_Integer aPosition) const; //! Returns the first defined char position
//! in the header of the file..
Standard_EXPORT Standard_Integer FirstDefinedChar() const; //! Returns the last defined char position
//! in the header of the file..
Standard_EXPORT Standard_Integer LastDefinedChar() const; //! Enable the char at position for reading.
Standard_EXPORT void SetChar(const Standard_Integer aPosition) ; //! Drawn the char at position
//! with the draw manager .
//! and returns FALSE if the drawing must be ended.
Standard_EXPORT Standard_Boolean DrawChar(const Handle(MFT_TextManager)& aTextManager,const Standard_Integer aPosition) ; //! Computes the bounding box of the char position .
Standard_EXPORT void ComputeBoundingBox(const Standard_Integer aPosition) ; //! Returns the next command descriptor
//! from the current char (see SetChar()).
//! Warning: the last command of the char descriptor
//! has a type MFC_TOC_ENDCHAR.
Standard_EXPORT static MFT_CommandDescriptor NextCommand(MFT_FileRecord& aRecord) ; //! Returns the value type at position
//! from the descriptor command.
//! Trigger - If the position is < 1 or > the command length.
Standard_EXPORT static MFT_TypeOfValue Value(const MFT_CommandDescriptor& aDescriptor,const Standard_Integer aRank) ; //! Returns the integer parameter at position
//! of the current command.
//! Trigger --If the position is < 1 or > the command length.
//! or if the value is not an INT value.
Standard_EXPORT static Standard_Integer IValue(MFT_FileRecord& aRecord,const Standard_Integer aRank) ; //! Returns the float parameter at position
//! of the current command.
//! Trigger - If the position is < 1 or > the command length.
//! or if the value is not a FLOAT value.
Standard_EXPORT static Standard_ShortReal FValue(MFT_FileRecord& aRecord,const Standard_Integer aRank) ; //! Returns the string parameter at position
//! of the current command.
//! Trigger - If the position is < 1 or > the command length.
//! or if the value is not a STRING value.
Standard_EXPORT static Standard_CString SValue(MFT_FileRecord& aRecord,const Standard_Integer aRank) ; //! Dumps the font descriptor of the character at
//! position .
Standard_EXPORT void Dump(const Standard_Integer aPosition) ; TCollection_AsciiString myFileName; OSD_OpenMode myFileMode; MFT_FileHandle myFileHandle; Standard_Boolean myIsComposite; Standard_Boolean myIsFixedPitch; Standard_ShortReal myItalicAngle; Standard_Integer myPaintType; Standard_ShortReal myCharWidth; Standard_ShortReal myCharHeight; Standard_ShortReal myCharSlant; Standard_ShortReal myCharPrecision; Standard_Boolean myCharCapsHeight; MFT_FileRecord myFileHeader; MFT_FileRecord myCharEntries; MFT_FileRecord myCommandBuffer; }; // other Inline functions and methods (like "C++: function call" methods) #endif