Fonts

From Official Kodi Wiki
Revision as of 20:21, 26 May 2006 by Dankula (talk) (How to Generate XPR Font Files)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

There's one special file called font.xml. This file contains a list of all fonts the skin uses. XBMC will load all the fonts mentioned in this file from the /myskin/fonts directory first, and if that fails, will attempt to load them from XBMC/media/fonts. You can modify this file as you like and add/delete/change fonts. The user friendly font name is referenced by the other xml files mentioned below.

1 File Format

The font.xml file is divided into font sets, which includes a set of fonts used by the skin. Every font set must contain the same font names in order for the skin to work with all font sets. <xml>

 <fontset id="Latin" unicode="false">
     
      ....
     
     
     ....
     
     ....
 </fontset>
 <fontset id="Arial" unicode="true">
     
     ....
     
     ....
 </fontset>

</xml> A font set has the following attributes:

id
Name of the font set. Displayed to the user. Can have any value.
unicode
Whether or not a font set supports unicode characters. Supported values are “true” or “false”

There has to be at least one font set with the unicode attribute set to true else languages like Chinese or Korean will not display properly. There is a font called Arialuni.TTF with a size of 20MB. It is a unicode True Type Font and works with all languages xbmc supports.


Note: XBMC will automatically switch to the first available unicode font set if the user selects a language that needs one. This switch will not be made if the currently loaded font set already supports unicode.

2 Supported Font Types

2.1 Bitmap Fonts

Bitmap fonts must have a .xpr suffix. Instructions for how to generate them will follow. Example: <xml>

 
    <name>font12</name>
    <filename>myfont12.xpr</filename>
 

</xml>

2.1.1 How to Generate XPR Font Files

To generate XPR fonts, you require the programs “FontMaker" and “Bundler” from the Xbox Developers Kit. The steps required are as follows:

  • Load FontMaker.
  • Load in the Truetype font of the size you wish to convert to XPR.
  • Apply any styles (outline, bold, italics, shadow etc.) that you wish the font to have.
  • Select the range of characters (Glyphs) that you want the font to contain.
  • Size the output texture so that all the characters are displayed.
  • Save the fonts. This will create a .tga and .abc file (eg Arial_24.tga and Arial_24.abc)
  • Create a text file in the same folder as your font files from 6 with the following content.

<xml>

 Texture Font
 {

Source Arial_24.tga Format D3DFMT_A4R4G4B4 Levels 1

 }
 UserData FontData
 {
 	DataFile Arial_24.abc
 }

</xml>

  • Open a command prompt, and cd to the folder containing your font files.
  • Run “Bundler Arial_24.txt" to create Arial_24.xpr.

As a second option, you can download the Media X Menu Accessory “Font Bundle” (from the Usual Places).

1. Run Font Bundle. 2. Click the “Font Maker” button and follow the above Font Maker instructions to create your font(s). 3. Click the “Load” button in Font Bundle and select your new font. 4. Click the “Build”.

Your new Font.xpr file should be saved in the same folder as your font files.

2.2 True type Fonts

True type fonts must have a .ttf suffix. For a true type font it is possible to define the size (default 20) and a style (normal, bold, italics or bolditalics). Example: <xml>

 
    <name>font12</name>
    <filename>arial.ttf</name>
    <size>12</size>
    <style>bold</style>
 

</xml>