Browse Source

rename TextMaker to PNMTextMaker

David Rose 24 years ago
parent
commit
8723b8aede

+ 2 - 2
pandaapp/src/indexify/Sources.pp

@@ -15,7 +15,7 @@
     indexify.cxx indexify.h \
     photo.cxx photo.h \
     rollDirectory.cxx rollDirectory.h \
-    textGlyph.cxx textGlyph.h \
-    textMaker.cxx textMaker.h
+    pnmTextGlyph.cxx pnmTextGlyph.h \
+    pnmTextMaker.cxx pnmTextMaker.h
 
 #end bin_target

+ 3 - 3
pandaapp/src/indexify/indexImage.cxx

@@ -19,7 +19,7 @@
 #include "indexImage.h"
 #include "rollDirectory.h"
 #include "photo.h"
-#include "textMaker.h"
+#include "pnmTextMaker.h"
 #include "indexParameters.h"
 #include "pnmImage.h"
 
@@ -88,7 +88,7 @@ add_photo(int photo_index) {
 //               failure.
 ////////////////////////////////////////////////////////////////////
 bool IndexImage::
-generate_images(const Filename &archive_dir, TextMaker *text_maker) {
+generate_images(const Filename &archive_dir, PNMTextMaker *text_maker) {
   int count = _photos.size();
   int num_rows = (count + thumb_count_x - 1) / thumb_count_x;
   int actual_index_height = thumb_y_space + num_rows * (thumb_height + thumb_caption_height + thumb_y_space);
@@ -248,7 +248,7 @@ generate_images(const Filename &archive_dir, TextMaker *text_maker) {
 				 pinfo._x_place + x_center, 
 				 pinfo._y_place + y_center);
       
-      if (text_maker != (TextMaker *)NULL) {
+      if (text_maker != (PNMTextMaker *)NULL) {
 	text_maker->generate_into(photo->get_frame_number(), index_image, 
 				  pinfo._x_place + thumb_width / 2, 
 				  pinfo._y_place + thumb_height + thumb_caption_height);

+ 2 - 2
pandaapp/src/indexify/indexImage.h

@@ -26,7 +26,7 @@
 
 class RollDirectory;
 class Photo;
-class TextMaker;
+class PNMTextMaker;
 class PNMImage;
 class PNMImageHeader;
 
@@ -42,7 +42,7 @@ public:
   ~IndexImage();
 
   bool add_photo(int index);
-  bool generate_images(const Filename &archive_dir, TextMaker *text_maker);
+  bool generate_images(const Filename &archive_dir, PNMTextMaker *text_maker);
   bool generate_html(ostream &root_html, const Filename &archive_dir,
                      const Filename &roll_dir_root);
 

+ 9 - 9
pandaapp/src/indexify/indexify.cxx

@@ -19,7 +19,7 @@
 #include "indexify.h"
 #include "rollDirectory.h"
 #include "notify.h"
-#include "textMaker.h"
+#include "pnmTextMaker.h"
 #include "default_font.h"
 #include "default_index_icons.h"
 #include "indexParameters.h"
@@ -213,7 +213,7 @@ Indexify() {
      &Indexify::dispatch_filename, NULL, &up_icon);
 
   _photo_extension = "jpg";
-  _text_maker = (TextMaker *)NULL;
+  _text_maker = (PNMTextMaker *)NULL;
   _font_aa_factor = 4.0;
 }
 
@@ -230,7 +230,7 @@ Indexify::
     delete roll_dir;
   }
 
-  if (_text_maker != (TextMaker *)NULL) {
+  if (_text_maker != (PNMTextMaker *)NULL) {
     delete _text_maker;
   }
 }
@@ -324,23 +324,23 @@ post_command_line() {
     
   if (caption_font_size != 0) {
     if (!_font_filename.empty()) {
-      _text_maker = new TextMaker(_font_filename, 0);
+      _text_maker = new PNMTextMaker(_font_filename, 0);
       if (!_text_maker->is_valid()) {
 	delete _text_maker;
-	_text_maker = (TextMaker *)NULL;
+	_text_maker = (PNMTextMaker *)NULL;
       }
     }
     
-    if (_text_maker == (TextMaker *)NULL) {
-      _text_maker = new TextMaker(default_font, default_font_size, 0);
+    if (_text_maker == (PNMTextMaker *)NULL) {
+      _text_maker = new PNMTextMaker(default_font, default_font_size, 0);
       if (!_text_maker->is_valid()) {
 	nout << "Unable to open default font.\n";
 	delete _text_maker;
-	_text_maker = (TextMaker *)NULL;
+	_text_maker = (PNMTextMaker *)NULL;
       }
     }
     
-    if (_text_maker != (TextMaker *)NULL) {
+    if (_text_maker != (PNMTextMaker *)NULL) {
       _text_maker->set_pixel_size(caption_font_size, _font_aa_factor);
     }
   }

+ 2 - 2
pandaapp/src/indexify/indexify.h

@@ -26,7 +26,7 @@
 #include "pvector.h"
 
 class RollDirectory;
-class TextMaker;
+class PNMTextMaker;
 
 ////////////////////////////////////////////////////////////////////
 //       Class : Indexify
@@ -57,7 +57,7 @@ public:
   typedef pvector<RollDirectory *> RollDirs;
   RollDirs _roll_dirs;
 
-  TextMaker *_text_maker;
+  PNMTextMaker *_text_maker;
 };
 
 #endif

+ 14 - 14
pandaapp/src/indexify/textGlyph.cxx → pandaapp/src/indexify/pnmTextGlyph.cxx

@@ -1,4 +1,4 @@
-// Filename: textGlyph.cxx
+// Filename: pnmTextGlyph.cxx
 // Created by:  drose (03Apr02)
 //
 ////////////////////////////////////////////////////////////////////
@@ -16,15 +16,15 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#include "textGlyph.h"
+#include "pnmTextGlyph.h"
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextGlyph::Constructor
+//     Function: PNMTextGlyph::Constructor
 //       Access: Public
 //  Description: 
 ////////////////////////////////////////////////////////////////////
-TextGlyph::
-TextGlyph(double advance) : 
+PNMTextGlyph::
+PNMTextGlyph(double advance) : 
   _advance(advance) 
 {
   _left = 0;
@@ -33,21 +33,21 @@ TextGlyph(double advance) :
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextGlyph::Destructor
+//     Function: PNMTextGlyph::Destructor
 //       Access: Public
 //  Description: 
 ////////////////////////////////////////////////////////////////////
-TextGlyph::
-~TextGlyph() {
+PNMTextGlyph::
+~PNMTextGlyph() {
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextGlyph::rescale
+//     Function: PNMTextGlyph::rescale
 //       Access: Public
 //  Description: After the image has been rendered large by FreeType,
 //               scales it small again for placing.
 ////////////////////////////////////////////////////////////////////
-void TextGlyph::
+void PNMTextGlyph::
 rescale(double scale_factor) {
   if (scale_factor == 1.0) {
     return;
@@ -103,23 +103,23 @@ rescale(double scale_factor) {
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextGlyph::get_advance
+//     Function: PNMTextGlyph::get_advance
 //       Access: Public
 //  Description: Returns the number of pixels by which the pen should
 //               be advanced after rendering this glyph.
 ////////////////////////////////////////////////////////////////////
-int TextGlyph::
+int PNMTextGlyph::
 get_advance() const {
   return _int_advance;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextGlyph::place
+//     Function: PNMTextGlyph::place
 //       Access: Public
 //  Description: Copies the glyph to the indicated destination image
 //               at the indicated origin.
 ////////////////////////////////////////////////////////////////////
-void TextGlyph::
+void PNMTextGlyph::
 place(PNMImage &dest_image, int xp, int yp) {
   if (!_image.is_valid()) {
     // If we have no image, do nothing.

+ 9 - 9
pandaapp/src/indexify/textGlyph.h → pandaapp/src/indexify/pnmTextGlyph.h

@@ -1,4 +1,4 @@
-// Filename: textGlyph.h
+// Filename: pnmTextGlyph.h
 // Created by:  drose (03Apr02)
 //
 ////////////////////////////////////////////////////////////////////
@@ -16,21 +16,21 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifndef TEXTGLYPH_H
-#define TEXTGLYPH_H
+#ifndef PNMTEXTGLYPH_H
+#define PNMTEXTGLYPH_H
 
 #include "pandatoolbase.h"
 
 #include "pnmImage.h"
 
 ////////////////////////////////////////////////////////////////////
-//       Class : TextGlyph
-// Description : A single glyph in the font.
+//       Class : PNMTextGlyph
+// Description : A single glyph in a PNMTextMaker.
 ////////////////////////////////////////////////////////////////////
-class TextGlyph {
+class PNMTextGlyph {
 public:
-  TextGlyph(double advance);
-  ~TextGlyph();
+  PNMTextGlyph(double advance);
+  ~PNMTextGlyph();
 
   void rescale(double scale_factor);
   int get_advance() const;
@@ -44,7 +44,7 @@ private:
   double _advance;
   int _int_advance;
 
-  friend class TextMaker;
+  friend class PNMTextMaker;
 };
 
 #endif

+ 39 - 39
pandaapp/src/indexify/textMaker.cxx → pandaapp/src/indexify/pnmTextMaker.cxx

@@ -16,25 +16,25 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#include "textMaker.h"
-#include "textGlyph.h"
+#include "pnmTextMaker.h"
+#include "pnmTextGlyph.h"
 #include "filename.h"
 #include "pnmImage.h"
 
-FT_Library TextMaker::_ft_library;
-bool TextMaker::_ft_initialized = false;
-bool TextMaker::_ft_ok = false;
+FT_Library PNMTextMaker::_ft_library;
+bool PNMTextMaker::_ft_initialized = false;
+bool PNMTextMaker::_ft_ok = false;
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextMaker::Constructor
+//     Function: PNMTextMaker::Constructor
 //       Access: Public
 //  Description: 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).
 ////////////////////////////////////////////////////////////////////
-TextMaker::
-TextMaker(const Filename &font_filename, int face_index) {
+PNMTextMaker::
+PNMTextMaker(const Filename &font_filename, int face_index) {
   _is_valid = false;
 
   if (!_ft_initialized) {
@@ -92,14 +92,14 @@ TextMaker(const Filename &font_filename, int face_index) {
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextMaker::Constructor
+//     Function: PNMTextMaker::Constructor
 //       Access: Public
 //  Description: This constructor works as above, but it takes the
 //               font data from an in-memory buffer instead of from a
 //               named file.
 ////////////////////////////////////////////////////////////////////
-TextMaker::
-TextMaker(const char *font_data, int font_data_size, int face_index) {
+PNMTextMaker::
+PNMTextMaker(const char *font_data, int font_data_size, int face_index) {
   _is_valid = false;
 
   if (!_ft_initialized) {
@@ -144,12 +144,12 @@ TextMaker(const char *font_data, int font_data_size, int face_index) {
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextMaker::Destructor
+//     Function: PNMTextMaker::Destructor
 //       Access: Public
 //  Description: 
 ////////////////////////////////////////////////////////////////////
-TextMaker::
-~TextMaker() {
+PNMTextMaker::
+~PNMTextMaker() {
   empty_cache();
 
   if (_is_valid) {
@@ -159,18 +159,18 @@ TextMaker::
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextMaker::is_valid
+//     Function: PNMTextMaker::is_valid
 //       Access: Public
-//  Description: Returns true if the TextMaker is valid and ready to
+//  Description: Returns true if the PNMTextMaker is valid and ready to
 //               generate text, false otherwise.
 ////////////////////////////////////////////////////////////////////
-bool TextMaker::
+bool PNMTextMaker::
 is_valid() const {
   return _is_valid;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextMaker::set_pixel_size
+//     Function: PNMTextMaker::set_pixel_size
 //       Access: Public
 //  Description: Specifies the pixel size of the font to use to
 //               generate future text.  If the scale_factor is
@@ -185,7 +185,7 @@ is_valid() const {
 //               scale_factor to produce the requested pixel_size
 //               output from the closest matching input size.
 ////////////////////////////////////////////////////////////////////
-void TextMaker::
+void PNMTextMaker::
 set_pixel_size(int pixel_size, double scale_factor) {
   nassertv(_is_valid);
   reset_scale(pixel_size, scale_factor);
@@ -193,20 +193,20 @@ set_pixel_size(int pixel_size, double scale_factor) {
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextMaker::generate_into
+//     Function: PNMTextMaker::generate_into
 //       Access: Public
 //  Description: Generates text into the indicated image at the
 //               indicated position.  Currently, text is centered
 //               horizontally, with the baseline on the y position.
 ////////////////////////////////////////////////////////////////////
-void TextMaker::
+void PNMTextMaker::
 generate_into(const string &text, PNMImage &dest_image, int x, int y) {
   // First, measure the total width in pixels, so we can center.
   int width = 0;
   string::const_iterator ti;
   for (ti = text.begin(); ti != text.end(); ++ti) {
     int ch = (unsigned char)(*ti);
-    TextGlyph *glyph = get_glyph(ch);
+    PNMTextGlyph *glyph = get_glyph(ch);
     width += glyph->get_advance();
   }
 
@@ -216,19 +216,19 @@ generate_into(const string &text, PNMImage &dest_image, int x, int y) {
   // Now place the text.
   for (ti = text.begin(); ti != text.end(); ++ti) {
     int ch = (unsigned char)(*ti);
-    TextGlyph *glyph = get_glyph(ch);
+    PNMTextGlyph *glyph = get_glyph(ch);
     glyph->place(dest_image, xp, yp);
     xp += glyph->get_advance();
   }
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextMaker::get_glyph
+//     Function: PNMTextMaker::get_glyph
 //       Access: Private
 //  Description: Returns the glyph for the indicated index, or NULL if
 //               it is not defined in the font.
 ////////////////////////////////////////////////////////////////////
-TextGlyph *TextMaker::
+PNMTextGlyph *PNMTextMaker::
 get_glyph(int character) {
   int glyph_index = FT_Get_Char_Index(_face, character);
 
@@ -238,23 +238,23 @@ get_glyph(int character) {
     return (*gi).second;
   }
 
-  TextGlyph *glyph = make_glyph(glyph_index);
+  PNMTextGlyph *glyph = make_glyph(glyph_index);
   _glyphs.insert(Glyphs::value_type(glyph_index, glyph));
   return glyph;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextMaker::make_glyph
+//     Function: PNMTextMaker::make_glyph
 //       Access: Private
-//  Description: Creates a new TextGlyph object for the indicated
+//  Description: Creates a new PNMTextGlyph object for the indicated
 //               index, if possible.
 ////////////////////////////////////////////////////////////////////
-TextGlyph *TextMaker::
+PNMTextGlyph *PNMTextMaker::
 make_glyph(int glyph_index) {
   int error = FT_Load_Glyph(_face, glyph_index, FT_LOAD_RENDER);
   if (error) {
     nout << "Unable to render glyph " << glyph_index << "\n";
-    return (TextGlyph *)NULL;
+    return (PNMTextGlyph *)NULL;
   }
 
   FT_GlyphSlot slot = _face->glyph;
@@ -264,12 +264,12 @@ make_glyph(int glyph_index) {
 
   if (bitmap.width == 0 || bitmap.rows == 0) {
     // If we got an empty bitmap, it's a special case.
-    TextGlyph *glyph = new TextGlyph(advance);
+    PNMTextGlyph *glyph = new PNMTextGlyph(advance);
     glyph->rescale(_scale_factor);
     return glyph;
 
   } else {
-    TextGlyph *glyph = new TextGlyph(advance);
+    PNMTextGlyph *glyph = new PNMTextGlyph(advance);
     PNMImage &glyph_image = glyph->_image;
     glyph_image.clear(bitmap.width, bitmap.rows, 1);
 
@@ -322,12 +322,12 @@ make_glyph(int glyph_index) {
 }
  
 ////////////////////////////////////////////////////////////////////
-//     Function: TextMaker::reset_scale
+//     Function: PNMTextMaker::reset_scale
 //       Access: Private
 //  Description: Sets the font to use the appropriate scale pixels,
 //               and sets _scale_factor accordingly.
 ////////////////////////////////////////////////////////////////////
-bool TextMaker::
+bool PNMTextMaker::
 reset_scale(int pixel_size, double scale_factor) {
   _scale_factor = scale_factor;
   int want_pixel_size = (int)(pixel_size * _scale_factor + 0.5);
@@ -372,26 +372,26 @@ reset_scale(int pixel_size, double scale_factor) {
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextMaker::empty_cache
+//     Function: PNMTextMaker::empty_cache
 //       Access: Private
 //  Description: Empties the cache of previously-generated glyphs.
 ////////////////////////////////////////////////////////////////////
-void TextMaker::
+void PNMTextMaker::
 empty_cache() {
   Glyphs::iterator gi;
   for (gi = _glyphs.begin(); gi != _glyphs.end(); ++gi) {
-    TextGlyph *glyph = (*gi).second;
+    PNMTextGlyph *glyph = (*gi).second;
     delete glyph;
   }
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: TextMaker::initialize_ft_library
+//     Function: PNMTextMaker::initialize_ft_library
 //       Access: Private, Static
 //  Description: Should be called exactly once to initialize the
 //               FreeType library.
 ////////////////////////////////////////////////////////////////////
-void TextMaker::
+void PNMTextMaker::
 initialize_ft_library() {
   if (!_ft_initialized) {
     int error = FT_Init_FreeType(&_ft_library);

+ 12 - 12
pandaapp/src/indexify/textMaker.h → pandaapp/src/indexify/pnmTextMaker.h

@@ -1,4 +1,4 @@
-// Filename: textMaker.h
+// Filename: pnmTextMaker.h
 // Created by:  drose (03Apr02)
 //
 ////////////////////////////////////////////////////////////////////
@@ -16,8 +16,8 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifndef TEXTMAKER_H
-#define TEXTMAKER_H
+#ifndef PNMTEXTMAKER_H
+#define PNMTEXTMAKER_H
 
 #include "pandatoolbase.h"
 #include "pmap.h"
@@ -28,18 +28,18 @@
 
 class Filename;
 class PNMImage;
-class TextGlyph;
+class PNMTextGlyph;
 
 ////////////////////////////////////////////////////////////////////
-//       Class : TextMaker
+//       Class : PNMTextMaker
 // Description : An object that uses Freetype to generate text at a
 //               fixed pixel size into a PNMImage.
 ////////////////////////////////////////////////////////////////////
-class TextMaker : public Namable {
+class PNMTextMaker : public Namable {
 public:
-  TextMaker(const Filename &font_filename, int face_index);
-  TextMaker(const char *font_data, int font_data_size, int face_index);
-  ~TextMaker();
+  PNMTextMaker(const Filename &font_filename, int face_index);
+  PNMTextMaker(const char *font_data, int font_data_size, int face_index);
+  ~PNMTextMaker();
 
   bool is_valid() const;
 
@@ -49,8 +49,8 @@ public:
                      PNMImage &dest_image, int x, int y);
 
 private:
-  TextGlyph *get_glyph(int character);
-  TextGlyph *make_glyph(int glyph_index);
+  PNMTextGlyph *get_glyph(int character);
+  PNMTextGlyph *make_glyph(int glyph_index);
   bool reset_scale(int pixel_size, double scale_factor);
   void empty_cache();
 
@@ -58,7 +58,7 @@ private:
 
   bool _is_valid;
 
-  typedef pmap<int, TextGlyph *> Glyphs;
+  typedef pmap<int, PNMTextGlyph *> Glyphs;
   Glyphs _glyphs;
 
   FT_Face _face;

+ 1 - 1
pandaapp/src/indexify/rollDirectory.cxx

@@ -273,7 +273,7 @@ get_index_image(int n) const {
 //               success, false on failure.
 ////////////////////////////////////////////////////////////////////
 bool RollDirectory::
-generate_images(const Filename &archive_dir, TextMaker *text_maker) {
+generate_images(const Filename &archive_dir, PNMTextMaker *text_maker) {
   nassertr(!_index_images.empty(), false);
 
   IndexImages::iterator ii;

+ 2 - 2
pandaapp/src/indexify/rollDirectory.h

@@ -26,7 +26,7 @@
 
 class Photo;
 class IndexImage;
-class TextMaker;
+class PNMTextMaker;
 
 ////////////////////////////////////////////////////////////////////
 //       Class : RollDirectory
@@ -52,7 +52,7 @@ public:
   int get_num_index_images() const;
   IndexImage *get_index_image(int n) const;
 
-  bool generate_images(const Filename &archive_dir, TextMaker *text_maker);
+  bool generate_images(const Filename &archive_dir, PNMTextMaker *text_maker);
   bool generate_html(ostream &root_html, const Filename &archive_dir,
                      const Filename &roll_dir_root);