GlyphString
(text, glyphs, x=0, y=0)¶An immutable string of glyphs that can be rendered quickly.
This class is ideal for quickly rendering single or multi-line strings of text that use the same font. To wrap text using a glyph string, call get_break_index to find the optimal breakpoint for each line, the repeatedly call draw for each breakpoint.
Warning
Deprecated. Use pyglet.text.layout classes.
Constructor:
__init__
(text, glyphs, x=0, y=0)¶Create a glyph string.
The text string is used to determine valid breakpoints; all glyphs must have already been determined using pyglet.font.base.Font.get_glyphs. The string will be positioned with the baseline of the left-most glyph at the given coordinates.
Parameters: |
|
---|
Methods:
draw
([from_index, to_index])Draw a region of the glyph string. get_break_index
(from_index, width)Find a breakpoint within the text for a given width. get_subwidth
(from_index, to_index)Return the width of a slice of this string.
GlyphString.
draw
(from_index=0, to_index=None)¶Draw a region of the glyph string.
Assumes texture state is enabled. To enable the texture state:
from pyglet.gl import *
glEnable(GL_TEXTURE_2D)
Parameters: |
|
---|
GlyphString.
get_break_index
(from_index, width)¶Find a breakpoint within the text for a given width.
Returns a valid breakpoint after from_index so that the text between from_index and the breakpoint fits within width pixels.
This method uses precomputed cumulative glyph widths to give quick answer, and so is much faster than pyglet.font.base.Font.get_glyphs_for_width.
Parameters: |
|
---|---|
Return type: | int |
Returns: | the index of text which will be used as the breakpoint, or from_index if there is no valid breakpoint. |
GlyphString.
get_subwidth
(from_index, to_index)¶Return the width of a slice of this string.
Parameters: |
|
---|---|
Return type: | float |