[][src]Module stb::easy_font

Quick-and-dirty easy-to-deploy bitmap font for printing frame rate, etc Intended for when you just want to get some text displaying in a 3D app as quickly as possible.

Rust implementation notes:

stb_easy_font_print accepts a buffer for quads with the size of your choice. Currently stb C API offers no way to predict buffer's size depending on text string. If the buffer is not large enought, quads will be truncated.

Structs

Vertex

Font quad vertex. You can ignore z and color if you get them from elsewhere. This format was chosen in the hopes it would make it easier for you to reuse existing vertex-buffer-drawing code.

Functions

stb_easy_font_height

Takes a string and returns the vertical size (which can vary if text has newlines)

stb_easy_font_print

Takes a string (which can contain '\n') and fills out a vertex buffer with renderable data to draw the string. Output data assumes increasing x is rightwards, increasing y is downwards. The vertex data is divided into quads, i.e. there are four vertices in the vertex buffer for each quad. If you pass in None for color, it becomes [255, 255, 255, 255]. Returns the number of quads. If the buffer isn't large enough, it will truncate. Expect it to use an average of ~270 bytes per character.

stb_easy_font_spacing

Use positive values to expand the space between characters, and small negative values (no smaller than -1.5) to contract the space between characters. E.g. spacing = 1 adds one "pixel" of spacing between the characters. spacing = -1 is reasonable but feels a bit too compact to me; -0.5 is a reasonable compromise as long as you're scaling the font up.

stb_easy_font_width

Takes a string and returns the horizontal size