Version 1

Solartech Formatted Message Format

The goal of the Solartech Formatted Message (SFM) format is to allow people to create messages with specified font sizes, line breaks, etc. It is, necessarily, an alternative to MULTI (the NTCIP format), but it's not a direct competitor. MULTI is meant to be one-size-fits all, so it includes things like images, data sources, and scroll and blink elements. (Somehow they didn't learn from html that scrolling and blinking are both very bad ideas.)

SFM is meant only for laying out static monochrome messages, and is mostly motivated by DOTs have requirements for font sizes in their messages. There is SFM2 to handle fancier layout, color, etc. The guiding principle behind SFM is currently simplicity.

SFM messages are encoded in unicode, with a 3-byte binary header. The first byte is a binary encoding of the number of lines in the message. The second and third bytes are a big-endian unsigned short indicating the size of the rest of the message in bytes (basically, something suitable to be read in by Java's DataInput.readUTF()).

SFM is a tagged language. For the sake of easy parsing and reduced storage space, tags will be special characters, mostly from the unused portion of the first unicode plane (historical ascii) which historically came from terminal types, and are consequently completely useless in our context. Tags are not just escape characters, though, they may begin an escape sequence. (The most obvious is the named font escape tag.)

Lines are terminated by newline characters ("\n", i.e. 0x000a). Since determining newlines means parsing the entire mesage (since the length of a font name could easily be 10), the number of lines in the message is encoded in the first byte. For simplicity of parsing, every line must be terminated with a newline, including the last. This is true even if the message is one line long.

Font tags switch the current font. All of the characters on a line are aligned to the same baseline; characters in larger fonts are simply taller. Lines which are either too tall or too long should simply be truncated.

If no font is specified via a tag, the default font is 7pxRoadSafety-normal.

The special escape characters are:

Escape Characters
Escape Character Name Meaning
0x0000 Reserved There's no good reason not to use 0x0000 as a tag, but given how often null is used as something special, it's probably best to avoid it.
0x0001 1 Line This tag switches the current font to 20pxRoadSafety
0x0002 2 Line This tag switches the current font to 11pxRoadSafety
0x0003 3 Line This tag switches the current font to 7pxRoadSafety-normal
0x0004 3 Line Bold This tag switches the current font to 7pxRoadSafety-bold
0x0005 3 Line Narrow This tag switches the current font to 7pxRoadSafety-narrow
0x0006 3 Line Condensed This tag switches the current font to 7pxRoadSafety-condensed
0x0007 4 Line This tag switches the current font to 5pxRoadSafety
0x0008 Specified Font This tag is used to specify a font by name. Immediately following two numerals indicating the length of the font name, followed by the name. This name is the full name of the font to use.