Monday, October 10, 2022
HomeGame DevelopmentThe best way to cache RichText font in Cocos Creator 3.5.0 -...

The best way to cache RichText font in Cocos Creator 3.5.0 – Cocos Creator


I attempted to make use of RichText element and use my very own font (not system font). The fonts are OK and accurately loaded once I run it on browser for debugging.

However the issue is that once I run it on the android gadget, the font just isn’t loaded and it use Arial as a substitute.

Is there any approach to resolve it? I keep in mind that we’ve got Cache in Label element, however I couldn’t discovered it on RichText.

I’m making a sport for Android gadget utilizing Cocos Creator 3.5.0


Examine if the font-family and font-name of ttf fonts are the identical.

The Font-Household property just isn’t obtainable on the RichText in 3.5.0

Are you able to present the font you’re utilizing now?

It’s displaying on my screenshot above.
Font is Silkscreen-Common.ttf

Are you able to give me your font for take a look at?

you possibly can obtain it right here: https://fonts.google.com/obtain?household=Silkscreen

Anyway, it occur on all fonts that I attempted. Even Calibri…


The font-family and font-name aren’t the identical. You should use this software to vary the font:FontCreator for Home windows – the most well-liked font editor

I’ve tried it:

Nonetheless no luck, the font nonetheless not loaded.

right here is the font

i’ve take a look at with the font you give, all works properly, right here is my demo:
57256.zip (38.9 KB)
and right here is screenshot in my cellphone, my cellphone is huaweiP30Pro

it’s RichText, not Label element, proper?

i don’t know why it’s nonetheless not engaged on mine:

It work if i take advantage of Label, but it surely doesn’t work in RichText

I attempted to log the Font and FontFamily of the RichText:

D/jswrapper: JS: Popup_Manager::show_credits() Font GUI =  belongings/predominant/native/2a/2a613d4e-f148-4a8b-9cc7-e07a5ff8f58f/Silkscreen.ttf
2022-10-01 02:10:06.982 13860-13903/com.juarasatu.muscleman
D/jswrapper: JS: Popup_Manager::show_credits() FontFamily GUI =  Arial

By default even after I exploit the font file it at all times have ARIAL because the Font-Household. And that i although if I manually change it to Silkscreen it can work. However seems it doesn’t.

RichText.FontFamily = "Silkcreen";

Are you able to make a demo of this a part of your undertaking and ship it to me?

I solved it :slight_smile:

But it surely’s fairly bizarre one.
So, the steps are:

  1. On the RichMedia element, choose “Use System Font”.
  2. Then set the “Font Household” properties to the proper one. On this case “Silkscreen”
  3. Unselect “Use System Font”
  4. Choose the font

And it really works similar to that. I don’t know why, but it surely works. :slight_smile:
This work for unique font file (from google.fonts) and the one I edited to adjustments the Font Household attribute.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments