Panda3D

staticTextFont.h

00001 // Filename: staticTextFont.h
00002 // Created by:  drose (03May01)
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 STATICTEXTFONT_H
00016 #define STATICTEXTFONT_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "config_text.h"
00021 #include "textFont.h"
00022 #include "textGlyph.h"
00023 #include "pandaNode.h"
00024 #include "geom.h"
00025 #include "geom.h"
00026 #include "pointerTo.h"
00027 #include "pmap.h"
00028 
00029 class Node;
00030 class GeomPoint;
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //       Class : StaticTextFont
00034 // Description : A StaticTextFont is loaded up from a model that was
00035 //               previously generated via egg-mkfont, and contains all
00036 //               of its glyphs already generated and available for
00037 //               use.  It doesn't require linking with any external
00038 //               libraries like FreeType.
00039 ////////////////////////////////////////////////////////////////////
00040 class EXPCL_PANDA_TEXT StaticTextFont : public TextFont {
00041 PUBLISHED:
00042   StaticTextFont(PandaNode *font_def);
00043 
00044   virtual PT(TextFont) make_copy() const;
00045 
00046   virtual void write(ostream &out, int indent_level) const;
00047 
00048 public:
00049   virtual bool get_glyph(int character, const TextGlyph *&glyph);
00050 
00051 private:
00052   void find_character_gsets(PandaNode *root, CPT(Geom) &ch, CPT(Geom) &dot,
00053                             const RenderState *&state,
00054                             const RenderState *net_state);
00055   void find_characters(PandaNode *root,
00056                        const RenderState *net_state);
00057 
00058   typedef pmap<int, PT(TextGlyph)> Glyphs;
00059   Glyphs _glyphs;
00060   PN_stdfloat _font_height;
00061   PT(PandaNode) _font;
00062 
00063 public:
00064   static TypeHandle get_class_type() {
00065     return _type_handle;
00066   }
00067   static void init_type() {
00068     TextFont::init_type();
00069     register_type(_type_handle, "StaticTextFont",
00070                   TextFont::get_class_type());
00071   }
00072   virtual TypeHandle get_type() const {
00073     return get_class_type();
00074   }
00075   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00076 
00077 private:
00078   static TypeHandle _type_handle;
00079 };
00080 
00081 #include "staticTextFont.I"
00082 
00083 #endif
 All Classes Functions Variables Enumerations