Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

CRYENGINE comes with a localization system that allows text localization for the UI. The Localization (moved to DOC2) System is documented within the Asset Creation Manual.

...

Localization\<language>_XML.pak

Folder

Packaged location

Description

GameSDK\Libs\*.gfx

GameSDK\GameData.pak

Flash assets

Localization\<language>\HUD_Font_LocFont.gfx

Localization\<language>_XML.pak

Font lib for each language

Localization\<language>\HUD_Font_LocFont_glyphs.gfx

Glyph set for each language

  Localization\<language>\text_ui_*.xml
Localization\<language>_XML.pak

Translated strings

...

Code Block
titlecpp
IFlashUIPtr pFlashUI = GetIFlashUIPtr();
if( NULL != pFlashUI )
{
   IUIElement* pElement = pFlashUI->GetUIElement("MyElement");
   if( NULL != pElement)
   {
      pUIElement->SetVariable("MyTextbox", SUIArguments("@somelabel"));
   }
}

...

Font libraries and glyph sets

It is recommended to use one font library and glyph set for all flash assets. One reason is to save memory since you don't want to embed every font in every flash file. This technique also allows embedding different glyph sets for different languages.

It also makes sure that your corporate design is consistent over all UI assets and changes are even easier since it is only necessary to change two files one file per language to switch the font for the whole UI.

Setup

...

There are two files that are needed:

  • gfxfontlib.gfx - Font library.
  • gfxfontlib_glyphs.gfx - Glyph set.

The gfxfontlib.gfx defines all your fonts that are used in your UI.

Since exported fonts in flash always hold every glyph for the chosen font it is necessary to create a gfxfontlib_glyphs.gfx file that allows embedding only the glyphs you want.

Setup gfxfontlib_glyphs.gfx

This file holds every glyph for every font that is used in the UI.

Create a new flash file and name it gfxfontlib_glyphs.fla.

Create Dynamic Textboxes on the stage for each font and font-style and embed the needed characters.

Image Removed

Create an empty dummy MovieClip and mark it for "Export for runtime sharing".

Image Removed

...

font library

A font library is a GFX file that exports Action Script symbols describing a font, and contains the associated glyph data to render the font in the game.
When dynamic text is composed by the user, the glyphs will be loaded by Scaleform from this source file.

It is possible to set up a font library with more than one font (with different Action Script export names), but in the GameSDK sample we only use one.

In the GameSDK sample project, we use the library HUD_Font_LocFont.gfx file. The flash file used to generate this GFX in the SDK can be downloaded from here as a sample: HUD_Font_LocFont.flaHowever, you can create your own if you prefer to create a font library from scratch.

For each distinct font you wish to use, create new font symbols and set the font-style in the library (Right-Click -> New font).

Go to the font's properties to set up the export settings.
Make sure to check both the export checkboxes, and set the Identifier to an unique name. This is the name will be used in flash files using this font.
The sharing URL should be set to the name of the final GFX file (with .SWF extension)
Image Added 

After you set up all the fonts you wish to use in the UI, you should create localized copies of the font library for each language you wish to support.
The most optimized and efficient way to do this is to select a sub-set of glyphs that can be used in some language, and only export this set of glyphs for that specific language. This saves disk and memory space, as only the necessary glyphs will be available.

In the options dialog for the font, you can set the font groups to embed glyphs for. The glyphs will be processed from the given OS font and styles. 

Image Added 

After you finish setting up the fonts in the font library for a language, publish the flash file to .SWF
This should result in HUD_Font_LocFont.swf file for that specific language.

Now, use gfxexport tool to convert the font library to Scaleform GFX format.

Code Block
gfxexport.exe -c -i DDS -share_images -rescale hi gfxfontlibHUD_Font_glyphsLocFont.swf

Setup gfxfontlib.gfx

This file defines all fonts and font-styles for the UI.

Create a new flash file and name it gfxfontlib.fla. Create new font symbols for each font and font-style in the library (Right-Click -> New font).

Choose font and style, give it a name and mark "Export for runtime sharing".

Image Removed

Create an empty MovieClip and mark it as "import for runtime sharing" (or just copy and paste the dummy MovieClip from the gfxfontlib_glyphs.fla). This step is necessary to create a dependency to the glyph file.

Image Removed

Export the gfxfontlib.swf file with the following command:

Code Block
gfxexport.exe -c -i DDS -share_images -rescale hi -strip_font_shapes gfxfontlib.swf

Make sure to copy the resulting GFX into your per-language localized asset file (so it eventually ends up in Localization/<language>_xml.pak for that language, for the default asset build script you would store it as Localization/<language/HUD_Font_LocFont.gfx)

These steps should be repeated for each language you want to support in your project that needs distinct glyph sets for it's fonts. Alternatively, you can only create one (large) font library and re-use it for each language.

Info

At runtime you have to reload the UI elements after switching to a different language to make sure the new glyphs take effect.

Import fonts to any flash asset

Finally you need to import the exported fonts from gfxfontlib.gfx to the font library into your flash assets. You can just copy and paste them.

Image Removed


You need to set up a font in the flash file's library, and mark it for import as seen here.
Enter the same Identifier for the font you exported in the font library GFX file, and set the import URL to the GFX file. 

Image Added

While authoring the flash file, you can use the imported font symbol in the library instead of referring to an OS font.
At runtime, this font will be loaded from the font library. 

Export your flash assets with the following command:

...

To use the fonts on your textboxes just choose them in the font dropdown list.
Note, the * on the font means that the font resides in the font library. 

Info

If you use translation labels for static textboxes you have to make them dynamic! Otherwise the translation doesn't work.

Different Font Libraries and Glyph Sets for Different Languages

Just create gfxfontlib.gfx and gfxfontlib_glyphs.gfx files for each language and place them under: Localization\<language>\*.gfx

...