Free commonly used 35,000, 7,000, and 20,000 Chinese font packages
1. Select Window/TextMeshPro/Font Asset Creator
Note: Prepare fonts: Get Chinese font files from font libraries or other sources, usually in .ttf, .otf or .ttc format. The easiest way is to drag a .ttc file from the Font folder in the Windows system files (C drive > Windows folder > Fonts folder). The ttf and otf formats do not seem to be supported. You need to copy the font files and font library files to the Assets folder or its subfolders in the Unity project.
2. Font Asset Creator settings interface, click Generate Font Atlas after setting up.
Attribute explanation
Source Font File: Select the font used to generate the Text Mesh Pro font assets.
Sampling Point Size:设置用于生成字体纹理的字体大小(以磅为单位)。 Auto Sizing(默认):使用尽可能大的磅值,同时仍然适合纹理上的所有字符。 Custom Size:使用自定义磅值,在文本框中输入所需的大小,使用此设置可实现对仅位图字体的像素精确控制。
Padding: Specifies the spacing (in pixels) between characters in the font texture. The larger the padding, the smoother the transition, allowing higher quality rendering and larger effects such as thick outlines. For a 512x512 texture, a padding of 5 is usually good.
Packing Method:指定如何使字符适合字体纹理。 Optimum:查找仍然适合纹理中所有字符的最大可能自动字体大小。(最后打包的时候用) Fast(默认):更快地计算字符打包,但可能使用比优化模式更小的字体大小。(测试时使用) Atlas Resolution:设置字体纹理的大小宽度和高度,以像素为单位,512 x 512 的分辨率对于大多数字体来说都很好,只要您只包含 ASCII 字符即可。使用 SDF字体时,更高的分辨率会产生更精细的渐变,从而产生更高质量的文本。
Character Set: Select a predefined character set: the character range of the font you created, that is, all the characters to be included in the TextMeshPro font you want to create. In our case, it is all Chinese characters. Generally speaking, common Chinese characters + English words + symbols are enough.
Select Characters from File from the drop-down menu, and then select the txt file containing all the required characters (need to be imported into Unity first). The download address is at the beginning of the articleASCII(默认):包括 ASCII 字符集中的可见字符。 Extended ASCII:包括扩展 ASCII 字符集中的可见字符。 ASCII Lowercase:仅包含 ASCII 字符集中可见的小写字符。 ASCII Uppercase:仅包含 ASCII 字符集中可见的大写字符 Numbers+Sysbols:仅包括来自 ASCII 字符集的可见数字和符号。 Custom Range:输入一系列十进制值或值范围,以指定要包括的字符。 Unicode Range(Hex):输入一系列 unicode 十六进制值或值范围,以指定要包含的字符。 Custom Characters:输入字符序列以指定要包含的字符。 Characters from File:包括小伙伴们指定的文本资源中的所有字符。
Render Mode: Specifies the rendering mode to use when outputting the font atlas.
SMOOTH:将图集渲染为抗锯齿位图。 RASTER:将图集渲染为非抗锯齿位图。 SMOOTH_HINTED:将图集渲染为抗锯齿位图,并将字符像素与纹理像素对齐以获得更清晰的结果。 RASTER_HINTED:将图集渲染为非抗锯齿位图,并将字符像素与纹理像素对齐以获得更清晰的结果。 SDF:使用较慢但更准确的 SDF 生成模式渲染图集,并且没有过采样。 SDFAA:使用更快但不太准确的 SDF 生成模式渲染图集,它生成的字体图集足以满足大多数情况。 SDFAA_HINTED:使用更快但不太准确的 SDF 生成模式渲染图集,并将字符像素与纹理像素对齐以获得更清晰的结果,它生成的字体图集足以满足大多数情况。 SDF8:使用较慢但更准确的 SDF 生成模式和 8 倍过采样渲染图集。 SDF16:使用更慢但更准确的 SDF 生成模式和 16 倍过采样渲染图集。 SDF32:使用较慢但更准确的 SDF 生成模式和 32 倍过采样渲染图集。将此设置用于具有复杂或小字符的字体。
Get Kerning Pairs: Enable this option to copy kerning data from the font.
Generate Font Atlas: Generate font atlas texture.
3. After generation, as shown below
Click Save to save.
Note: If there are too many missing characters, you can try changing the font.
Bug Fixes
Each character has a white semi-transparent background because TextMeshPro uses a signed distance field for rendering.
Solution: Set the Shader property of the Text (TMP) material to Bitmap.
Warning 1: Unable to add the requested character to font asset [msyhbd SDF]'s atlas texture. Please make the texture [msyhbd SDF Atlas] readable.
Solution 1: Select the atlas texture included in the font in the Project panel, then change the inspector to Debug mode and check Is Readable.
Solution 2: Open the .asset file in the font file directory with Notepad, find m_Isreadable:0, change it to 1 and save it. The principle is the same as Solution 1. Warning
2: The character used for Underline is not available in font asset [msyhbd SDF].
Solution 1: Find the TextMeshPro file in the Project panel, select Resources > TMP Settings, and check Disable warnings in the Inspector to turn off the warning. Solution
2: The warning translates to: "The character used for underline is not available in the font asset [msyhbd SDF]", that is, the underline style cannot be used. For this warning, just add the underline character to the character set and repeat the above steps.
Warning 3: "The character with Unicode value \u3002 was not found in the [msyhbd SDF] font asset or any potential fallbacks. It was replaced by Unicode character \u25A1 in text object [Text (TMP)]."
Solution: The warning is translated as: "The character with Unicode value \u3002 was not found in the [msyhbd SDF] font asset or any potential fallbacks. It was replaced by Unicode character \u25A1 in text object [Text (TMP)]." That is, we entered a character that is not in the font text. The solution is the same as Warning 2 Solution 1, turning off the warning. In this way, even if we enter a character that is not in the font text, only the Unicode character \u25A1 will appear in the Scene interface, and no warning will appear, which is convenient for project debugging.