aboutsummaryrefslogtreecommitdiff
path: root/font.c (unfollow)
Commit message (Collapse)AuthorLines
2019-12-01tllist: remove git submodule and local copy under subprojectsDaniel Eklöf-809/+0
2019-12-01font: log fontconfig/freetype version when debug logging has been enabledDaniel Eklöf-0/+20
2019-12-01Revert "font: ceil:ing the top value seems to look better when scaled"Daniel Eklöf-1/+1
This reverts commit 95d97b39734026e05f47b2064fe686da1ae40d20.
2019-11-30font: ceil:ing the top value seems to look better when scaledDaniel Eklöf-1/+1
2019-11-30font: fix estimated underline thickness; descent is typically negativeDaniel Eklöf-1/+1
2019-11-30render: fix underline/strikeout positioningDaniel Eklöf-9/+9
There were two errors: * We subtracted half the line width instead of adding it to the baseline * We rounded the line positioning and thickness before the positioning calculation. In particular, rounding the thickness before using it to adjust the position was wrong. Now we round just before the pixman call.
2019-11-30font: bug: bad multiplier when converting from 16.16 fixed floatDaniel Eklöf-1/+1
2019-11-30font: cache_size -> glyph_cache_sizeDaniel Eklöf-4/+4
This makes it more clear it has nothing to do with the font cache.
2019-11-30font: destructor: pop elements as we goDaniel Eklöf-1/+1
Otherwise we'll end up free:ing the same font over and over again.
2019-11-30font: original -> requestedDaniel Eklöf-8/+8
2019-11-30font: log freetype errorsDaniel Eklöf-3/+19
2019-11-29font: never set glyph->cols to something that is less than 0Daniel Eklöf-1/+4
2019-11-28font: add missing ';'Daniel Eklöf-1/+1
2019-11-28font: use pixelsizefixupfactor on regular bitmap fonts too, if setDaniel Eklöf-12/+9
But if it isn't set, only estimate it if the font is a *scalable* non-outline (bitmap) font.
2019-11-27font: set pixman filter when re-scaling glyphDaniel Eklöf-14/+5
2019-11-26font: estimate pixel size fixup when not provided by fontconfigDaniel Eklöf-25/+73
But only do this when the font is scalable but not an outline. This is only true for color bitmap fonts (emoji fonts), and not e.g. regular bitmap fonts.
2019-11-26font: use DPI=75 if there's no DPI attribute from fontconfigDaniel Eklöf-1/+1
This is the fontconfig default as well
2019-11-26font: underline/strikeout: use y-scale, not x-scaleDaniel Eklöf-9/+9
2019-11-26font: move metrics from terminal struct to font structDaniel Eklöf-0/+16
2019-11-25font: cleanup and return error when failing to load font fileDaniel Eklöf-1/+4
2019-11-25font: use FT_Set_Pixel_Sizes() instead of FT_Set_Char_Size()Daniel Eklöf-2/+8
Since we're working with pixel sizes anyway...
2019-11-20font: don't spam failures to lookup glyphsDaniel Eklöf-2/+2
2019-11-01font: cache loaded fonts globallyDaniel Eklöf-0/+52
Each font instance has a ref-counter. Whenever we want to instantiate a font that has already been loaded, we instead return the already-loaded instance, and bump the ref counter. When the last font instance is destroyed, it is also removed from the cache.
2019-10-18font: glyph_for_wchar(): ensure glyph->valid == false, in *all* error casesDaniel Eklöf-4/+6
2019-10-17font: load fallback fonts on demandDaniel Eklöf-18/+29
When instantiating a primary font, build the fallback font list, but don't actually instantiate the fallback fonts. Instead, remember the (full) pattern that we should use if/when we instantiate it. Then, when looking up a glyph and we need a fallback font, loop the list and instantiate the font(s) there and then.
2019-10-17font: load all fallbacks when instantiating a primary fontDaniel Eklöf-114/+41
The caching of fallback fonts didn't work. It "worked" because we didn't free the fonts... When we started doing that, the fallback fonts were no longer cached. Another solution would have been to keep the cached fallback fonts around until exit, and free them there. But that didn't seem very clean. So, for now, load *all* fallbacks when instantiating a primary (non-fallback) font. Note that this slows down initial startup time.
2019-10-17font: rename cache -> glyph_cacheDaniel Eklöf-13/+15
2019-10-17font: fc_idx may not be the requested oneDaniel Eklöf-2/+4
2019-10-17font: rename fc_loaded_fonts -> fc_loaded_fallbacksDaniel Eklöf-10/+11
2019-10-16font: cache top-level fontsDaniel Eklöf-1/+62
This greatly improves the performance when loading user-configured fallback fonts. Previously, we had to re-load these fallback fonts over and over again for each (new) glyph.
2019-10-16font: from_name() returns an allocated font structDaniel Eklöf-22/+19
2019-10-16font: cache loaded fontconfig fallback fontsDaniel Eklöf-19/+51
2019-10-16font: font_from_name() returns an allocated font structDaniel Eklöf-3/+7
2019-09-29font: calculate underline/strikeout metrics in font, not mainDaniel Eklöf-0/+41
2019-08-19font: tentative support for BGR, V-RGB and V-BGRDaniel Eklöf-7/+22
2019-08-18refactor: break out stride calculation to new functionDaniel Eklöf-2/+2
2019-08-18font: implement subpixel antialiasingDaniel Eklöf-48/+76
2019-08-16Remove all references to cairo; we now use pixman onlyDaniel Eklöf-1/+1
2019-08-16wip: render background and glyphs using pixmanDaniel Eklöf-19/+33
2019-08-16font: fix broken debug logDaniel Eklöf-1/+1
2019-08-13font: don't bother creating a cairo surface for zero-width glyphsDaniel Eklöf-1/+4
2019-08-13font: handle invalid glyphs correctlyDaniel Eklöf-1/+5
*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-10font: cleanupDaniel Eklöf-30/+7
2019-08-10font: initial support for fontconfig font fallbackDaniel Eklöf-42/+115
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-08font: improve loggingDaniel Eklöf-6/+6
2019-08-02cell: pack more efficiently and store glyph as a wcharDaniel Eklöf-16/+7
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-07-31font: initial support for double-width *and* color emoji glyphsDaniel Eklöf-31/+46
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-30font: add support for fallback fontsDaniel Eklöf-32/+187
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-29font: set FT load and render flags from FontConfig propertiesDaniel Eklöf-18/+121
2019-07-28font: populate glyph cache (ASCII characters only) when instantiating fontDaniel Eklöf-0/+25
2019-07-28font: add font_glyph_for_utf8()Daniel Eklöf-0/+76
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-28cairo-ft: remove all usages of cairo-ftDaniel Eklöf-38/+0
2019-07-28font: load FreeType face, and set it's pixel sizesDaniel Eklöf-15/+48
2019-07-18font: don't warn when failing to get hinting/antialiasDaniel Eklöf-6/+2
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-18font: remove assert that was only there for debuggingDaniel Eklöf-1/+0
2019-07-17font: sync cairo's options with the FC patternDaniel Eklöf-1/+24
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-06-13initial grid implementationDaniel Eklöf-0/+85
This allows us to render *something*, even though it's inefficient, stupid and far far away from the real thing.