aboutsummaryrefslogtreecommitdiff
path: root/font.h
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-30 16:04:28 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-30 16:04:28 +0000
commit73b4d5d05ab3d3059017a0d3e2a5c798a241da87 (patch)
treef4d7bc75128f8cf061493467954a1805fedd9a03 /font.h
parentrender: add a 'clean' bit to each cell; only render cells that aren't clean (diff)
font: add support for fallback fonts
A top-level font now has a list of fallback fonts. When a glyph cannot be found, we try each fallback font in turn, until we either find one that has the glyph, or until we've exhausted the list. To make this actually work in practise (read: to make performance acceptable), the cache is re-worked and is now populated on demand. It also supports non-ASCII characters, by using the 4-byte unicode character as index instead. Since having an array that can be indexed by a 4-byte value isn't really viable, we now have a simple hash table instead of an array.
Diffstat (limited to 'font.h')
-rw-r--r--font.h55
1 files changed, 51 insertions, 4 deletions
diff --git a/font.h b/font.h
index 192640a9..0f2c9833 100644
--- a/font.h
+++ b/font.h
@@ -3,9 +3,56 @@
#include <stdbool.h>
#include <threads.h>
-#include "terminal.h"
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_LCD_FILTER_H
+#include <cairo.h>
-bool font_from_name(const char *name, struct font *result);
-bool font_glyph_for_utf8(
- struct font *font, const char *utf8, struct glyph *glyph);
+#include "tllist.h"
+//#include "terminal.h"
+
+typedef tll(const char *) font_list_t;
+
+struct glyph {
+ wchar_t wc;
+
+ void *data;
+ cairo_surface_t *surf;
+ int left;
+ int top;
+
+#if 0
+ int format;
+ int width;
+ int height;
+ int stride;
+#endif
+};
+
+typedef tll(struct glyph) hash_entry_t;
+
+struct font {
+ FT_Face face;
+ int load_flags;
+ int render_flags;
+ FT_LcdFilter lcd_filter;
+ struct {
+ double position;
+ double thickness;
+ } underline;
+ struct {
+ double position;
+ double thickness;
+ } strikeout;
+
+ bool is_fallback;
+ tll(char *) fallbacks;
+
+ //struct glyph cache[256];
+ hash_entry_t **cache;
+ mtx_t lock;
+};
+
+bool font_from_name(font_list_t names, const char *attributes, struct font *result);
+const struct glyph *font_glyph_for_utf8(struct font *font, const char *utf8);
void font_destroy(struct font *font);