BlueRoseNote/03-UnrealEngine/Gameplay/Other/TextRender显示中文的方法.md
2023-06-29 11:55:02 +08:00

24 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: TextRender显示中文的方法
date: 2023-01-28 14:01:57
excerpt:
tags: TextRender
rating: ⭐
---
# 前言
早几年学习UE的时候发现TextRender渲染中文的时候会出现□的情况一直都去解决。最近又遇到这个需求了最终在官方论坛上找到了解决方案现在分享给大家。
# 步骤
![450](https://cdn.jsdelivr.net/gh/blueroseslol/ImageBag@latest/ImageBag/Images/3860c2f3ccfba6adad440ba3455d5c9e618ebd64.jpeg)
1. 导入一个字体生成Font资产或者新建一个Font资产接下来对Font资产进行设置。
2. 将**FontCacheType** 设置成**Offline**。
3. 下面设置**ImportOptions**,设置**FontName**为想要的字体名称。
4. 设置**UnicodeRange**为**4E00-9FFF** 。
5. 勾选**Use Distance Field Alpha**选项。
6. 在Font资产编辑器汇总点击Asset-Reimport Font_XXXX,来重新导入字体资产,之后会卡比较长的时间。
7. 复制默认字体材质球EngineContent-EngineMaterials->DefaultTextMaterialOpaque或者新建一个字体材质球作为TextRender的材质并且修改材质里的Font资产。
8. 在对应的TextRender中修改材质与Font资产即可显示中文。
![TextRender_Result.png](https://cdn.jsdelivr.net/gh/blueroseslol/ImageBag@latest/ImageBag/Images/TextRender_Result.png)
但是可以看得出一些中文符号是没办法正常显示的,原因是**4E00-9FFF**只包含了文字没有包含中文符号。所以要么是使用英文符号来代替要么就是提高Unicode-Range的范围。