- Email: jhzhuustc@gmail.com
- Date: January 1, May 23, 2013
1. background: Today, web games are booming, and the demand for Flash games is getting higher and higher. appropriate and diverse fonts not only make the boring words in the game more friendly, more organized and more instructive. however, the embedding of multiple fonts will greatly increase downloads, which is a heavy blow to the gaming experience. is there a way to foster strengths and circumvent weaknesses? The answer is certainly yes: How can tech men save the world... to put it simply, we package all the characters used in the same SWF without packaging any words. in this way, the load is greatly reduced. 2. unicode encoding range acquisition
View the unicode Character Table
This is the encoding distribution of the Asian language on the Unicolde official website. The Chinese part is the above CJK uniied Ideographs (han). The encoding range is 4E00-9FCF. Other codes are basically unavailable.If you have installed Flash Builder or Flash CS, you will find the sdk in the installation directory. Otherwise, you must download the Flash SDK by yourself. Then you can find it in the SDK directory.
{SDK directory} \ bin \ fontswf. bat
Open fontswf. bat and you can see the following internal sentence:
java -Dsun.io.useCanonCaches=false -Xms32m -Xmx512m -jar "%~dp0..\lib\flex-fontkit.jar" %*
No, you must know where to find our lovely flex-fontkit.jar.
As for the flex-fontkit.jar function, I directly moved Adobe official documentation (click to visit ):
The fontswf utility is a simple command line tool that converts a single font face from a font file into a SWF file. this SWF file can be used as the source of an embedded font in your applications. supported font file types are *. ttf ,*. otf ,*. ttc, and *. dfont.
-U,-unicode-rangeRange
Option |
Description |
-A,-aliasName |
Sets the font's alias. The default is the font's family name. |
-B,-bold |
Embeds the font's bold face. |
-I,-italic |
Embeds the font's italic face. |
-O,-outputFile_path |
Sets the output file path for the SWF file. |
Sets the sorted ded character range. The default value is "*", which has des all characters. For information on using character ranges, see. |
-3 |
Generates a font SWF file for applications that use TextField-based text rendering. Use this option if you are creating a font SWF file for a Flex 3 application. |
-4 |
Generates a font SWF file for applications that support CFF (Flex 4) with Flash Player 10. This is the default option. |
This tool basically meets all our requirements. but, we must add an but. When we select too many Chinese characters, setting the-u parameter becomes a very tedious task. in essence, the tool in this blog is to "Convert txt files containing Chinese characters to-u parameters", so that we can add or delete fonts.
FontCreater basically has nothing to do with creativity. The main functions have been described above. again: the tool in this blog is "converting txt files containing Chinese characters to-u parameters", so that we can add or delete fonts. click to download the tool FontCreater. fontCreater. jar ready-made Toolkit (recommended) FontCreater source code 4.1 FontCreater use 4.1.1 configuration file mode:
After downloading and decompressing the package, you can see config. properties.
Set the configuration file config. properties:
Open the config. properties file. Each setting option is described.
Command Line running mode:
java -jar FontCreater.jar config.properties
Description of the config. properties file:
fontfile =C:/Users/efen/Adobe Flash Builder 4.5/TestUIEditedTool/output/assets/font/fontname =characterfile =./outputSwf=./codeRange=0-65535
4.1.2 running parameter method:
Command Line running mode:
javar -jar FontCreater.jar -o outputswfurl -c character.txt -f xxx.ttf -n fontname [-r characterRangeStr]
Use Case:
java -jar FontCreater.jar -o ./huakang.swf -c ./char.txt -f "C:/Users/efen/Adobe Flash Builder 4.5/TestUIEditedTool/output/assets/font/HelveticaBold.ttf" -n huakang
Command line parameter description:
-O |
Output font file XXX.swf |
-C (char) |
All the required font text (for example, you only need to add the three Chinese characters "you and I" to char.txt. then the generated swf font file will have the three font characters |
-F (font) |
Font File url |
-N (name) |
Generated font file name (set fontFamily in AS3 to use this name) |
-R (range) |
Encoding range of the characters to be selected (0-65535) |
4.2 download link: FontCreater. jar ready-made Toolkit (recommended) FontCreater source code