This section covers issues including translation of text, font setup, font usage, and using Scaleform's Input Method Editor (IME).
To support a range of font types and character sets, a few extra steps must be taken when developing with GFx and Flash. It's important to be aware of the Flash Studio limitations that drive this process.
To work around these issues we have developed a two-part font scheme that works well for both latin and international languages. For more details see the Font and Text Configuration Overview.
Most European and Asian languages with a TTF font are supported for text rendering. We also support Asian text input through IME (see below).
We support built-in fonts in Windows, “PS4” built-in fonts, and external font files through FreeType 2.
To enable support for external fonts, developers need to create and install GFxFontProviderWin32, GFxFontProviderPS3, or GFxFontProviderFT2 state on the loader, respectively.
Scaleform GFx and Flash Studio offer a convenient and powerful localization solution for application developers. There are three main areas of localization:
The GFx IME SDK has been tested with the following standard IMEs on Windows XP and Vista:
This IME is distributed as a separate add-on package for Scaleform GFx. Since IME is provided separately, existing licensed customers will need to contact Autodesk Scaleform to get an IME evaluation key. Evaluation customers should not need to do this, since the same key will work for both packages.
Developers who are targeting the Korean language under Windows should not need to install this package, since Korean input support is built into the core of GFx. However, supporting Korean still requires developers to follow the message passing procedures described in Input Method Configuration Overview.
To begin with, please remember that GFxFontLib.swf is just a placeholder for your virtual fonts, and does not actually get loaded or shipped with your game. Your real fonts should be kept in a different file (or files), and this file (or files) should be added to GFxFontLib and pinned. GFxFontMap is used to map your virtual fonts to the real ones for a particular language. Here is an example:
Let's say your game file uses $Title and $Normal fonts, and it imports them from the GFxFontLib.swf file. In gfxfontlib.swf library you should have only two exported fonts: $Title and $Normal. You do not need to have anything else in this file (e.g., no other fonts, no text fields).
Then you can have two other movie files (let's say font_en.swf for English and font_ja.swf for Japanese) using real fonts. In those files you need to have two text files with embedded (for simplicity) fonts: the first for $Title font and the second for $Normal font. Assume that in font_en.swf your first text field has the "Times New Roman" font and the second text field has the "Tahoma" font, and in font_ja.swf both text fields have the "Arial Unicode MS" font. Now when you switch to English, your GFxFontMap should map $Title to "Times New Roman" and $Normal to "Tahoma" and when you switch to Japanese both $Title and $Normal should be mapped to "Arial Unicode MS".
For more detailed information, please refer to Font and Text Configuration Overview.
If your glyph is being displayed as a square, typically that means the glyph is not available in the font you have chosen. Here is the most common way to fix this issue:
Verify that your glyph is being embedded, and review your GFxFontLib and GFxFontMap setup to ensure that the fonts for that text field are being properly accessed. Also ensure that your font is in the same style as your text (e.g., if you have an embedded bold font, make sure that you are using bold text).
In GFx 2.2, a font report is introduced that will enable you to look into the trace output log. There is also a log of how the fonts are searched. If you have an issue, then you can use this log to determine what font is found; if there is no glyph available, compare with what you expect to see and then you will see what the difference is.
Yes, but we do not recommended it, for a variety of reasons. If you don't set GFxFontLib, then your GFxFontLib.swf will be loaded as a regular shared SWF that exports fonts. Thus, all huge fonts from it will be loaded into memory, instead of using a smaller file like fonts_en.swf. Also, the glyphs that Flash embeds for that file depend on your local system configuration and NOT on any meaningful Flash studio setting; if a different person generates a file on a different machine, the result could be different. This is precisely why we recommend generating fonts in separate files such as fonts_en.swf, so that you do NOT export them and thus get control over character embedding.
When GFxFontLib IS available, GFxFontLib.swf is not used, and will not need to be shipped with your game. Again, for more detailed information, please refer to Font and Text Configuration Overview.
Yes, it is possible to use SetVariable for textfield.text, so text code can be placed inside of a button or movie clip and also modified accordingly. We also support the substitution of character strings for images, which may be useful here. For more information, please read this helpful forum post.
This is a known issue, and is caused by the way in which Flash stores this formatting. The problem occurs when using HTML here. Flash may use HTML implicitly, even if you haven't checked "Render as HTML" option. Flash uses HTML when you use kerning ("Auto kern") or letter spacing (value other than "0").
When HTML is used, the information about "boldness" or "italicness" is stored as a part of HTML; for example "Hello" or "Hi". Information about font is encoded as a plain name, for example <FONT FACE='Arial'>. Thus, once you reassign the text value, the information about "boldness"/"italicness" is lost (since tags <b> and/or <i> are no longer there). Thus, GFx and Flash try to use the plain font "Arial" after such reassignment. If "Arial" is not embedded and there is no system font provider then you will most likely see "squares" instead of glyphs (in GFx).
There are two workarounds here. The first one is to assign a complete HTML string instead of plain text, using <b>/<i> tags:
Code:
myTxt.text="Hello";
As a "sub-workaround" here you may set the plain text, but set bold/italic attributes by using the TextField.SetTextFormat function:
Code:
myTxt.text = "Hello"; var fmt = new TextFormat; fmt.bold = true; myTxt.setTextFormat(fmt);
The second workaround is to avoid using HTML, especially implicitly. Make sure you don't check "Render as HTML" and "Auto kern" options. In addition, ensure that you do not set letter spacing in value other than zero. In this case the information about "boldness"/"italicness" is not stored in a text field; the text field just contains a direct pointer to the bold/italic font (through font ID). Thus, the text reassignment will not lead to loss of formatting information.
Make sure that you are calling GRenderer::BeginFrame / GRenderer::EndFrame around your game's frame rendering logic (please refer to FxPlayer.cpp as an example). The entries in font cache may be locked until you call GRenderer::EndFrame, and if you don't call GRenderer::BeginFrame / GRenderer::EndFrame, then the font cache could be overflowed
Try to increase the size of font cache texture or number of textures and see if this improves the situation:
Code: GFxFontCacheManager::TextureConfig fontCacheConfig; fontCacheConfig.TextureWidth = 1024; fontCacheConfig.TextureHeight = 1024; fontCacheConfig.MaxNumTextures = 2; fontCacheConfig.MaxSlotHeight = 48; fontCacheConfig.SlotPadding = 2; Loader.GetFontCacheManager()->SetTextureConfig(fontCacheConfig); Loader.GetFontCacheManager()->EnableDynamicCache(true); Loader.GetFontCacheManager()->SetMaxRasterScale(1.0f);
Also, MaxSlotHeight might be reduced to fit more glyph entries on the texture. MaxSlotHeight is the maximal height of the glyphs on the texture in pixels. Note that bigger glyphs will be rendered as vector shapes and to avoid this you need to change MaxRasterScale by calling the SetMaxRasterScale method. This parameter controls the point at which the texture-to-vector rendering switch occurs. For example, if you have reduced MaxSlotHeight from 48 to 32 then set MaxRasterScale to 48/32 = 1.5 to preserve the same texture-to-vector switching point as with using MaxSlotHeight = 48. To avoid using vector shapes at all (this step may save some conventional memory) just set this parameter to some big value, for example 100.0. Refer to the Font and Text Configuration Overview for further details.
You may also use "Antialias for animation" instead of "Antialias for readability" for large or animated text fields. If you use "Antialias for readability" then the font cache contains separate glyph entries of a certain letter for each font size (for example, it will contain two entries for the letter 'A' if you use it with fonts 10 pts and 15 pts). And since the text field contains a lot of characters or its text is being changed frequently, the font cache might be overflowed pretty quickly. If a text field uses "Antialias for animation" then only one entry, regardless of font size will be used in font cache.