aboutsummaryrefslogtreecommitdiff
path: root/font.h
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-31 16:03:35 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-31 16:03:35 +0000
commit858a0d9906a66f2eb9c2ffaf6d71e1153dad33f7 (patch)
treef1ee47f7dd884924656727bf27976a56a8af9b60 /font.h
parentvt: disable flash on bell, it's too annoying in e.g. zsh (diff)
font: initial support for double-width *and* color emoji glyphs
Fonts are now loaded with FT_LOAD_COLOR and we recognize and support the FT_PIXEL_MODE_BGRA pixel mode. This is mapped to a CAIRO_FORMAT_ARGB32 surface, that is blitted as-is (instead of used as a mask like we do for gray and mono glyphs). Furthermore, since many emojis are double-width, we add initial support for double-width glyphs. These are assumed to always be utf8. When PRINT:ing an utf8 character, we check its width, and add empty "spacer" cells after the cell with the multi-column glyph. When rendering, we render the columns in each row backwards. This ensures the spacer cells get cleared *before* we render the glyph (so that we don't end up erasing part of the glyph). Finally, emoji fonts are usually bitmap fonts with *large* glyphs. These aren't automatically scaled down. I.e. even if we request a glyph of 13 pixels, we might end up getting a 100px glyph. To handle this, fontconfig must be configured to scale bitmap fonts. When it is, we can look at the 'scalable' and 'pixelsizefixup' properties, and use these to scale the rendered glyph.
Diffstat (limited to 'font.h')
-rw-r--r--font.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/font.h b/font.h
index 0f2c9833..9746eaac 100644
--- a/font.h
+++ b/font.h
@@ -15,18 +15,13 @@ typedef tll(const char *) font_list_t;
struct glyph {
wchar_t wc;
+ int width;
- void *data;
cairo_surface_t *surf;
int left;
int top;
-#if 0
- int format;
- int width;
- int height;
- int stride;
-#endif
+ double pixel_size_fixup;
};
typedef tll(struct glyph) hash_entry_t;
@@ -36,10 +31,13 @@ struct font {
int load_flags;
int render_flags;
FT_LcdFilter lcd_filter;
+ double pixel_size_fixup; /* Scale factor - should only be used with ARGB32 glyphs */
+
struct {
double position;
double thickness;
} underline;
+
struct {
double position;
double thickness;
@@ -48,7 +46,6 @@ struct font {
bool is_fallback;
tll(char *) fallbacks;
- //struct glyph cache[256];
hash_entry_t **cache;
mtx_t lock;
};