00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TEXTFONT_H
00020 #define TEXTFONT_H
00021
00022 #include "pandabase.h"
00023
00024 #include "config_text.h"
00025 #include "typedReferenceCount.h"
00026 #include "namable.h"
00027 #include "pmap.h"
00028
00029 class Node;
00030 class TextGlyph;
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 class EXPCL_PANDA TextFont : public TypedReferenceCount, public Namable {
00043 public:
00044 TextFont();
00045
00046 PUBLISHED:
00047 virtual ~TextFont();
00048
00049 INLINE bool is_valid() const;
00050 INLINE float get_line_height() const;
00051 INLINE void set_line_height(float line_height);
00052
00053 INLINE float get_space_advance() const;
00054 INLINE void set_space_advance(float space_advance);
00055
00056 float calc_width(int character);
00057 float calc_width(const string &line);
00058 string wordwrap_to(const string &text, float wordwrap_width,
00059 bool preserve_trailing_whitespace);
00060
00061 virtual void write(ostream &out, int indent_level) const;
00062
00063 public:
00064 float calc_width(const wstring &line);
00065 wstring wordwrap_to(const wstring &text, float wordwrap_width,
00066 bool preserve_trailing_whitespace);
00067
00068 virtual bool get_glyph(int character, const TextGlyph *&glyph)=0;
00069
00070 protected:
00071 bool _is_valid;
00072 float _line_height;
00073 float _space_advance;
00074
00075 public:
00076 static TypeHandle get_class_type() {
00077 return _type_handle;
00078 }
00079 static void init_type() {
00080 TypedReferenceCount::init_type();
00081 register_type(_type_handle, "TextFont",
00082 TypedReferenceCount::get_class_type());
00083 }
00084 virtual TypeHandle get_type() const {
00085 return get_class_type();
00086 }
00087 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00088
00089 private:
00090 static TypeHandle _type_handle;
00091 };
00092
00093 #include "textFont.I"
00094
00095 #endif