Panda3D

eggMakeFont.h

00001 // Filename: eggMakeFont.h
00002 // Created by:  drose (16Feb01)
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 #ifndef EGGMAKEFONT_H
00016 #define EGGMAKEFONT_H
00017 
00018 #include "pandatoolbase.h"
00019 #include "rangeDescription.h"
00020 
00021 #include "eggWriter.h"
00022 #include "eggTexture.h"
00023 #include "pmap.h"
00024 #include "pvector.h"
00025 #include "vector_string.h"
00026 
00027 class PNMTextMaker;
00028 class PNMTextGlyph;
00029 class EggVertexPool;
00030 class EggGroup;
00031 class TextureImage;
00032 
00033 ////////////////////////////////////////////////////////////////////
00034 //       Class : EggMakeFont
00035 // Description : This program uses FreeType to generate an egg file
00036 //               and a series of texture images from a font file
00037 //               input, such as a TTF file.  The resulting egg file
00038 //               can be loaded in Panda as a StaticTextFont object for
00039 //               rendering text, even if FreeType is not compiled into
00040 //               the executing Panda.
00041 ////////////////////////////////////////////////////////////////////
00042 class EggMakeFont : public EggWriter {
00043 public:
00044   EggMakeFont();
00045 
00046 protected:
00047   virtual bool handle_args(Args &args);
00048 
00049 public:
00050   void run();
00051 
00052 private:
00053   static bool dispatch_range(const string &, const string &arg, void *var);
00054   EggVertex *make_vertex(const LPoint2d &xy);
00055 
00056   void add_character(int code);
00057   void make_geom(PNMTextGlyph *glyph, int character);
00058   EggTexture *get_tref(PNMTextGlyph *glyph, int character);
00059   EggTexture *make_tref(PNMTextGlyph *glyph, int character);
00060   void add_extra_glyphs(const Filename &extra_filename);
00061   void r_add_extra_glyphs(EggGroupNode *egg_group);
00062   static bool is_numeric(const string &str);
00063 
00064 
00065 private:
00066   LColor _fg, _bg, _interior;
00067   bool _got_interior;
00068   RangeDescription _range;
00069   vector_string _extra_filenames;
00070   double _pixels_per_unit;
00071   double _point_size;
00072   double _poly_margin;
00073   int _tex_margin;
00074   double _render_margin;
00075   bool _got_scale_factor;
00076   double _scale_factor;
00077   bool _no_reduce;
00078   bool _no_native_aa;
00079   bool _no_palettize;
00080   int _palette_size[2];
00081 
00082   double _palettize_scale_factor;
00083   Filename _input_font_filename;
00084   int _face_index;
00085   string _output_glyph_pattern;
00086   string _output_palette_pattern;
00087 
00088   PNMTextMaker *_text_maker;
00089   
00090   EggTexture::Format _format;
00091   int _num_channels;
00092   EggVertexPool *_vpool;
00093   EggGroup *_group;
00094 
00095   typedef pmap<PNMTextGlyph *, EggTexture *> TRefs;
00096   TRefs _trefs;
00097 
00098   typedef pvector<TextureImage *> Textures;
00099   Textures _textures;
00100 };
00101 
00102 
00103 #endif
00104 
 All Classes Functions Variables Enumerations