2023-06-17 17:00:55 +00:00
|
|
|
/* date = May 7th 2023 10:16 am */
|
|
|
|
|
|
|
|
#ifndef VN_FONT_H
|
|
|
|
#define VN_FONT_H
|
|
|
|
|
|
|
|
enum font_id
|
|
|
|
{
|
|
|
|
Font_Regular,
|
|
|
|
Font_Bold,
|
|
|
|
Font_Monospace,
|
2023-06-27 14:14:28 +00:00
|
|
|
Font_Hand,
|
2023-06-17 17:00:55 +00:00
|
|
|
Font_Icons,
|
|
|
|
|
|
|
|
Font_Count,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define FontIcon_None 0x0000
|
|
|
|
#define FontIcon_Pencil 0xe800
|
|
|
|
#define FontIcon_Forward 0xe801
|
|
|
|
#define FontIcon_Book 0xe802
|
|
|
|
#define FontIcon_FolderOpen 0xe803
|
|
|
|
#define FontIcon_Wrench 0xe804
|
|
|
|
#define FontIcon_CW 0xe805
|
|
|
|
#define FontIcon_CCW 0xe806
|
|
|
|
#define FontIcon_ArrowsCW 0xe807
|
|
|
|
#define FontIcon_ResizeVertical 0xe808
|
|
|
|
#define FontIcon_ResizeHorizontal 0xe809
|
|
|
|
#define FontIcon_Play 0xe80a
|
|
|
|
#define FontIcon_Stop 0xe80b
|
|
|
|
#define FontIcon_Floppy 0xe80c
|
|
|
|
#define FontIcon_Pause 0xe80d
|
|
|
|
#define FontIcon_Folder 0xe80e
|
|
|
|
#define FontIcon_Cog 0xe80f
|
|
|
|
#define FontIcon_Attention 0xe810
|
|
|
|
#define FontIcon_Cancel 0xe811
|
|
|
|
#define FontIcon_Filter 0xf0b0
|
|
|
|
#define FontIcon_Menu 0xf0c9
|
|
|
|
#define FontIcon_CircleEmpty 0xf10c
|
|
|
|
#define FontIcon_Circle 0xf111
|
|
|
|
#define FontIcon_Reply 0xf112
|
|
|
|
#define FontIcon_Terminal 0xf120
|
|
|
|
#define FontIcon_Ellipsis 0xf141
|
|
|
|
#define FontIcon_Document 0xf15b
|
|
|
|
#define FontIcon_DocumentText 0xf15c
|
|
|
|
#define FontIcon_Eyedropper 0xf1fb
|
|
|
|
#define FontIcon_WindowMaximize 0xf2d0
|
|
|
|
#define FontIcon_WindowMinimize 0xf2d1
|
|
|
|
#define FontIcon_WindowRestore 0xf2d2
|
|
|
|
#define FontIcon_WindowClose 0xf2d4
|
|
|
|
#define FontIcon_DownDir 0xe812
|
|
|
|
#define FontIcon_UpDir 0xe813
|
|
|
|
#define FontIcon_LeftDir 0xe814
|
|
|
|
#define FontIcon_RightDir 0xe815
|
|
|
|
#define FontIcon_TextAlignLeft 0xe816
|
|
|
|
#define FontIcon_TextAlignCenter 0xe817
|
|
|
|
#define FontIcon_TextAlignRight 0xe818
|
|
|
|
|
|
|
|
struct glyph
|
|
|
|
{
|
|
|
|
glyph *LRUNext;
|
|
|
|
glyph *LRUPrev;
|
|
|
|
|
|
|
|
font_id Font;
|
|
|
|
u32 Codepoint;
|
|
|
|
r32 Size;
|
|
|
|
s32 Subpixel;
|
|
|
|
|
2023-06-21 16:59:36 +00:00
|
|
|
v2_s32 P0;
|
|
|
|
v2_s32 P1;
|
2023-06-17 17:00:55 +00:00
|
|
|
v2 Offset;
|
|
|
|
r32 Advance;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DEFAULT_GLYPH_ATLAS_DIM 1024
|
|
|
|
#define MAX_GLYPH_SIZE 64
|
|
|
|
|
|
|
|
#define STB_TRUETYPE_IMPLEMENTATION
|
|
|
|
#include "third_party/stb_truetype.h"
|
|
|
|
|
|
|
|
struct loaded_font
|
|
|
|
{
|
|
|
|
stbtt_fontinfo Info;
|
|
|
|
string Data;
|
|
|
|
|
|
|
|
s32 Ascent;
|
|
|
|
s32 Descent;
|
|
|
|
s32 LineGap;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct glyph_atlas
|
|
|
|
{
|
2023-07-19 15:09:41 +00:00
|
|
|
memory_arena *Arena;
|
2023-06-17 17:00:55 +00:00
|
|
|
|
|
|
|
s32 MaxGlyphCount;
|
|
|
|
s32 GlyphsUsed;
|
|
|
|
glyph *Glyphs;
|
|
|
|
|
|
|
|
glyph *LRUFirst;
|
|
|
|
glyph *LRULast;
|
|
|
|
|
|
|
|
vn_render_commands *RenderCommands;
|
|
|
|
render_handle Texture;
|
|
|
|
|
|
|
|
u8 *BitmapBuffer;
|
|
|
|
s32 BitmapSize;
|
|
|
|
s32 GlyphSize;
|
|
|
|
|
|
|
|
loaded_font Fonts[Font_Count];
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //VN_FONT_H
|