Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to display Chinese characters in A. Net Micro Framework

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to display Chinese characters in A. Net Micro Framework, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Edit the .fntdef file

First create a text document (.txt). Here we take the Chinese Xingkai font as an example, so it is named hwxk.txt. This is the file we used to configure the exported font, and we added the following:

◆ AddFontToProcess C: "WINDOWS" Fonts "STXINGKA.TTF"

◆ SelectFont "WE:400,HE:20,FN: the Song style"

◆ ImportRange 32 126

◆ ImportRange 19968 40869

The commands commonly used in the configuration file are as follows:

1) AddFontToProcess

Format: AddFontToProcess path

Description: enter the path information of the Chinese font (the path of the source of the font, you need to enter an absolute path). If there is a space in the path, be sure to enclose it in quotation marks, as shown in the example:

AddFontToProcess C: "Windows" Fonts "Miramo.ttf

AddFontToProcess "C:"Program Files"Microsoft .NET Micro Framework"v2.0.3036"Tools"Fonts"TrueType"Miramo.ttf"

2) SelectFont

Format: SelectFont "selectionstring"

Description: there are many parameters, the commonly used are the following, the rest please see the relevant articles of msdn.

The thickness of WE (Weight) fonts is 0mm 1000, standard 400, and bold 700

FN (Face Name) font name, enclosed in quotation marks if it contains spaces

HE (Height) font size (actual test range 1x36)

WI (Width) font width (actual test range 1x12)

IT (Italic) sets the tilt angle of the font

UN (Underline) sets the underline under the font

Note that this command is Select Font, that is, from the font source to select the specified parameters of the font,. Net Mirco Framework and .net reduced frameset and .net frameset different, its font size, bold, italics and other parameters can not be arbitrarily changed in the program, you export what kind of font, that is what font, can not be changed, born to determine fate. For example, if you display different sizes for the same string, you need to export a font library for each size.

3) ImportRange

Format: ImportRange start end

Description: this is more important, refers to the font from the font to export the start and end position, can be used in conjunction with multiple commands.

For detailed introduction, there are relevant instructions on msdn: ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MSVS.PSDK/PSDK/PSDK_TF_Fntdef.htm

two。 Open the command line tool

On the desktop, click "start" à "run" à type CMD, and use the cd command to navigate to the Tools folder of SDK. Using the dir command, we can see the contents of the directory as shown in the figure:

3. Use the TFConvert tool

Let's assume that the directory of samplefonts has been created under disk c, copy TFconvert.exe and hwxk.ttf (take Chinese Xingkai as an example) to that directory, and copy the. fntdef such as hwxk.fntdef that you just created to this directory. It is recommended that you use this tool under windows xp.

How to use ◆ TFconvert: TFconvert

< input file>

< output file>

◆ Input file= font definition file. Fntdef

◆ output file = font output file .tinyfnt

Under the dos command line, change to the samplesfont directory, enter: TFconvert c: "samplefonts" hwxk.fntdef c: "samplefonts" hwxk.tinyfnt enter, so that the hwxk.tinyfnt file is generated in that directory. Of course, the directory here can also be customized by you.

4. Test

Create a new Windows Application in Visual Studio. First, double-click Resources.resx. In the Tab page that appears, we change the content of String1 from "Hello World" to the Chinese you want to display, and then click the small arrow next to String in the upper left corner to select Files:

Then click the small arrow to the right of "Add Resouces" next to it, select "Add Existing File", and browse to the same file directory as the tinyfnt we generated earlier. Select hwxk.tinyfnt and add it to the resource file.

Then we open Program.cs, and the code generated by default will:

Text.Font = Resources.GetFont (Resources.FontResources.small)

Change to:

Text.Font = Resources.GetFont (Resources.FontResources.hwxk); the above is how to display Chinese characters in .Net Micro Framework. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report