15 #ifndef DYNAMICTEXTFONT_H 16 #define DYNAMICTEXTFONT_H 18 #include "pandabase.h" 23 #include "freetypeFont.h" 24 #include "dynamicTextGlyph.h" 25 #include "dynamicTextPage.h" 31 #include FT_FREETYPE_H 43 class EXPCL_PANDA_TEXT DynamicTextFont :
public TextFont,
public FreetypeFont {
45 DynamicTextFont(
const Filename &font_filename,
int face_index = 0);
46 DynamicTextFont(
const char *font_data,
int data_length,
int face_index);
47 DynamicTextFont(
const DynamicTextFont ©);
48 virtual ~DynamicTextFont();
50 virtual PT(
TextFont) make_copy()
const;
52 INLINE
const string &get_name()
const;
54 INLINE
bool set_point_size(PN_stdfloat point_size);
55 INLINE PN_stdfloat get_point_size()
const;
57 INLINE
bool set_pixels_per_unit(PN_stdfloat pixels_per_unit);
58 INLINE PN_stdfloat get_pixels_per_unit()
const;
60 INLINE
bool set_scale_factor(PN_stdfloat scale_factor);
61 INLINE PN_stdfloat get_scale_factor()
const;
63 INLINE
void set_native_antialias(
bool native_antialias);
64 INLINE
bool get_native_antialias()
const;
66 INLINE
int get_font_pixel_size()
const;
71 INLINE
void set_texture_margin(
int texture_margin);
72 INLINE
int get_texture_margin()
const;
73 INLINE
void set_poly_margin(PN_stdfloat poly_margin);
74 INLINE PN_stdfloat get_poly_margin()
const;
76 INLINE
void set_page_size(
int x_size,
int y_size);
77 INLINE
int get_page_x_size()
const;
78 INLINE
int get_page_y_size()
const;
80 INLINE
void set_minfilter(SamplerState::FilterType filter);
81 INLINE SamplerState::FilterType get_minfilter()
const;
82 INLINE
void set_magfilter(SamplerState::FilterType filter);
83 INLINE SamplerState::FilterType get_magfilter()
const;
84 INLINE
void set_anisotropic_degree(
int anisotropic_degree);
85 INLINE
int get_anisotropic_degree()
const;
87 INLINE
void set_render_mode(RenderMode render_mode);
88 INLINE RenderMode get_render_mode()
const;
89 INLINE
void set_winding_order(WindingOrder winding_order);
90 INLINE WindingOrder get_winding_order()
const;
92 INLINE
void set_fg(
const LColor &fg);
93 INLINE
const LColor &get_fg()
const;
94 INLINE
void set_bg(
const LColor &bg);
95 INLINE
const LColor &get_bg()
const;
96 INLINE
void set_outline(
const LColor &outline_color, PN_stdfloat outline_width,
97 PN_stdfloat outline_feather);
98 INLINE
const LColor &get_outline_color()
const;
99 INLINE PN_stdfloat get_outline_width()
const;
100 INLINE PN_stdfloat get_outline_feather()
const;
101 INLINE Texture::Format get_tex_format()
const;
103 int get_num_pages()
const;
104 DynamicTextPage *get_page(
int n)
const;
105 MAKE_SEQ(get_pages, get_num_pages, get_page);
107 int garbage_collect();
110 virtual void write(ostream &out,
int indent_level)
const;
117 void update_filters();
118 void determine_tex_format();
119 DynamicTextGlyph *make_glyph(
int character, FT_Face face,
int glyph_index);
120 void copy_bitmap_to_texture(
const FT_Bitmap &bitmap, DynamicTextGlyph *glyph);
121 void copy_pnmimage_to_texture(
const PNMImage &image, DynamicTextGlyph *glyph);
122 void blend_pnmimage_to_texture(
const PNMImage &image, DynamicTextGlyph *glyph,
124 DynamicTextGlyph *slot_glyph(
int character,
int x_size,
int y_size);
126 void render_wireframe_contours(DynamicTextGlyph *glyph);
127 void render_polygon_contours(DynamicTextGlyph *glyph,
bool face,
bool extrude);
129 static int outline_move_to(
const FT_Vector *to,
void *user);
130 static int outline_line_to(
const FT_Vector *to,
void *user);
131 static int outline_conic_to(
const FT_Vector *control,
132 const FT_Vector *to,
void *user);
133 static int outline_cubic_to(
const FT_Vector *control1,
134 const FT_Vector *control2,
135 const FT_Vector *to,
void *user);
139 PN_stdfloat _poly_margin;
140 int _page_x_size, _page_y_size;
142 SamplerState::FilterType _minfilter;
143 SamplerState::FilterType _magfilter;
144 int _anisotropic_degree;
146 RenderMode _render_mode;
147 WindingOrder _winding_order;
149 LColor _fg, _bg, _outline_color;
150 PN_stdfloat _outline_width;
151 PN_stdfloat _outline_feather;
153 Texture::Format _tex_format;
154 bool _needs_image_processing;
170 EmptyGlyphs _empty_glyphs;
176 INLINE ContourPoint(PN_stdfloat px, PN_stdfloat py, PN_stdfloat tx, PN_stdfloat ty);
177 INLINE
void connect_to(
const LVector2 &out);
198 static void init_type() {
199 TextFont::init_type();
200 register_type(_type_handle,
"DynamicTextFont",
201 TextFont::get_class_type());
204 return get_class_type();
206 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
214 INLINE ostream &operator << (ostream &out,
const DynamicTextFont &dtf);
216 #include "dynamicTextFont.I" 218 #endif // HAVE_FREETYPE This is our own Panda specialization on the default STL map.
PN_stdfloat get_space_advance() const
Returns the number of units wide a space is.
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
PN_stdfloat get_line_height() const
Returns the number of units high each line of text is.
An encapsulation of a font; i.e.
This is our own Panda specialization on the default STL vector.
The name of a file, such as a texture file or an Egg file.
A representation of a single glyph (character) from a font.
This is the base class for all three-component vectors and points.
This is a two-component vector offset.
The primary interface to this module.
This is a two-component point in space.
TypeHandle is the identifier used to differentiate C++ class types.
The result of a NurbsCurveEvaluator.
const TextGlyph * get_glyph(int character)
Gets the glyph associated with the given character code, as well as an optional scaling parameter tha...