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 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 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 FreetypeFont ©) | |
PNMTextMaker (const PNMTextMaker ©) | |
int | calc_width (const std::string &text) |
Returns the width in pixels of the indicated line of text. | |
int | calc_width (const std::wstring &text) |
Returns the width in pixels of the indicated line of text. | |
int | generate_into (const std::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 std::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 |
int | get_distance_field_radius () const |
Returns the radius previously set with set_distance_field_radius, or 0 otherwise. | |
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_distance_field_radius (int radius) |
If this is set to something other than 0, Panda will generate a signed distance field with the given radius. | |
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 35 of file pnmTextMaker.h.
enum PNMTextMaker::Alignment |
Definition at line 43 of file pnmTextMaker.h.
|
explicit |
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.
|
explicit |
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 38 of file pnmTextMaker.cxx.
|
explicit |
Definition at line 62 of file pnmTextMaker.cxx.
PNMTextMaker::PNMTextMaker | ( | const PNMTextMaker & | copy | ) |
Definition at line 47 of file pnmTextMaker.cxx.
PNMTextMaker::~PNMTextMaker | ( | ) |
Definition at line 73 of file pnmTextMaker.cxx.
|
inline |
Returns the width in pixels of the indicated line of text.
Definition at line 134 of file pnmTextMaker.I.
References calc_width(), TextEncoder::get_wtext(), and TextEncoder::set_text.
Referenced by calc_width(), and generate_into().
int PNMTextMaker::calc_width | ( | const std::wstring & | text | ) |
Returns the width in pixels of the indicated line of text.
Definition at line 123 of file pnmTextMaker.cxx.
References PNMTextGlyph::get_advance(), and get_glyph().
|
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 124 of file pnmTextMaker.I.
References generate_into(), TextEncoder::get_wtext(), and TextEncoder::set_text.
Referenced by generate_into().
int PNMTextMaker::generate_into | ( | const std::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 82 of file pnmTextMaker.cxx.
References calc_width(), PNMTextGlyph::get_advance(), get_glyph(), and PNMTextGlyph::place().
|
inline |
Definition at line 34 of file pnmTextMaker.I.
|
inline |
Returns the radius previously set with set_distance_field_radius, or 0 otherwise.
Definition at line 115 of file pnmTextMaker.I.
|
inline |
Returns the foreground color of text that will be generated by future calls to generate_into().
Definition at line 78 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 139 of file pnmTextMaker.cxx.
Referenced by calc_width(), and generate_into().
|
inline |
Returns the color that will be used to render the interior portions of hollow fonts.
Definition at line 97 of file pnmTextMaker.I.
|
inline |
Definition at line 59 of file pnmTextMaker.I.
|
inline |
Returns true if the PNMTextMaker is valid and ready to generate text, false otherwise.
Definition at line 18 of file pnmTextMaker.I.
|
inline |
Definition at line 26 of file pnmTextMaker.I.
|
inline |
If this is set to something other than 0, Panda will generate a signed distance field with the given radius.
Definition at line 106 of file pnmTextMaker.I.
|
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 69 of file pnmTextMaker.I.
|
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 88 of file pnmTextMaker.I.
|
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 48 of file pnmTextMaker.I.