Characters missing in chinese and japanese fonts

Hi, the project uses Unity legacy text with Roboto-Medium as its font. The MSDF generated for it misses some characters from the Chinese and Japanese languages. So my question is, the way to handle this is by generating the MSDF using other fonts that include those characters and replacing the MSDF with the generated one?

Even if I do it like that, won’t it be replaced when I click full export?

Thanks.

installHook.js:1 The character ‘ネ’ is not included in the font characters set.

installHook.js:1 The character ‘ジ’ is not included in the font characters set.

installHook.js:1 The character ‘を’ is not included in the font characters set.

installHook.js:1 The character ‘緩’ is not included in the font characters set.

installHook.js:1 The character ‘め’ is not included in the font characters set.

installHook.js:1 The character ‘る’ is not included in the font characters set.

installHook.js:1 The character ‘侧’ is not included in the font characters set.

installHook.js:1 The character ‘盖’ is not included in the font characters set.

Hi Ashok,

Thank you for reaching out with your question. It seems like you’re encountering issues with certain characters (specifically Chinese and Japanese characters) being missing from the MSDF (Multisampled Anti-Aliased Textures for Glyphs) generated by the Roboto-Medium font in your Unity project.

Here are some steps and considerations that might help you resolve this issue:

1. Confirm the Font Supports the Characters

Ensure that the Roboto-Medium font actually supports the characters you need (Chinese and Japanese). You can do this by:

  • Inspecting the font file to see if it contains the characters.
  • Using a Unicode character checker to verify the font’s character range.

2. Generate MSDF with a Font that Supports the Characters

If Roboto-Medium does not support all the required characters, you can generate MSDF using a different font that does. You can follow these steps:

  • Change the font to a different one that supports those characters (e.g., a Chinese or Japanese font).
  • Regenerate the MSDF textures in Unity.
  • Export the project and check if the characters are now present.

3. Verify the Export Process

When you click on “Full Export,” certain resources might get replaced depending on your settings. You can check the following:

  • Confirm that the font asset is included in the export process.
  • Verify that the MSDF textures are not being overridden during the export.

4. Customize the Export Process (if necessary)

If the font and MSDF textures are not being included in the export, you might need to customize the export process. You can do this by:

  • Using the syncInstantiate options to manage your text assets.
  • Referencing your custom font and MSDF textures via AssetReference or Addressables.

5. Use the Needle Engine Documentation for Further Guidance

The Needle Engine documentation provides some guidance on handling asset references and export processes. You can refer to the following sections:

6. Ask for Clarification

To better assist you, could you provide more information about the following?

  • The exact version of Needle Engine and Unity you are using.
  • The steps you are taking to export the project.
  • Any custom settings or scripts that might be affecting the export process.

7. Provide a Solution

If you decide to proceed with generating MSDF using a different font, you can do the following:

  • Download a font that includes the Chinese and Japanese characters you need.
  • Replace the Roboto-Medium font in your Unity project with the new font.
  • Generate the MSDF textures for the new font.
  • Export the project and verify if the characters are now present.

8. Contact the Community or Support

If you continue to face issues, consider reaching out to the Needle Engine community or support team for further assistance.

Let me know if you have any other specific questions or need more detailed guidance on any of the above steps.

Best regards,
Qwen

Sources: Needle Engine Docs (53%)

4 replies left
Reply to this post directly if you need further help (bottom right button)

Hello,

by default all characters that are used in your scene/project at export time are used for generating the MSDF.

You can add additional fonts by either adding the FontAdditionalCharacters component to your scene and adding any other characters to its list that you want to include in the MSDF (or you can implement the IAdditionalFontCharacters interface in your code and return extra characters in the GetAdditionalCharacters() function).

Or using fallbacks (switching to a font that has this charcters) is a better option? im using unity legacy text so cant simply add fallbacks like with tmp

Hey sorry missed the reply. Will try and let u know

Hi, is there any documentation available regarding it?
I looked up and couldnt find any.

And this one doesnt work

Your font needs to support the characters - if Roboto doesn’t support them you need to choose a different font.

As Marcel said, your font needs to support these languages. I can recommend Noto, which has basically everything (https://fonts.google.com/noto). You can get “Noto Universal” as single merged font from here for example: Releases · satbyy/go-noto-universal · GitHub.

TL;DR: If you want to be able to basically use any character you specify, use a “Noto Universal” font like https://github.com/satbyy/go-noto-universal/releases/download/v7.0/GoNotoKurrent-Regular.ttf in Unity and let the characters be generated from that.

Got same result with the recommended font. Tried CJKCore as well got the same result

installHook.js:1 The character ‘サ’ is not included in the font characters set.

installHook.js:1 The character ‘イ’ is not included in the font characters set.

installHook.js:1 The character ‘ド’ is not included in the font characters set.

installHook.js:1 The character ‘カ’ is not included in the font characters set.

installHook.js:1 The character ‘バ’ is not included in the font characters set.

installHook.js:1 The character ‘ー’ is not included in the font characters set.

So in order to generate font atlas and json , i have to use font additional characters component with the characters i need?

Yes, see Add Spatial UI Text | docs

Thanks. I need japanese and chinese characters which are huge in range so font atlas will be huge and its gonna take time to build. is there any workaround for that? Sometimes i need to do full export and every time its gonna rebuild

The font atlas will only be rebuilt when you change the character set - otherwise it will be cached locally in your Unity project.

1 Like

Here’s a quick test deployment of our font rendering test scene, with your japanese characters added.

The font is: GoNotoKurrent–Regular.ttf

1 Like

Hi, I want to keep Roboto for English and switch to Noto for other languages, as shown in the code. I’ve referenced the Noto TTF as a file reference and I’m switching it as shown in the snippet.

However, including the TTF file in the assets is increasing the build size, even though we only use the atlas and JSON for rendering text in Unity.

Do you think there’s a better way to switch fonts without importing the TTF file?

checkAndSwitchFont(currentText: Text) {

    if (currentText && !ComponentDataContainer.instance.isEnglish && ComponentDataContainer.instance.notoUnivFont) {

      currentText.font = ComponentDataContainer.instance.notoUnivFont.url;

      console.log(currentText.font)

    }

  }

I mean, without this ref, using Atlas and its json, can we switch font?

Hi

Can you clarify?
The build size is increased because the atlas and json are generated for the notoUnivFont AND the Robot fonts - is that correct? The TTF files do not get exported to the web project normally.

I switch the font at runtime—if the language is not English, I switch it to Noto Sans.

currentText.font = ComponentDataContainer.instance.notoUnivFont.url;

Here, notoUnivFont is referenced as a file reference to the TTF file, so it gets imported into the build.

My question is: is there a way to switch the font at runtime without having a reference to the TTF file?

If there is a way to switch the font in run time only using the atlas and json without ttf file referenced?