Commit graph

8 commits

Author SHA1 Message Date
Aliaksandr Kalenik
1cc8895e4b LibGfx: Introduce with_size method for Font 2023-02-11 20:59:13 +00:00
Andreas Kling
850b4a03e6 LibGfx: Cache font pixel metrics in ScaledFont
Instead of recomputing the pixel metrics over and over, we can just
cache them with the font and avoid a bunch of expensive computation.
2023-01-24 14:13:59 +01:00
Andreas Kling
2a61d66b0a LibGfx: Make Font::preferred_line_height() more correct
Return a float, and fix a bogus calculation of ascender + descender.
2023-01-06 12:02:20 +01:00
MacDue
ada48a1daf LibGfx: Add ability to request glyphs at subpixel offsets to fonts
This adds the option to pass a subpixel offset when fetching a glyph
from a font, this offset is currently snapped to thirds of a pixel
(i.e. 0, 0.33, 0.66). This is then used when rasterizing the glyph,
which is then cached like usual.

Note that when using subpixel offsets you're trading a bit of space
for accuracy. With the current third of a pixel offsets you can end
up with up to 9 bitmaps per glyph.
2023-01-05 12:09:35 +01:00
Andreas Kling
555d7a6fce LibGfx: Make Font::glyph_width*() APIs return float 2023-01-03 15:25:02 +01:00
Andreas Kling
3407ab0fd1 LibGfx: Make Font::width() return a float 2023-01-03 15:25:02 +01:00
Andreas Kling
44025e837f LibGfx: Use float when calculating text width in ScaledFont
This fixes an issue where we'd truncate the fractional part of each
glyph width, often making the returned width slightly too short.
2022-07-09 22:16:18 +02:00
Simon Wanner
5136c5ae1a LibGfx: Move ScaledFont and new base class VectorFont out of TTF 2022-04-09 23:48:18 +02:00