FreetypeFont
from panda3d.core import FreetypeFont
- class FreetypeFont
Bases:
Bases:
Namable
This is a common base class for both
DynamicTextFont
andPNMTextMaker
. Both of these are utility classes that use the FreeType library to generate glyphs from fonts; this class abstracts out that common wrapper around FreeType.Inheritance diagram
-
enum WindingOrder
-
enumerator WO_default = 0
-
enumerator WO_left = 1
-
enumerator WO_right = 2
-
enumerator WO_invalid = 3
-
enumerator WO_default = 0
- getFontPixelSize() int
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.
- getNativeAntialias() bool
Returns whether Freetype’s built-in antialias mode is enabled. See
setNativeAntialias()
.
- getPixelsPerUnit() float
Returns the resolution of the texture map. See
setPixelsPerUnit()
.
- static getPointsPerInch() float
Returns the number of points in one inch. This is a universal typographic convention.
- static getPointsPerUnit() float
Returns the point size of the font that is one Panda unit high. This is an arbitrary Panda convention for text, and is set to 10.0.
- getScaleFactor() float
Returns the antialiasing scale factor. See
setScaleFactor()
.
- getWindingOrder() WindingOrder
Returns the winding order set via
setWindingOrder()
.
- setNativeAntialias(native_antialias: bool)
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.
- setPixelSize(pixel_size: float) bool
Computes the appropriate pixels_per_unit value to set the size of the font in the texture to the indicated number of pixels. This is just another way to specify pixels_per_unit().
- setPixelsPerUnit(pixels_per_unit: float) bool
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(point_size: float) bool
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().
- setScaleFactor(scale_factor: float) bool
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
setPixelsPerUnit()
. 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().
- setWindingOrder(winding_order: WindingOrder)
Specifies an explicitly winding order on this particular font. This is only necessary if the render_mode is RM_polygon or RM_solid, and only if FreeType appears to guess wrong on this font. Normally, you should leave this at WO_default.
- property winding_order WindingOrder
- Getter
Returns the winding order set via
setWindingOrder()
.- Setter
Specifies an explicitly winding order on this particular font. This is only necessary if the render_mode is RM_polygon or RM_solid, and only if FreeType appears to guess wrong on this font. Normally, you should leave this at WO_default.
-
enum WindingOrder