Changes

Jump to navigation Jump to search
move custom-font fields into the custom font section, expand & clarify
Line 43: Line 43:  
* <code>[DAY_OF_WEEK]</code>: the abbreviated day of week as returned by <code>Game1.shortDayDisplayNameFromDayOfSeason</code> (like <samp>Mon</samp> for Monday).
 
* <code>[DAY_OF_WEEK]</code>: the abbreviated day of week as returned by <code>Game1.shortDayDisplayNameFromDayOfSeason</code> (like <samp>Mon</samp> for Monday).
 
* <code>[DAY_OF_MONTH]</code>: the numerical day of the month.
 
* <code>[DAY_OF_MONTH]</code>: the numerical day of the month.
|-
  −
| <samp>UseLatinFont</samp>
  −
| Whether the language uses the game's default fonts. If set to <samp>false</samp>, you must set the <samp>FontFile</samp> field.
  −
|-
  −
| <samp>FontFile</samp>
  −
| ''(optional)'' The asset name for the font file to use (if <samp>UseLatinFont</samp> is <samp>false</samp>). See [[#Custom font|''custom font'']] below.
  −
|-
  −
| <samp>FontPixelZoom</samp>
  −
| ''(optional)'' A factor by while to multiply the font size.
   
|-
 
|-
 
| <samp>FontApplyYOffset</samp>
 
| <samp>FontApplyYOffset</samp>
| ''(optional)'' Whether to shift the font up by four pixels (multiplied by the <samp>FontPixelZoom</samp>), to better align languages with larger characters like Chinese and Japanese.
+
| ''(optional)'' Whether to shift the font up by four pixels (multiplied by the <samp>FontPixelZoom</samp>), to better align languages with larger characters like Chinese and Japanese. Default false.
 
|-
 
|-
 
| <samp>NumberComma</samp>
 
| <samp>NumberComma</samp>
| ''(optional)'' The string to use as the thousands separator (''e.g.,'' <code>","</code> for <code>5,000,000</code>). Defaults to a comma.
+
| ''(optional)'' The string to use as the thousands separator (like <code>","</code> for <code>5,000,000</code>). Defaults to a comma.
 
|-
 
|-
 
| <samp>SmallFontLineSpacing</samp>
 
| <samp>SmallFontLineSpacing</samp>
Line 66: Line 57:     
Specifically, this affects the <samp>Strings\StringsFromCSFiles:SocialPage.cs.11635</samp> translation ("''(Single)''"). When enabled, it can contain male and female translations separated by <code>/</code>, like the vanilla Portuguese translation: "''(solteiro)/(solteira)''".
 
Specifically, this affects the <samp>Strings\StringsFromCSFiles:SocialPage.cs.11635</samp> translation ("''(Single)''"). When enabled, it can contain male and female translations separated by <code>/</code>, like the vanilla Portuguese translation: "''(solteiro)/(solteira)''".
 +
|-
 +
| ''custom font fields''
 +
| See ''[[#Add a custom font|add a custom font]]'' below.
 
|}
 
|}
   Line 116: Line 110:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
==Custom font==
+
==Add a custom font==
If you set <samp>UseLatinFont: false</samp> in the language data, you can provide your own Bitmap font with the <samp>FontFile</samp> 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 <samp>Content</samp> folder]] and look at the Chinese, Japanese, Korean, and Russian fonts in the <samp>Fonts</samp> folder for examples of how this looks in practice.
+
You can provide your own Bitmap font for your custom language, which maps arbitrary Unicode characters to sprites in your font texture. You can [[Modding:Editing XNB files#Unpack game files|unpack your game's <samp>Content</samp> folder]] and look at the Chinese, Japanese, Korean, and Russian fonts in the <samp>Fonts</samp> folder for examples of how this looks in practice.
 +
 
 +
===Data format===
 +
To enable a custom font, add these three extra fields to [[#Add a custom language|your <samp>Data/AdditionalLanguages</samp> entry]]:
 +
 
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! description
 +
|-
 +
| <samp>UseLatinFont</samp>
 +
| Whether the language uses the game's default fonts. '''Set to <samp>false</samp>''' to enable a custom font.
 +
|-
 +
| <samp>FontFile</samp>
 +
| The asset name for your <samp>.fnt</samp> font data file (see [[#Font files|''font files'']] below). This must be the asset's name in the game's <samp>Content</samp> folder, not the file path in your content pack; see [[#Example 2|the example below]].
 +
|-
 +
| <samp>FontPixelZoom</samp>
 +
| A factor by which to multiply the font size. The recommended baseline is 1.5, but you can adjust it to make your text smaller or bigger in-game.
 +
|}
    
===Font files===
 
===Font files===
 
; Font data
 
; Font data
: Each font must have a text (XML) file with the <tt>.fnt</tt> extension which describes the font.
+
: Each font must have a text (XML) file with the <samp>.fnt</samp> extension which describes the font.
    
: For example, here's the <samp>Content/Fonts/Japanese.fnt</samp> file (with most of the characters stripped out for brevity):
 
: For example, here's the <samp>Content/Fonts/Japanese.fnt</samp> file (with most of the characters stripped out for brevity):
Line 192: Line 204:  
: <div style="display: inline-block; background:#000;">[[File:Modding - example font texture.png|300px]]</div>
 
: <div style="display: inline-block; background:#000;">[[File:Modding - example font texture.png|300px]]</div>
   −
===Provide the font files===
+
===Example===
 
If you're using [[Modding:Content Patcher|Content Patcher]], your content pack should look something like this with the files described above:
 
If you're using [[Modding:Content Patcher|Content Patcher]], your content pack should look something like this with the files described above:
 
<pre>
 
<pre>
Line 203: Line 215:  
</pre>
 
</pre>
   −
Now you just need to make them available through the game's <samp>Content/Fonts</samp> folder. Make sure the target for the <samp>.fnt</samp> file matches what you specified via <tt>FontFile</tt> in the [[#Add a custom language|language data]], and the target for the image matches what you specified via <samp>pages</samp> in the [[#Font files|font data]].
+
Now you just need to make them available through the game's <samp>Content/Fonts</samp> folder. Make sure the target for the <samp>.fnt</samp> file matches what you specified via <samp>FontFile</samp> in the [[#Add a custom language|language data]], and the target for the image matches what you specified via <samp>pages</samp> in the [[#Font files|font data]].
    
For example, here's the previous Esperanto example with a custom font (note the <samp>UseLatinFont</samp> and <samp>FontFile</samp> fields in the language data, and the two new patches at the bottom):
 
For example, here's the previous Esperanto example with a custom font (note the <samp>UseLatinFont</samp> and <samp>FontFile</samp> fields in the language data, and the two new patches at the bottom):
translators
8,446

edits

Navigation menu