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

Download Font [ XXX_LABEL] failed, using Arial or system default font instead #17778

Open
XenonSheng opened this issue Oct 25, 2024 · 9 comments
Labels
Bug Needs Triage Needs to be assigned by the team

Comments

@XenonSheng
Copy link

Cocos Creator version

2.4.13

System information

Windows 10, Android, IOS browsers (Web Mobile)

Issue description

Sometimes might get this error "Download Font [ XXX_LABEL] failed, using Arial or system default font instead". Mostly happens on first time launch the website.

Found the solution that can solve this problem by increasing the _timeout from font_loader.js.
After updated _timeout from 3s to 60s, have tested on windows 10, android, and ios devices, so far so good.
Suspect that require more time to load the font.

Recommend to make the timeout variable as global variable. So we can adjust ourselves based on our needs.

Hope someone can be updated for next v2 release. Thankss

Relevant error log output

Download Font [ XXX_LABEL] failed, using Arial or system default font instead

Steps to reproduce

Get any ttf files with chinese fonts.

Minimal reproduction project

No response

@XenonSheng XenonSheng added Bug Needs Triage Needs to be assigned by the team labels Oct 25, 2024
@longchuan
Copy link
Contributor

longchuan commented Oct 25, 2024

the net was timeout or the resource did not exist

@XenonSheng
Copy link
Author

No network timeout. TTF files are downloaded successfully with (200 OK response).


Suspect it take longer time than 3 seconds. Haven't finished loaded the font, already go into the following line

@longchuan
Copy link
Contributor

longchuan commented Oct 25, 2024

2.4.13 did not support the reject(Promise)

@XenonSheng
Copy link
Author

我觉得 不关 reject promise 的事, 应该是可以运行的

ttf 文件 是下载成功了

可是我觉得在加载font的时候,需要更长的时间(需要大于3秒)
原因可能是华语font 比英文font 复杂

我怀疑它还没完成加载font就被强制timeout,导致font出现问题

我自己尝试了 把3秒换成 60秒, 再也没遇到这个问题

@Remmoze
Copy link

Remmoze commented Oct 30, 2024

My tester has also found this bug when playing on slow internet. Even when the font is loaded it is not used properly. I would love to be able to change _timeout externally, without building the engine

@longchuan
Copy link
Contributor

我觉得 不关 reject promise 的事, 应该是可以运行的

ttf 文件 是下载成功了

可是我觉得在加载font的时候,需要更长的时间(需要大于3秒) 原因可能是华语font 比英文font 复杂

我怀疑它还没完成加载font就被强制timeout,导致font出现问题

我自己尝试了 把3秒换成 60秒, 再也没遇到这个问题

加了promise也是可以运行的,但是不支持异步,会直接执行后面的代码,而异步的还在执行中,导致问题

@longchuan
Copy link
Contributor

你可以尝试不使用then函数,应该会正常

@XenonSheng
Copy link
Author

对不起 我有点不太明白您的意思。。。 因为你说的promise 只有在native 的function 用到
我在windows 一样会有font 问题, 不只是在IOS 和 ANDROID
我理解到的是 有两个function 以 useNativeCheck 来定义 用哪个

第一个是 _checkFontLoaded (用于Windows的浏览器 或者 useNativeCheck false)
这里 并没有用到任何promise。。。
而且我有尝试加入 cc.log 如图下, 确实超时了。。
image

第二个是 nativeCheckFontLoaded (用于ANDROID/IOS的浏览器 或者 useNativeCheck true )
这里 才有用到promise
而且我有尝试加入 cc.log 如图下, 也确实超时了。。通常会进入 ’2‘ 的cc.log
image

可是当我把 _timeout 换成 60秒, 就解决了。。 并没有再出现font的问题。。
image
所以我才建议,如果可以, 把这个_timeout弄成全局变量(Global Variable) 这样可以根据我们的需要进行更改。。 我们也不需要自己build engine

@longchuan
Copy link
Contributor

也许是我说错了,我认为Promise.then()是不可靠的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Needs to be assigned by the team
Projects
None yet
Development

No branches or pull requests

3 participants