aboutsummaryrefslogtreecommitdiff
path: root/drw.h
diff options
context:
space:
mode:
Diffstat (limited to 'drw.h')
-rw-r--r--drw.h38
1 files changed, 34 insertions, 4 deletions
diff --git a/drw.h b/drw.h
index 84bec3b..578fd2a 100644
--- a/drw.h
+++ b/drw.h
@@ -18,10 +18,39 @@ typedef struct {
} Canvas;
typedef struct {
+ const char *path;
+ int loaded;
FT_Library library;
FT_Face face;
} Font;
+enum FontType {
+ FONT_NORMAL,
+ FONT_ITALIC,
+ FONT_BOLD,
+ FONT_BOLD_ITALIC,
+ FONT_TYPE_SIZE
+};
+
+typedef Font FontFamily[FONT_TYPE_SIZE];
+typedef char *FontPath[FONT_TYPE_SIZE];
+
+struct FontCacheElement_;
+typedef struct FontCacheElement_ {
+ FontFamily *family;
+ struct FontCacheElement_ *next;
+} FontCacheElement;
+
+typedef struct {
+ FontCacheElement *first;
+ unsigned fontsize;
+ unsigned fonttype;
+ struct {
+ unsigned width;
+ unsigned height;
+ } box;
+} FontCache;
+
typedef struct {
uint8_t r;
uint8_t g;
@@ -36,9 +65,10 @@ void free_drw(Canvas *canvas);
void draw_rect(Canvas *canvas, unsigned x, unsigned y, unsigned width, unsigned height, uint32_t color);
void draw_point(Canvas *canvas, unsigned x, unsigned y, uint32_t color);
-Font* create_font(const char *fontpath, unsigned size);
-void free_font(Font *font);
-unsigned draw_font(Canvas *canvas, Font *font, const char *text, unsigned x, unsigned y, uint32_t color);
-unsigned font_width(Font *font, const char *text);
+FontCache *create_font_cache(FontPath *fontpath, int size, unsigned fontsize);
+void font_cache_generate_box(FontCache *fontcache);
+void free_font_cache(FontCache *fontcache);
+unsigned draw_char(Canvas *canvas, FontCache *fontcache, uint_least32_t charcode, unsigned x, unsigned y, uint32_t color);
+unsigned font_width(FontCache *fontcache, const char *text);
#endif