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

custom text failed while no current char in chars of output #3086

Open
zhounan354 opened this issue May 9, 2024 · 0 comments
Open

custom text failed while no current char in chars of output #3086

zhounan354 opened this issue May 9, 2024 · 0 comments

Comments

@zhounan354
Copy link

zhounan354 commented May 9, 2024

当我想替换lottie的文字的时候,如果shape中没有对应的字符,就不绘制这个字符了,这回引起极大的困扰,建议应该做一个保底方案,找不到对应字符的shape时,就通过默认字体绘制,只需要改一处简单的代码就行。
这是源代码:
if (fontManager.chars) { charData = fontManager.getCharData(currentChar, fontData.fStyle, fontManager.getFontByName(documentData.f).fFamily); cLength = newLineFlag ? 0 : charData.w * documentData.finalSize / 100; } else { // var charWidth = fontManager.measureText(val, documentData.f, documentData.finalSize); // tCanvasHelper.font = documentData.finalSize + 'px '+ fontManager.getFontByName(documentData.f).fFamily; cLength = fontManager.measureText(val, documentData.f, documentData.finalSize); } //
希望可以对getCharData的返回值做一个判断,如果找不到,就执行下方的else中的代码。
辛苦大佬们google翻译一下看看吧哈哈哈哈,感谢!

PS:
我现在用了一个方法规避,就是拿到lootie的json后,删除chars这个数组,如此,就会全部走入else的默认字体绘制了。

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

1 participant