1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-11-16 16:09:42 +01:00

Clean up Font.h, move structs into Font.cpp

None of the structs in the new font system ended up being "publicly"
accessible, they were all treated as implementation details for
Font.cpp to use, so these structs are now fully defined in Font.cpp
only.
This commit is contained in:
Dav999-v 2023-01-18 23:13:35 +01:00 committed by Misa Elizabeth Kai
parent d2461c90ce
commit 653eee505b
2 changed files with 51 additions and 50 deletions

View file

@ -7,6 +7,7 @@
#include "Constants.h"
#include "FileSystemUtils.h"
#include "Graphics.h"
#include "GraphicsUtil.h"
#include "Localization.h"
#include "UtilityClass.h"
#include "Vlogging.h"
@ -18,6 +19,52 @@ SDL_Texture* LoadImage(const char *filename, const TextureLoadType loadtype);
namespace font
{
#define GLYPH_EXISTS 0x1
#define GLYPH_COLOR 0x2
struct GlyphInfo
{
uint16_t image_idx;
uint8_t advance;
uint8_t flags;
};
/* Codepoints go up to U+10FFFF, so we have 0x110 (272) pages
* of 0x1000 (4096) glyphs, allocated as needed */
#define FONT_N_PAGES 0x110
#define FONT_PAGE_SIZE 0x1000
struct Font
{
char name[64];
uint8_t glyph_w;
uint8_t glyph_h;
SDL_Texture* image;
GlyphInfo* glyph_page[FONT_N_PAGES];
};
struct FontContainer
{
uint8_t count;
Font* fonts;
};
struct PrintFlags
{
uint8_t scale;
Font* font_sel;
uint8_t alpha;
uint8_t colorglyph_bri;
bool border;
bool align_cen;
bool align_right;
bool cjk_low;
bool cjk_high;
};
static FontContainer fonts_main = {};
static FontContainer fonts_custom = {};

View file

@ -30,56 +30,6 @@
#include <stdint.h>
#include <string>
#include "GraphicsUtil.h"
namespace font
{
#define GLYPH_EXISTS 0x1
#define GLYPH_COLOR 0x2
struct GlyphInfo
{
uint16_t image_idx;
uint8_t advance;
uint8_t flags;
};
/* Codepoints go up to U+10FFFF, so we have 0x110 (272) pages
* of 0x1000 (4096) glyphs, allocated as needed */
#define FONT_N_PAGES 0x110
#define FONT_PAGE_SIZE 0x1000
struct Font
{
char name[64];
uint8_t glyph_w;
uint8_t glyph_h;
SDL_Texture* image;
GlyphInfo* glyph_page[FONT_N_PAGES];
};
struct FontContainer
{
uint8_t count;
Font* fonts;
};
struct PrintFlags
{
uint8_t scale;
Font* font_sel;
uint8_t alpha;
uint8_t colorglyph_bri;
bool border;
bool align_cen;
bool align_right;
bool cjk_low;
bool cjk_high;
};
#define PR_1X (0 << 0) /* default, 1x scale */
#define PR_2X (1 << 0) /* 2x scale */
@ -106,6 +56,10 @@ struct PrintFlags
#define PR_CJK_LOW (1 << 20) /* larger fonts should stick out fully on the bottom (draw at Y) */
#define PR_CJK_HIGH (2 << 20) /* larger fonts should stick out fully on the top */
namespace font
{
bool find_main_font_by_name(const char* name, uint8_t* idx);
const char* get_main_font_name(uint8_t idx);
uint8_t get_font_idx_8x8(void);