Skottie with font fallback?

194 views
Skip to first unread message

dan.r...@dockyard.com

unread,
Sep 19, 2023, 8:31:04 PM9/19/23
to skia-discuss
I have a Skottie animation, from After Effects, that animates dynamic text. However, a single line text can have different characters, such as: "XYZ 新年快樂" that are not necessarily going found in a single font. Is there a way to designate a fallback font when a character is not found within a single line of text?

Florin Malita

unread,
Sep 20, 2023, 4:00:25 PM9/20/23
to skia-d...@googlegroups.com
You can pass an SkFontMgr to the animation builder, and it will be used to resolve missing glyphs.  Skia provides several SkFontMgr implementations, including a FontConfig flavor.  Or you can always write your own if you need custom fallback rules.

On Tue, Sep 19, 2023 at 8:31 PM 'dan.r...@dockyard.com' via skia-discuss <skia-d...@googlegroups.com> wrote:
I have a Skottie animation, from After Effects, that animates dynamic text. However, a single line text can have different characters, such as: "XYZ 新年快樂" that are not necessarily going found in a single font. Is there a way to designate a fallback font when a character is not found within a single line of text?

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/414c5cd8-1762-4d2c-9cae-f61a50914762n%40googlegroups.com.

dan.r...@dockyard.com

unread,
Sep 20, 2023, 6:38:07 PM9/20/23
to skia-discuss
Thanks. I was under the impression that SkFontMgr was only available for Paragraph builder. Does SkFontMgr apply to all text in Skottie? In particular purely defined in Lottie json from After Effects animations? 

Florin Malita

unread,
Sep 20, 2023, 7:58:54 PM9/20/23
to skia-d...@googlegroups.com
On Wed, Sep 20, 2023 at 6:38 PM 'dan.r...@dockyard.com' via skia-discuss <skia-d...@googlegroups.com> wrote:
Thanks. I was under the impression that SkFontMgr was only available for Paragraph builder. Does SkFontMgr apply to all text in Skottie? In particular purely defined in Lottie json from After Effects animations?

Yes, Skottie uses SkShaper for text shaping, which in turn uses an SkFontMgr for font fallback.  The SkFontMgr that you pass to skottie::Animation::Builder is plumbed all the way to SkShaper.
 

On Wednesday, September 20, 2023 at 4:00:25 PM UTC-4 Florin Malita wrote:
You can pass an SkFontMgr to the animation builder, and it will be used to resolve missing glyphs.  Skia provides several SkFontMgr implementations, including a FontConfig flavor.  Or you can always write your own if you need custom fallback rules.

On Tue, Sep 19, 2023 at 8:31 PM 'dan.r...@dockyard.com' via skia-discuss <skia-d...@googlegroups.com> wrote:
I have a Skottie animation, from After Effects, that animates dynamic text. However, a single line text can have different characters, such as: "XYZ 新年快樂" that are not necessarily going found in a single font. Is there a way to designate a fallback font when a character is not found within a single line of text?

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/414c5cd8-1762-4d2c-9cae-f61a50914762n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.

Miguel Camba

unread,
Sep 21, 2023, 10:52:24 AM9/21/23
to skia-discuss
I am trying this too, but I can't see a way of passing a FontManager to an animation in any way.
`CanvasKit.MakeManagedAnimation` does not take any arguments we can use (https://github.com/google/skia/blob/50814d9ca5bb4f2b14d0eb53bcb4f4dca88ebb04/modules/canvaskit/skottie.js#L17) and neither seems to do the underlying `CanvasKit.MakeAnimation`. The animation object returned by either of them doesn't seem to have any methods related to font managers, such as `setForManager`.
Bear in mind that C++ is not my strong suit of mine (or even a weak one), but I don't see this surfacing anywhere in the javascript implementation. Is there any example anywhere of this feature being used?
The goals is to have a skottie animation fallback to the system font when glyphs are not found in the provided font.

Ben Wagner

unread,
Sep 21, 2023, 11:20:30 AM9/21/23
to skia-d...@googlegroups.com
Yes, it looks like skottie::Animation::setFontManager isn't exposed in
any way in the CanvasKit Skottie bindings. It looks like this should
be added.
> To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/ba191a65-c0f9-4eb1-b245-2fb6f968b9den%40googlegroups.com.

Ben Wagner

unread,
Sep 21, 2023, 11:27:53 AM9/21/23
to skia-d...@googlegroups.com
And by that I mean skottie::Animation::Builder::setFontManager [0].
Accidentally left out a step there.

Looks like this would need to go through
CanvasKit.MakeManagedAnimation to MakeManagedAnimation::Make (which
uses the Builder).

[0] https://skia.googlesource.com/skia/+/850c9014501bd2ad79f72d4f7b8a25987e527103/modules/skottie/include/Skottie.h#127

Miguel Camba

unread,
Sep 21, 2023, 11:39:46 AM9/21/23
to skia-discuss
That was my guess, since it seems that the C++ code is wrapped into a JS api somewhat declaratively. If you can make this happen I can be your tester. Specifically we have some nice animations that will be seen by a lot of people and they may include glyphs in several alphabets, and for Chinese/Japanese/Korean is not feasible to ship a comprehensive font. At best we could ship a reduced font set that would render correctly the 99th percentile of words. But if we can fallback to system fonts, the problem disappears altoghether.

Ben Wagner

unread,
Sep 21, 2023, 11:49:35 AM9/21/23
to skia-d...@googlegroups.com
You would still need to create your own FontMgr objects which means
providing the font data. The wasm sandbox itself has no access to any
font data (unless the data is built into the wasm) so it would be up
to you to get font data into the wasm sandbox, either through
downloading web fonts from somewhere or from something like Local Font
Access API (https://font-access-api.glitch.me/).
> To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/58ec7191-477e-4882-bd7f-b4337c1b4e29n%40googlegroups.com.

Miguel Camba

unread,
Sep 21, 2023, 12:05:28 PM9/21/23
to skia-discuss
Using a local font API sounds acceptable.

Miguel Camba

unread,
Sep 21, 2023, 12:12:53 PM9/21/23
to skia-discuss
I just found that safari doesn't support font-access 😭

Miguel Camba

unread,
Sep 21, 2023, 1:28:28 PM9/21/23
to skia-discuss
But shouldn't FontManager be able to access the default system font without using the Local Font Access API? If i'm not aiming to load a specific font, does that require to explicitly pass a font?

Ben Wagner

unread,
Sep 21, 2023, 1:47:11 PM9/21/23
to skia-d...@googlegroups.com
If you're running in the web browser the Local Font Access API is the
way to access system fonts (including any "default" system font). The
font system in CanvasKit is completely separate from the system in the
browser. CanvasKit must be provided the font data of any font it uses.
This data must either be built into the the wasm or provided to the
wasm sandbox.
> To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/e34838ca-a549-49b1-83b9-d2d96e1b9e56n%40googlegroups.com.

Ben Wagner

unread,
Sep 21, 2023, 1:50:28 PM9/21/23
to skia-d...@googlegroups.com
Filed https://skbug.com/301446788 to track adding FontMgr to the list
of things that can be passed when creating a Skottie animation in
CanvasKit.

dan.r...@dockyard.com

unread,
Sep 21, 2023, 1:53:46 PM9/21/23
to skia-discuss
That seems problematic. Complete CJK (Chinese Japanese, Korean) fonts are often 70-100MB and are too large to build into wasm. Is there no way system-ui could be accessible as a universal fallback without building into wasm?

dan.r...@dockyard.com

unread,
Sep 21, 2023, 1:55:59 PM9/21/23
to skia-discuss
Local Font Access API appears to not be supported by Safari. Or, at least the https://font-access-api.glitch.me/ site does not work. I suspect that is to prevent fingerprinting, because the site is able to query all the fonts on my system with Chrome. Or am I misunderstanding?

dan.r...@dockyard.com

unread,
Jun 6, 2024, 2:15:39 PMJun 6
to skia-discuss
@bungeman, was https://issues.skia.org/issues/301446788 ever fixed? I see fixes to FontManager in the Skottie changelog, but it's not clear to me if the bug was actually fixed or not.
Reply all
Reply to author
Forward
0 new messages