Still working on my scrolling text and bug fixing.

This commit is contained in:
2021-07-16 22:26:04 -07:00
parent 06202f6f7e
commit f619b7c9d2
26 changed files with 495 additions and 115 deletions

View File

@ -25,7 +25,7 @@
#define FONT_FILL_MODE 1
/** Passed to STBTT for scaling the font nicely, essentially the font size. */
#define FONT_TEXTURE_SIZE 112
#define FONT_TEXTURE_SIZE 32
// Chars
#define FONT_NEWLINE '\n'
@ -36,25 +36,41 @@
#define FONT_INITIAL_LINE FONT_LINE_HEIGHT*0.75
#define FONT_SPACE_SIZE FONT_TEXTURE_SIZE*0.45
/** Maximum number of characters a font text info can hold. */
#define FONT_TEXT_INFO_CHARS_MAX 1024
/** Maximum number of newlines that a font text info can hold. */
#define FONT_TEXT_INFO_LINES_MAX FONT_TEXT_INFO_CHARS_MAX/50
/** 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 {
/** What (real character) index the line starts at */
int32_t start;
/** How many (real) characters the line is in length */
int32_t length;
} fonttextinfoline_t;
typedef struct {
/** How many raw chars are in the string */
int32_t length;
/** How many rendered chars are in the string */
/** How many real characters (non whitespace) are in the string */
int32_t realLength;
/** How many lines is the string? Trailing newlines will count */
int32_t lines;
int32_t lineCount;
/** The real character info for each line */
fonttextinfoline_t lines[FONT_TEXT_INFO_LINES_MAX];
/** Dimensions of the string */
float width, height;
/** Array of precalculated quads */
stbtt_aligned_quad *quads;
stbtt_aligned_quad quads[FONT_TEXT_INFO_CHARS_MAX];
} fonttextinfo_t;