| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#pragma once |
| 27 |
|
| 28 |
#include <SDL_surface.h> |
| 29 |
|
| 30 |
#include "c_array.h" |
| 31 |
#include "vector.h" |
| 32 |
|
| 33 |
#define ARROW_LEFT "\x11" |
| 34 |
#define ARROW_RIGHT "\x10" |
| 35 |
#define ARROW_UP "\x1e" |
| 36 |
#define ARROW_DOWN "\x1f" |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
typedef struct |
| 41 |
{ |
| 42 |
struct vec2i Size; |
| 43 |
int Stride; |
| 44 |
struct |
| 45 |
{ |
| 46 |
int Left; |
| 47 |
int Top; |
| 48 |
int Right; |
| 49 |
int Bottom; |
| 50 |
} Padding; |
| 51 |
struct vec2i Gap; |
| 52 |
CArray Chars; |
| 53 |
} Font; |
| 54 |
|
| 55 |
typedef enum |
| 56 |
{ |
| 57 |
ALIGN_START = 0, |
| 58 |
ALIGN_CENTER, |
| 59 |
ALIGN_END |
| 60 |
} FontAlign; |
| 61 |
typedef struct |
| 62 |
{ |
| 63 |
FontAlign HAlign; |
| 64 |
FontAlign VAlign; |
| 65 |
struct vec2i Area; |
| 66 |
struct vec2i Pad; |
| 67 |
color_t Mask; |
| 68 |
} FontOpts; |
| 69 |
|
| 70 |
extern Font gFont; |
| 71 |
|
| 72 |
FontOpts FontOptsNew(void); |
| 73 |
|
| 74 |
void FontLoad( |
| 75 |
Font *f, const char *imgPath, const bool isProportional, |
| 76 |
const struct vec2i spaceSize); |
| 77 |
void FontTerminate(Font *f); |
| 78 |
|
| 79 |
int FontW(const char c); |
| 80 |
int FontH(void); |
| 81 |
struct vec2i FontChSize(const char c); |
| 82 |
int FontStrW(const char *s); |
| 83 |
int FontSubstrW(const char *s, int len); |
| 84 |
int FontStrH(const char *s); |
| 85 |
struct vec2i FontStrSize(const char *s); |
| 86 |
int FontStrNumLines(const char *s); |
| 87 |
|
| 88 |
|
| 89 |
struct vec2i FontCh(const char c, const struct vec2i pos); |
| 90 |
struct vec2i FontChMask( |
| 91 |
const char c, const struct vec2i pos, const color_t mask); |
| 92 |
struct vec2i FontStr(const char *s, struct vec2i pos); |
| 93 |
struct vec2i FontStrMask(const char *s, struct vec2i pos, const color_t mask); |
| 94 |
struct vec2i FontStrMaskWrap( |
| 95 |
const char *s, struct vec2i pos, color_t mask, const int width); |
| 96 |
void FontStrOpt(const char *s, struct vec2i pos, const FontOpts opts); |
| 97 |
void FontStrCenter(const char *s); |
| 98 |
|
| 99 |
void FontSplitLines(const char *text, char *buf, const int width); |
| 100 |
|
| 101 |
struct vec2i Vec2iAligned( |
| 102 |
const struct vec2i v, const struct vec2i size, const FontAlign hAlign, |
| 103 |
const FontAlign vAlign, const struct vec2i area); |