Panda3D
|
This object uses the Freetype library to generate text directly into an image. More...
#include "pnmTextMaker.h"
Public Types | |
enum | Alignment { A_left, A_right, A_center } |
Public Member Functions | |
PNMTextMaker (const Filename &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 (const char *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. | |
PNMTextMaker (const PNMTextMaker ©) | |
int | calc_width (const string &text) |
Returns the width in pixels of the indicated line of text. | |
int | calc_width (const wstring &text) |
Returns the width in pixels of the indicated line of text. | |
int | generate_into (const 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 | generate_into (const wstring &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 | get_align () const |
const LColor & | get_fg () const |
Returns the foreground color of text that will be generated by future calls to generate_into(). | |
PNMTextGlyph * | get_glyph (int character) |
Returns the glyph for the indicated index, or NULL if it is not defined in the font. | |
const LColor & | get_interior () const |
Returns the color that will be used to render the interior portions of hollow fonts. | |
bool | get_interior_flag () const |
bool | is_valid () const |
Returns true if the PNMTextMaker is valid and ready to generate text, false otherwise. | |
void | set_align (Alignment align_type) |
void | set_fg (const LColor &fg) |
Sets the foreground color of text that will be generated by future calls to generate_into(). | |
void | set_interior (const LColor &interior) |
Sets the color that will be used to render the interior portions of hollow fonts in future calls to generate_into(). | |
void | set_interior_flag (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.
Definition at line 39 of file pnmTextMaker.h.
PNMTextMaker::PNMTextMaker | ( | const Filename & | 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).
Definition at line 28 of file pnmTextMaker.cxx.
PNMTextMaker::PNMTextMaker | ( | const char * | 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.
Definition at line 41 of file pnmTextMaker.cxx.
int PNMTextMaker::calc_width | ( | const string & | text | ) | [inline] |
Returns the width in pixels of the indicated line of text.
Definition at line 148 of file pnmTextMaker.I.
References TextEncoder::get_wtext(), and TextEncoder::set_text().
Referenced by generate_into().
int PNMTextMaker::calc_width | ( | const wstring & | text | ) |
Returns the width in pixels of the indicated line of text.
Definition at line 124 of file pnmTextMaker.cxx.
References PNMTextGlyph::get_advance(), and get_glyph().
int PNMTextMaker::generate_into | ( | const string & | text, |
PNMImage & | dest_image, | ||
int | x, | ||
int | y | ||
) | [inline] |
Generates a single line of text into the indicated image at the indicated position; the return value is the total width in pixels.
Definition at line 135 of file pnmTextMaker.I.
References TextEncoder::get_wtext(), and TextEncoder::set_text().
int PNMTextMaker::generate_into | ( | const wstring & | 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.
Definition at line 80 of file pnmTextMaker.cxx.
References calc_width(), PNMTextGlyph::get_advance(), get_glyph(), and PNMTextGlyph::place().
const LColor & PNMTextMaker::get_fg | ( | ) | const [inline] |
Returns the foreground color of text that will be generated by future calls to generate_into().
Definition at line 99 of file pnmTextMaker.I.
PNMTextGlyph * PNMTextMaker::get_glyph | ( | int | character | ) |
Returns the glyph for the indicated index, or NULL if it is not defined in the font.
Definition at line 142 of file pnmTextMaker.cxx.
Referenced by calc_width(), and generate_into().
const LColor & PNMTextMaker::get_interior | ( | ) | const [inline] |
Returns the color that will be used to render the interior portions of hollow fonts.
Definition at line 123 of file pnmTextMaker.I.
bool PNMTextMaker::is_valid | ( | ) | const [inline] |
Returns true if the PNMTextMaker is valid and ready to generate text, false otherwise.
Definition at line 23 of file pnmTextMaker.I.
void PNMTextMaker::set_fg | ( | const LColor & | fg | ) | [inline] |
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.
Definition at line 88 of file pnmTextMaker.I.
void PNMTextMaker::set_interior | ( | const LColor & | interior | ) | [inline] |
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.
Definition at line 112 of file pnmTextMaker.I.
void PNMTextMaker::set_interior_flag | ( | bool | interior_flag | ) | [inline] |
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.
Definition at line 62 of file pnmTextMaker.I.