Commit graph

23 commits

Author SHA1 Message Date
Daniel Eklöf
9029478e8c
font: tentative support for BGR, V-RGB and V-BGR 2019-08-19 17:45:21 +02:00
Daniel Eklöf
33b5210a6a
refactor: break out stride calculation to new function 2019-08-18 17:59:43 +02:00
Daniel Eklöf
0060e33912
font: implement subpixel antialiasing 2019-08-18 17:40:57 +02:00
Daniel Eklöf
f45e5c6aef
Remove all references to cairo; we now use pixman only 2019-08-16 22:11:22 +02:00
Daniel Eklöf
bed7b34c28
wip: render background and glyphs using pixman 2019-08-16 20:40:32 +02:00
Daniel Eklöf
30d5847d06
font: fix broken debug log 2019-08-16 18:00:56 +02:00
Daniel Eklöf
9e7106018e
font: don't bother creating a cairo surface for zero-width glyphs 2019-08-13 20:44:30 +02:00
Daniel Eklöf
8035bbfbdb
font: handle invalid glyphs correctly
*All* glyphs are cached.

But we never set the 'wc' member of failed glyphs, causing a later
cache lookup of the same glyph miss in the cache, and thus re-generate
yet another glyph (that is inserted into the cache). I.e. if the
same (invalid) glyph is rendered over and over again, we'll end up
growing the cache indefinitely.

Fix by setting the 'wc' member of invalid glyphs. This causes a cache
lookup to hit. But, we must also check the glyphs validity, and return
NULL if the glyph isn't valid.

Finally, when destroying a font, skip invalid glyphs, since they have
no resources that needs to be freed.
2019-08-13 20:41:21 +02:00
Daniel Eklöf
00b6948d9f
font: cleanup 2019-08-10 21:10:56 +02:00
Daniel Eklöf
92319d1570
font: initial support for fontconfig font fallback
When we've exhausted our own fallback list, try the font list provided
by fontconfig.

This means, the user's fallback fonts have priority, but in case all
of them fail, we hopefully get lucky with fontconfig...
2019-08-10 20:34:22 +02:00
Daniel Eklöf
83a10402af
font: improve logging 2019-08-08 17:57:58 +02:00
Daniel Eklöf
4d7993b36f
cell: pack more efficiently and store glyph as a wchar
The 'attributes' struct is now 8 bytes and naturally packed (used to
be 9 bytes, artificially packed).

'cell' struct is now 12 bytes, naturally packed (used to be 13 bytes,
artificially packed).

Furthermore, the glyph is stored as a wchar instead of a char*. This
makes it easier (faster) to do glyph lookup when rendering.
2019-08-02 18:19:07 +02:00
Daniel Eklöf
858a0d9906
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.
2019-07-31 18:03:35 +02:00
Daniel Eklöf
73b4d5d05a
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.
2019-07-30 18:04:28 +02:00
Daniel Eklöf
4302d3eb68
font: set FT load and render flags from FontConfig properties 2019-07-29 20:10:55 +02:00
Daniel Eklöf
fe882bddba
font: populate glyph cache (ASCII characters only) when instantiating font 2019-07-28 21:03:38 +02:00
Daniel Eklöf
9e57ba2108
font: add font_glyph_for_utf8()
This function fills in a struct glyph with glyph bitmap data for the
provided utf-8 character (essentially a FT_Bitmap wrapped in a cairo
surface).
2019-07-28 20:37:59 +02:00
Daniel Eklöf
175dc9cf94
cairo-ft: remove all usages of cairo-ft 2019-07-28 12:45:01 +02:00
Daniel Eklöf
cb02c9cf41
font: load FreeType face, and set it's pixel sizes 2019-07-28 12:09:22 +02:00
Daniel Eklöf
df929a251a
font: don't warn when failing to get hinting/antialias
These properties aren't always included in the pattern, and when they
aren't, trying to get them will fail.

This isn't an error, just fallback to a default value.
2019-07-18 10:03:08 +02:00
Daniel Eklöf
7ad87fdf2b
font: remove assert that was only there for debugging 2019-07-18 09:29:36 +02:00
Daniel Eklöf
89450bfd44
font: sync cairo's options with the FC pattern
Configure cairo's 'options' with default values, then update the
FontConfig pattern. Finally, update the cairo options after having
retrieved the final FontConfig option.
2019-07-17 22:50:26 +02:00
Daniel Eklöf
9ccc8433c3
initial grid implementation
This allows us to render *something*, even though it's inefficient,
stupid and far far away from the real thing.
2019-06-13 16:24:35 +02:00