Panda3D
Loading...
Searching...
No Matches
pnmTextMaker.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file pnmTextMaker.I
10 * @author drose
11 * @date 2003-09-07
12 */
13
14/**
15 * Returns true if the PNMTextMaker is valid and ready to generate text, false
16 * otherwise.
17 */
18INLINE bool PNMTextMaker::
19is_valid() const {
20 return _is_valid;
21}
22
23/**
24 *
25 */
26INLINE void PNMTextMaker::
27set_align(PNMTextMaker::Alignment align_type) {
28 _align = align_type;
29}
30
31/**
32 *
33 */
34INLINE PNMTextMaker::Alignment PNMTextMaker::
35get_align() const {
36 return _align;
37}
38
39/**
40 * Sets the flag that indicates whether the interior of hollow fonts is
41 * identified as a preprocess as each glyph is loaded. If this flag is true,
42 * you may specify an interior color along with a fg and bg color when you
43 * place text; if the flag is false, the interior color is ignored.
44 *
45 * It is generally best to set_native_antialias(0) when using this feature.
46 * Also, this works best when the pixel size is not very small.
47 */
48INLINE void PNMTextMaker::
49set_interior_flag(bool interior_flag) {
50 if (_interior_flag != interior_flag) {
51 _interior_flag = interior_flag;
52 empty_cache();
53 }
54}
55
56/**
57 *
58 */
59INLINE bool PNMTextMaker::
60get_interior_flag() const {
61 return _interior_flag;
62}
63
64/**
65 * Sets the foreground color of text that will be generated by future calls to
66 * generate_into(). This is the color that all of the "on" pixels in the font
67 * will show as.
68 */
69INLINE void PNMTextMaker::
70set_fg(const LColor &fg) {
71 _fg = fg;
72}
73
74/**
75 * Returns the foreground color of text that will be generated by future calls
76 * to generate_into().
77 */
78INLINE const LColor &PNMTextMaker::
79get_fg() const {
80 return _fg;
81}
82
83/**
84 * Sets the color that will be used to render the interior portions of hollow
85 * fonts in future calls to generate_into(). This is respected only if
86 * interior_flag is true.
87 */
88INLINE void PNMTextMaker::
89set_interior(const LColor &interior) {
90 _interior = interior;
91}
92
93/**
94 * Returns the color that will be used to render the interior portions of
95 * hollow fonts.
96 */
97INLINE const LColor &PNMTextMaker::
98get_interior() const {
99 return _interior;
100}
101
102/**
103 * If this is set to something other than 0, Panda will generate a signed
104 * distance field with the given radius.
105 */
106INLINE void PNMTextMaker::
107set_distance_field_radius(int distance_field_radius) {
108 _distance_field_radius = distance_field_radius;
109}
110
111/**
112 * Returns the radius previously set with set_distance_field_radius, or 0
113 * otherwise.
114 */
117 return _distance_field_radius;
118}
119
120/**
121 * Generates a single line of text into the indicated image at the indicated
122 * position; the return value is the total width in pixels.
123 */
125generate_into(const std::string &text, PNMImage &dest_image, int x, int y) {
126 TextEncoder encoder;
127 encoder.set_text(text);
128 return generate_into(encoder.get_wtext(), dest_image, x, y);
129}
130
131/**
132 * Returns the width in pixels of the indicated line of text.
133 */
135calc_width(const std::string &text) {
136 TextEncoder encoder;
137 encoder.set_text(text);
138 return calc_width(encoder.get_wtext());
139}
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
Definition pnmImage.h:58
int get_distance_field_radius() const
Returns the radius previously set with set_distance_field_radius, or 0 otherwise.
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 ...
int calc_width(const std::string &text)
Returns the width in pixels of the indicated line of text.
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 g...
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 ...
const LColor & get_fg() const
Returns the foreground color of text that will be generated by 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 ea...
bool is_valid() const
Returns true if the PNMTextMaker is valid and ready to generate text, false otherwise.
const LColor & get_interior() const
Returns the color that will be used to render the interior portions of hollow fonts.
This class can be used to convert text between multiple representations, e.g.
Definition textEncoder.h:33
set_text
Changes the text that is stored in the encoder.
const std::wstring & get_wtext() const
Returns the text associated with the TextEncoder, as a wide-character string.