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

Enable using OT SVG in FreeType #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tchayen
Copy link

@tchayen tchayen commented Aug 26, 2024

Hi! I reached out recently on Discord asking if emoji support is something that is in scope of this binding.

I analyzed current possibilities:

  • sbix – Apple format, bitmap, used only by apple emoji font AFAIK
  • COLRv0 - very simple colored shapes, added by Microsoft and used in the not exactly pretty Win10 emoji font
  • OT SVG - effort from Adobe and Microsoft to bring full SVGs to TTF glyphs. Heavy and wasteful but currently the simplest to implement.
  • COLRv1 - arguably the future of colored fonts. It's like lightweight binary subset of SVG, allowing for all visual complexity of SVG without its quirks and parts that wouldn't be useful in fonts anyway. As of now, it is possible to parse COLRv1 information using FreeType but it requires a separate renderer. See this comment - similarly to OT SVG, rendering of COLRv1 is out of scope for FT, but maybe hooks like the ones for OT SVG might come in future. But either way, there are no public standalone COLRv1 renderers yet so might be better to wait here.

Judging from the above, I decided that OT SVG is the most worthwhile format to implement now. I like how smooth the integration with FT is.

I have a proof that this works - my toy playground for text rendering - repository. I used PlutoSVG library which is meant for usecases like this and provides ready hooks.

All the setup I had to write in my user code was:

const hooks = plutosvg.c.plutosvg_ft_svg_hooks() orelse return error.PlutoSVG;
try ft_lib.setProperty("ot-svg", "svg-hooks", hooks);

I am not exactly sure how compilation of C files in Zig looks like. Does including those 2 files means that everyone using mach-freetype will get those files in their final binary? If yes maybe there's a way to make the otsvg.h optional.


  • By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.

@tchayen tchayen force-pushed the tchayen/enable-ot-svg branch from 977ab24 to 80fd898 Compare August 26, 2024 12:01
src/freetype.zig Outdated Show resolved Hide resolved
@tchayen tchayen force-pushed the tchayen/enable-ot-svg branch from 80fd898 to 8bd5600 Compare September 2, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant