Panda3D
 All Classes Functions Variables Enumerations
Public Types | Public Member Functions | Static Public Member Functions | List of all members
TextFont Class Referenceabstract

An encapsulation of a font; i.e. More...

#include "textFont.h"

Inheritance diagram for TextFont:
TypedReferenceCount Namable TypedObject ReferenceCount MemoryBase MemoryBase MemoryBase StaticTextFont

Public Types

enum  RenderMode {
  RM_texture, RM_wireframe, RM_polygon, RM_extruded,
  RM_solid, RM_invalid
}
 
enum  WindingOrder { WO_default, WO_left, WO_right, WO_invalid }
 

Public Member Functions

 TextFont (const TextFont &copy)
 
virtual TypeHandle force_init_type ()
 
const TextGlyphget_glyph (int character)
 Gets the glyph associated with the given character code, as well as an optional scaling parameter that should be applied to the glyph's geometry and advance parameters. More...
 
virtual bool get_glyph (int character, const TextGlyph *&glyph)=0
 
TextGlyphget_invalid_glyph ()
 Returns a special glyph that can be used as a placeholder for any character not in the font. More...
 
PN_stdfloat get_line_height () const
 Returns the number of units high each line of text is. More...
 
PN_stdfloat get_space_advance () const
 Returns the number of units wide a space is. More...
 
virtual TypeHandle get_type () const
 
bool is_valid () const
 Returns true if the font is valid and ready to use, false otherwise. More...
 
 operator bool () const
 Returns true if the font is valid and ready to use, false otherwise. More...
 
virtual PT (TextFont) make_copy() const =0
 
void set_line_height (PN_stdfloat line_height)
 Changes the number of units high each line of text is. More...
 
void set_space_advance (PN_stdfloat space_advance)
 Changes the number of units wide a space is. More...
 
virtual void write (ostream &out, int indent_level) const
 
- Public Member Functions inherited from TypedReferenceCount
 TypedReferenceCount (const TypedReferenceCount &copy)
 
void operator= (const TypedReferenceCount &copy)
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
void operator= (const TypedObject &copy)
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 Returns the current reference count. More...
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
void weak_ref (WeakPointerToVoid *ptv)
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref (WeakPointerToVoid *ptv)
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 
- Public Member Functions inherited from Namable
 Namable (const string &initial_name="")
 
 Namable (const Namable &copy)
 
void clear_name ()
 Resets the Namable's name to empty. More...
 
const string & get_name () const
 
bool has_name () const
 Returns true if the Namable has a nonempty name set, false if the name is empty. More...
 
Namableoperator= (const Namable &other)
 
void output (ostream &out) const
 Outputs the Namable. More...
 
void set_name (const string &name)
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
static RenderMode string_render_mode (const string &string)
 Returns the RenderMode value associated with the given string representation, or RM_invalid if the string does not match any known RenderMode value. More...
 
static WindingOrder string_winding_order (const string &string)
 Returns the WindingOrder value associated with the given string representation, or WO_invalid if the string does not match any known WindingOrder value. More...
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from Namable
static TypeHandle get_class_type ()
 
static void init_type ()
 

Detailed Description

An encapsulation of a font; i.e.

a set of glyphs that may be assembled together by a TextNode to represent a string of text.

This is just an abstract interface; see StaticTextFont or DynamicTextFont for an actual implementation.

Definition at line 36 of file textFont.h.

Member Function Documentation

const TextGlyph * TextFont::get_glyph ( int  character)
inline

Gets the glyph associated with the given character code, as well as an optional scaling parameter that should be applied to the glyph's geometry and advance parameters.

Returns the glyph on success. On failure, it may still return a printable glyph, or it may return NULL.

Definition at line 91 of file textFont.I.

Referenced by TextAssembler::has_exact_character(), and TextAssembler::is_whitespace().

TextGlyph * TextFont::get_invalid_glyph ( )

Returns a special glyph that can be used as a placeholder for any character not in the font.

Note that it is not guaranteed that a font will return this particular glyph for a missing character (it may return a glyph of its own devising instead).

Also note that even if a particular accented letter is missing from the font, Panda may still be able to render a suitable replacement by composing different glyphs together to simulate accent marks; this happens automatically behind the scenes.

Definition at line 89 of file textFont.cxx.

Referenced by StaticTextFont::get_glyph().

PN_stdfloat TextFont::get_line_height ( ) const
inline

Returns the number of units high each line of text is.

Definition at line 45 of file textFont.I.

Referenced by TextNode::get_line_height().

PN_stdfloat TextFont::get_space_advance ( ) const
inline

Returns the number of units wide a space is.

Definition at line 66 of file textFont.I.

Referenced by TextAssembler::calc_width().

bool TextFont::is_valid ( ) const
inline

Returns true if the font is valid and ready to use, false otherwise.

Definition at line 23 of file textFont.I.

TextFont::operator bool ( ) const
inline

Returns true if the font is valid and ready to use, false otherwise.

Definition at line 34 of file textFont.I.

void TextFont::set_line_height ( PN_stdfloat  line_height)
inline

Changes the number of units high each line of text is.

Definition at line 56 of file textFont.I.

void TextFont::set_space_advance ( PN_stdfloat  space_advance)
inline

Changes the number of units wide a space is.

Definition at line 76 of file textFont.I.

TextFont::RenderMode TextFont::string_render_mode ( const string &  string)
static

Returns the RenderMode value associated with the given string representation, or RM_invalid if the string does not match any known RenderMode value.

Definition at line 104 of file textFont.cxx.

TextFont::WindingOrder TextFont::string_winding_order ( const string &  string)
static

Returns the WindingOrder value associated with the given string representation, or WO_invalid if the string does not match any known WindingOrder value.

Definition at line 128 of file textFont.cxx.


The documentation for this class was generated from the following files: