OpenGLContext.scenegraph.text.font
Abstract base-class for all font implementations
Classes
class BitmapFontMixIn(
object
):
Mix-in providing justification routines for bitmap fonts
For OpenGL 3.1 and beyond, we'll need some more
bookkeeping done at the font level, basically we'll
have X textures/shaders per font. The characters to
render for the shader will all be composed into a single
VBO to be rendered. Changing the text will update the
VBO set (which is a fairly small data-set, as it's just
the quads involved).
Each character needs a reference to the texture involved
as well as the texture-coordinates for the 4 vertices.
So we're going to wind up getting a general "compile"
operation that iterates over all lines which use a Font,
gathering the (translated) coordinates to pass to the
renderer, when those are all gathered, we render the
data-set to the card in one go...
class CharacterMetrics(
object
):
Abstract base-class for all font implementations
getChar(
self
,
char
,
mode
= None
)
Get (and/or create) a single-character display-list (with metrics)
lists(
self
,
value
,
mode
= None
)
Get a sequence of display-list integers for value
Basically, this does a bit of trickery to do
as-required compilation of display-lists, so
that only those characters actually required
by the displayed text are compiled.
NOTE: Must be called from within the rendering
thread and within the rendering pass!
normalise(
self
,
value
)
Return a normalised value for the given value
In our case, this means decoding utf-8 strings
if they are passed.
render(
self
,
lines
,
fontStyle
= None
,
mode
= None
)
Render value in this font, with control-character support
- lines
- list of Line objects to be rendered, alternately a string/unicode object to be converted to lines with self.toLines( lines, mode=mode )
- mode
- active rendering mode
toLines(
self
,
value
,
mode
= None
)
Convert value to a set of expanded lines
Basically what this does is split value by line,
then expand tabs (using 4-spaces per-tab),
then return a list of Line instances for the
resulting strings.
verticalAdjust(
self
,
spacing
,
lines
,
fontStyle
,
mode
= None
)
Calculate adjustement for first line's position
This needs to take into account the fontStyle's
"minor" alignment, which specifies one of:
FIRST -- use the bottom of the first line
BEGIN -- if topToBottom true, top of top line, bottom
of bottom line otherwise
MIDDLE -- y-coordinate middle of the middle-most line
END -- if topToBottom true, bottom edge of the last line
class NoDepthBufferMixIn(
object
):
class PolygonalFontMixIn(
object
):
Mix-in providing justification functions for polygonal text
_leftJustify(
self
,
lines
,
fontStyle
,
mode
= None
)
Left-justify a list of lines (actual function)
centerJustify(
self
,
lines
,
fontStyle
,
mode
= None
)
Center-justify a list of lines (wrapper to do in child matrix)
class RenderSelectMixIn(
object
):
Mix-in providing quadrangle-based invisible-pass rendering
XXX This should all be display-listed!
XXX This is only usable for polygonal geometry!