| PdfDestination.h | | PdfDestination.h | |
| | | | |
| skipping to change at line 27 | | skipping to change at line 27 | |
| * Free Software Foundation, Inc.,
* | | * Free Software Foundation, Inc.,
* | |
| * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | |
| **************************************************************************
*/ | | **************************************************************************
*/ | |
| | | | |
| #ifndef _PDF_DESTINATION_H_ | | #ifndef _PDF_DESTINATION_H_ | |
| #define _PDF_DESTINATION_H_ | | #define _PDF_DESTINATION_H_ | |
| | | | |
| #include "PdfDefines.h" | | #include "PdfDefines.h" | |
| | | | |
| #include "PdfArray.h" | | #include "PdfArray.h" | |
|
| | | #include "PdfRect.h" | |
| #include "PdfReference.h" | | #include "PdfReference.h" | |
| | | | |
| namespace PoDoFo { | | namespace PoDoFo { | |
| | | | |
| class PdfAction; | | class PdfAction; | |
| class PdfPage; | | class PdfPage; | |
| class PdfRect; | | class PdfRect; | |
| | | | |
| enum EPdfDestinationFit { | | enum EPdfDestinationFit { | |
| ePdfDestinationFit_Fit, | | ePdfDestinationFit_Fit, | |
| ePdfDestinationFit_FitH, | | ePdfDestinationFit_FitH, | |
| ePdfDestinationFit_FitV, | | ePdfDestinationFit_FitV, | |
| ePdfDestinationFit_FitB, | | ePdfDestinationFit_FitB, | |
| ePdfDestinationFit_FitBH, | | ePdfDestinationFit_FitBH, | |
| ePdfDestinationFit_FitBV, | | ePdfDestinationFit_FitBV, | |
| | | | |
| ePdfDestinationFit_Unknown = 0xFF | | ePdfDestinationFit_Unknown = 0xFF | |
| }; | | }; | |
| | | | |
|
| | | /** Destination type, as per 12.3.2.2 of the Pdf spec. | |
| | | * | |
| | | * (see table 151 in the pdf spec) | |
| | | */ | |
| | | enum EPdfDestinationType { | |
| | | ePdfDestinationType_XYZ, | |
| | | ePdfDestinationType_Fit, | |
| | | ePdfDestinationType_FitH, | |
| | | ePdfDestinationType_FitV, | |
| | | ePdfDestinationType_FitR, | |
| | | ePdfDestinationType_FitB, | |
| | | ePdfDestinationType_FitBH, | |
| | | ePdfDestinationType_FitBV, | |
| | | | |
| | | ePdfDestinationType_Unknown = 0xFF | |
| | | }; | |
| | | | |
| /** A destination in a PDF file. | | /** A destination in a PDF file. | |
| * A destination can either be a page or an action. | | * A destination can either be a page or an action. | |
| * | | * | |
| * \see PdfOutlineItem \see PdfAnnotation \see PdfDocument | | * \see PdfOutlineItem \see PdfAnnotation \see PdfDocument | |
| */ | | */ | |
| class PODOFO_API PdfDestination { | | class PODOFO_API PdfDestination { | |
| public: | | public: | |
| | | | |
| /** Create an empty destination - points to nowhere | | /** Create an empty destination - points to nowhere | |
| */ | | */ | |
| | | | |
| skipping to change at line 111 | | skipping to change at line 129 | |
| const PdfDestination & operator=( const PdfDestination & rhs ); | | const PdfDestination & operator=( const PdfDestination & rhs ); | |
| | | | |
| /** Get the page that this destination points to | | /** Get the page that this destination points to | |
| * Requires that this PdfDestination was somehow | | * Requires that this PdfDestination was somehow | |
| * created by or from a PdfDocument. Won't work otherwise. | | * created by or from a PdfDocument. Won't work otherwise. | |
| * | | * | |
| * \returns the referenced PdfPage | | * \returns the referenced PdfPage | |
| */ | | */ | |
| PdfPage* GetPage(); | | PdfPage* GetPage(); | |
| | | | |
|
| | | /** Get the destination fit type | |
| | | * | |
| | | * \returns the fit type | |
| | | */ | |
| | | inline EPdfDestinationType GetType() const; | |
| | | | |
| | | /** Get the destination zoom | |
| | | * Destination must be of type XYZ | |
| | | * otherwise exception is thrown. | |
| | | * | |
| | | * \returns the zoom | |
| | | */ | |
| | | inline double GetZoom() const; | |
| | | | |
| | | /** Get the destination rect | |
| | | * Destination must be of type FirR | |
| | | * otherwise exception is thrown | |
| | | * | |
| | | * \returns the destination rect | |
| | | */ | |
| | | inline PdfRect GetRect() const; | |
| | | | |
| | | /** Get the destination Top position | |
| | | * Destination must be of type XYZ, FitH, FitR, FitBH | |
| | | * otherwise exception is thrown. | |
| | | * | |
| | | * \returns the Top position | |
| | | */ | |
| | | inline double GetTop() const; | |
| | | | |
| | | /** Get the destination Left position | |
| | | * Destination must be of type XYZ, FitV or FitR | |
| | | * otherwise exception is thrown. | |
| | | * | |
| | | * \returns the Left position | |
| | | */ | |
| | | inline double GetLeft() const; | |
| | | | |
| | | /** Get the destination Value | |
| | | * Destination must be of type FitH, FitV | |
| | | * or FitBH, otherwise exception is thrown | |
| | | * | |
| | | * \returns the destination Value | |
| | | */ | |
| | | inline double GetDValue() const; | |
| | | | |
| /** Get access to the internal object | | /** Get access to the internal object | |
|
| | | * | |
| * \returns the internal PdfObject | | * \returns the internal PdfObject | |
| */ | | */ | |
| inline PdfObject* GetObject(); | | inline PdfObject* GetObject(); | |
| | | | |
| /** Get access to the internal object | | /** Get access to the internal object | |
| * This is an overloaded member function. | | * This is an overloaded member function. | |
| * | | * | |
| * \returns the internal PdfObject | | * \returns the internal PdfObject | |
| */ | | */ | |
| inline const PdfObject* GetObject() const; | | inline const PdfObject* GetObject() const; | |
| | | | |
|
| | | /** Get access to the internal array | |
| | | * \returns the internal PdfArray | |
| | | */ | |
| | | inline PdfArray &GetArray(); | |
| | | | |
| | | /** Get access to the internal array | |
| | | * This is an overloaded member function. | |
| | | * | |
| | | * \returns the internal PdfArray | |
| | | */ | |
| | | inline const PdfArray &GetArray() const; | |
| | | | |
| /** Adds this destination to an dictionary. | | /** Adds this destination to an dictionary. | |
| * This method handles the all the complexities of making sure it's ad
ded correctly | | * This method handles the all the complexities of making sure it's ad
ded correctly | |
| * | | * | |
| * If this destination is empty. Nothing will be added. | | * If this destination is empty. Nothing will be added. | |
| * | | * | |
| * \param dictionary the destination will be added to this dictionary | | * \param dictionary the destination will be added to this dictionary | |
| */ | | */ | |
| void AddToDictionary( PdfDictionary & dictionary ) const; | | void AddToDictionary( PdfDictionary & dictionary ) const; | |
| | | | |
| private: | | private: | |
| | | | |
| skipping to change at line 161 | | skipping to change at line 238 | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| inline const PdfObject* PdfDestination::GetObject() const | | inline const PdfObject* PdfDestination::GetObject() const | |
| { | | { | |
| return m_pObject; | | return m_pObject; | |
| } | | } | |
| | | | |
|
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| | | inline PdfArray &PdfDestination::GetArray() | |
| | | { | |
| | | return m_array; | |
| | | } | |
| | | | |
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| | | inline const PdfArray &PdfDestination::GetArray() const | |
| | | { | |
| | | return m_array; | |
| | | } | |
| | | | |
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| | | inline EPdfDestinationType PdfDestination::GetType() const | |
| | | { | |
| | | if ( !m_array.size() ) | |
| | | return ePdfDestinationType_Unknown; | |
| | | | |
| | | PdfName tp = m_array[1].GetName(); | |
| | | | |
| | | if ( tp == PdfName("XYZ") ) return ePdfDestinationType_XYZ; | |
| | | if ( tp == PdfName("Fit") ) return ePdfDestinationType_Fit; | |
| | | if ( tp == PdfName("FitH") ) return ePdfDestinationType_FitH; | |
| | | if ( tp == PdfName("FitV") ) return ePdfDestinationType_FitV; | |
| | | if ( tp == PdfName("FitR") ) return ePdfDestinationType_FitR; | |
| | | if ( tp == PdfName("FitB") ) return ePdfDestinationType_FitB; | |
| | | if ( tp == PdfName("FitBH") ) return ePdfDestinationType_FitBH; | |
| | | if ( tp == PdfName("FitBV") ) return ePdfDestinationType_FitBV; | |
| | | | |
| | | return ePdfDestinationType_Unknown; | |
| | | } | |
| | | | |
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| | | inline double PdfDestination::GetDValue() const | |
| | | { | |
| | | EPdfDestinationType tp = GetType(); | |
| | | | |
| | | if ( tp != ePdfDestinationType_FitH | |
| | | && tp != ePdfDestinationType_FitV | |
| | | && tp != ePdfDestinationType_FitBH ) | |
| | | { | |
| | | PODOFO_RAISE_ERROR( ePdfError_WrongDestinationType ); | |
| | | } | |
| | | | |
| | | return m_array[2].GetReal(); | |
| | | } | |
| | | | |
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| | | inline double PdfDestination::GetLeft() const | |
| | | { | |
| | | EPdfDestinationType tp = GetType(); | |
| | | | |
| | | if ( tp != ePdfDestinationType_FitV | |
| | | && tp != ePdfDestinationType_XYZ | |
| | | && tp != ePdfDestinationType_FitR ) | |
| | | { | |
| | | PODOFO_RAISE_ERROR( ePdfError_WrongDestinationType ); | |
| | | } | |
| | | | |
| | | return m_array[2].GetReal(); | |
| | | } | |
| | | | |
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| | | inline PdfRect PdfDestination::GetRect() const | |
| | | { | |
| | | if ( GetType() != ePdfDestinationType_FitR ) | |
| | | { | |
| | | PODOFO_RAISE_ERROR( ePdfError_WrongDestinationType ); | |
| | | } | |
| | | | |
| | | return PdfRect(m_array[2].GetReal(), m_array[3].GetReal(), | |
| | | m_array[4].GetReal(), m_array[5].GetReal()); | |
| | | } | |
| | | | |
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| | | inline double PdfDestination::GetTop() const | |
| | | { | |
| | | EPdfDestinationType tp = GetType(); | |
| | | | |
| | | switch (tp) | |
| | | { | |
| | | case ePdfDestinationType_XYZ: | |
| | | return m_array[3].GetReal(); | |
| | | case ePdfDestinationType_FitH: | |
| | | case ePdfDestinationType_FitBH: | |
| | | return m_array[2].GetReal(); | |
| | | case ePdfDestinationType_FitR: | |
| | | return m_array[5].GetReal(); | |
| | | case ePdfDestinationType_Fit: | |
| | | case ePdfDestinationType_FitV: | |
| | | case ePdfDestinationType_FitB: | |
| | | case ePdfDestinationType_FitBV: | |
| | | case ePdfDestinationType_Unknown: | |
| | | default: | |
| | | { | |
| | | PODOFO_RAISE_ERROR( ePdfError_WrongDestinationType ); | |
| | | } | |
| | | }; | |
| | | } | |
| | | | |
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| | | inline double PdfDestination::GetZoom() const | |
| | | { | |
| | | if ( GetType() != ePdfDestinationType_XYZ ) | |
| | | { | |
| | | PODOFO_RAISE_ERROR( ePdfError_WrongDestinationType ); | |
| | | } | |
| | | | |
| | | return m_array[4].GetReal(); | |
| | | } | |
| | | | |
| }; | | }; | |
| | | | |
| #endif // _PDF_DESTINATION_H_ | | #endif // _PDF_DESTINATION_H_ | |
| | | | |
End of changes. 6 change blocks. |
| 0 lines changed or deleted | | 204 lines changed or added | |
|
| PdfEncrypt.h | | PdfEncrypt.h | |
| | | | |
| skipping to change at line 91 | | skipping to change at line 91 | |
| ePdfPermissions_Edit = 0x00000008, ///< Allow modifying
the document besides annotations, form fields or chaning pages | | ePdfPermissions_Edit = 0x00000008, ///< Allow modifying
the document besides annotations, form fields or chaning pages | |
| ePdfPermissions_Copy = 0x00000010, ///< Allow text and g
raphic extraction | | ePdfPermissions_Copy = 0x00000010, ///< Allow text and g
raphic extraction | |
| ePdfPermissions_EditNotes = 0x00000020, ///< Add or modify te
xt annoations or form fields (if ePdfPermissions_Edit is set also allow to
create interactive form fields including signature) | | ePdfPermissions_EditNotes = 0x00000020, ///< Add or modify te
xt annoations or form fields (if ePdfPermissions_Edit is set also allow to
create interactive form fields including signature) | |
| ePdfPermissions_FillAndSign = 0x00000100, ///< Fill in existing
form or signature fields | | ePdfPermissions_FillAndSign = 0x00000100, ///< Fill in existing
form or signature fields | |
| ePdfPermissions_Accessible = 0x00000200, ///< Extract text and
graphics to support user with disabillities | | ePdfPermissions_Accessible = 0x00000200, ///< Extract text and
graphics to support user with disabillities | |
| ePdfPermissions_DocAssembly = 0x00000400, ///< Assemble the doc
ument: insert, create, rotate delete pages or add bookmarks | | ePdfPermissions_DocAssembly = 0x00000400, ///< Assemble the doc
ument: insert, create, rotate delete pages or add bookmarks | |
| ePdfPermissions_HighPrint = 0x00000800 ///< Print a high res
olution version of the document | | ePdfPermissions_HighPrint = 0x00000800 ///< Print a high res
olution version of the document | |
| } EPdfPermissions; | | } EPdfPermissions; | |
| | | | |
| typedef enum { | | typedef enum { | |
|
| ePdfEncryptAlgorithm_RC4V1, ///< RC4 Version 1 encryption using a 4 | | ePdfEncryptAlgorithm_RC4V1 = 1, ///< RC4 Version 1 encryption using | |
| 0bit key | | a 40bit key | |
| ePdfEncryptAlgorithm_RC4V2, ///< RC4 Version 2 encryption using a k | | ePdfEncryptAlgorithm_RC4V2 = 2, ///< RC4 Version 2 encryption using | |
| ey with 40-128bit | | a key with 40-128bit | |
| ePdfEncryptAlgorithm_AESV2 ///< AES encryption with an 128 bit key | | ePdfEncryptAlgorithm_AESV2 = 4 ///< AES encryption with an 128 bit | |
| (PDF1.6) | | key (PDF1.6) | |
| } EPdfEncryptAlgorithm; | | } EPdfEncryptAlgorithm; | |
| | | | |
| /** Create a PdfEncrypt object which can be used to encrypt a PDF file. | | /** Create a PdfEncrypt object which can be used to encrypt a PDF file. | |
| * | | * | |
| * \param userPassword the user password (if empty the user does not h
ave | | * \param userPassword the user password (if empty the user does not h
ave | |
| * to enter a password to open the document) | | * to enter a password to open the document) | |
| * \param ownerPassword the owner password | | * \param ownerPassword the owner password | |
| * \param protection several EPdfPermissions values or'ed together to
set | | * \param protection several EPdfPermissions values or'ed together to
set | |
| * the users permissions for this document | | * the users permissions for this document | |
| * \param eRevision the revision of the encryption algorithm to be use
d | | * \param eRevision the revision of the encryption algorithm to be use
d | |
| | | | |
| skipping to change at line 128 | | skipping to change at line 128 | |
| ePdfPermissions_DocAssembly | | | ePdfPermissions_DocAssembly | | |
| ePdfPermissions_HighPrint, | | ePdfPermissions_HighPrint, | |
| EPdfEncryptAlgorithm eAlgorithm =
ePdfEncryptAlgorithm_RC4V1, | | EPdfEncryptAlgorithm eAlgorithm =
ePdfEncryptAlgorithm_RC4V1, | |
| EPdfKeyLength eKeyLength = ePdfKe
yLength_40 ); | | EPdfKeyLength eKeyLength = ePdfKe
yLength_40 ); | |
| | | | |
| /** Initialize a PdfEncrypt object from an encryption dictionary in a P
DF file. | | /** Initialize a PdfEncrypt object from an encryption dictionary in a P
DF file. | |
| * | | * | |
| * This is required for encrypting a PDF file, but handled internally
in PdfParser | | * This is required for encrypting a PDF file, but handled internally
in PdfParser | |
| * for you. | | * for you. | |
| * | | * | |
|
| | | * Will use only encrypting algorithms that are enabled. | |
| | | * | |
| * \param pObject a PDF encryption dictionary | | * \param pObject a PDF encryption dictionary | |
|
| | | * | |
| | | * \see GetEnabledEncryptionAlgorithms | |
| */ | | */ | |
| static PdfEncrypt * CreatePdfEncrypt( const PdfObject* pObject ); | | static PdfEncrypt * CreatePdfEncrypt( const PdfObject* pObject ); | |
| | | | |
| /** Copy constructor | | /** Copy constructor | |
| * | | * | |
| * \param rhs another PdfEncrypt object which is copied | | * \param rhs another PdfEncrypt object which is copied | |
| */ | | */ | |
| static PdfEncrypt * CreatePdfEncrypt( const PdfEncrypt & rhs ); | | static PdfEncrypt * CreatePdfEncrypt( const PdfEncrypt & rhs ); | |
| | | | |
|
| | | /** | |
| | | * Retrieve the list of encryption algorithms that are used | |
| | | * when loading a PDF document. | |
| | | * | |
| | | * By default all alogrithms are enabled. | |
| | | * | |
| | | * \see IsEncryptionEnabled | |
| | | * \see SetEnabledEncryptionAlgorithms | |
| | | * | |
| | | * \return an or'ed together list of all enabled encryption algorithms | |
| | | */ | |
| | | static int GetEnabledEncryptionAlgorithms(); | |
| | | | |
| | | /** | |
| | | * Specify the list of encryption algorithms that should be used by PoD | |
| | | oFo | |
| | | * when loading a PDF document. | |
| | | * | |
| | | * This can be used to disable for example AES encryption/decryption | |
| | | * which is unstable in certain cases. | |
| | | * | |
| | | * \see GetEnabledEncryptionAlgorithms | |
| | | * \see IsEncryptionEnabled | |
| | | */ | |
| | | static void SetEnabledEncryptionAlgorithms(int nEncryptionAlgorithms); | |
| | | | |
| | | /** | |
| | | * Test if a certain encryption algorithm is enabled for loading PDF do | |
| | | cuments. | |
| | | * | |
| | | * \returns ture if the encryption algorithm is enabled | |
| | | * \see GetEnabledEncryptionAlgorithms | |
| | | * \see SetEnabledEncryptionAlgorithms | |
| | | */ | |
| | | static bool IsEncryptionEnabled(EPdfEncryptAlgorithm eAlgorithm); | |
| | | | |
| /** Destruct the PdfEncrypt object | | /** Destruct the PdfEncrypt object | |
| */ | | */ | |
| virtual ~PdfEncrypt(); | | virtual ~PdfEncrypt(); | |
| | | | |
| /** Assignment operator | | /** Assignment operator | |
| * | | * | |
| * \param rhs another PdfEncrypt object which is copied | | * \param rhs another PdfEncrypt object which is copied | |
| */ | | */ | |
| const PdfEncrypt & operator=( const PdfEncrypt & rhs ); | | const PdfEncrypt & operator=( const PdfEncrypt & rhs ); | |
| | | | |
| | | | |
| skipping to change at line 371 | | skipping to change at line 409 | |
| int m_pValue; ///< P entry in pdf document | | int m_pValue; ///< P entry in pdf document | |
| EPdfKeyLength m_eKeyLength; ///< The key length | | EPdfKeyLength m_eKeyLength; ///< The key length | |
| std::string m_userPass; ///< User password | | std::string m_userPass; ///< User password | |
| std::string m_ownerPass; ///< Owner password | | std::string m_ownerPass; ///< Owner password | |
| unsigned char m_rc4key[16]; ///< last RC4 key | | unsigned char m_rc4key[16]; ///< last RC4 key | |
| unsigned char m_rc4last[256]; ///< last RC4 state table | | unsigned char m_rc4last[256]; ///< last RC4 state table | |
| unsigned char m_uValue[32]; ///< U entry in pdf document | | unsigned char m_uValue[32]; ///< U entry in pdf document | |
| unsigned char m_oValue[32]; ///< O entry in pdf document | | unsigned char m_oValue[32]; ///< O entry in pdf document | |
| | | | |
| private: | | private: | |
|
| | | static int s_nEnabledEncryptionAlgorithms; ///< Or'ed int containing | |
| | | the enabled encryption algorithms | |
| | | | |
| unsigned char m_encryptionKey[16]; ///< Encryption key | | unsigned char m_encryptionKey[16]; ///< Encryption key | |
| | | | |
| PdfReference m_curReference; ///< Reference of the current PdfObj
ect | | PdfReference m_curReference; ///< Reference of the current PdfObj
ect | |
| | | | |
| std::string m_documentId; ///< DocumentID of the current docum
ent | | std::string m_documentId; ///< DocumentID of the current docum
ent | |
| }; | | }; | |
| | | | |
| /** A class that is used to encrypt a PDF file (AES-128) | | /** A class that is used to encrypt a PDF file (AES-128) | |
| * | | * | |
| * Client code is working only with PdfEncrypt class and knows nothing | | * Client code is working only with PdfEncrypt class and knows nothing | |
| | | | |
End of changes. 5 change blocks. |
| 6 lines changed or deleted | | 49 lines changed or added | |
|
| PdfFontMetrics.h | | PdfFontMetrics.h | |
| | | | |
| skipping to change at line 28 | | skipping to change at line 28 | |
| * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | |
| **************************************************************************
*/ | | **************************************************************************
*/ | |
| | | | |
| #ifndef _PDF_FONT_METRICS_H_ | | #ifndef _PDF_FONT_METRICS_H_ | |
| #define _PDF_FONT_METRICS_H_ | | #define _PDF_FONT_METRICS_H_ | |
| | | | |
| #include "PdfDefines.h" | | #include "PdfDefines.h" | |
| #include "Pdf3rdPtyForwardDecl.h" | | #include "Pdf3rdPtyForwardDecl.h" | |
| #include "PdfString.h" | | #include "PdfString.h" | |
| | | | |
|
| #ifndef PODOFO_CONVERSION_CONSTANT | | | |
| #define PODOFO_CONVERSION_CONSTANT 0.002834645669291339 | | | |
| #endif // PODOFO_CONVERSION_CONSTANT | | | |
| | | | |
| namespace PoDoFo { | | namespace PoDoFo { | |
| | | | |
| class PdfArray; | | class PdfArray; | |
| class PdfObject; | | class PdfObject; | |
| class PdfVariant; | | class PdfVariant; | |
| | | | |
| /** | | /** | |
|
| * Enum for the different font formats supported by PoDoFo | | * This abstract class provides access | |
| | | * to fontmetrics informations. | |
| */ | | */ | |
|
| enum EPdfFontType { | | | |
| ePdfFontType_TrueType, | | | |
| ePdfFontType_Type1Pfa, | | | |
| ePdfFontType_Type1Pfb, | | | |
| | | | |
| ePdfFontType_Unknown = 0xff | | | |
| }; | | | |
| | | | |
| class PODOFO_API PdfFontMetrics { | | class PODOFO_API PdfFontMetrics { | |
| public: | | public: | |
|
| /** Create a font metrics object for a given true type file | | PdfFontMetrics( EPdfFontType eFontType, const char* pszFilename, const | |
| * \param pLibrary handle to an initialized FreeType2 library handle | | char* pszSubsetPrefix ); | |
| * \param pszFilename filename of a truetype file | | | |
| * \param pszSubsetPrefix unique prefix for font subsets (see GetFontS | | | |
| ubsetPrefix) | | | |
| */ | | | |
| PdfFontMetrics( FT_Library* pLibrary, const char* pszFilename, | | | |
| const char* pszSubsetPrefix = NULL ); | | | |
| | | | |
| /** Create a font metrics object for a given memory buffer | | | |
| * \param pLibrary handle to an initialized FreeType2 library handle | | | |
| * \param pBuffer block of memory representing the font data (PdfFontM | | | |
| etrics will copy the buffer) | | | |
| * \param nBufLen the length of the buffer | | | |
| * \param pszSubsetPrefix unique prefix for font subsets (see GetFontS | | | |
| ubsetPrefix) | | | |
| */ | | | |
| PdfFontMetrics( FT_Library* pLibrary, const char* pBuffer, unsigned int | | | |
| nBufLen, | | | |
| const char* pszSubsetPrefix = NULL); | | | |
| | | | |
| /** Create a font metrics object for a given true type file | | | |
| * \param pLibrary handle to an initialized FreeType2 library handle | | | |
| * \param rBuffer a buffer containing a font file | | | |
| * \param pszSubsetPrefix unique prefix for font subsets (see GetFontS | | | |
| ubsetPrefix) | | | |
| */ | | | |
| PdfFontMetrics( FT_Library* pLibrary, const PdfRefCountedBuffer & rBuff | | | |
| er, | | | |
| const char* pszSubsetPrefix = NULL); | | | |
| | | | |
| /** Create a font metrics object for a given freetype font. | | | |
| * \param pLibrary handle to an initialized FreeType2 library handle | | | |
| * \param face a valid freetype font face | | | |
| * \param pszSubsetPrefix unique prefix for font subsets (see GetFontS | | | |
| ubsetPrefix) | | | |
| */ | | | |
| PdfFontMetrics( FT_Library* pLibrary, FT_Face face, | | | |
| const char* pszSubsetPrefix = NULL); | | | |
| | | | |
| /** Create a font metrics object based on an existing PdfObject | | | |
| * | | | |
| * \param pLibrary handle to an initialized FreeType2 library handle | | | |
| * \param pObject an existing font descriptor object | | | |
| */ | | | |
| PdfFontMetrics( FT_Library* pLibrary, PdfObject* pDescriptor ); | | | |
| | | | |
| virtual ~PdfFontMetrics(); | | virtual ~PdfFontMetrics(); | |
| | | | |
| /** Create a width array for this font which is a required part | | /** Create a width array for this font which is a required part | |
| * of every font dictionary. | | * of every font dictionary. | |
| * \param var the final width array is written to this PdfVariant | | * \param var the final width array is written to this PdfVariant | |
| * \param nFirst first character to be in the array | | * \param nFirst first character to be in the array | |
| * \param nLast last character code to be in the array | | * \param nLast last character code to be in the array | |
| */ | | */ | |
|
| void GetWidthArray( PdfVariant & var, unsigned int nFirst, unsigned int
nLast ) const; | | virtual void GetWidthArray( PdfVariant & var, unsigned int nFirst, unsi
gned int nLast ) const = 0; | |
| | | | |
| /** Get the width of a single glyph id | | /** Get the width of a single glyph id | |
| * | | * | |
| * \returns the width of a single glyph id | | * \returns the width of a single glyph id | |
| */ | | */ | |
|
| double GetGlyphWidth( int nGlyphId ) const; | | virtual double GetGlyphWidth( int nGlyphId ) const = 0; | |
| | | | |
| /** Create the bounding box array as required by the PDF reference | | /** Create the bounding box array as required by the PDF reference | |
| * so that it can be written directly to a PDF file. | | * so that it can be written directly to a PDF file. | |
| * | | * | |
| * \param array write the bounding box to this array. | | * \param array write the bounding box to this array. | |
| */ | | */ | |
|
| void GetBoundingBox( PdfArray & array ) const; | | virtual void GetBoundingBox( PdfArray & array ) const = 0; | |
| | | | |
| /** Retrieve the width of a given text string in PDF units when | | /** Retrieve the width of a given text string in PDF units when | |
| * drawn with the current font | | * drawn with the current font | |
| * \param rsString a PdfString from which the width shall be calculate
d | | * \param rsString a PdfString from which the width shall be calculate
d | |
| * \returns the width in PDF units | | * \returns the width in PDF units | |
| * | | * | |
| * This is an overloaded method for your convinience! | | * This is an overloaded method for your convinience! | |
| */ | | */ | |
| inline double StringWidth( const PdfString & rsString ) const; | | inline double StringWidth( const PdfString & rsString ) const; | |
| | | | |
| | | | |
| skipping to change at line 139 | | skipping to change at line 90 | |
| double StringWidth( const char* pszText, pdf_long nLength = 0 ) const; | | double StringWidth( const char* pszText, pdf_long nLength = 0 ) const; | |
| | | | |
| /** Retrieve the width of a given text string in PDF units when | | /** Retrieve the width of a given text string in PDF units when | |
| * drawn with the current font | | * drawn with the current font | |
| * \param pszText a text string of which the width should be calculate
d | | * \param pszText a text string of which the width should be calculate
d | |
| * \param nLength if != 0 only the width of the nLength first characte
rs is calculated | | * \param nLength if != 0 only the width of the nLength first characte
rs is calculated | |
| * \returns the width in PDF units | | * \returns the width in PDF units | |
| */ | | */ | |
| double StringWidth( const pdf_utf16be* pszText, unsigned int nLength =
0 ) const; | | double StringWidth( const pdf_utf16be* pszText, unsigned int nLength =
0 ) const; | |
| | | | |
|
| | | #ifndef _WCHAR_T_DEFINED | |
| #if defined(_MSC_VER) && _MSC_VER <= 1200 // nicht f | | #if defined(_MSC_VER) && _MSC_VER <= 1200 // nicht f | |
| #else | | #else | |
| /** Retrieve the width of a given text string in PDF units when | | /** Retrieve the width of a given text string in PDF units when | |
| * drawn with the current font | | * drawn with the current font | |
| * \param pszText a text string of which the width should be calculate
d | | * \param pszText a text string of which the width should be calculate
d | |
| * \param nLength if != 0 only the width of the nLength first characte
rs is calculated | | * \param nLength if != 0 only the width of the nLength first characte
rs is calculated | |
| * \returns the width in PDF units | | * \returns the width in PDF units | |
| */ | | */ | |
| double StringWidth( const wchar_t* pszText, unsigned int nLength = 0 )
const; | | double StringWidth( const wchar_t* pszText, unsigned int nLength = 0 )
const; | |
| #endif | | #endif | |
|
| | | #endif | |
| | | | |
| /** Retrieve the width of a given text string in 1/1000th mm when | | /** Retrieve the width of a given text string in 1/1000th mm when | |
| * drawn with the current font | | * drawn with the current font | |
| * \param pszText a text string of which the width should be calculate
d | | * \param pszText a text string of which the width should be calculate
d | |
| * \param nLength if != 0 only the width of the nLength first characte
rs is calculated | | * \param nLength if != 0 only the width of the nLength first characte
rs is calculated | |
| * \returns the width in 1/1000th mm | | * \returns the width in 1/1000th mm | |
| */ | | */ | |
|
| unsigned long StringWidthMM( const char* pszText, unsigned int nLength
= 0 ) const; | | inline unsigned long StringWidthMM( const char* pszText, unsigned int n
Length = 0 ) const; | |
| | | | |
| /** Retrieve the width of a given text string in 1/1000th mm when | | /** Retrieve the width of a given text string in 1/1000th mm when | |
| * drawn with the current font | | * drawn with the current font | |
| * \param pszText a text string of which the width should be calculate
d | | * \param pszText a text string of which the width should be calculate
d | |
| * \param nLength if != 0 only the width of the nLength first characte
rs is calculated | | * \param nLength if != 0 only the width of the nLength first characte
rs is calculated | |
| * \returns the width in 1/1000th mm | | * \returns the width in 1/1000th mm | |
| */ | | */ | |
|
| unsigned long StringWidthMM( const pdf_utf16be* pszText, unsigned int n
Length = 0 ) const; | | inline unsigned long StringWidthMM( const pdf_utf16be* pszText, unsigne
d int nLength = 0 ) const; | |
| | | | |
|
| | | #ifndef _WCHAR_T_DEFINED | |
| #if defined(_MSC_VER) && _MSC_VER <= 1200 // nicht f | | #if defined(_MSC_VER) && _MSC_VER <= 1200 // nicht f | |
| #else | | #else | |
| /** Retrieve the width of a given text string in 1/1000th mm when | | /** Retrieve the width of a given text string in 1/1000th mm when | |
| * drawn with the current font | | * drawn with the current font | |
| * \param pszText a text string of which the width should be calculate
d | | * \param pszText a text string of which the width should be calculate
d | |
| * \param nLength if != 0 only the width of the nLength first characte
rs is calculated | | * \param nLength if != 0 only the width of the nLength first characte
rs is calculated | |
| * \returns the width in 1/1000th mm | | * \returns the width in 1/1000th mm | |
| */ | | */ | |
|
| unsigned long StringWidthMM( const wchar_t* pszText, unsigned int nLeng | | inline unsigned long StringWidthMM( const wchar_t* pszText, unsigned in | |
| th = 0 ) const; | | t nLength = 0 ) const; | |
| | | #endif | |
| #endif | | #endif | |
| | | | |
| /** Retrieve the width of the given character in PDF units in the curre
nt font | | /** Retrieve the width of the given character in PDF units in the curre
nt font | |
| * \param c character | | * \param c character | |
| * \returns the width in PDF units | | * \returns the width in PDF units | |
| */ | | */ | |
|
| double CharWidth( unsigned char c ) const; | | virtual double CharWidth( unsigned char c ) const = 0; | |
| | | | |
| // Peter Petrov 20 March 2009 | | // Peter Petrov 20 March 2009 | |
| /** Retrieve the width of the given character in PDF units in the curre
nt font | | /** Retrieve the width of the given character in PDF units in the curre
nt font | |
| * \param c character | | * \param c character | |
| * \returns the width in PDF units | | * \returns the width in PDF units | |
| */ | | */ | |
|
| double UnicodeCharWidth( unsigned short c ) const; | | virtual double UnicodeCharWidth( unsigned short c ) const = 0; | |
| | | | |
| /** Retrieve the width of the given character in 1/1000th mm in the cur
rent font | | /** Retrieve the width of the given character in 1/1000th mm in the cur
rent font | |
| * \param c character | | * \param c character | |
| * \returns the width in 1/1000th mm | | * \returns the width in 1/1000th mm | |
| */ | | */ | |
|
| unsigned long CharWidthMM( unsigned char c ) const; | | inline unsigned long CharWidthMM( unsigned char c ) const; | |
| | | | |
| /** Retrieve the line spacing for this font | | /** Retrieve the line spacing for this font | |
| * \returns the linespacing in PDF units | | * \returns the linespacing in PDF units | |
| */ | | */ | |
|
| inline double GetLineSpacing() const; | | virtual double GetLineSpacing() const = 0; | |
| | | | |
| /** Retrieve the line spacing for this font | | /** Retrieve the line spacing for this font | |
| * \returns the linespacing in 1/1000th mm | | * \returns the linespacing in 1/1000th mm | |
| */ | | */ | |
| inline unsigned long GetLineSpacingMM() const; | | inline unsigned long GetLineSpacingMM() const; | |
| | | | |
| /** Get the width of the underline for the current | | /** Get the width of the underline for the current | |
| * font size in PDF units | | * font size in PDF units | |
| * \returns the thickness of the underline in PDF units | | * \returns the thickness of the underline in PDF units | |
| */ | | */ | |
|
| inline double GetUnderlineThickness() const; | | virtual double GetUnderlineThickness() const = 0; | |
| | | | |
| /** Get the width of the underline for the current | | /** Get the width of the underline for the current | |
| * font size in 1/1000th mm | | * font size in 1/1000th mm | |
| * \returns the thickness of the underline in 1/1000th mm | | * \returns the thickness of the underline in 1/1000th mm | |
| */ | | */ | |
| inline unsigned long GetUnderlineThicknessMM() const; | | inline unsigned long GetUnderlineThicknessMM() const; | |
| | | | |
| /** Return the position of the underline for the current font | | /** Return the position of the underline for the current font | |
| * size in PDF units | | * size in PDF units | |
| * \returns the underline position in PDF units | | * \returns the underline position in PDF units | |
| */ | | */ | |
|
| inline double GetUnderlinePosition() const; | | virtual double GetUnderlinePosition() const = 0; | |
| | | | |
| /** Return the position of the underline for the current font | | /** Return the position of the underline for the current font | |
| * size in 1/1000th mm | | * size in 1/1000th mm | |
| * \returns the underline position in 1/1000th mm | | * \returns the underline position in 1/1000th mm | |
| */ | | */ | |
| inline long GetUnderlinePositionMM() const; | | inline long GetUnderlinePositionMM() const; | |
| | | | |
| /** Return the position of the strikeout for the current font | | /** Return the position of the strikeout for the current font | |
| * size in PDF units | | * size in PDF units | |
| * \returns the underline position in PDF units | | * \returns the underline position in PDF units | |
| */ | | */ | |
|
| inline double GetStrikeOutPosition() const; | | virtual double GetStrikeOutPosition() const = 0; | |
| | | | |
| /** Return the position of the strikeout for the current font | | /** Return the position of the strikeout for the current font | |
| * size in 1/1000th mm | | * size in 1/1000th mm | |
| * \returns the underline position in 1/1000th mm | | * \returns the underline position in 1/1000th mm | |
| */ | | */ | |
| inline unsigned long GetStrikeOutPositionMM() const; | | inline unsigned long GetStrikeOutPositionMM() const; | |
| | | | |
| /** Get the width of the strikeout for the current | | /** Get the width of the strikeout for the current | |
| * font size in PDF units | | * font size in PDF units | |
| * \returns the thickness of the strikeout in PDF units | | * \returns the thickness of the strikeout in PDF units | |
| */ | | */ | |
|
| inline double GetStrikeoutThickness() const; | | virtual double GetStrikeoutThickness() const = 0; | |
| | | | |
| /** Get the width of the strikeout for the current | | /** Get the width of the strikeout for the current | |
| * font size in 1/1000th mm | | * font size in 1/1000th mm | |
| * \returns the thickness of the strikeout in 1/1000th mm | | * \returns the thickness of the strikeout in 1/1000th mm | |
| */ | | */ | |
| inline unsigned long GetStrikeoutThicknessMM() const; | | inline unsigned long GetStrikeoutThicknessMM() const; | |
| | | | |
| /** Get a pointer to the path of the font file. | | /** Get a pointer to the path of the font file. | |
| * \returns a zero terminated string containing the filename of the fo
nt file | | * \returns a zero terminated string containing the filename of the fo
nt file | |
| */ | | */ | |
| inline const char* GetFilename() const; | | inline const char* GetFilename() const; | |
| | | | |
| /** Get a pointer to the actual font data - if it was loaded from memor
y. | | /** Get a pointer to the actual font data - if it was loaded from memor
y. | |
| * \returns a binary buffer of data containing the font data | | * \returns a binary buffer of data containing the font data | |
| */ | | */ | |
|
| inline const char* GetFontData() const; | | virtual const char* GetFontData() const = 0; | |
| | | | |
| /** Get the length of the actual font data - if it was loaded from memo
ry. | | /** Get the length of the actual font data - if it was loaded from memo
ry. | |
| * \returns a the length of the font data | | * \returns a the length of the font data | |
| */ | | */ | |
|
| inline pdf_long GetFontDataLen() const; | | virtual pdf_long GetFontDataLen() const = 0; | |
| | | | |
| /** Get a string with the postscript name of the font. | | /** Get a string with the postscript name of the font. | |
| * \returns the postscript name of the font or NULL string if no posts
cript name is available. | | * \returns the postscript name of the font or NULL string if no posts
cript name is available. | |
| */ | | */ | |
|
| const char* GetFontname() const; | | virtual const char* GetFontname() const = 0; | |
| | | | |
| /** | | /** | |
| * \returns NULL or a 6 uppercase letter and "+" sign prefix | | * \returns NULL or a 6 uppercase letter and "+" sign prefix | |
| * used for font subsets | | * used for font subsets | |
| */ | | */ | |
|
| const char* GetSubsetFontnamePrefix() const; | | inline const char* GetSubsetFontnamePrefix() const; | |
| | | | |
| /** Get the weight of this font. | | /** Get the weight of this font. | |
| * Used to build the font dictionay | | * Used to build the font dictionay | |
| * \returns the weight of this font (500 is normal). | | * \returns the weight of this font (500 is normal). | |
| */ | | */ | |
|
| inline unsigned int GetWeight() const; | | virtual unsigned int GetWeight() const = 0; | |
| | | | |
| /** Get the ascent of this font in PDF | | /** Get the ascent of this font in PDF | |
| * units for the current font size. | | * units for the current font size. | |
| * | | * | |
| * \returns the ascender for this font | | * \returns the ascender for this font | |
| * | | * | |
| * \see GetPdfAscent | | * \see GetPdfAscent | |
| */ | | */ | |
|
| inline double GetAscent() const; | | virtual double GetAscent() const = 0; | |
| | | | |
| /** Get the ascent of this font | | /** Get the ascent of this font | |
| * Used to build the font dictionay | | * Used to build the font dictionay | |
| * \returns the ascender for this font | | * \returns the ascender for this font | |
| * | | * | |
| * \see GetAscent | | * \see GetAscent | |
| */ | | */ | |
|
| inline double GetPdfAscent() const; | | virtual double GetPdfAscent() const = 0; | |
| | | | |
| /** Get the descent of this font in PDF | | /** Get the descent of this font in PDF | |
| * units for the current font size. | | * units for the current font size. | |
| * This value is usually negative! | | * This value is usually negative! | |
| * | | * | |
| * \returns the descender for this font | | * \returns the descender for this font | |
| * | | * | |
| * \see GetPdfDescent | | * \see GetPdfDescent | |
| */ | | */ | |
|
| inline double GetDescent() const; | | virtual double GetDescent() const = 0; | |
| | | | |
| /** Get the descent of this font | | /** Get the descent of this font | |
| * Used to build the font dictionay | | * Used to build the font dictionay | |
| * \returns the descender for this font | | * \returns the descender for this font | |
| * | | * | |
| * \see GetDescent | | * \see GetDescent | |
| */ | | */ | |
|
| inline double GetPdfDescent() const; | | virtual double GetPdfDescent() const = 0; | |
| | | | |
| /** Get the italic angle of this font. | | /** Get the italic angle of this font. | |
| * Used to build the font dictionay | | * Used to build the font dictionay | |
| * \returns the italic angle of this font. | | * \returns the italic angle of this font. | |
| */ | | */ | |
|
| inline int GetItalicAngle() const; | | virtual int GetItalicAngle() const = 0; | |
| | | | |
| /** Set the font size of this metrics object for width and height | | /** Set the font size of this metrics object for width and height | |
| * calculations. | | * calculations. | |
| * This is typically called from PdfFont for you. | | * This is typically called from PdfFont for you. | |
| * | | * | |
| * \param fSize font size in points | | * \param fSize font size in points | |
| */ | | */ | |
|
| void SetFontSize( float fSize ); | | inline void SetFontSize( float fSize ); | |
| | | | |
| /** Retrieve the current font size of this metrics object | | /** Retrieve the current font size of this metrics object | |
| * \returns the current font size | | * \returns the current font size | |
| */ | | */ | |
| inline float GetFontSize() const; | | inline float GetFontSize() const; | |
| | | | |
| /** Set the horizontal scaling of the font for compressing (< 100) and
expanding (>100) | | /** Set the horizontal scaling of the font for compressing (< 100) and
expanding (>100) | |
| * This is typically called from PdfFont for you. | | * This is typically called from PdfFont for you. | |
| * | | * | |
| * \param fScale scaling in percent | | * \param fScale scaling in percent | |
| */ | | */ | |
|
| void SetFontScale( float fScale ); | | inline void SetFontScale( float fScale ); | |
| | | | |
| /** Retrieve the current horizontal scaling of this metrics object | | /** Retrieve the current horizontal scaling of this metrics object | |
| * \returns the current font scaling | | * \returns the current font scaling | |
| */ | | */ | |
| inline float GetFontScale() const; | | inline float GetFontScale() const; | |
| | | | |
| /** Set the character spacing of this metrics object | | /** Set the character spacing of this metrics object | |
| * \param fCharSpace character spacing in percent | | * \param fCharSpace character spacing in percent | |
| */ | | */ | |
|
| void SetFontCharSpace( float fCharSpace ); | | inline void SetFontCharSpace( float fCharSpace ); | |
| | | | |
| /** Retrieve the current character spacing of this metrics object | | /** Retrieve the current character spacing of this metrics object | |
| * \returns the current font character spacing | | * \returns the current font character spacing | |
| */ | | */ | |
| inline float GetFontCharSpace() const; | | inline float GetFontCharSpace() const; | |
| | | | |
| /** | | /** | |
| * \returns the fonttype of the loaded font | | * \returns the fonttype of the loaded font | |
| */ | | */ | |
| inline EPdfFontType GetFontType() const; | | inline EPdfFontType GetFontType() const; | |
| | | | |
| /** Get the glyph id for a unicode character | | /** Get the glyph id for a unicode character | |
| * in the current font. | | * in the current font. | |
| * | | * | |
| * \param lUnicode the unicode character value | | * \param lUnicode the unicode character value | |
| * \returns the glyhph id for the character or 0 if the glyph was not
found. | | * \returns the glyhph id for the character or 0 if the glyph was not
found. | |
| */ | | */ | |
|
| long GetGlyphId( long lUnicode ) const; | | virtual long GetGlyphId( long lUnicode ) const = 0; | |
| | | | |
| /** Get direct access to the internal FreeType handle | | | |
| * | | | |
| * \returns the internal freetype handle | | | |
| */ | | | |
| inline FT_Face GetFace(); | | | |
| | | | |
| /** Symbol fonts do need special treatment in a few cases. | | /** Symbol fonts do need special treatment in a few cases. | |
| * Use this method to check if the current font is a symbol | | * Use this method to check if the current font is a symbol | |
| * font. Symbold fonts are detected by checking | | * font. Symbold fonts are detected by checking | |
| * if they use FT_ENCODING_MS_SYMBOL as internal encoding. | | * if they use FT_ENCODING_MS_SYMBOL as internal encoding. | |
| * | | * | |
| * \returns true if this is a symbol font | | * \returns true if this is a symbol font | |
| */ | | */ | |
|
| inline bool IsSymbol() const; | | virtual bool IsSymbol() const = 0; | |
| | | | |
| private: | | | |
| | | | |
| /** Initialize this object from an in memory buffer | | | |
| * Called internally by the constructors | | | |
| */ | | | |
| void InitFromBuffer(); | | | |
| | | | |
| /** Load the metric data from the FTFace data | | | |
| * Called internally by the constructors | | | |
| */ | | | |
| void InitFromFace(); | | | |
| | | | |
| /** Try to detect the internal fonttype from | | /** Try to detect the internal fonttype from | |
| * the file extension of a fontfile. | | * the file extension of a fontfile. | |
| * | | * | |
|
| * This function will set the member m_eFontType. | | | |
| * | | | |
| * \param pszFilename must be the filename of a font file | | * \param pszFilename must be the filename of a font file | |
|
| | | * | |
| | | * \return font type | |
| */ | | */ | |
|
| void SetFontTypeFromFilename( const char* pszFilename ); | | static EPdfFontType FontTypeFromFilename( const char* pszFilename ); | |
| | | | |
| public: | | | |
| FT_Face m_face; | | | |
| // Peter Petrov 19 March 2009 | | | |
| std::string m_sFilename; | | | |
| | | | |
| protected: | | protected: | |
|
| FT_Library* m_pLibrary; | | /** | |
| | | * Set the fonttype. | |
| private: | | * \param eFontType fonttype | |
| bool m_bSymbol; ///< Internal member to singnal a symbol font | | */ | |
| | | inline void SetFontType(EPdfFontType eFontType); | |
| unsigned int m_nWeight; | | | |
| int m_nItalicAngle; | | | |
| | | | |
| double m_dAscent; | | | |
| double m_dPdfAscent; | | | |
| double m_dDescent; | | | |
| double m_dPdfDescent; | | | |
| | | | |
| double m_dLineSpacing; | | | |
| double m_dUnderlineThickness; | | | |
| double m_dUnderlinePosition; | | | |
| double m_dStrikeOutThickness; | | | |
| double m_dStrikeOutPosition; | | | |
| | | | |
|
| PdfRefCountedBuffer m_bufFontData; | | protected: | |
| | | std::string m_sFilename; | |
| float m_fFontSize; | | float m_fFontSize; | |
| float m_fFontScale; | | float m_fFontScale; | |
| float m_fFontCharSpace; | | float m_fFontCharSpace; | |
| | | | |
| std::vector<double> m_vecWidth; | | std::vector<double> m_vecWidth; | |
| | | | |
| EPdfFontType m_eFontType; | | EPdfFontType m_eFontType; | |
| std::string m_sFontSubsetPrefix; | | std::string m_sFontSubsetPrefix; | |
| }; | | }; | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| double PdfFontMetrics::StringWidth( const PdfString & rsString ) const | | unsigned long PdfFontMetrics::CharWidthMM( unsigned char c ) const | |
| { | | { | |
|
| return (rsString.IsUnicode() ? this->StringWidth( rsString.GetUnicode(
) ) : this->StringWidth( rsString.GetString() )); | | return static_cast<unsigned long>(this->CharWidth( c ) / PODOFO_CONVERS
ION_CONSTANT); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| double PdfFontMetrics::GetLineSpacing() const | | double PdfFontMetrics::StringWidth( const PdfString & rsString ) const | |
| { | | { | |
|
| return m_dLineSpacing; | | return (rsString.IsUnicode() ? this->StringWidth( rsString.GetUnicode(
) ) : this->StringWidth( rsString.GetString() )); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| unsigned long PdfFontMetrics::GetLineSpacingMM() const | | unsigned long PdfFontMetrics::StringWidthMM( const char* pszText, unsigned
int nLength ) const | |
| { | | { | |
|
| return static_cast<unsigned long>(m_dLineSpacing / PODOFO_CONVERSION_CO
NSTANT); | | return static_cast<unsigned long>(this->StringWidth( pszText, nLength )
/ PODOFO_CONVERSION_CONSTANT); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| double PdfFontMetrics::GetUnderlinePosition() const | | unsigned long PdfFontMetrics::StringWidthMM( const pdf_utf16be* pszText, un
signed int nLength ) const | |
| { | | { | |
|
| return m_dUnderlinePosition; | | return static_cast<unsigned long>(this->StringWidth( pszText, nLength )
/ PODOFO_CONVERSION_CONSTANT); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| long PdfFontMetrics::GetUnderlinePositionMM() const | | #ifndef _WCHAR_T_DEFINED | |
| | | #if defined(_MSC_VER) && _MSC_VER <= 1200 // nicht f | |
| | | #else | |
| | | unsigned long PdfFontMetrics::StringWidthMM( const wchar_t* pszText, unsign | |
| | | ed int nLength ) const | |
| { | | { | |
|
| return static_cast<long>(m_dUnderlinePosition / PODOFO_CONVERSION_CONS
TANT); | | return static_cast<unsigned long>(this->StringWidth( pszText, nLength )
/ PODOFO_CONVERSION_CONSTANT); | |
| } | | } | |
|
| | | #endif | |
| | | #endif | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| double PdfFontMetrics::GetStrikeOutPosition() const | | unsigned long PdfFontMetrics::GetLineSpacingMM() const | |
| { | | { | |
|
| return m_dStrikeOutPosition; | | return static_cast<unsigned long>(this->GetLineSpacing() / PODOFO_CONVE
RSION_CONSTANT); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| unsigned long PdfFontMetrics::GetStrikeOutPositionMM() const | | long PdfFontMetrics::GetUnderlinePositionMM() const | |
| { | | { | |
|
| return static_cast<long>(m_dStrikeOutPosition / PODOFO_CONVERSI
ON_CONSTANT); | | return static_cast<long>(this->GetUnderlinePosition() / PODOFO_CONVERS
ION_CONSTANT); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| double PdfFontMetrics::GetUnderlineThickness() const | | unsigned long PdfFontMetrics::GetStrikeOutPositionMM() const | |
| { | | { | |
|
| return m_dUnderlineThickness; | | return static_cast<long>(this->GetStrikeOutPosition() / PODOFO_CONV
ERSION_CONSTANT); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| unsigned long PdfFontMetrics::GetUnderlineThicknessMM() const | | unsigned long PdfFontMetrics::GetUnderlineThicknessMM() const | |
| { | | { | |
|
| return static_cast<unsigned long>(m_dUnderlineThickness / PODOFO_CONVER | | return static_cast<unsigned long>(this->GetUnderlineThickness() / PODOF | |
| SION_CONSTANT); | | O_CONVERSION_CONSTANT); | |
| } | | | |
| | | | |
| // ----------------------------------------------------- | | | |
| // | | | |
| // ----------------------------------------------------- | | | |
| double PdfFontMetrics::GetStrikeoutThickness() const | | | |
| { | | | |
| return m_dStrikeOutThickness; | | | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| unsigned long PdfFontMetrics::GetStrikeoutThicknessMM() const | | unsigned long PdfFontMetrics::GetStrikeoutThicknessMM() const | |
| { | | { | |
|
| return static_cast<unsigned long>(m_dStrikeOutThickness / PODOFO_CONVER
SION_CONSTANT); | | return static_cast<unsigned long>(this->GetStrikeoutThickness() / PODOF
O_CONVERSION_CONSTANT); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| const char* PdfFontMetrics::GetFilename() const | | const char* PdfFontMetrics::GetFilename() const | |
| { | | { | |
| return m_sFilename.c_str(); | | return m_sFilename.c_str(); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| const char* PdfFontMetrics::GetFontData() const | | EPdfFontType PdfFontMetrics::GetFontType() const | |
| { | | | |
| return m_bufFontData.GetBuffer(); | | | |
| } | | | |
| | | | |
| // ----------------------------------------------------- | | | |
| // | | | |
| // ----------------------------------------------------- | | | |
| pdf_long PdfFontMetrics::GetFontDataLen() const | | | |
| { | | | |
| return m_bufFontData.GetSize(); | | | |
| } | | | |
| | | | |
| // ----------------------------------------------------- | | | |
| // | | | |
| // ----------------------------------------------------- | | | |
| unsigned int PdfFontMetrics::GetWeight() const | | | |
| { | | | |
| return m_nWeight; | | | |
| } | | | |
| | | | |
| // ----------------------------------------------------- | | | |
| // | | | |
| // ----------------------------------------------------- | | | |
| double PdfFontMetrics::GetAscent() const | | | |
| { | | | |
| return m_dAscent; | | | |
| } | | | |
| | | | |
| // ----------------------------------------------------- | | | |
| // | | | |
| // ----------------------------------------------------- | | | |
| double PdfFontMetrics::GetPdfAscent() const | | | |
| { | | { | |
|
| return m_dPdfAscent; | | return m_eFontType; | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| double PdfFontMetrics::GetDescent() const | | void PdfFontMetrics::SetFontType(EPdfFontType eFontType) | |
| { | | { | |
|
| return m_dDescent; | | m_eFontType = eFontType; | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| double PdfFontMetrics::GetPdfDescent() const | | float PdfFontMetrics::GetFontSize() const | |
| { | | { | |
|
| return m_dPdfDescent; | | return m_fFontSize; | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| int PdfFontMetrics::GetItalicAngle() const | | void PdfFontMetrics::SetFontSize( float fSize ) | |
| { | | { | |
|
| return m_nItalicAngle; | | m_fFontSize = fSize; | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| EPdfFontType PdfFontMetrics::GetFontType() const | | float PdfFontMetrics::GetFontScale() const | |
| { | | | |
| return m_eFontType; | | | |
| } | | | |
| | | | |
| // ----------------------------------------------------- | | | |
| // | | | |
| // ----------------------------------------------------- | | | |
| float PdfFontMetrics::GetFontSize() const | | | |
| { | | { | |
|
| return m_fFontSize; | | return m_fFontScale; | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| float PdfFontMetrics::GetFontScale() const | | float PdfFontMetrics::GetFontCharSpace() const | |
| { | | { | |
|
| return m_fFontScale; | | return m_fFontCharSpace; | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| float PdfFontMetrics::GetFontCharSpace() const | | const char* PdfFontMetrics::GetSubsetFontnamePrefix() const | |
| { | | { | |
|
| return m_fFontCharSpace; | | return m_sFontSubsetPrefix.c_str(); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| FT_Face PdfFontMetrics::GetFace() | | void PdfFontMetrics::SetFontScale( float fScale ) | |
| { | | { | |
|
| return m_face; | | m_fFontScale = fScale; | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| bool PdfFontMetrics::IsSymbol() const | | void PdfFontMetrics::SetFontCharSpace( float fCharSpace ) | |
| { | | { | |
|
| return m_bSymbol; | | m_fFontCharSpace = fCharSpace; | |
| } | | } | |
| | | | |
| }; | | }; | |
| | | | |
| #endif // _PDF_FONT_METRICS_H_ | | #endif // _PDF_FONT_METRICS_H_ | |
| | | | |
End of changes. 78 change blocks. |
| 219 lines changed or deleted | | 91 lines changed or added | |
|