bw logo

Chapter 15. .font

Mentioned in document Client Programming Guide's section Graphical User Interface (GUI) Fonts.

Named <font_name>_<font_size>.font and located in the folder specified by section <system>/<fontRoot> in file <res>/resources.xml, a font file has the grammar described below:

<file_name>

  +<creation>
     <sourceFont>       string           </sourceFont>
     <sourceFontSize>   integer          </sourceFontSize>
     <startChar>        [U+hex|integer]  </startChar>
     <endChar>          [U+hex|integer]  </endChar>
     <widestChar>       [U+hex|integer]  </widestChar>
     <fixedWidth>       integer          </fixedWidth>
     <effectsMargin>    integer          </effectsMargin>
     <textureMargin>    integer          </textureMargin>
     <spaceProxyChar>   integer          </spaceProxyChar>
     <maxTextureWidth>  integer          </maxTextureWidth>
     <dropShadow>      [true|false]      </dropShadow>
     <shadowAlpha>      integer          </shadowAlpha> 
     <antialias>       [true|false]      </antialias>
     <bold>            [true|false]      </bold>
    *<secondary>
       <sourceFont>     string              </sourceFont>
       <unicodeRange>   U+hex-U+hex         </unicodeRange>
       <bold>           [true|false]        </bold>
       <antialias>      [true|false]        </antialias>
       <dropShadow>     [true|false]        </dropShadow>
     </secondary>
   </creation>
  *<generated>
     <map>             file          </map>
     <mapDimensions>   float float   </mapDimensions>
     <maxWidth>        integer       </maxWidth>
     <height>          integer       </height>
     <uvs>             string        </uvs>
     <widths>          string        </widths>
   </generated>
</file_name>

Grammar of font file

The list below describes the tags in the font file:

  • creation

    Tag for section with font description.

    • antialias

      If set to true, then characters will be anti-aliased.

      Defaults to true.

    • bold

      If set to true, then the lfWeight member of the LOGFONT structure will be set to FW_BOLD, otherwise it will be set to FW_NORMAL.

      Defaults to false.

    • dropShadow

      If set to true, then BigWorld will automatically create a drop shadow in the font. This will help displaying text against any coloured background, as long as the text is drawn blended.

      Defaults to false.

    • effectsMargin

      Number of pixels used by BigWorld font effects. For example, if you use dropShadow, then you should include 1 pixel for it.

      Defaults to 0.

    • fixedWidth

      Width of all character in the font map.

      Set this value to 0 if font has variable width (proportional spacing).

    • maxTextureWidth

      Maximum allowed width for the generated texture map.

    • maxWidth

      Maximum width assumed by any of the font characters.

    • shadowAlpha

      Alpha value to use when creating the shadow.

      A value of 255 generates a fully opaque shadow. Lower values will create softer, and usually better looking, shadows.

      Defaults to 255.

    • sourceFont

      This is set into the lfFaceName member of the Windows API LOGFONT structure.

    • sourceFontSize

      This is set into the lfHeight member of the Windows API LOGFONT structure.

    • spaceProxyChar

      ASCII code of the character to be used for calculating the width of a space character.

      Defaults to 105 (character i).

    • startChar

      Unicode value of the first character to preload into the glyph cache.

      Defaults to 0.

    • endChar

      Unicode value of the last character to preload into the glyph cache.

      Defaults to 0.

    • textureMargin

      How many extra texels will be added in-between each glyph.

      If a font is to be used with bilinear filtering turned on, it is best to include at least 1 texel worth of textureMargin, so the filtering will not sample from neighbouring glyphs.

      Defaults to 0.

    • secondary

      Tag for section to define a secondary font to use when rendering a characters from a particular Unicode range. Multiple secondary fonts can be specified for different ranges.

      • sourceFont

        The face name of the font to use.

      • unicodeRange

        The range, in Unicode of characters, that this secondary font will apply.

      • bold

        If set to true, the font characters will be bold.

        Defaults to the value of bold in the parent creation section.

      • antialias

        If set to true, the font characters will be antialiased.

        Defaults to the value of antialias in the parent creation section.

      • dropShadow

        If set to true, then BigWorld will automatically create a drop shadow in the font. This will help displaying text against any coloured background, as long as the text is drawn blended. The value of shadowAlpha in the parent creation section will be used.

        Defaults to the value of dropShadow in the parent creation section.

  • generated

    Tag for section with generated font metrics.

    • height

      Upon font generation, this tag will store the global font height.

    • map

      This tag will store the name of the texture containing the font map.

    • mapDimensions

      Upon font generation, this tag will store font map dimensions.

    • uvs

      List of UV coordinates for each of the characters in the font map.

    • widths

      List of widths for each of the characters in the font map.

    • maxWidth

      Maximum width assumed by any of the font characters.