Text Wrapping Complete

This commit is contained in:
2021-05-25 07:52:53 -07:00
parent ad8b1ccd3e
commit 6e6497ca43
6 changed files with 182 additions and 6 deletions

View File

@ -27,21 +27,35 @@
/** Refer to STBTT docs for OpenGL Fill Mode v d3d Fill Modes */
#define FONT_FILL_MODE 1
// Chars
#define FONT_NEWLINE '\n'
#define FONT_SPACE ' '
// Heights
#define FONT_LINE_HEIGHT FONT_TEXTURE_SIZE*0.75
#define FONT_INITIAL_LINE FONT_LINE_HEIGHT*0.75
#define FONT_SPACE_SIZE FONT_TEXTURE_SIZE*0.75
#define FONT_SPACE_SIZE FONT_TEXTURE_SIZE*0.45
#define FONT_SCALE_ADJUST 0.03
/** Representation of a font that can be used to render text */
typedef struct {
texture_t texture;
stbtt_bakedchar characterData[FONT_NUM_CHARS];
} font_t;
typedef struct {
/** How many raw chars are in the string */
int32_t length;
/** How many rendered chars are in the string */
int32_t realLength;
/** How many lines is the string? Trailing newlines will count */
int32_t lines;
/** Dimensions of the string */
float width, height, scale;
/** Array of precalculated quads */
stbtt_aligned_quad *quads;
} fonttextinfo_t;