-
Notifications
You must be signed in to change notification settings - Fork 229
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
Add support for color fonts #735
Conversation
So I just tried adding support for SVG and the positioning seems to work out-of-the-box (for horizontal writing), so the issue definitely seems limited to bitmap emojis... |
Thanks, will take a look. |
COLRv0 works now, too! <svg id="svg1" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"
font-size="25">
<title>Emojis</title>
<path id="crosshair" d="M 20 100 L 180 100 M 100 20 L 100 180"
stroke="gray" stroke-width="0.5"/>
<text id="text1" x="0" y="50" font-family="Segoe UI Emoji">Hii😀 😁how </text>
<text id="text1" x="0" y="90" font-family="Twitter Color Emoji">Hii😀😁how </text>
<text id="text1" x="0" y="130" font-family="Apple Color Emoji">Hii😀😁how </text>
<text id="text1" x="0" y="160" font-family="Noto Color Emoji">Hii😀😁how </text>
<!-- image frame -->
<rect id="frame" x="1" y="1" width="198" height="198" fill="none" stroke="black"/>
</svg> |
Here is a toy sbix font we can use to debug: https://github.com/simoncozens/test-fonts?tab=readme-ov-file#cff-and-sbixotf If I install it locally and open the following SVG: <svg id="svg1" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"
font-size="25">
<title>Emojis</title>
<path id="crosshair" d="M 20 100 L 180 100 M 100 20 L 100 180"
stroke="gray" stroke-width="0.5"/>
<text id="text1" x="0" y="100" font-family="CFF Outlines and SBIX">AAA</text>
<!-- image frame -->
<rect id="frame" x="1" y="1" width="198" height="198" fill="none" stroke="black"/>
</svg> I get the same behaviour on Firefox and Chrome. I'm trying to change different glyph metrics and recompile the font with EDIT: I tried changing different glyph metrics, and apart from x and y offset, none of them have any effect on the positioning... But in the original font the y offset is already 0, so that can't be where it is coming from. |
Thanks for looking into it. |
Looks like we are not the only ones troubled by this: harfbuzz/harfbuzz#2679 (comment) So can we ignore it for now? |
We should at least try to use the same hack everyone else is using. |
So Cool! Thank you for all you have done for this. |
Sounds good to me. |
Regarding subsetting, I think I tried that but iirc fonttools didn't support subsetting SVG tables. But I will try again. So should I disregard TTB writing for now? |
Writing to SVG? Or do you mean the layout? It's fine. |
I remember that Alternatively, you can use nanoemoji to convert SVG files into color fonts in a variety of formats, which will produce test fonts that are small enough to use. |
Huh okay, I'll try it again then, thanks! |
I think I'm getting close now. I'll try to investigate the tb writing mode issue again, then clean up and then it should be ready. Hopefully will be done within the next few days. |
I've added a few small TODOs where I wasn't sure what I should change it to. But otherwise it should be good, I hope. |
transform: glyph.svg_transform(), | ||
..Group::empty() | ||
}; | ||
// TODO: Probably need to update abs_transform of children? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm still thinking about a better abs_transform
implementation. The current one is pretty meh.
..Group::empty() | ||
}; | ||
// TODO: Probably need to update abs_transform of children? | ||
group.children.push(Node::Group(Box::new(tree.root))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we should keep it as Image::SVG
. But I guess it can be changed later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah true... Yeah I guess both would work.
Thanks! Looks good to me. |
Ready to merge? |
I think so! |
Not polished code yet, but it should be enough to test it.
Oh, and top-to-bottom text also doesn't quite work yet. 😅