Difference between revisions of "Action12"

From GRFSpecs
Jump to navigationJump to search
m (9 revisions)
(Fix style and format)
Line 1: Line 1:
  +
==Introduction==
   
 
This action allows loading and defining glyphs for any [http://www.unicode.org/ Unicode] character in the BMP (Basic Multilingual Plane), i.e. up to U+FFFF.
'''''Load font glyphs'''''
 
 
=Action 12=
 
 
Load font glyphs
 
 
-=Description=-
 
 
This action allows defining glyphs for any [http://www.unicode.org/|Unicode] character in the BMP (Basic Multilingual Plane), i.e. up to U+FFFF.
 
   
 
''Note'': If any .grf file containing an action 12 is loaded (even if it is inactive), TTDPatch is put into UTF-8 mode. This changes how character input is processed and how custom strings are stored in the savegame (they are converted to UTF-8 encoding). It is not possible to prevent this, and because of possible bugs in UTF-8 mode it is therefore preferable to put all font glyphs in separate .grf files to allow them to not be loaded in the case of problems.
 
''Note'': If any .grf file containing an action 12 is loaded (even if it is inactive), TTDPatch is put into UTF-8 mode. This changes how character input is processed and how custom strings are stored in the savegame (they are converted to UTF-8 encoding). It is not possible to prevent this, and because of possible bugs in UTF-8 mode it is therefore preferable to put all font glyphs in separate .grf files to allow them to not be loaded in the case of problems.
Line 14: Line 7:
 
Available since 2.0.1 alpha 73.
 
Available since 2.0.1 alpha 73.
   
-=Format=-
+
==Format==
   
 
The data looks as follows:
 
The data looks as follows:
   
<pre>-+&lt;sprite-number&gt; * &lt;length&gt; 12 &lt;num-def&gt; <nowiki><nowiki>(&lt;font&gt; &lt;num-char&gt; &lt;base-char&gt;){n}</nowiki></nowiki>+-</pre>
+
<sprite-number> * <length> 12 <num-def> <nowiki>(<font> <num-char> <base-char>){n}</nowiki>
   
  +
{| |-
||'''Element'''|[[GRFActionsDetailed|'''Size''']]|'''Description'''
+
!'''Element'''!![[GRFActionsDetailed|'''Size''']]!!'''Description'''
  +
|-
 
|<sprite-number>||dec||A sequential sprite number
  +
|-
 
|<length>||dec||The total number of bytes in the action
  +
|-
 
|12||B||Action 12
  +
|-
 
|num-def||B||Number of definitions
  +
|-
 
|font||B||Font for which to provide glyphs
  +
|-
 
|num-char||B||Number of consecutive glyphs
  +
|-
 
|base-char||W||First Unicode character for which to provide glyphs
  +
|}
   
 
Following the action 12 must be the real sprites for all glyphs, as many sprites as all <num-char> added up.
&lt;sprite-number&gt;|dec|A sequential sprite number
 
 
&lt;length&gt;|dec|The total number of bytes in the action
 
 
12|B|Action 12
 
 
num-def|B|Number of definitions
 
 
font|B|Font for which to provide glyphs
 
 
num-char|B|Number of consecutive glyphs
 
 
base-char|W|First Unicode character for which to provide glyphs||
 
 
Following the action 12 must be the real sprites for all glyphs, as many sprites as all &lt;num-char&gt; added up.
 
   
 
Glyphs sprites may only use colors 00 (transparent), 01 (foreground) and 02 (shadow). A sprite that uses the shadow color MUST NOT use the [[RealSprites#compression|chunked data format]].
 
Glyphs sprites may only use colors 00 (transparent), 01 (foreground) and 02 (shadow). A sprite that uses the shadow color MUST NOT use the [[RealSprites#compression|chunked data format]].
   
 
==Description==
-=Filling in the terms=-
 
   
 
===sprite-number===
 
===sprite-number===
Line 52: Line 47:
 
===num-def===
 
===num-def===
   
This specifies how many definitions follow, each having &lt;font&gt;, &lt;basechar&gt; and &lt;numchar&gt;.
+
This specifies how many definitions follow, each having <font>, <basechar> and <numchar>.
   
 
===font===
 
===font===
Line 66: Line 61:
 
The first Unicode character in a range to provide glyphs for. &nbsp;This can be any Unicode character in the BMP.
 
The first Unicode character in a range to provide glyphs for. &nbsp;This can be any Unicode character in the BMP.
   
Note that all characters of a definition (i.e., &lt;font&gt; &lt;basechar&gt; &lt;numchar&gt; triplet) must fit within a &quot;block&quot; of 128 characters, i.e. you cannot define characters U+00E0..U+011F with one definition; instead you must split it into U+00E0..U+00FF and U+0100..U+011F because those are two different blocks.
+
Note that all characters of a definition (i.e., <font> <basechar> <numchar> triplet) must fit within a &quot;block&quot; of 128 characters, i.e. you cannot define characters U+00E0..U+011F with one definition; instead you must split it into U+00E0..U+00FF and U+0100..U+011F because those are two different blocks.
 
-=Example=-
 
 
<pre>-+ 583 * 10 12 02 00 08 F8 00 00 0C 00 01+-</pre>
 
 
||'''Byte'''|'''Meaning'''
 
 
583|&lt;sprite-number&gt;
 
 
10|&lt;length&gt; of the action in bytes; start counting at 12 (&lt;action&gt;)
 
 
12|&lt;action&gt;: sets this pseudo-sprite to function as action 12
 
 
02|&lt;num-def&gt;: we're defining two ranges of characters
 
 
00|&lt;font&gt;: first range, defining font 0 (normal size)
 
 
08|&lt;num-char&gt;: defining 8 characters in a row
 
 
F8 00|&lt;base-char&gt;: character U+00F8 is the first character
 
   
 
==Example==
00|&lt;font&gt;: second range, also defining font 0 (normal size)
 
   
 
583 * 10 12 02 00 08 F8 00 00 0C 00 01
0C|&lt;num-char&gt;: defining another 12 characters
 
   
  +
{| |-
00 01|&lt;base-char&gt;: character U+0100 is the first character||
 
 
!'''Byte'''!!'''Meaning'''
  +
|-
 
|583||<sprite-number>
  +
|-
 
|10||<length> of the action in bytes; start counting at 12 (<action>)
  +
|-
 
|12||<action>: sets this pseudo-sprite to function as action 12
  +
|-
 
|02||<num-def>: we're defining two ranges of characters
  +
|-
 
|00||<font>: first range, defining font 0 (normal size)
  +
|-
 
|08||<num-char>: defining 8 characters in a row
  +
|-
 
|F8 00||<base-char>: character U+00F8 is the first character
  +
|-
 
|00||<font>: second range, also defining font 0 (normal size)
  +
|-
 
|0C||<num-char>: defining another 12 characters
  +
|-
 
|00 01||<base-char>: character U+0100 is the first character
  +
|}
   
 
Therefore, this action 12 defines glyphs for Unicode characters U+00F8..U+010B. They are split into two definitions because a definition cannot cross a block boundary.
 
Therefore, this action 12 defines glyphs for Unicode characters U+00F8..U+010B. They are split into two definitions because a definition cannot cross a block boundary.

Revision as of 22:11, 14 June 2011

Introduction

This action allows loading and defining glyphs for any Unicode character in the BMP (Basic Multilingual Plane), i.e. up to U+FFFF.

Note: If any .grf file containing an action 12 is loaded (even if it is inactive), TTDPatch is put into UTF-8 mode. This changes how character input is processed and how custom strings are stored in the savegame (they are converted to UTF-8 encoding). It is not possible to prevent this, and because of possible bugs in UTF-8 mode it is therefore preferable to put all font glyphs in separate .grf files to allow them to not be loaded in the case of problems.

Available since 2.0.1 alpha 73.

Format

The data looks as follows:

<sprite-number> * <length> 12 <num-def> (<font> <num-char> <base-char>){n}
Element Size Description
<sprite-number> dec A sequential sprite number
<length> dec The total number of bytes in the action
12 B Action 12
num-def B Number of definitions
font B Font for which to provide glyphs
num-char B Number of consecutive glyphs
base-char W First Unicode character for which to provide glyphs

Following the action 12 must be the real sprites for all glyphs, as many sprites as all <num-char> added up.

Glyphs sprites may only use colors 00 (transparent), 01 (foreground) and 02 (shadow). A sprite that uses the shadow color MUST NOT use the chunked data format.

Description

sprite-number

The current sprite number.

length

The total number of bytes in this action 12.

num-def

This specifies how many definitions follow, each having , <basechar> and <numchar>.

font

The font to define glyphs for. The value can be 0 for the normal size, 1 for the small size, or 2 for the large size font.

num-char

The number of characters in the range.

base-char

The first Unicode character in a range to provide glyphs for.  This can be any Unicode character in the BMP.

Note that all characters of a definition (i.e., <basechar> <numchar> triplet) must fit within a "block" of 128 characters, i.e. you cannot define characters U+00E0..U+011F with one definition; instead you must split it into U+00E0..U+00FF and U+0100..U+011F because those are two different blocks.

Example

583 * 10 12 02 00 08 F8 00 00 0C 00 01
Byte Meaning
583 <sprite-number>
10 <length> of the action in bytes; start counting at 12 (<action>)
12 <action>: sets this pseudo-sprite to function as action 12
02 <num-def>: we're defining two ranges of characters
00 : first range, defining font 0 (normal size)
08 <num-char>: defining 8 characters in a row
F8 00 <base-char>: character U+00F8 is the first character
00 : second range, also defining font 0 (normal size)
0C <num-char>: defining another 12 characters
00 01 <base-char>: character U+0100 is the first character

Therefore, this action 12 defines glyphs for Unicode characters U+00F8..U+010B. They are split into two definitions because a definition cannot cross a block boundary.

After this action 12 follow 20 real sprites containing the glyphs for the above characters.