Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for COLRv1 fonts #7140

Closed
unnamedname opened this issue Feb 20, 2024 · 9 comments
Closed

Support for COLRv1 fonts #7140

unnamedname opened this issue Feb 20, 2024 · 9 comments

Comments

@unnamedname
Copy link

unnamedname commented Feb 20, 2024

Is your feature request related to a problem? Please describe.
Kitty won't display COLRv1 (emoji) fonts.

Describe the solution you'd like

Describe alternatives you've considered

Additional context
colrv1

@kovidgoyal
Copy link
Owner

kovidgoyal commented Feb 20, 2024

Works fine for me with Segoe UI Emoji which uses COLRv1

kitty --config=None --debug-font-fallback -o 'symbol_map U+1f63a Segoe UI Emoji' sh -c 'printf "\U1f63a"; read'

screenshot

@unnamedname
Copy link
Author

Thanks for so prompt reply!

It indeed works with Segoe UI Emoji, but no luck with COLRv1 variant Noto Color Emoji:

kitty --config=None --debug-font-fallback -o 'symbol_map U+1f63a Noto Color Emoji' sh -c 'printf "\U1f63a"; read'

kitty-noto-emoji

Also I noticed that the Segoe UI Emoji displayed by Kitty (left) is different from the one in GTK (right):
kitty-segoe-emoji

This is most likely because the Segoe UI Emoji is a hybrid font that supports both COLRv1 and COLRv0, and Kitty actual displayed COLRv0 glyphs.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Feb 21, 2024

screenshot
Works fine with Noto Color Emoji as well

kitty --config=None --debug-font-fallback -o 'symbol_map U+1f63a Noto Color Emoji' sh -c 'printf "\U1f63a"; read'

Presumably that has bitmap fallbacks too?

@unnamedname
Copy link
Author

Maybe the COLRv1 version share the same font name Noto Color Emoji with the CDBT version packaged by most distros (assuming your system has the both installed).
Anyway, I suppose we could simply try to scale the interface large enough to determine if it is in CBDT or COLR format:
CBDT (packaged by Archlinux):
cat-cdbt

COLRv1 (packaged by the PKGBUILD):
pkgname=noto-color-emoji
pkgver=2.042
pkgrel=1
epoch=1
pkgdesc='Google Noto color emoji font using COLRv1'
arch=(any)
url='https://www.google.com/get/noto/'
license=(custom:OFL)
provides=(noto-fonts-emoji emoji-font)
conflicts=(noto-fonts-emoji)
source=(
    NotoColorEmoji.ttf::https://github.com/googlefonts/noto-emoji/raw/v$pkgver/fonts/Noto-COLRv1.ttf
    LICENSE::https://github.com/googlefonts/noto-emoji/raw/v$pkgver/LICENSE
)
sha256sums=('d5ce808f06f4776023202c22441d03d7e57f8980091d2107404438592f2b62f6'
            'c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4')

package() {
  mkdir -p "$pkgdir"/usr/share/fonts/noto
  install -m644 NotoColorEmoji.ttf "$pkgdir"/usr/share/fonts/noto/
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

cat-colrv1

@kovidgoyal
Copy link
Owner

Well given that the distro packaged fonts include color bitmaps, whats the motivation for supporting rendering of SVG? It's much slower/wasteful of CPU cycles.

@unnamedname
Copy link
Author

Well, I would have thought that with FreeType supporting COLRv1, Kitty could easily support it like COLRv0.
Since the harms outweigh the benefits, it doesn't count as an enhancement and duplicates #2691.

Thanks for your hard work!

@kovidgoyal
Copy link
Owner

You are welcome. If there is ever a reasonably widely used font that supports only COLRv1 without COLRv0 fallbacks we can reconsider, but as it stands I dont think the performance hit is worth it. Using pre-rendered bitmaps for emoji works fine.

@kovidgoyal
Copy link
Owner

And just for the record, it takes approx 1200 lines of C to render a COLRv1 glyph and thats using the facilities already provided by the cairo library. See for example https://fossies.org/linux/firefox/gfx/cairo/cairo/src/cairo-colr-glyph-render.c

Definitely not worth the effort.

@kovidgoyal
Copy link
Owner

I have enabled support for COLRv1 fonts by depending on the cairo library for rendering them (was about 300 lines of code in kitty). There is now a usecase for these as kitty supports multiple text sizes, see #8226. The support is in the cell branch will be merged to master eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants