DynamicTextFont

from panda3d.core import DynamicTextFont
class DynamicTextFont

Bases: TextFont, FreetypeFont

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 diagram

Inheritance diagram of DynamicTextFont

__init__(*args, **kwargs)
anisotropic_degree
bg
clear()

C++ Interface: clear(const DynamicTextFont self)

/**
  • 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.

*/

fg
font_pixel_size
garbageCollect()

C++ Interface: garbage_collect(const DynamicTextFont self)

/**
  • Removes all of the glyphs from the font that are no longer being used by

  • any Geoms. Returns the number of glyphs removed.

*/

garbage_collect()

C++ Interface: garbage_collect(const DynamicTextFont self)

/**
  • Removes all of the glyphs from the font that are no longer being used by

  • any Geoms. Returns the number of glyphs removed.

*/

getAnisotropicDegree()

C++ Interface: get_anisotropic_degree(DynamicTextFont self)

/**
  • Returns the current anisotropic degree for textures created for this font.

  • See set_anisotropic_degree().

*/

getBg()

C++ Interface: get_bg(DynamicTextFont self)

/**
  • Returns the color of the background pixels of the font as they are rendered

  • into the font texture. See set_bg().

*/

getClassType()

C++ Interface: get_class_type()

getFg()

C++ Interface: get_fg(DynamicTextFont self)

/**
  • Returns the color of the foreground pixels of the font as they are rendered

  • into the font texture. See set_fg().

*/

getFontPixelSize()

C++ Interface: get_font_pixel_size(DynamicTextFont self)

/**
  • 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()

C++ Interface: get_line_height(DynamicTextFont self)

/**
  • Returns the number of units high each line of text is.

*/

getMagfilter()

C++ Interface: get_magfilter(DynamicTextFont self)

/**
  • Returns the filter type used when enlarging the textures created for this

  • font.

*/

getMinfilter()

C++ Interface: get_minfilter(DynamicTextFont self)

/**
  • Returns the filter type used when minimizing the textures created for this

  • font.

*/

getName()

C++ Interface: get_name(DynamicTextFont self)

/**
  • Disambiguates the get_name() method between that inherited from TextFont

  • and that inherited from FreetypeFont.

*/

getNativeAntialias()

C++ Interface: get_native_antialias(DynamicTextFont self)

/**
  • Returns whether Freetype’s built-in antialias mode is enabled. See

  • set_native_antialias().

*/

getNumPages()

C++ Interface: get_num_pages(DynamicTextFont self)

/**
  • 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.

*/

getOutlineColor()

C++ Interface: get_outline_color(DynamicTextFont self)

/**
  • Returns the color of the outline pixels of the font as they are rendered

  • into the font texture. See set_outline().

*/

getOutlineFeather()

C++ Interface: get_outline_feather(DynamicTextFont self)

/**
  • Returns the softness of the outline pixels of the font, as a value in the

  • range 0.0 to 1.0. See set_outline().

*/

getOutlineWidth()

C++ Interface: get_outline_width(DynamicTextFont self)

/**
  • Returns the width of the outline pixels of the font, as the number of

  • points beyond each letter. See set_outline().

*/

getPage()

C++ Interface: get_page(DynamicTextFont self, int n)

/**
  • 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.

*/

getPageSize()

C++ Interface: get_page_size(DynamicTextFont self)

/**
  • Returns the size of the textures that are created for the DynamicTextFont.

  • See set_page_size().

*/

getPageXSize()

C++ Interface: get_page_x_size(DynamicTextFont self)

/**
  • Returns the x size of the textures that are created for the

  • DynamicTextFont. See set_page_size().

*/

getPageYSize()

C++ Interface: get_page_y_size(DynamicTextFont self)

/**
  • Returns the y size of the textures that are created for the

  • DynamicTextFont. See set_page_size().

*/

getPages()
getPixelsPerUnit()

C++ Interface: get_pixels_per_unit(DynamicTextFont self)

/**
  • Returns the resolution of the texture map. See set_pixels_per_unit().

*/

getPointSize()

C++ Interface: get_point_size(DynamicTextFont self)

/**
  • Returns the point size of the font.

*/

getPolyMargin()

C++ Interface: get_poly_margin(DynamicTextFont self)

/**
  • Returns the number of pixels of padding that is included around each glyph

  • in the generated polygons. See set_poly_margin().

*/

getRenderMode()

C++ Interface: get_render_mode(DynamicTextFont self)

/**
  • Returns the way the glyphs on this particular font are generated. See

  • set_render_mode().

*/

getScaleFactor()

C++ Interface: get_scale_factor(DynamicTextFont self)

/**
  • Returns the antialiasing scale factor. See set_scale_factor().

*/

getSpaceAdvance()

C++ Interface: get_space_advance(DynamicTextFont self)

/**
  • Returns the number of units wide a space is.

*/

getTexFormat()

C++ Interface: get_tex_format(DynamicTextFont self)

/**
  • Returns the texture format used to render the individual pages. This is

  • set automatically according to the colors selected.

*/

getTextureMargin()

C++ Interface: get_texture_margin(DynamicTextFont self)

/**
  • Returns the number of pixels of padding that is added around the border of

  • each glyph in the texture map. See set_texture_margin().

*/

get_anisotropic_degree()

C++ Interface: get_anisotropic_degree(DynamicTextFont self)

/**
  • Returns the current anisotropic degree for textures created for this font.

  • See set_anisotropic_degree().

*/

get_bg()

C++ Interface: get_bg(DynamicTextFont self)

/**
  • Returns the color of the background pixels of the font as they are rendered

  • into the font texture. See set_bg().

*/

get_class_type()

C++ Interface: get_class_type()

get_fg()

C++ Interface: get_fg(DynamicTextFont self)

/**
  • Returns the color of the foreground pixels of the font as they are rendered

  • into the font texture. See set_fg().

*/

get_font_pixel_size()

C++ Interface: get_font_pixel_size(DynamicTextFont self)

/**
  • 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.

*/

get_line_height()

C++ Interface: get_line_height(DynamicTextFont self)

/**
  • Returns the number of units high each line of text is.

*/

get_magfilter()

C++ Interface: get_magfilter(DynamicTextFont self)

/**
  • Returns the filter type used when enlarging the textures created for this

  • font.

*/

get_minfilter()

C++ Interface: get_minfilter(DynamicTextFont self)

/**
  • Returns the filter type used when minimizing the textures created for this

  • font.

*/

get_name()

C++ Interface: get_name(DynamicTextFont self)

/**
  • Disambiguates the get_name() method between that inherited from TextFont

  • and that inherited from FreetypeFont.

*/

get_native_antialias()

C++ Interface: get_native_antialias(DynamicTextFont self)

/**
  • Returns whether Freetype’s built-in antialias mode is enabled. See

  • set_native_antialias().

*/

get_num_pages()

C++ Interface: get_num_pages(DynamicTextFont self)

/**
  • 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.

*/

get_outline_color()

C++ Interface: get_outline_color(DynamicTextFont self)

/**
  • Returns the color of the outline pixels of the font as they are rendered

  • into the font texture. See set_outline().

*/

get_outline_feather()

C++ Interface: get_outline_feather(DynamicTextFont self)

/**
  • Returns the softness of the outline pixels of the font, as a value in the

  • range 0.0 to 1.0. See set_outline().

*/

get_outline_width()

C++ Interface: get_outline_width(DynamicTextFont self)

/**
  • Returns the width of the outline pixels of the font, as the number of

  • points beyond each letter. See set_outline().

*/

get_page()

C++ Interface: get_page(DynamicTextFont self, int n)

/**
  • 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.

*/

get_page_size()

C++ Interface: get_page_size(DynamicTextFont self)

/**
  • Returns the size of the textures that are created for the DynamicTextFont.

  • See set_page_size().

*/

get_page_x_size()

C++ Interface: get_page_x_size(DynamicTextFont self)

/**
  • Returns the x size of the textures that are created for the

  • DynamicTextFont. See set_page_size().

*/

get_page_y_size()

C++ Interface: get_page_y_size(DynamicTextFont self)

/**
  • Returns the y size of the textures that are created for the

  • DynamicTextFont. See set_page_size().

*/

get_pages()
get_pixels_per_unit()

C++ Interface: get_pixels_per_unit(DynamicTextFont self)

/**
  • Returns the resolution of the texture map. See set_pixels_per_unit().

*/

get_point_size()

C++ Interface: get_point_size(DynamicTextFont self)

/**
  • Returns the point size of the font.

*/

get_poly_margin()

C++ Interface: get_poly_margin(DynamicTextFont self)

/**
  • Returns the number of pixels of padding that is included around each glyph

  • in the generated polygons. See set_poly_margin().

*/

get_render_mode()

C++ Interface: get_render_mode(DynamicTextFont self)

/**
  • Returns the way the glyphs on this particular font are generated. See

  • set_render_mode().

*/

get_scale_factor()

C++ Interface: get_scale_factor(DynamicTextFont self)

/**
  • Returns the antialiasing scale factor. See set_scale_factor().

*/

get_space_advance()

C++ Interface: get_space_advance(DynamicTextFont self)

/**
  • Returns the number of units wide a space is.

*/

get_tex_format()

C++ Interface: get_tex_format(DynamicTextFont self)

/**
  • Returns the texture format used to render the individual pages. This is

  • set automatically according to the colors selected.

*/

get_texture_margin()

C++ Interface: get_texture_margin(DynamicTextFont self)

/**
  • Returns the number of pixels of padding that is added around the border of

  • each glyph in the texture map. See set_texture_margin().

*/

magfilter
makeCopy()

C++ Interface: make_copy(DynamicTextFont self)

/**
  • Returns a new copy of the same font.

*/

make_copy()

C++ Interface: make_copy(DynamicTextFont self)

/**
  • Returns a new copy of the same font.

*/

minfilter
native_antialias
page_size
pages
pixels_per_unit
point_size
poly_margin
render_mode
scale_factor
setAnisotropicDegree()

C++ Interface: set_anisotropic_degree(const DynamicTextFont self, int anisotropic_degree)

/**
  • Enables or disables anisotropic filtering on the textures created for this

  • font. The default value is specified by the text-anisotropic-degree

  • variable. See Texture::set_anisotropic_degree().

*/

setBg()

C++ Interface: set_bg(const DynamicTextFont self, const LVecBase4f bg)

/**
  • Changes the color of the background pixels of the font as they are rendered

  • into the font texture. The default is (1, 1, 1, 0), or transparent white,

  • which allows text created with the font to be colored individually. (Note

  • that it should not generally be (0, 0, 0, 0), which would tend to bleed

  • into the foreground color, unless you have also specified a outline color

  • of (0, 0, 0, 1)) .

  • Normally, you would not change this unless you really need a particular

  • color effect to appear in the font itself.

  • This should only be called before any characters have been requested out of

  • the font, or immediately after calling clear().

*/

setFg()

C++ Interface: set_fg(const DynamicTextFont self, const LVecBase4f fg)

/**
  • Changes the color of the foreground pixels of the font as they are rendered

  • into the font texture. The default is (1, 1, 1, 1), or opaque white, which

  • allows text created with the font to be colored individually. Normally,

  • you would not change this unless you really need a particular color effect

  • to appear in the font itself.

  • This should only be called before any characters have been requested out of

  • the font, or immediately after calling clear().

*/

setMagfilter()

C++ Interface: set_magfilter(const DynamicTextFont self, int filter)

/**
  • Sets the filter type used when enlarging the textures created for this

  • font.

*/

setMinfilter()

C++ Interface: set_minfilter(const DynamicTextFont self, int filter)

/**
  • Sets the filter type used when minimizing the textures created for this

  • font.

*/

setNativeAntialias()

C++ Interface: set_native_antialias(const DynamicTextFont self, bool native_antialias)

/**
  • 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.

*/

setOutline()

C++ Interface: set_outline(const DynamicTextFont self, const LVecBase4f outline_color, float outline_width, float outline_feather)

/**
  • Sets up the font to have an outline around each font letter. This is

  • achieved via a Gaussian post-process as each letter is generated; there is

  • some runtime cost for this effect, but it is minimal as each letter is

  • normally generated only once and then cached.

  • The color is the desired color of the outline, width is the number of

  • points beyond the letter that the outline extends (a typical font is 10

  • points high), and feather is a number in the range 0.0 .. 1.0 that controls

  • the softness of the outline. Set the width to 0.0 to disable the outline.

  • This should only be called before any characters have been requested out of

  • the font, or immediately after calling clear().

*/

setPageSize()

C++ Interface: set_page_size(const DynamicTextFont self, const LVecBase2i page_size) set_page_size(const DynamicTextFont self, int x_size, int y_size)

/**
  • Sets the x, y size of the textures that are created for the

  • DynamicTextFont.

*/

/**
  • Sets the x, y size of the textures that are created for the

  • DynamicTextFont.

*/

setPixelsPerUnit()

C++ Interface: set_pixels_per_unit(const DynamicTextFont self, float pixels_per_unit)

/**
  • 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()

C++ Interface: set_point_size(const DynamicTextFont self, float point_size)

/**
  • 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()

C++ Interface: set_poly_margin(const DynamicTextFont self, float poly_margin)

/**
  • 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).

*/

setRenderMode()

C++ Interface: set_render_mode(const DynamicTextFont self, int render_mode)

/**
  • Specifies the way the glyphs on this particular font are generated. The

  • default is RM_texture, which is the only mode supported for bitmap fonts.

  • Other modes are possible for most modern fonts.

*/

setScaleFactor()

C++ Interface: set_scale_factor(const DynamicTextFont self, float scale_factor)

/**
  • 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, but it is probably small.

  • This should only be called before any characters have been requested out of

  • the font, or immediately after calling clear().

*/

setTextureMargin()

C++ Interface: set_texture_margin(const DynamicTextFont self, int texture_margin)

/**
  • 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.

*/

set_anisotropic_degree()

C++ Interface: set_anisotropic_degree(const DynamicTextFont self, int anisotropic_degree)

/**
  • Enables or disables anisotropic filtering on the textures created for this

  • font. The default value is specified by the text-anisotropic-degree

  • variable. See Texture::set_anisotropic_degree().

*/

set_bg()

C++ Interface: set_bg(const DynamicTextFont self, const LVecBase4f bg)

/**
  • Changes the color of the background pixels of the font as they are rendered

  • into the font texture. The default is (1, 1, 1, 0), or transparent white,

  • which allows text created with the font to be colored individually. (Note

  • that it should not generally be (0, 0, 0, 0), which would tend to bleed

  • into the foreground color, unless you have also specified a outline color

  • of (0, 0, 0, 1)) .

  • Normally, you would not change this unless you really need a particular

  • color effect to appear in the font itself.

  • This should only be called before any characters have been requested out of

  • the font, or immediately after calling clear().

*/

set_fg()

C++ Interface: set_fg(const DynamicTextFont self, const LVecBase4f fg)

/**
  • Changes the color of the foreground pixels of the font as they are rendered

  • into the font texture. The default is (1, 1, 1, 1), or opaque white, which

  • allows text created with the font to be colored individually. Normally,

  • you would not change this unless you really need a particular color effect

  • to appear in the font itself.

  • This should only be called before any characters have been requested out of

  • the font, or immediately after calling clear().

*/

set_magfilter()

C++ Interface: set_magfilter(const DynamicTextFont self, int filter)

/**
  • Sets the filter type used when enlarging the textures created for this

  • font.

*/

set_minfilter()

C++ Interface: set_minfilter(const DynamicTextFont self, int filter)

/**
  • Sets the filter type used when minimizing the textures created for this

  • font.

*/

set_native_antialias()

C++ Interface: set_native_antialias(const DynamicTextFont self, bool native_antialias)

/**
  • 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.

*/

set_outline()

C++ Interface: set_outline(const DynamicTextFont self, const LVecBase4f outline_color, float outline_width, float outline_feather)

/**
  • Sets up the font to have an outline around each font letter. This is

  • achieved via a Gaussian post-process as each letter is generated; there is

  • some runtime cost for this effect, but it is minimal as each letter is

  • normally generated only once and then cached.

  • The color is the desired color of the outline, width is the number of

  • points beyond the letter that the outline extends (a typical font is 10

  • points high), and feather is a number in the range 0.0 .. 1.0 that controls

  • the softness of the outline. Set the width to 0.0 to disable the outline.

  • This should only be called before any characters have been requested out of

  • the font, or immediately after calling clear().

*/

set_page_size()

C++ Interface: set_page_size(const DynamicTextFont self, const LVecBase2i page_size) set_page_size(const DynamicTextFont self, int x_size, int y_size)

/**
  • Sets the x, y size of the textures that are created for the

  • DynamicTextFont.

*/

/**
  • Sets the x, y size of the textures that are created for the

  • DynamicTextFont.

*/

set_pixels_per_unit()

C++ Interface: set_pixels_per_unit(const DynamicTextFont self, float pixels_per_unit)

/**
  • 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().

*/

set_point_size()

C++ Interface: set_point_size(const DynamicTextFont self, float point_size)

/**
  • 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().

*/

set_poly_margin()

C++ Interface: set_poly_margin(const DynamicTextFont self, float poly_margin)

/**
  • 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).

*/

set_render_mode()

C++ Interface: set_render_mode(const DynamicTextFont self, int render_mode)

/**
  • Specifies the way the glyphs on this particular font are generated. The

  • default is RM_texture, which is the only mode supported for bitmap fonts.

  • Other modes are possible for most modern fonts.

*/

set_scale_factor()

C++ Interface: set_scale_factor(const DynamicTextFont self, float scale_factor)

/**
  • 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, but it is probably small.

  • This should only be called before any characters have been requested out of

  • the font, or immediately after calling clear().

*/

set_texture_margin()

C++ Interface: set_texture_margin(const DynamicTextFont self, int texture_margin)

/**
  • 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.

*/

tex_format
texture_margin
upcastToFreetypeFont()

C++ Interface: upcast_to_FreetypeFont(const DynamicTextFont self)

upcast from DynamicTextFont to FreetypeFont

upcastToTextFont()

C++ Interface: upcast_to_TextFont(const DynamicTextFont self)

upcast from DynamicTextFont to TextFont

upcast_to_FreetypeFont()

C++ Interface: upcast_to_FreetypeFont(const DynamicTextFont self)

upcast from DynamicTextFont to FreetypeFont

upcast_to_TextFont()

C++ Interface: upcast_to_TextFont(const DynamicTextFont self)

upcast from DynamicTextFont to TextFont

write()

C++ Interface: write(DynamicTextFont self, ostream out, int indent_level)

/**

*/