Added True Type fonts
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
// Display / Rendering
|
||||
#include "display/debug/grid.h"
|
||||
|
||||
#include "display/gui/bitmapfont.h"
|
||||
#include "display/gui/font.h"
|
||||
|
||||
#include "display/camera.h"
|
||||
|
26
include/dawn/display/gui/bitmapfont.h
Normal file
26
include/dawn/display/gui/bitmapfont.h
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
|
||||
/** Which is the first character within the font tilemap */
|
||||
#define BITMAP_FONT_CHAR_START 33
|
||||
|
||||
/** Center a font along the X axis */
|
||||
#define BITMAP_FONT_CENTER_X 9876543
|
||||
|
||||
/** Center a font along the Y axis */
|
||||
#define BITMAP_FONT_CENTER_Y -BITMAP_FONT_CENTER_X
|
||||
|
||||
/** Align right edge of font to origin */
|
||||
#define BITMAP_FONT_RIGHT_X (BITMAP_FONT_CENTER_X-1)
|
||||
|
||||
typedef struct {
|
||||
float width, height;
|
||||
int32_t lines;
|
||||
} bitmapfontmeasure_t;
|
@ -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;
|
@ -8,6 +8,8 @@
|
||||
// Static Libs
|
||||
#include <cglm/cglm.h>
|
||||
#include <glad/glad.h>
|
||||
#include <stb_image.h>
|
||||
#include <stb_truetype.h>
|
||||
|
||||
// Standard Libs
|
||||
#include <stdio.h>
|
||||
@ -20,6 +22,4 @@
|
||||
// Windows Fixes
|
||||
# define strtok_r strtok_s
|
||||
# define sleep(n) _sleep(n)
|
||||
#else
|
||||
|
||||
#endif
|
@ -17,16 +17,17 @@
|
||||
#include "../display/tileset.h"
|
||||
|
||||
/** Rounds that the game can be in */
|
||||
#define POKER_ROUND_DEAL 0x00
|
||||
#define POKER_ROUND_BLINDS 0x01
|
||||
#define POKER_ROUND_BET0 0x02
|
||||
#define POKER_ROUND_FLOP 0X03
|
||||
#define POKER_ROUND_BET1 0x04
|
||||
#define POKER_ROUND_TURN 0x05
|
||||
#define POKER_ROUND_BET2 0x06
|
||||
#define POKER_ROUND_RIVER 0x07
|
||||
#define POKER_ROUND_BET3 0x08
|
||||
#define POKER_ROUND_WINNER 0x09
|
||||
#define POKER_ROUND_MATCH 0x00
|
||||
#define POKER_ROUND_DEAL 0x01
|
||||
#define POKER_ROUND_BLINDS 0x02
|
||||
#define POKER_ROUND_BET0 0x03
|
||||
#define POKER_ROUND_FLOP 0X04
|
||||
#define POKER_ROUND_BET1 0x05
|
||||
#define POKER_ROUND_TURN 0x06
|
||||
#define POKER_ROUND_BET2 0x07
|
||||
#define POKER_ROUND_RIVER 0x08
|
||||
#define POKER_ROUND_BET3 0x09
|
||||
#define POKER_ROUND_WINNER 0x10
|
||||
|
||||
/** How many cards the dealer can hold in their hand */
|
||||
#define POKER_DEALER_HAND 5
|
||||
|
Reference in New Issue
Block a user