Re: [dev] Suckless font rendering library

From: <suigin_AT_national.shitposting.agency>
Date: Sun, 15 May 2016 17:38:30 -0700

On Sun, May 15, 2016 at 08:28:20PM +0300, Alexander Krotov wrote:
> Need to state somewhere that it is a vector format, as bitmap fonts are
> already ok. dwm supported bitmap fonts only before it switched to Xft.
> Plan 9 font format is bitmap [1], it is used internally for all font
> rendering, and also it is the only font format supported in Go [2].
>
> There is a FreeType port [3] for Plan 9 to prerender existing
> vector fonts, but it may be a bad idea to prerender fonts offline
> instead
> of caching them in memory due to file size. So tinyfont can complement
> subfont format in the field of vector fonts. Following subfont
> file format, but replacing bitmaps with vector glyphs may be a good
> direction.

There's another alternative to bitmap and vector glyphs to consider.
Signed distance fields [1]. If you're not averse to OpenGL and/or
Vulkan, then this might be something to take a look at, at least as an
alternative to existing font rendering libraries. The state of the art
algorithms combine signed distance fields with contour fields [2].

It gives you the fidelity and memory characteristics of vector rendering
combined with the speed and runtime performance of bitmap rendering--and
then some, because it'll be GPU accelerated and you get effects like
strokes, shadows, gradients and so on for free--some can even be done in
a single pass.

You only need a single signed distance map and optional contour maps for
each glyph, which can then be used to render the glyph at all
resolutions. Thus, offline processing is feasible, as you don't need
pre-rendered glyphs for all required resolutions. Typically, you mmap in
your font file, and page the glyph data into a GPU texture atlas
as needed for rendering.

Freetype can be relegated for offline use and only when OpenType
shaping is a concern do you need to worry about writing a Harfbuzz
backend. Maybe make the Harfbuzz plugin an optional component so those
who need it can layer Harfbuzz on top of your library.

Just putting some ideas out there.

[1]
http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf
[2]
https://lambdacube3d.wordpress.com/2014/11/12/playing-around-with-font-rendering/
Received on Mon May 16 2016 - 02:38:30 CEST

This archive was generated by hypermail 2.3.0 : Mon May 16 2016 - 02:48:10 CEST