# DynamicTextFont

from pandac.PandaModules import DynamicTextFont

Class : DynamicTextFont
Description : A DynamicTextFont is a special TextFont object that rasterizes its glyphs from a standard font file (e.g. a TTF file) on the fly. It requires the FreeType 2.0 library (or any higher, backward-compatible version).

## Inheritance:

DynamicTextFont: TextFont FreetypeFont
TextFont: TypedReferenceCount Namable
TypedReferenceCount: TypedObject ReferenceCount
TypedObject:
ReferenceCount:
Namable:
FreetypeFont:

## Methods of DynamicTextFont:

clear
garbageCollect
getAnisotropicDegree
getClassType
getFontPixelSize
getLineHeight
getMagfilter
getMinfilter
getName
getNativeAntialias
getNumPages
getPage
getPageXSize
getPageYSize
getPixelsPerUnit
getPointSize
getPolyMargin
getScaleFactor
getSpaceAdvance
getTextureMargin
setAnisotropicDegree
setMagfilter
setMinfilter
setNativeAntialias
setPageSize
setPixelsPerUnit
setPointSize
setPolyMargin
setScaleFactor
setTextureMargin
write

## Methods of TextFont:

getClassType
getLineHeight
getSpaceAdvance
isValid
setLineHeight
setSpaceAdvance
write

## Methods of TypedReferenceCount:

getClassType

## Methods of TypedObject:

getBestParentFromSet
getClassType
getType
getTypeIndex
isExactType
isOfType

## Methods of ReferenceCount:

getClassType
getRefCount
ref
testRefCountIntegrity
unref

## Methods of Namable:

clearName
getClassType
getName
hasName
operator =
output
setName

clear void DynamicTextFont::clear(void); Description: Drops all the glyphs out of the cache and frees any association with any previously-generated pages. Calling this frequently can result in wasted texture memory, as any previously rendered text will still keep a pointer to the old, previously-generated pages. As long as the previously rendered text remains around, the old pages will also remain around.

garbageCollect int DynamicTextFont::garbage_collect(void); Description: Removes all of the glyphs from the font that are no longer being used by any Geoms. Returns the number of glyphs removed.

getAnisotropicDegree int DynamicTextFont::get_anisotropic_degree(void) const; Description: Returns the current anisotropic degree for textures created for this font. See set_anisotropic_degree().

getClassType static TypeHandle DynamicTextFont::get_class_type(void); Undocumented function.

getFontPixelSize int DynamicTextFont::get_font_pixel_size(void) const; Description: This is used to report whether the requested pixel size is being only approximated by a fixed-pixel-size font. This returns 0 in the normal case, in which a scalable font is used, or the fixed-pixel-size font has exactly the requested pixel size. If this returns non-zero, it is the pixel size of the font that we are using to approximate our desired size.

getLineHeight float DynamicTextFont::get_line_height(void) const; Description: Returns the number of units high each line of text is.

getMagfilter Texture::FilterType DynamicTextFont::get_magfilter(void) const; Description: Returns the filter type used when enlarging the textures created for this font.

getMinfilter Texture::FilterType DynamicTextFont::get_minfilter(void) const; Description: Returns the filter type used when minimizing the textures created for this font.

getName string const &DynamicTextFont::get_name(void) const; Filename: dynamicTextFont.I Created by: drose (08Feb02) PANDA 3D SOFTWARE Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved All use of this software is subject to the terms of the Panda 3d Software license. You should have received a copy of this license along with this source code; you will also find a current copy of the license at http://etc.cmu.edu/panda3d/docs/license/ . To contact the maintainers of this program write to panda3d-general@lists.sourceforge.net . Description: Disambiguates the get_name() method between that inherited from TextFont and that inherited from FreetypeFont.

getNativeAntialias bool DynamicTextFont::get_native_antialias(void) const; Description: Returns whether Freetype's built-in antialias mode is enabled. See set_native_antialias().

getNumPages int DynamicTextFont::get_num_pages(void) const; Description: Returns the number of pages associated with the font. Initially, the font has zero pages; when the first piece of text is rendered with the font, it will add additional pages as needed. Each page is a Texture object that contains the images for each of the glyphs currently in use somewhere.

getPage DynamicTextPage *DynamicTextFont::get_page(int n) const; Description: Returns the nth page associated with the font. Initially, the font has zero pages; when the first piece of text is rendered with the font, it will add additional pages as needed. Each page is a Texture object that contains the images for each of the glyphs currently in use somewhere.

getPageXSize int DynamicTextFont::get_page_x_size(void) const; Description: Returns the x size of the textures that are created for the DynamicTextFont. See set_page_size().

getPageYSize int DynamicTextFont::get_page_y_size(void) const; Description: Returns the y size of the textures that are created for the DynamicTextFont. See set_page_size().

getPixelsPerUnit float DynamicTextFont::get_pixels_per_unit(void) const; Description: Returns the resolution of the texture map. See set_pixels_per_unit().

getPointSize float DynamicTextFont::get_point_size(void) const; Description: Returns the point size of the font.

getPolyMargin float DynamicTextFont::get_poly_margin(void) const; Description: Returns the number of pixels of padding that is included around each glyph in the generated polygons. See set_poly_margin().

getScaleFactor float DynamicTextFont::get_scale_factor(void) const; Description: Returns the antialiasing scale factor. See set_scale_factor().

getSpaceAdvance float DynamicTextFont::get_space_advance(void) const; Description: Returns the number of units wide a space is.

getTextureMargin int DynamicTextFont::get_texture_margin(void) const; Description: Returns the number of pixels of padding that is added around the border of each glyph in the texture map. See set_texture_margin().

setAnisotropicDegree void DynamicTextFont::set_anisotropic_degree(int anisotropic_degree); Description: Enables or disables anisotropic filtering on the textures created for this font. The default value is usually 1, or off. See Texture::set_anisotropic_degree().

setMagfilter void DynamicTextFont::set_magfilter(Texture::FilterType filter); Description: Sets the filter type used when enlarging the textures created for this font.

setMinfilter void DynamicTextFont::set_minfilter(Texture::FilterType filter); Description: Sets the filter type used when minimizing the textures created for this font.

setNativeAntialias void DynamicTextFont::set_native_antialias(bool native_antialias); Description: Sets whether the Freetype library's built-in antialias mode is enabled. There are two unrelated ways to achieve antialiasing: with Freetype's native antialias mode, and with the use of a scale_factor greater than one. By default, both modes are enabled. At low resolutions, some fonts may do better with one mode or the other. In general, Freetype's native antialiasing will produce less blurry results, but may introduce more artifacts.

setPageSize void DynamicTextFont::set_page_size(int x_size, int y_size); Description: Sets the x, y size of the textures that are created for the DynamicTextFont.

setPixelsPerUnit bool DynamicTextFont::set_pixels_per_unit(float pixels_per_unit); Description: Set the resolution of the texture map, and hence the clarity of the resulting font. This sets the number of pixels in the texture map that are used for each onscreen unit. Setting this number larger results in an easier to read font, but at the cost of more texture memory. This should only be called before any characters have been requested out of the font, or immediately after calling clear().

setPointSize bool DynamicTextFont::set_point_size(float point_size); Description: Sets the point size of the font. This controls the apparent size of the font onscreen. By convention, a 10 point font is about 1 screen unit high. This should only be called before any characters have been requested out of the font, or immediately after calling clear().

setPolyMargin void DynamicTextFont::set_poly_margin(float poly_margin); Description: Sets the number of pixels of padding that is included around each glyph in the generated polygons. This helps prevent the edges of the glyphs from being cut off at small minifications. It is not related to the amount of extra pixels reserved in the texture map (but it should be set somewhat smaller than this number, which is controlled by set_texture_margin(), to prevent bleed-in from neighboring letters in the texture).

setScaleFactor bool DynamicTextFont::set_scale_factor(float scale_factor); Description: Sets the factor by which the font is rendered larger by the FreeType library before being filtered down to its actual size in the texture as specified by set_pixels_per_unit(). This may be set to a number larger than 1.0 to improve the font's antialiasing (since FreeType doesn't really do a swell job of antialiasing by itself). There is some performance implication for setting this different than 1.0. This should only be called before any characters have been requested out of the font, or immediately after calling clear().

setTextureMargin void DynamicTextFont::set_texture_margin(int texture_margin); Description: Sets the number of pixels of padding that is added around the border of each glyph before adding it to the texture map. This reduces the bleed in from neighboring glyphs in the texture map.

write virtual void DynamicTextFont::write(ostream &out, int indent_level) const; Description:

getClassType static TypeHandle TextFont::get_class_type(void); Undocumented function.

getLineHeight float TextFont::get_line_height(void) const; Description: Returns the number of units high each line of text is.

getSpaceAdvance float TextFont::get_space_advance(void) const; Description: Returns the number of units wide a space is.

isValid bool TextFont::is_valid(void) const; Filename: textFont.I Created by: drose (08Feb02) PANDA 3D SOFTWARE Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved All use of this software is subject to the terms of the Panda 3d Software license. You should have received a copy of this license along with this source code; you will also find a current copy of the license at http://etc.cmu.edu/panda3d/docs/license/ . To contact the maintainers of this program write to panda3d-general@lists.sourceforge.net . Description: Returns true if the font is valid and ready to use, false otherwise.

setLineHeight void TextFont::set_line_height(float line_height); Description: Changes the number of units high each line of text is.

setSpaceAdvance void TextFont::set_space_advance(float space_advance); Description: Changes the number of units wide a space is.

write virtual void TextFont::write(ostream &out, int indent_level) const; Description:

getClassType static TypeHandle TypedReferenceCount::get_class_type(void); Undocumented function.

getBestParentFromSet int TypedObject::get_best_parent_from_Set(set< int > const &) const; Description: Returns true if the current object is the indicated type exactly.

getClassType static TypeHandle TypedObject::get_class_type(void); Undocumented function.

getType virtual TypeHandle TypedObject::get_type(void) const = 0; Derived classes should override this function to return get_class_type().

getTypeIndex int TypedObject::get_type_index(void) const; Description: Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. This is equivalent to get_type().get_index().

isExactType bool TypedObject::is_exact_type(TypeHandle handle) const; Description: Returns true if the current object is the indicated type exactly.

isOfType bool TypedObject::is_of_type(TypeHandle handle) const; Description: Returns true if the current object is or derives from the indicated type.

getClassType static TypeHandle ReferenceCount::get_class_type(void); Undocumented function.

getRefCount int ReferenceCount::get_ref_count(void) const; Description: Returns the current reference count.

ref void ReferenceCount::ref(void) const; Description: Explicitly increments the reference count. User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

testRefCountIntegrity bool ReferenceCount::test_ref_count_integrity(void) const; Description: Does some easy checks to make sure that the reference count isn't completely bogus. Returns true if ok, false otherwise.

unref bool ReferenceCount::unref(void) const; Description: Explicitly decrements the reference count. Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic; plus, we don't have a virtual destructor anyway.) However, see the helper function unref_delete(). User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it. The return value is true if the new reference count is nonzero, false if it is zero.

clearName void Namable::clear_name(void); Description: Resets the Namable's name to empty.

getClassType static TypeHandle Namable::get_class_type(void); Undocumented function.

getName string const &Namable::get_name(void) const; Description:

hasName bool Namable::has_name(void) const; Description: Returns true if the Namable has a nonempty name set, false if the name is empty.

operator = Namable &Namable::operator =(Namable const &other); Description:

output void Namable::output(ostream &out) const; In the absence of any definition to the contrary, outputting a Namable will write out its name. Description: Outputs the Namable. This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.

setName void Namable::set_name(string const &name); Description: