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

Canvas Renderer: Unable to render text without converting fonts to shapes #250

Closed
mattkahl opened this issue Feb 6, 2017 · 1 comment
Closed

Comments

@mattkahl
Copy link

mattkahl commented Feb 6, 2017

I have a very simple test project that I'm using to explore the boundaries of bodymovin. Great work on the library. My preferred renderer, as far as I can tell, will be the CanvasRenderer. However, I'm unable to get the project to load in the player without checking the "Glyphs" option (as far as I understand, this is exporting every letter used as a shape).

I'm also noticing a commented out line in CVTextElement:

///ctx.fillText(this.textSpans[i].val,0,0);

Maybe this is a hint that this functionality is not yet implemented.

For reference, the error thrown is (from the beginning of getCharData in FontManager):

TypeError: null is not an object (evaluating 'this.chars.length')

The SVGRenderer handles this properly by catching the case of this.globalData.fontManager.chars being undefined.

So, a couple of questions:

  1. Is this a known issue?
  2. Any hints on implementing a PR myself?
  3. Would a workaround be exporting every character as a shape? If so, how would I do that? (Hidden text element with all characters? Kind of gross, but I imagine it would probably work.)
  4. Does exporting fonts as shapes cause any problems with dynamic text? I don't think it would, other than the character not existing.
@bodymovin
Copy link
Collaborator

Hi, you've done all the research yourself :)
Indeed, I discarded supporting real text on the canvas renderer because it has a really bad performance compared to drawing a shape and it doesn't help for accessibility either.
If you need to support a whole character set, I'd recommend that you export a hidden text layer with all of the glyphs as you said.
Eventually you can create a small script or module to inject all the chars to another animation in order to not have that hidden layer.
Regarding dynamic text, exporting font as shapes should work fine. You won't have special ligatures and that sort of text features, but it will work fine for normal cases.

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

No branches or pull requests

2 participants