New patch release of #fcft is out: https://codeberg.org/dnkl/fcft/releases/tag/3.3.3

This release fixes an issue where COLRv1 fonts resulted in "nothing" being rendered.

Note that the fix is not (yet) to actually render COLRv1, but to skip COLRv1 fonts and try the next fallback font instead.

Implementing COLRv1 support is still an open issue (https://codeberg.org/dnkl/fcft/issues/114)

Fcft is a font rasterization library, built on top of fontconfig and freetype, and is used by e.g. #foot and #fuzzel to render text.

Cookie monster!

Hi @dnkl, for a project (#X11 with #XRender using #xcb, still in experimentation phase), I was looking for a sane way to render #SVG fonts with #freetype. Looking for a sane library to do the rasterizing, I finally found the solution (#nanosvg 👍) in your #fcft project (thanks!).

I tried to "steal" your metrics calculations at first, but the result was completely broken with the "Twitter Color Emoji" font, so I started over (meanwhile ditching most floating-point stuff in favor of freetype's fixed-point formats), and now the result looks sane. In case you're interested, here's my nanosvg/freetype adapter:
https://github.com/Zirias/xmoji/blob/master/src/bin/xmoji/svghooks.c

But of course I have doubts now, maybe the font I'm testing with is "unusual"? Which fonts do you test with? Thanks!

xmoji/src/bin/xmoji/svghooks.c at master · Zirias/xmoji

Contribute to Zirias/xmoji development by creating an account on GitHub.

GitHub

You might experience slightly larger, or smaller, fonts in e g #foot after upgrading #fcft to 3.1.8 (just now tagged and released).

This is expected, as fcft is now using FreeType size-setting APIs with higher-resolution parameters.

A simplified explanation is that fcft used to round the size (the pixel size, not the point size) to the nearest integer. Now it doesn't.

For those interested: here's the fcft patch: https://codeberg.org/dnkl/fcft/pulls/63

fcft: use FT_Set_Char_Size() instead of FT_Set_Pixel_Sizes()

`FT_Set_Char_Size()` is more fine-grained, and lets us set the size more precisely, since it allows a fractional point size. Since the input size is already in pixels, use a DPI of 72 (meaning, a pixel has the same size as a point).

Codeberg.org
@mc look at that - it uses #fcft 😊

#Harfbuzz 5.0 breaks bitmap font rendering in #foot and all other #fcft based applications (assuming fcft has been built with harfbuzz support, of course).

https://github.com/harfbuzz/harfbuzz/issues/3755

Fix has been pushed to harfbuzz, but as far as I can tell, has not yet been released.

harfbuzz 5.0.0 and higher breaks terminus font · Issue #3755 · harfbuzz/harfbuzz

On Arch Linux and other distros, upgrading to harfbuzz 5.0.0 or higher (in testing repository on arch) breaks the terminus font (otb version) in foot terminal. Before After

GitHub

#fcft 3.1.0, with OT-SVG support, is out!

https://codeberg.org/dnkl/fcft/releases/tag/3.1.0

fcft

A simple library for font loading and glyph rasterization using FontConfig, FreeType and pixman.

Codeberg.org

I've been working on OT-SVG support in #fcft the whole day, and is finally starting to get somewhere...

https://codeberg.org/dnkl/fcft/issues/49

Support for SVG in Opentype fonts

Because support has recently been added to FreeType2 for the OpenType SVG specification, it would be a a nice addition to support this capability. This includes the color SVG support for glyphs. I am not sure how large of a lift this would be, but would be a nice addition for supporting SVG icon fonts in `yambar` See: https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/122 https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/68

Codeberg.org

I was working on #fcft to improve the support for emoji presentation selectors, and accidentally fixed mixed LTR/RTL!

https://codeberg.org/dnkl/fcft/pulls/38

Take emoji default presentation into account, mixed LTR/RTL

Emoji's have a "default presentation", that can either be "text" or "emoji". This is something we have completely ignored up until now; we've simply been searching the fallback list "as usual", using the first font in the list that has glyphs for the searched-for codepoint. With this patch, we now ignore emoji fonts when looking for an **emoji** codepoint whose default presentation is "text", and we ignore non-emoji fonts when looking for a codepoint whose default presentation is "emoji". On a side not: if one is to generalize, the emojis that have "text" as their default presentation are the same ones that `wcwidth()` returns 1 for. Some images: the text used here is `"$(echo -e '\u263a xyz \u263a\ufe0e abc \u263a\ufe0f') | اَلْعَرَبِيَّةُ | xyz | ויקיפדיה"` I.e. `WHITE SMILING FACE` (U+263a) using its default presentation (text), followed by the same emoji again, first with an explicit text presentation selector, and then with an emoji presentation selector. Thus, on each row we expect **two** text-emojis, and **one** graphical emoji. This is then followed by "arabic", "xyz", and "hebrew". There are three rows in the images: the first row is rendered one codepoint at a time, using `fcft_glyph_rasterize()`. The second row is rendered one **grapheme** at a time, using `fcft_grapheme_rasterize()`. The last row is rendered as a single run, using `fcft_text_run_rasterize()`. ## Before ### Limited primary font (non-ascii glyphs from fallback font): ![https://codeberg.org/attachments/086b3616-32d4-4804-a5b4-f1c9bbed1597](https://codeberg.org/attachments/086b3616-32d4-4804-a5b4-f1c9bbed1597) Note how the emojis are wrong: the primary font doesn't have this codepoint, and we're falling back to a colored emoji font. Only `fcft_grapheme_rasterize()` pays any attention to presentation selectors, and only explicit ones. We're _almost_ rendering the arabic and hebrew correctly; the only issue is that the last emoji should come **before** the arabic text. ### Large/full primary font (primary font has most glyphs): ![https://codeberg.org/attachments/c66571dc-8db9-46ae-b62f-6eae752a2de7](https://codeberg.org/attachments/c66571dc-8db9-46ae-b62f-6eae752a2de7) Emojis may appear to look better, but that's just because this primary font has the `WHITE SMILING FACE` emoji. Again, `fcft_grapheme_rasterize()` handles explicit presentation selectors, and thus the last emoji in the middle row is correct. The last row is pretty bad; since this primary font has **all** glyphs, it is shaped in a single go. This is the reason both the arabic and hebrew is rendered "reversed". ## After ### Limited primary font (non-ascii glyphs from fallback font): ![https://codeberg.org/attachments/c4743550-eea6-4ef7-8b92-29f1dcd0fc7b](https://codeberg.org/attachments/c4743550-eea6-4ef7-8b92-29f1dcd0fc7b) ### Large/full primary font (primary font has most glyphs): ![https://codeberg.org/attachments/2264d7bd-b36d-430e-b1a1-9d7ea3f7a380](https://codeberg.org/attachments/2264d7bd-b36d-430e-b1a1-9d7ea3f7a380) Both images are rendered as correct as one can expect. The ascii/latin characters look different in the two images since the primary font is different. But LTR/RTL is all correct, emojis are all correct (the last emoji in the first row is incorrect, but this is to be expected with `fcft_glyph_rasterize()`, since it only takes a single codepoint). ## Real usage Here's a real-world example; two yambar instances, top one using fcft from master, bottom one using fcft from this PR: ![https://codeberg.org/attachments/787c5e74-bfd2-4f42-a79d-c1f220ee8032](https://codeberg.org/attachments/787c5e74-bfd2-4f42-a79d-c1f220ee8032) The three emojis are using the default presentation, explicit text presentation, and emoji presentation, respectively.

I just released #fcft 2.2.7, with a single change: downscaled bitmap fonts (e.g. emoji fonts) are lanczos3 filtered. This greatly improves the visual quality.

Old one to the left, new one to the right: