/* date = May 7th 2023 10:16 am */ #ifndef VN_FONT_H #define VN_FONT_H enum font_id { Font_Regular, Font_Bold, Font_Monospace, Font_MonospaceOblique, Font_Fancy, 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 0xe819 #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 #define FontIcon_DocumentInverted 0xf15b #define FontIcon_DocumentInvertedText 0xf15c #define FontIcon_DocumentFileImage 0xf1c5 #define FontIcon_DocumentFileAudio 0xf1c7 #define FontIcon_DocumentFileCode 0xf1c9 #define FontIcon_UserPlus 0xf234 #define FontIcon_UserTimes 0xf235 #define FontIcon_History 0xf235 #define FontIcon_Trash 0xf1f8 #define FontIcon_Debug 0xf188 #define FontIcon_Gamepad 0xf11b #define FontIcon_Paste 0xf0ea #define FontIcon_Cut 0xe825 #define FontIcon_Lock 0xe821 #define FontIcon_LockOpen 0xe822 #define FontIcon_Pin 0xe820 #define FontIcon_User 0xe81e #define FontIcon_Users 0xe81f struct glyph { glyph *LRUNext; glyph *LRUPrev; font_id Font; u32 Codepoint; r32 Size; s32 Subpixel; v2_s32 P0; v2_s32 P1; v2 Offset; r32 Advance; }; #define DEFAULT_GLYPH_ATLAS_DIM 1024*4 #define MAX_GLYPH_SIZE 128 #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 { arena *Arena; 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