This object uses the Freetype library to generate text directly into an image. More...
Public Types | |
enum | Alignment { ALeft = 0, ARight = 1, ACenter = 2 } |
Public Member Functions | |
PNMTextMaker (Filename const font_filename, int face_index) | |
The constructor expects the name of some font file that FreeType can read, along with face_index, indicating which font within the file to load (usually 0). | |
PNMTextMaker (PNMTextMaker const copy) | |
PNMTextMaker (string font_data, int data_length, int face_index) | |
This constructor works as above, but it takes the font data from an in-memory buffer instead of from a named file. | |
int | calcWidth (string text) |
Returns the width in pixels of the indicated line of text. | |
int | calcWidth (string text) |
Returns the width in pixels of the indicated line of text. | |
int | generateInto (string text, PNMImage dest_image, int x, int y) |
Generates a single line of text into the indicated image at the indicated position; the return value is the total width in pixels. | |
int | generateInto (string text, PNMImage dest_image, int x, int y) |
Generates a single line of text into the indicated image at the indicated position; the return value is the total width in pixels. | |
Alignment | getAlign () |
VBase4 const | getFg () |
Returns the foreground color of text that will be generated by future calls to generate_into(). | |
PNMTextGlyph | getGlyph (int character) |
Returns the glyph for the indicated index, or NULL if it is not defined in the font. | |
VBase4 const | getInterior () |
Returns the color that will be used to render the interior portions of hollow fonts. | |
bool | getInteriorFlag () |
bool | isValid () |
Returns true if the PNMTextMaker is valid and ready to generate text, false otherwise. | |
setAlign (Alignment align_type) | |
setFg (VBase4 const fg) | |
Sets the foreground color of text that will be generated by future calls to generate_into(). | |
setInterior (VBase4 const interior) | |
Sets the color that will be used to render the interior portions of hollow fonts in future calls to generate_into(). | |
setInteriorFlag (bool interior_flag) | |
Sets the flag that indicates whether the interior of hollow fonts is identified as a preprocess as each glyph is loaded. |
This object uses the Freetype library to generate text directly into an image.
It is different from the TextNode/DynamicTextFont interface, which use the Freetype library to generate text in the scene graph, to be rendered onscreen via the Panda render traversal.
enum Alignment |
PNMTextMaker | ( | Filename const | font_filename, |
int | face_index | ||
) |
The constructor expects the name of some font file that FreeType can read, along with face_index, indicating which font within the file to load (usually 0).
PNMTextMaker | ( | PNMTextMaker const | copy | ) |
PNMTextMaker | ( | string | font_data, |
int | data_length, | ||
int | face_index | ||
) |
This constructor works as above, but it takes the font data from an in-memory buffer instead of from a named file.
int generateInto | ( | string | text, |
PNMImage | dest_image, | ||
int | x, | ||
int | y | ||
) |
Generates a single line of text into the indicated image at the indicated position; the return value is the total width in pixels.
int generateInto | ( | string | text, |
PNMImage | dest_image, | ||
int | x, | ||
int | y | ||
) |
Generates a single line of text into the indicated image at the indicated position; the return value is the total width in pixels.
Returns the foreground color of text that will be generated by future calls to generate_into().
PNMTextGlyph getGlyph | ( | int | character | ) |
Returns the glyph for the indicated index, or NULL if it is not defined in the font.
VBase4 const getInterior | ( | ) |
Returns the color that will be used to render the interior portions of hollow fonts.
bool getInteriorFlag | ( | ) |
bool isValid | ( | ) |
Returns true if the PNMTextMaker is valid and ready to generate text, false otherwise.
Sets the foreground color of text that will be generated by future calls to generate_into().
This is the color that all of the "on" pixels in the font will show as.
setInterior | ( | VBase4 const | interior | ) |
Sets the color that will be used to render the interior portions of hollow fonts in future calls to generate_into().
This is respected only if interior_flag is true.
setInteriorFlag | ( | bool | interior_flag | ) |
Sets the flag that indicates whether the interior of hollow fonts is identified as a preprocess as each glyph is loaded.
If this flag is true, you may specify an interior color along with a fg and bg color when you place text; if the flag is false, the interior color is ignored.
It is generally best to set_native_antialias(0) when using this feature. Also, this works best when the pixel size is not very small.