|
#include <Font.h>
Public Types | |
| enum | StandardType1Font { e_times_roman = 0, e_times_bold, e_times_italic, e_times_bold_italic, e_helvetica, e_helvetica_bold, e_helvetica_oblique, e_helvetica_bold_oblique, e_courier, e_courier_bold, e_courier_oblique, e_courier_bold_oblique, e_symbol, e_zapf_dingbats, e_null } |
| enum | Type { e_Type1, e_TrueType, e_MMType1, e_Type3, e_Type0, e_CIDType0, e_CIDType2 } |
Public Member Functions | |
| Font (SDF::Obj font_dict=0) | |
| Create a PDF::Font object from an existing SDF font object that is embedded in the document. | |
| Font (const Font &c) | |
| Font & | operator= (const Font &c) |
| Type | GetType () |
| |
| bool | IsSimple () |
| |
| SDF::Obj | GetSDFObj () |
| |
| SDF::Obj | GetDescriptor () |
| |
| const char * | GetName () |
| |
| const char * | GetFamilyName () |
| |
| bool | IsFixedWidth () |
| |
| bool | IsSerif () |
| |
| bool | IsSymbolic () |
| |
| bool | IsItalic () |
| |
| bool | IsAllCap () |
| |
| bool | IsForceBold () |
| |
| bool | IsHorizontalMode () |
| |
| double | GetWidth (UInt char_code) |
| |
| double | GetMaxWidth () |
| |
| double | GetMissingWidth () |
| |
| Common::Iterator< UInt > | GetCharCodeIterator () |
| GetCharCodeIterator represents an iterator interface used to traverse a list of char codes for which there is a glyph outline in the embedded font. | |
| bool | GetGlyphPath (UInt char_code, std::vector< UChar > &out_oprs, std::vector< double > &out_data, bool conics2cubics, Common::Matrix2D *transform=0) |
| The function retrieves the glyph outline for a given character code. | |
| bool | MapToUnicode (UInt char_code, Unicode *out_uni_arr, const int in_uni_sz, int &out_chars) |
| Maps the encoding specific 'charcode' to Unicode. | |
| const char ** | GetEncoding () |
| |
| bool | IsEmbedded () |
| Tests whether or not the specified font is stored as a font file in a stream embedded in the PDF file. | |
| const char * | GetEmbeddedFontName () |
| |
| SDF::Obj | GetEmbeddedFont () |
| |
| int | GetEmbeddedFontBufSize () |
| |
| UShort | GetUnitsPerEm () |
| |
| Rect | GetBBox () |
| |
| double | GetAscent () |
| The face's ascender is the vertical distance from the baseline to the topmost point of any glyph in the face. | |
| double | GetDescent () |
| The face's descender is the vertical distance from the baseline to the bottommost point of any glyph in the face. | |
| int | GetStandardType1FontType () |
| |
| bool | IsCFF () |
| |
| Common::Matrix2D | GetType3FontMatrix () |
| |
| SDF::Obj | GetType3GlyphStream (UInt char_code) |
| |
| double | GetVerticalAdvance (UInt char_code, double &out_pos_vect_x, double &out_pos_vect_y) |
| |
| Font | GetDescendant () |
| |
| UInt | MapToCID (UInt char_code) |
| |
| int | MapToCID (const UChar *char_data, int char_data_avail, UInt &out_charcode, UInt &out_cid) |
| The function maps charcode (out_charcode) from char_data buffer to a CID (out_cid) and return the number of bytes representing the CID in the buffer. | |
Static Public Member Functions | |
| static Font | Create (SDF::SDFDoc &doc, StandardType1Font type) |
| Create a PDF::Font object for the given standard (also known as base 14 font). | |
| static Font | CreateTrueTypeFont (SDF::SDFDoc &doc, const UString &font_path, bool embed=true, bool subset=true) |
| Embed an external TrueType font in the document as a Simple font. | |
| static Font | CreateCIDTrueTypeFont (SDF::SDFDoc &doc, const UString &font_path, bool embed=true, bool subset=true, const char *encoding="Identity-H") |
| Create a TrueType PDF font with the characteristics specified in the LOGFONT structure. | |
| static Font | CreateType1Font (SDF::SDFDoc &doc, const UString &font_path, bool embed=true) |
| Create a CID TrueType PDF font with the characteristics specified in the LOGFONT structure. | |
| static Type | GetType (SDF::Obj font_dict) |
| |
It corresponds to a Font Resource in a PDF file. More than one page may reference the same Font object. A Font has a number of attributes, including an array of widths, the character encoding, and the font’s resource name.
PDF document can contain several different types of fonts and Font class represents a single, flat interface around all PDF font types.
There are two main classes of fonts in PDF: simple and composite fonts.
Simple fonts are Type1, TrueType, and Type3 fonts. All simple fonts have the following properties:
A composite font is one whose glyphs are obtained from a font like object called a CIDFont (e.g. CIDType0Font and CIDType0Font). A composite font is represented by a font dictionary whose Subtype value is Type0. The Type 0 font is known as the root font, while its associated CIDFont is called its descendant. CID-keyed fonts provide a convenient and efficient method for defining multiple-byte character encodings and fonts with a large number of glyphs. These capabilities provide great flexibility for representing text in writing systems for languages with large character sets, such as Chinese, Japanese, and Korean (CJK).
| pdftron::PDF::Font::Font | ( | SDF::Obj | font_dict = 0 |
) |
| pdftron::PDF::Font::Font | ( | const Font & | c | ) |
| static Font pdftron::PDF::Font::Create | ( | SDF::SDFDoc & | doc, | |
| StandardType1Font | type | |||
| ) | [static] |
Create a PDF::Font object for the given standard (also known as base 14 font).
| static Font pdftron::PDF::Font::CreateTrueTypeFont | ( | SDF::SDFDoc & | doc, | |
| const UString & | font_path, | |||
| bool | embed = true, |
|||
| bool | subset = true | |||
| ) | [static] |
Embed an external TrueType font in the document as a Simple font.
| doc | Document in which the external font should be embedded. | |
| font_path | Path to the external font file. | |
| embed | A boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'. | |
| subset | A boolean indicating whether the embedded font should be subsetted. |
| static Font pdftron::PDF::Font::CreateCIDTrueTypeFont | ( | SDF::SDFDoc & | doc, | |
| const UString & | font_path, | |||
| bool | embed = true, |
|||
| bool | subset = true, |
|||
| const char * | encoding = "Identity-H" | |||
| ) | [static] |
Create a TrueType PDF font with the characteristics specified in the LOGFONT structure.
| doc | Document in which the external font should be embedded. | |
| logfont | A pointer to a Windows LOGFONT structure that defines the characteristics of the logical font. | |
| embed | A boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'. | |
| subset | A boolean indicating whether the embedded font should be subsetted. |
| doc | - document in which the external font should be embedded. | |
| font_path | - path to the external font file. | |
| embed | - a boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'. | |
| subset | - a boolean indicating whether the embedded font should be subsetted |
| static Font pdftron::PDF::Font::CreateType1Font | ( | SDF::SDFDoc & | doc, | |
| const UString & | font_path, | |||
| bool | embed = true | |||
| ) | [static] |
Create a CID TrueType PDF font with the characteristics specified in the LOGFONT structure.
| doc | - document in which the external font should be embedded. | |
| logfont | A pointer to a Windows LOGFONT structure that defines the characteristics of the logical font. | |
| embed | - a boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'. | |
| subset | - a boolean indicating whether the embedded font should be subsetted |
| doc | - document in which the external font should be embedded. | |
| font_path | - path to the external font file. | |
| embed | - a boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'. |
| bool pdftron::PDF::Font::IsSimple | ( | ) |
All simple fonts have the following properties:
| SDF::Obj pdftron::PDF::Font::GetDescriptor | ( | ) |
| const char* pdftron::PDF::Font::GetName | ( | ) |
| const char* pdftron::PDF::Font::GetFamilyName | ( | ) |
This is an ASCII string, usually in English, which describes the typeface's family (like 'Times New Roman', 'Bodoni', 'Garamond', etc). This is a least common denominator used to list fonts.
| bool pdftron::PDF::Font::IsFixedWidth | ( | ) |
| bool pdftron::PDF::Font::IsSerif | ( | ) |
| bool pdftron::PDF::Font::IsSymbolic | ( | ) |
| bool pdftron::PDF::Font::IsItalic | ( | ) |
| bool pdftron::PDF::Font::IsAllCap | ( | ) |
| bool pdftron::PDF::Font::IsForceBold | ( | ) |
| bool pdftron::PDF::Font::IsHorizontalMode | ( | ) |
| double pdftron::PDF::Font::GetWidth | ( | UInt | char_code | ) |
The function gets the advance width of the font glyph. The advance width is the amount by which the current point advances when the glyph is drawn. The advance width may not correspond to the visible width of the glyph and for this reason, the advance width cannot be used to determine the glyphs’ bounding boxes.
| double pdftron::PDF::Font::GetMaxWidth | ( | ) |
| double pdftron::PDF::Font::GetMissingWidth | ( | ) |
| Common::Iterator<UInt> pdftron::PDF::Font::GetCharCodeIterator | ( | ) |
GetCharCodeIterator represents an iterator interface used to traverse a list of char codes for which there is a glyph outline in the embedded font.
| bool pdftron::PDF::Font::GetGlyphPath | ( | UInt | char_code, | |
| std::vector< UChar > & | out_oprs, | |||
| std::vector< double > & | out_data, | |||
| bool | conics2cubics, | |||
| Common::Matrix2D * | transform = 0 | |||
| ) |
The function retrieves the glyph outline for a given character code.
| char_code | character to query | |
| out_oprs | a vector of operators. The array is filled in by the method. | |
| out_data | a vector of data points that represent arguments for operators. The array is filled in by the method. | |
| conics2cubics | if set to true converts all quadratic Bezier curves to cubic Beziers, otherwise no conversion is performed. | |
| An | optional matrix used to transform glyph data coordinates. If null/unspecified, glyph data points will not be transformed. |
This function is not applicable to Type3 font and will throw an exception. Use GetType3GlyphStream instead.
| bool pdftron::PDF::Font::MapToUnicode | ( | UInt | char_code, | |
| Unicode * | out_uni_arr, | |||
| const int | in_uni_sz, | |||
| int & | out_chars | |||
| ) |
Maps the encoding specific 'charcode' to Unicode.
Conversion of 'charcode' to Unicode can result in up to four Unicode characters.
| char_code | encoding specific 'charcode' that needs to be converted to Unicode. | |
| out_uni_arr | A pointer to an array of Unicode characters where the conversion result will be stored. | |
| in_uni_sz | The number of characters that can be written to out_uni_arr. You can assume that the function will never map to more than 10 characters. | |
| out_char_num | The function will modify this value to return the number of Unicode characters written in 'out_uni_arr' array. |
| const char** pdftron::PDF::Font::GetEncoding | ( | ) |
The array contains 256 pointers. If a pointer is not NULL, it points to a C string containing the name of the glyph for the code point corresponding to the index. If it is NULL, then the name of the glyph is unchanged from that specified by the font's built-in encoding.
For a Type 3 font, all glyph names will be present in the encoding array, and NULL entries correspond to unencoded code points.
This function is not applicable to composite fonts (e_type0, e_CIDType0, and e_CIDType2) and will throw an exception.
| bool pdftron::PDF::Font::IsEmbedded | ( | ) |
Tests whether or not the specified font is stored as a font file in a stream embedded in the PDF file.
| const char* pdftron::PDF::Font::GetEmbeddedFontName | ( | ) |
If the embedded font name is not available the function returns the empty string .
| SDF::Obj pdftron::PDF::Font::GetEmbeddedFont | ( | ) |
| int pdftron::PDF::Font::GetEmbeddedFontBufSize | ( | ) |
This function is not applicable to Type3 font and will throw exception.
| UShort pdftron::PDF::Font::GetUnitsPerEm | ( | ) |
This is typically 2048 for TrueType fonts, 1000 for Type1 fonts
This function is not applicable to Type3 font and will throw an exception. Use GetType3FontMatrix instead.
| Rect pdftron::PDF::Font::GetBBox | ( | ) |
This is the smallest rectangle enclosing the shape that would result if all of the glyphs of the font were placed with their origins coincident and then filled.
| double pdftron::PDF::Font::GetAscent | ( | ) |
The face's ascender is the vertical distance from the baseline to the topmost point of any glyph in the face.
This field's value is a positive number, expressed in the glyph coordinate system. For all font types except Type 3, the units of glyph space are one-thousandth of a unit of text space. Some font designs use a value different from 'bbox.yMax'.
| double pdftron::PDF::Font::GetDescent | ( | ) |
The face's descender is the vertical distance from the baseline to the bottommost point of any glyph in the face.
This field's value is a negative number expressed in the glyph coordinate system. For all font types except Type 3, the units of glyph space are one-thousandth of a unit of text space. Some font designs use a value different from 'bbox.yMin'.
| int pdftron::PDF::Font::GetStandardType1FontType | ( | ) |
| bool pdftron::PDF::Font::IsCFF | ( | ) |
| Common::Matrix2D pdftron::PDF::Font::GetType3FontMatrix | ( | ) |
If specified char_code is not found in CharPorcs dictionary the function returns NULL.
| double pdftron::PDF::Font::GetVerticalAdvance | ( | UInt | char_code, | |
| double & | out_pos_vect_x, | |||
| double & | out_pos_vect_y | |||
| ) |
vertical advance is a displacement vector for vertical writing mode (i.e. writing mode 1); its horizontal component is always 0.
| char_code | character to query for vertical advance | |
| out_pos_vect_x | - initialized by the method. horizontal component of the position vector defining the position of the vertical writing mode origin relative to horizontal writing mode origin. | |
| out_pos_vect_y | - initialized by the method. vertical component of the position vector defining the position of the vertical writing mode origin relative to horizontal writing mode origin. |
Relevant only for a Type0 font.
| Font pdftron::PDF::Font::GetDescendant | ( | ) |
| int pdftron::PDF::Font::MapToCID | ( | const UChar * | char_data, | |
| int | char_data_avail, | |||
| UInt & | out_charcode, | |||
| UInt & | out_cid | |||
| ) |
The function maps charcode (out_charcode) from char_data buffer to a CID (out_cid) and return the number of bytes representing the CID in the buffer.
| char_data | the input data buffer containing one or more bytes of input charcode | |
| char_data_avail | the number of bytes in the char_data buffer | |
| out_charcode | the first charcode in char_data buffer. | |
| out_cid | CID corresponding to the out_charcode parsed from char_data buffer. |