Panda3D

pnmTextMaker.I

00001 // Filename: pnmTextMaker.I
00002 // Created by:  drose (07Sep03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: PNMTextMaker::is_valid
00018 //       Access: Public
00019 //  Description: Returns true if the PNMTextMaker is valid and ready to
00020 //               generate text, false otherwise.
00021 ////////////////////////////////////////////////////////////////////
00022 INLINE bool PNMTextMaker::
00023 is_valid() const {
00024   return _is_valid;
00025 }
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: PNMTextMaker::set_align
00029 //       Access: Published
00030 //  Description:
00031 ////////////////////////////////////////////////////////////////////
00032 INLINE void PNMTextMaker::
00033 set_align(PNMTextMaker::Alignment align_type) {
00034   _align = align_type;
00035 }
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //     Function: PNMTextMaker::get_align
00039 //       Access: Published
00040 //  Description:
00041 ////////////////////////////////////////////////////////////////////
00042 INLINE PNMTextMaker::Alignment PNMTextMaker::
00043 get_align() const {
00044   return _align;
00045 }
00046 
00047 ////////////////////////////////////////////////////////////////////
00048 //     Function: PNMTextMaker::set_interior_flag
00049 //       Access: Published
00050 //  Description: Sets the flag that indicates whether the interior of
00051 //               hollow fonts is identified as a preprocess as each
00052 //               glyph is loaded.  If this flag is true, you may
00053 //               specify an interior color along with a fg and bg
00054 //               color when you place text; if the flag is false, the
00055 //               interior color is ignored.
00056 //
00057 //               It is generally best to set_native_antialias(0) when
00058 //               using this feature.  Also, this works best when the
00059 //               pixel size is not very small.
00060 ////////////////////////////////////////////////////////////////////
00061 INLINE void PNMTextMaker::
00062 set_interior_flag(bool interior_flag) {
00063   if (_interior_flag != interior_flag) {
00064     _interior_flag = interior_flag;
00065     empty_cache();
00066   }
00067 }
00068 
00069 ////////////////////////////////////////////////////////////////////
00070 //     Function: PNMTextMaker::get_interior_flag
00071 //       Access: Published
00072 //  Description:
00073 ////////////////////////////////////////////////////////////////////
00074 INLINE bool PNMTextMaker::
00075 get_interior_flag() const {
00076   return _interior_flag;
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: PNMTextMaker::set_fg
00081 //       Access: Published
00082 //  Description: Sets the foreground color of text that will be
00083 //               generated by future calls to generate_into().  This
00084 //               is the color that all of the "on" pixels in the font
00085 //               will show as.
00086 ////////////////////////////////////////////////////////////////////
00087 INLINE void PNMTextMaker::
00088 set_fg(const LColor &fg) {
00089   _fg = fg;
00090 }
00091 
00092 ////////////////////////////////////////////////////////////////////
00093 //     Function: PNMTextMaker::get_fg
00094 //       Access: Published
00095 //  Description: Returns the foreground color of text that will be
00096 //               generated by future calls to generate_into().
00097 ////////////////////////////////////////////////////////////////////
00098 INLINE const LColor &PNMTextMaker::
00099 get_fg() const {
00100   return _fg;
00101 }
00102 
00103 ////////////////////////////////////////////////////////////////////
00104 //     Function: PNMTextMaker::set_interior
00105 //       Access: Published
00106 //  Description: Sets the color that will be used to render the
00107 //               interior portions of hollow fonts in future calls to
00108 //               generate_into().  This is respected only if
00109 //               interior_flag is true.
00110 ////////////////////////////////////////////////////////////////////
00111 INLINE void PNMTextMaker::
00112 set_interior(const LColor &interior) {
00113   _interior = interior;
00114 }
00115 
00116 ////////////////////////////////////////////////////////////////////
00117 //     Function: PNMTextMaker::get_interior
00118 //       Access: Published
00119 //  Description: Returns the color that will be used to render the
00120 //               interior portions of hollow fonts.
00121 ////////////////////////////////////////////////////////////////////
00122 INLINE const LColor &PNMTextMaker::
00123 get_interior() const {
00124   return _interior;
00125 }
00126 
00127 ////////////////////////////////////////////////////////////////////
00128 //     Function: PNMTextMaker::generate_into
00129 //       Access: Public
00130 //  Description: Generates a single line of text into the indicated
00131 //               image at the indicated position; the return value is
00132 //               the total width in pixels.
00133 ////////////////////////////////////////////////////////////////////
00134 INLINE int PNMTextMaker::
00135 generate_into(const string &text, PNMImage &dest_image, int x, int y) {
00136   TextEncoder encoder;
00137   encoder.set_text(text);
00138   return generate_into(encoder.get_wtext(), dest_image, x, y);
00139 }
00140 
00141 ////////////////////////////////////////////////////////////////////
00142 //     Function: PNMTextMaker::calc_width
00143 //       Access: Public
00144 //  Description: Returns the width in pixels of the indicated line of
00145 //               text.
00146 ////////////////////////////////////////////////////////////////////
00147 INLINE int PNMTextMaker::
00148 calc_width(const string &text) {
00149   TextEncoder encoder;
00150   encoder.set_text(text);
00151   return calc_width(encoder.get_wtext());
00152 }
 All Classes Functions Variables Enumerations