Changes

+ custom fonts
Line 22: Line 22:  
| <tt>ButtonTexture</tt>
 
| <tt>ButtonTexture</tt>
 
| The asset name for a 174x78 pixel texture containing the button of the language for language selection menu. The top half of the sprite is the default state, while the bottom half is the hover state.
 
| The asset name for a 174x78 pixel texture containing the button of the language for language selection menu. The top half of the sprite is the default state, while the bottom half is the hover state.
|-
  −
| <tt>UseLatinFont</tt>
  −
| Whether the language uses the same Latin character font as English. If set to <tt>false</tt>, you must set the <tt>FontFile</tt> field.
   
|-
 
|-
 
| <tt>TimeFormat</tt>
 
| <tt>TimeFormat</tt>
Line 46: Line 43:  
* <code>[DAY_OF_WEEK]</code>: the abbreviated day of week as returned by <code>Game1.shortDayDisplayNameFromDayOfSeason</code> (like <tt>Mon</tt> for Monday).
 
* <code>[DAY_OF_WEEK]</code>: the abbreviated day of week as returned by <code>Game1.shortDayDisplayNameFromDayOfSeason</code> (like <tt>Mon</tt> for Monday).
 
* <code>[DAY_OF_MONTH]</code>: the numerical day of the month.
 
* <code>[DAY_OF_MONTH]</code>: the numerical day of the month.
 +
|-
 +
| <tt>UseLatinFont</tt>
 +
| Whether the language uses the game's default fonts. If set to <tt>false</tt>, you must set the <tt>FontFile</tt> field.
 
|-
 
|-
 
| <tt>FontFile</tt>
 
| <tt>FontFile</tt>
| ''(optional)'' The asset name for the font file to use (if <tt>UseLatinFont</tt> is <tt>false</tt>).
+
| ''(optional)'' The asset name for the font file to use (if <tt>UseLatinFont</tt> is <tt>false</tt>). See [[#Custom font|''custom font'']] below.
 
|-
 
|-
 
| <tt>FontPixelZoom</tt>
 
| <tt>FontPixelZoom</tt>
Line 115: Line 115:  
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
==Custom font==
 +
If you set <tt>UseLatinFont: false</tt> in the language data, you can provide your own Bitmap font with the <tt>FontFile</tt> field. This lets you map arbitrary Unicode characters to sprites in your font texture. You can [[Modding:Editing XNB files#Unpack game files|unpack your game's <tt>Content</tt> folder]] and look at the Chinese, Japanese, Korean, and Russian fonts in the <tt>Fonts</tt> folder for some examples.
 +
 +
For example, here's the <tt>Content/Fonts/Japanese.fnt</tt> file (with most of the characters stripped out for brevity):
 +
 +
<syntaxhighlight lang="xml">
 +
<?xml version="1.0"?>
 +
<font>
 +
  <info face="SetoFont-SP" size="24" bold="0" italic="0" charset="" unicode="1" stretchH="100" smooth="1" aa="1" padding="0,0,0,0" spacing="1,1" outline="0"/>
 +
  <common lineHeight="24" base="21" scaleW="1024" scaleH="1024" pages="2" packed="0" alphaChnl="0" redChnl="4" greenChnl="4" blueChnl="4"/>
 +
  <pages>
 +
    <page id="0" file="Japanese_0" />
 +
    <page id="1" file="Japanese_1" />
 +
  </pages>
 +
  <chars count="2514">
 +
    ...
 +
    <char id="37347" x="100" y="265" width="24" height="22" xoffset="0" yoffset="1" xadvance="24" page="0" chnl="15" />
 +
    ...
 +
  </chars>
 +
</font>
 +
</syntaxhighlight>
 +
 +
See the [https://www.angelcode.com/products/bmfont/doc/file_format.html official format documentation] to understand all the options, but at a high level:
 +
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! description
 +
|-
 +
| <tt>info</tt>
 +
| Describes the font itself: the name, TrueType size, padding and spacing, etc.
 +
|-
 +
| <tt>common</tt>
 +
| Provides common info which applies to all of the characters, like the line height.
 +
|-
 +
| <tt>pages</tt>
 +
| Lists the sprite textures that are part of the font. In the above example, the Japanese character sprites are split into two images: <tt>Japanese_0.png</tt> and <tt>Japanese_1.png</tt>. Each character in <tt>chars</tt> specifies which page it's on.
 +
|-
 +
| <tt>chars</tt>
 +
| Maps each Unicode character you'll use in-game to the sprite font. The example above defines one character with these <tt>char</tt> fields:
 +
 +
{| class="wikitable"
 +
|-
 +
! char attribute
 +
! explanation
 +
|-
 +
| <tt>id</tt>
 +
| The decimal Unicode ID for the character (e.g. 37347 in the example above is 釣). You can search characters in [https://www.unicodepedia.com/unicode/cjk-unified-ideographs/91e3/cjk-unified-ideograph-91e3/ Unicodepedia] to find their Unicode IDs.
 +
|-
 +
| <tt>x</tt><br /><tt>y</tt><br /><tt>width</tt><br /><tt>height</tt>
 +
| The top-left position and size of the character sprite in the page image, measured in pixels.
 +
|-
 +
| <tt>xoffset</tt><br /><tt>yoffset</tt>
 +
| A pixel offset to apply to the character when it's drawn to the screen.
 +
|-
 +
| <tt>xadvance</tt>
 +
| When drawing multiple characters to the screen, how many pixels drawing this character should advance the cursor.
 +
|-
 +
| <tt>page</tt>
 +
| The ID of the page image which contains the sprite, as defined in the <tt>pages</tt> field.
 +
|-
 +
| <tt>chnl</tt>
 +
| The color channel for which the sprite has data. (This is always <tt>15</tt> for all channels in Stardew Valley's current fonts.)
 +
|}
 +
|}
    
==See also==
 
==See also==
translators
8,404

edits