HGE Chinese display Solution

Source: Internet
Author: User

I recently learned from HGE to write a 2D game engine and accidentally saw a simple Chinese font solution. Let's take a look at it first.

HGE itself does not support Chinese display, so I use the solution provided by the subtle balance.

The Code provided by the great god contains the gfxfont. h and gfxfont. cpp files. You only need to add these two files to the project.

However, I am too lazy. To avoid adding two files to the project every time, I moved all the CPP Code to the. h file without authorization and made some minor changes.

In this way, you only need to introduce gfxfont. H into the project. Of course, I put this gfxfont. h directly into the include folder of HGE, so that I can directly

Use # include <gfxfont. h> to reference this file. (Of course, add the include directory of HGE to the project first .)

The following is the source code of the gfxfont. h file:

Gfxfont. h # ifndef gdifont_h # define gdifont_h # include 

Copy the source code, save it as gfxfont. H, and introduce it to the project.

Usage:

This method is a new solution to support Chinese display in the HGE project.

This solution does not need to rely on any image fonts and supports a wide range of display methods.

The usage is simple. You only need to perform the following steps:

1. Include the "gfxfont. H" header file.

2. Create a font pointer: gfxfont * fontspr = new gfxfont (font name, font size, bold, italic, smooth mode );

3. text color: fontspr-> setcolor (argb );

3. text rendering: fontspr-> Print (coordinate X, coordinate Y, text content );

4. Destroy Font: when the program ends, delete fontspr is used to destroy the font.

--- Subtle balance

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.