00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef PNMTEXTMAKER_H
00016 #define PNMTEXTMAKER_H
00017
00018 #include "pandabase.h"
00019 #include "pmap.h"
00020 #include "freetypeFont.h"
00021 #include "textEncoder.h"
00022
00023 #include <ft2build.h>
00024 #include FT_FREETYPE_H
00025
00026 class Filename;
00027 class PNMImage;
00028 class PNMTextGlyph;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class EXPCL_PANDA_PNMTEXT PNMTextMaker : public FreetypeFont {
00040 PUBLISHED:
00041 PNMTextMaker(const Filename &font_filename, int face_index);
00042 PNMTextMaker(const char *font_data, int data_length, int face_index);
00043 PNMTextMaker(const PNMTextMaker ©);
00044 ~PNMTextMaker();
00045
00046 enum Alignment {
00047 A_left,
00048 A_right,
00049 A_center,
00050 };
00051
00052 INLINE bool is_valid() const;
00053
00054 INLINE void set_align(Alignment align_type);
00055 INLINE Alignment get_align() const;
00056
00057 INLINE void set_interior_flag(bool interior_flag);
00058 INLINE bool get_interior_flag() const;
00059
00060 INLINE void set_fg(const LColor &fg);
00061 INLINE const LColor &get_fg() const;
00062
00063 INLINE void set_interior(const LColor &interior);
00064 INLINE const LColor &get_interior() const;
00065
00066 INLINE int generate_into(const string &text,
00067 PNMImage &dest_image, int x, int y);
00068 int generate_into(const wstring &text,
00069 PNMImage &dest_image, int x, int y);
00070 INLINE int calc_width(const string &text);
00071 int calc_width(const wstring &text);
00072
00073 PNMTextGlyph *get_glyph(int character);
00074
00075 private:
00076 void initialize();
00077 PNMTextGlyph *make_glyph(int glyph_index);
00078 void empty_cache();
00079
00080 bool _is_valid;
00081
00082 typedef pmap<int, PNMTextGlyph *> Glyphs;
00083 Glyphs _glyphs;
00084
00085 Alignment _align;
00086 bool _interior_flag;
00087 LColor _fg;
00088 LColor _interior;
00089 };
00090
00091 #include "pnmTextMaker.I"
00092
00093 #endif