UltravioletFramework / ultraviolet

The Ultraviolet Framework is a .NET game development framework written in C#.
https://github.com/UltravioletFramework/ultraviolet/wiki
MIT License
541 stars 46 forks source link

Is there a good way to draw Chinese characters? #55

Closed Majirefy closed 6 years ago

Majirefy commented 7 years ago

UltraViolet use sprite font like Monogame. But for languages like Chinese, Japanese, and Korean(known as CJK), there are too many glyphs in these languages.

So is there a better way to draw text?Simply using a ttf font file?

tlgkccampbell commented 7 years ago

For now, Ultraviolet does not support rendering TrueType fonts directly. However, the uvfont utility can generate a CJK sprite font for you which contains only the characters that your game actually uses.

The current (1.3.15) version of uvfont can be obtained from the TwistedLogik.Ultraviolet.Tools package on NuGet, or if you compile the latest version of Ultraviolet from source it should show up in the Binaries/AnyCPU folder.

If you call uvfont without any arguments, it will list all of the possible arguments and tell you what they do. The -sourcefile and -sourceculture arguments are the ones that you need. The utility will open the file specified by -sourcefile and create a font which only contains the characters which are needed to display that text.

The source file can be any text file, but if you point it at an XML localization file that Ultraviolet understands (like this one), then it will create a font based on the localized strings for the culture specified by the -sourceculture argument.

I realize that this may still be a limitation for games which use a very large amount of text. I'm interested in providing better support for non-Roman character sets, so if this solution doesn't help you, please let me know what functionality you'd like to see added.

Majirefy commented 7 years ago

Thanks!

I want to make an RPG with lots of dialogs and text, so there should cover lots of glyphs. Moreover, I want to add some functions to allow user input some text such as names. Doing so in Monogame is a nightmare. So I search for an alternative for Monogame in C# and better multi-platform support.

tlgkccampbell commented 7 years ago

I'll make a note to look into adding support for vector fonts in a future release. I can't give you an ETA right now, but it's definitely something I'm interested in doing.

tlgkccampbell commented 6 years ago

I realize it has been a long time since this issue was posted, but I've finally started working on adding support for the FreeType2 library. This will allow Ultraviolet to use TrueType and OpenType fonts, including CJK fonts. Barring any unexpected setbacks, my hope is to include the initial version of this functionality in the 2018.04 release.

CJK font in Ultraviolet

tlgkccampbell commented 6 years ago

Support for FreeType2 fonts is complete and has been included in the 2018.04 release.