Learn WP7 XNA game development together (III. 2 Sprite Texture Font)

Source: Internet
Author: User
Sprite Texture Font

For XNA fonts, apart from the previous SpriteFont, there is also a SpriteTextureFont, which is actually a generated bitmap image, that is, the bitmap font can be used as the XNA font set, in this way, the font library is expanded, so that the font library not in the mobile phone can also be used. The method of use is the same as that of SpriteFont, all of which are loaded with SpriteFont and then drawn using the DrawString method.

To use the image font, you must first create a font image. In http://www.daisy123.com /? The page_id = 427% 20 ttf2bmp project can directly generate a font image. This project is open-source.

This looks good, and it seems no problem to use Chinese! But in fact it is not so perfect, because if we want to generate more than 20 thousand Chinese characters, the image will be very large, which leads to the inability to load the image, because WP7 has a limit of 2048 K for the image, the image library that only generates thousands of characters has a dozen MB. It seems that it will take a lot of effort to process the font if you want to use Chinese characters.

 

 

This is a library image file generated by a tool:

 

Implementation:

Add the text image generated by the tool to the project. The implementation code is the same as that of spritefont.

 

Sample Code download: http://www.daisy123.com /? Page_id = 275 testTextureFont

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.