Added True Type fonts

This commit is contained in:
2021-05-23 10:53:00 -07:00
parent 98814982de
commit b0dce455f0
26 changed files with 575 additions and 167 deletions

View File

@ -7,19 +7,42 @@
#pragma once
#include "../../libs.h"
#include "../texture.h"
/** Which is the first character within the font tilemap */
#define FONT_CHAR_START 33
/** Which character (ASCII) to start the font from */
#define FONT_FIRST_CHAR 32
/** Center a font along the X axis */
#define FONT_CENTER_X 9876543
/** Center a font along the Y axis */
#define FONT_CENTER_Y -FONT_CENTER_X
/** How many characters (after the first char) to generate */
#define FONT_NUM_CHARS 96
/** Align right edge of font to origin */
#define FONT_RIGHT_X (FONT_CENTER_X-1)
/** Width of the loaded font texture */
#define FONT_TEXTURE_WIDTH 512
/** Height of the loaded font texture */
#define FONT_TEXTURE_HEIGHT FONT_TEXTURE_WIDTH
/** Refer to STBTT docs for OpenGL Fill Mode v d3d Fill Modes */
#define FONT_FILL_MODE 1
#define FONT_NEWLINE '\n'
#define FONT_SPACE ' '
#define FONT_LINE_HEIGHT 0.75
#define FONT_INITIAL_LINE FONT_LINE_HEIGHT*0.75
#define FONT_SPACE_SIZE 0.35
typedef struct {
float size;
texture_t texture;
stbtt_bakedchar characterData[FONT_NUM_CHARS];
} font_t;
typedef struct {
int32_t length;
int32_t realChars;
float lineHeight, spaceSize;
} fonttextinfo_t;
typedef struct {
float width, height;
int32_t lines;
stbtt_aligned_quad *quads;
} fontmeasure_t;