Orx1.2 new features custom fonts and Unicode are displayed in Chinese as an Example

Source: Internet
Author: User

Write by nine days Yan Ling (jtianling) -- blog.csdn.net/vagrxie

Discuss newsgroups and documents

In orx1.2, Unicode and custom fonts are supported. Now, orx supports Chinese display. In "uni-code to rule them all?
"Mentioned by the author in this article. This is mainly for Chinese users. I naturally need to support it.

First, because version 1.2 has not yet been released (the code has been completed, but according to the author's description, its video card is just broken, and the new video card has not been purchased yet, new graphics cards are required for Linux and Windows ).
.

In addition, the author has added new tutorial content for this function.
And this tutorial has a Chinese version
Now, you are welcome to check and learn. We would also like to thank all our colleagues who have been involved in orx wiki translation.

This tutorial is about the display of some Latin characters. Here, based on the content of the tutorial, I will actually complete the display of Chinese characters. However, the most depressing thing is that currently there is no good font generation tool to support Chinese characters. That is to say, there are many tools to convert Chinese characters from TTF and other formats to lattice graphs. However, there are not many tools that support Chinese characters.

In addition, considering the efficiency, the average game engine displays text in the image mode, which can be refreshed together with the normal game image content, with the fastest speed. The same is true for orx. Therefore, text in the image format is not directly supported rather than the font of TTF files.

First, let's take a look at the author's tutorial 10 and use the image: (because the author uses a white image, I reversed it to display it)

 

The usage is actually very simple based on the original text display: (the original tutorial content)

Add a font in the text field to indicate that you need to use a Custom font. The font content is the configuration segment of the Custom font and is related to locale. Finally, the font in the selected language configuration segment is used.

[Legend1text]

String = $ content

Font = $ localizedfont

The custom configuration section is as follows:

[Customfont]

Texture =.../../data/Object/penguinattack.png

Characterlist = "! "" # $ % & '() * +,-./0123456789:; <=>? @ Abcdefghijklmnopqrstuvwxyz [/] ^ _ 'abcdefghijklmnopqrstuvwxyz {| }~ € „... When ~~~~~******************************************************* 'microseconds · zookeeper °» zookeeper ************************************************************* ü ý þ"

Charactersize = (19, 24, 0)

For an image whose font is added to texture, characterlist adds the character corresponding to the font image. charactersize is a vector, indicating the size of each character in the image. This is the new content. The original iarwain display effect is as follows:

Now let's take a look at how to use Chinese characters. For example, there is still a problem here. Because Chinese characters are special, there is no way to put them in a font file like the ISO characters added by the author, however, the current font can be modified according to locale.

Because no proper tool is found (this is a problem. If someone finds a good tool, please remember to tell me ), so I used Photoshop to spell out a Chinese character image (using an online font to generate a website ).... Painful.

As follows:

Then, modify the configuration,

Modify part of the configuration in tutorial 10 as follows:


E:/myprogram/clipboardhighlighterversion0.2/untitled.html


1

2
[Locale]

3
Required agelist =
English # French # Spanish # German # Finnish # Swedish # Norwegian # Chinese
4

5
[Chinese]

6
Content =
This is a sign of zookeeper.
7
Lang =
(Chinese)
8
Localizedfont =
Chinesecustomfont
9

10
[Chinesecustomfont]

11
Texture =
.../../Data/Object/customchinesefont.png
12
Characterlist =
"This is a sign of zookeeper"
13
Charactersize =
(72, 72, 0)

As always, I also help iarwain emphasize that you do not need to change the code and directly run the program in the original tutorial to see the display effect: (pay attention to switch by space, after switching over n languages, you will see Chinese)

In this example, there is almost no benefit to using fonts, because each Chinese character is displayed only once, but the benefits can be seen by changing the character content.

For example:

[Chinese]

Content =
The identifier of zookeeper is
Lang =
(Chinese)

Localizedfont =
Chinesecustomfont

 

Besides, because there is no proper tool, the images I made in Photoshop still have problems ....... The backend space is too long, and the word cannot be cut .... At the same time, this also reflects the question raised by the author in the tutorial. All user-defined fonts must be equal-width fonts (otherwise, how can we cut them ?)

 

The author of the original article retains the copyright reprinted. Please indicate the original author and give a link

Write by nine days Yan Ling (jtianling) -- blog.csdn.net/vagrxie

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.