Specification for Simple Vector Format (SVF) v2.0





About SVF Design Criteria Specification SVF XML API SVF Products

Table of Contents


Overview

SVF is designed to be a simple format for describing vector images. The basic drawing objects include points, lines, circles, arcs, bezier curves, text, ellipses, and bitmaps. Features of the format include layers (for controlling the visibility of objects), hyperlinks (for allowing the user to click on a portion of the drawing to perform an action), notifications (for sending messages when the user has passed a certain zoom level), fills, the ability to override the default colors, object identifiers (for linking information to a database or the original drawing), custom user data and saved views. All text is stored in UTF-8 encoded Unicode.

The file is broken into 3 sections, the intro, the header, and the main body. The intro is simply a text string identifying the file as SVF and the version number. The header includes general information useful for displaying or manipulating the image like layers, extents, and colors. The main body describes how to draw the image and hyperlinks.

Objects are drawn in the order they occur in the file, so if you wish to draw overlapping objects, the later objects will be drawn on top of previous objects. Objects are drawn using the concept of a current state. An SVF file starts in a default state which can be changed in the file. Some commands start from the current pen position and may modify it.

As with most vector formats, the origin (0,0) is in the lower left corner with increasing x coordinates moving to the right and increasing y coordinates moving up. Using the Flags header command you can instead have the origin in the upper left, with y coordinates increasing as you move down. Coordinates are specified as positive integers or double precision floating point; offsets are signed integers or double precision floating point.

Header

The header contains information necessary for displaying and organizing the graphic information in the body. All header information should be specified before the body. All header commands are optional and should occur only once if at all (though most files will at least include Extents). Valid header commands include all tokens from 1 to 15 plus Extension. The Extension command is special and may appear multiple times.

Body

Body commands occur after the header. Unlike header commands, each body command may appear multiple times. Valid body commands consist of all tokens from 16 on up plus Extension.

Command Structures

Tokens

An SVF token or command is a single byte. This is generally followed by command specific information - numbers, text, etc. The two most significant bits of the token indicate how many bytes numbers will take, 1, 2, 4 or 8 (00 - 1, 01 - 2, 10 - 4, 11 - 8). For example, the token for the Point command is 16 (binary 0001 0000). 0001 0000 indicates that the point coordinates will be 1 byte each; 0101 0000 indicates 2 bytes each; 1001 0000 indicates 4 bytes; and 1101 0000 indicates 8 bytes.

Some commands may require an extra byte to describe the token. These commands start with an XHeader token (value 15) followed by the specific token. For example, DataTypes consists of an XHeader token (15) followed by the DataTypes token (1). The precision of this specific command is based on the high bits of the DataTypes token.

Numbers

The precision numbers and counts are stored at depends on the associated token. If it is stored in 1, 2 or 4 bytes, it generally should be interpreted as a positive integer. 8 byte numbers generally should be interpreted as a double precision floating point number. Use the Transform command to convert integer coordinates into floating point values. Raw integer coordinates are refered to as SVF Integer Coordinates. Floating point coordinates and transformed integer coordinates are known as SVF Transformed Coordinates. All numbers are stored bigendian. In this document, numbers listed for a command that have a green background depend on the token for their precision.

Offsets follow the same rules as numbers for how they're stored. The only difference is that integers are signed values instead of unsigned.

Angles follow the same rules as numbers for how they're stored. 1, 2 and 4 byte angles can be converted to radians using the formula angle * 2 * PI / MAXINT where MAXINT is the maximum value for the appropriate size integer. For example, a 2 byte integer would use the formula angle * 2 * PI / 0xffff. Angles stored as floating point are stored in radians. Angles start from the positive x axis and go counter clockwise.

IDs follow the same rules as numbers for how they're stored with the exception that the 8 byte version is interpreted as an 8 byte integer. Thus they are always unsigned integers.

Strings

All text in an SVF file, including layer names and text objects, are stored using the UTF-8 encoding of Unicode. This allows for fully international text. An advantage of UTF-8 is that standard ASCII (values 127 and lower) is also valid UTF-8. Most other European characters can be encoded in 2 bytes and others in 3 bytes

Unicode characters from 0-127 are stored in 1 byte. Characters from hex 80 to 7ff (decimal 128 to 2047) are stored in 2 bytes and hex 800 to ffff (decimal 2048 to 65535) are stored in 3 bytes.

   0000-007F   0xxxxxxx
   0080-07FF   110xxxxx 10xxxxxx
   0800-FFFF   1110xxxx 10xxxxxx 10xxxxxx

Link Actions

Hyperlinks and notifications can link to external documents or perform various actions. These are stored as a string and represent a URL.

Defaults

Until explicitly set in the SVF image, the following defaults are assumed.

extents (0,0)-(255,255)
drawing color white (color index 255)
background color black (color index 0)
transparent color none
available colors 256 colors (see colors) (or RGB)
pen position (0,0)
layer entry 0 (if there are layers)
fill mode off
text height 10 integer units
text rotation 0 (horizontal)
text font font entry 0 or monospaced if no fonts
pen width 0
linetype 0 (continuous)

Graphic objects

Most graphic objects start drawing from the current pen position and many also update it. To update the current point without drawing anything, you can use MoveTo or RelMoveTo. MoveTo moves the pen to the specified absolute coordinates. RelMoveTo specifies a relative offset. It is useful when a relative move takes less precision.

MoveTo (body)
type token number number
value 17 x coordinate y coordinate
updates current point

RelMoveTo (body)
type token offset offset
value 20 x offset y offset
updates current point

Changing the color and other properties of graphic objects is described in the graphic object properties section.

Lines

Lines are drawn from the current pen position and also update the current position. You can use either LineTo or RelLineTo. As with RelMoveTo, RelLineTo is useful when relative coordinates can be stored in less space than absolute coordinates.

LineTo (body)
type token number number
value 18 x coordinate y coordinate
uses current point
updates current point

RelLineTo (body)
type token offset offset
value 21 x offset y offset
uses current point
updates current point

Polylines

Polylines are a more efficient method for drawing a series of connected lines. They are drawn from the current pen position and also update the current position. The value for the number of points allowed in the polyline takes up the same number of bytes as the coordinate values (limit 255 for 1 byte coordinate values, etc.).

A polyline displayed with fill mode on is displayed as a filled polygon. The final line segment of the polygon is always an implicit line from the first point (current pen position) to the last point. Polyline link regions follow the same rules as drawing a polygon.

As with moves and lines, polylines can be specified using relative coordinates for more efficiency.

Polyline (body)
type token count { number number }
value 19 count x coordinate y coordinate
uses current point
updates current point
uses fill mode

RelPolyline (body)
type token count { offset offset }
value 22 count x offset y offset
uses current point
updates current point
uses fill mode

Points and rectangles

Points are simply a dot drawn at the given location

You can also draw rectangle outlines or filled areas (depending on the fill mode) which start at the current point. If the port origin is in the lower left (the default), the current point is interpreted as the lower left of the rectangle. If the port origin is in the upper left, the current point becomes the upper left corner of the rectangle.

Point (body)
type token number number
value 16 x coordinate y coordinate

Rectangle (body)
type token number number
value 23 width height
uses current point
uses fill mode

Circles and arcs

Circles and arcs are drawn with their center at the current point A filled arc looks like a piece of pie while a plain arc just consists of the curved arc segment. Arc link regions also behave like a piece of pie.

Arcs are specified by radius and start and end angles, the arc being drawn counter clockwise.

Circle (body)
type token number
value 24 radius
uses current point
uses fill mode

Arc (body)
type token number angle angle
value 25 radius start angle end angle
uses current point
uses fill mode

Ellipses and elliptical arcs

Ellipses and elliptical arcs follow similar rules to circles and arcs. They are specified using the height and width of the ellipse. Ellipses can be rotated.

The angles for elliptical arcs are actually the parameters for the parametric equation of an ellipse. An easy way to think of it is to picture the angles in a circular arc, then squish (scale) the arc to make an elliptical arc.

Ellipse (body)
type token number number angle
value 41 width height rotation
uses current point
uses fill mode
added with SVF2

EllipseArc (body)
type token number number angle angle angle
value 42 width height rotation start parameter end parameter
uses current point
uses fill mode
added with SVF2

Bezier curves

Cubic Bezier curves are supported. The first end point is the current point. The command specifies two control points followed by the second end point. This command updates the current point. Note that Bezier curves do not go through the control points. For link regions and filled regions, a Bezier curve region is defined as the area between the curve and a line connecting its two end points.

Bezier (body)
type token number number number number number number
value 26 control point 1 x control point 1 y control point 2 x control point 2 y end point x end point y
uses current point
updates current point
uses fill mode

Text

Specific text properties include height, width, rotation, font. The current point is used for the lower left corner of the text. Descenders may go below this baseline. Text is drawn using the current text height (default is 10). Text can be Unicode.

A width can also be specified with the text. If this value is 0, the text will be drawn using the font's default width. If a width is specified, the text will be scaled to fit. This is suggested if the width of the text is important because the font metrics may differ between systems.

Text can be drawn using different fonts. A list of fonts can be included in the header section of the file, then referenced by index in the body.

Text (body)
type token number string
value 27 width text
uses current point

TextHeight (body)
type token number
value 28 height

TextAngle (body)
type token angle
value 43 text rotation
added with SVF2

SetFont (body)
type token number
value 38 font table index
added with SVF2

To make subsequent text bold or italics, set the appropriate bit in the value passed to the TextFlags command.

By default, text is drawn using the current point as the location for the baseline. Alternately, you can have the current point be interpreted as the point below text descenders.

By default, when you specify the height of text, this is considered to be the height of a capital M. Alternately, you can have text height be the cell height, i.e. character height including ascenders, descenders and internal leading.

TextFlags (body)
type token number
value 48 flags
added with SVF2

bits C constant Java constant meaning
00000001 SVFTF_Bold eTF_Bold Bold if set, regular if not
00000010 SVFTF_Italics eTF_Italics Italics if set, regular if not
00000000 SVFTF_BasePointBaseLine eTF_BasePointBaseLine Text basepoint is at the baseline
00000100 SVFTF_BasePointBottom eTF_BasePointBottom Text basepoint is below the descenders
00001000 SVFTF_BasePointReserved1 eTF_BasePointReserved1 reserved for future use
00001100 SVFTF_BasePointReserved2 eTF_BasePointReserved2 reserved for future use
00000000 SVFTF_TextHeightM eTF_TextHeightM Text height is the height of an M
00010000 SVFTF_TextHeightCell eTF_TextHeightCell Text height is the cell height
00100000 SVFTF_TextHeightReserved1 eTF_TextHeightReserved1 reserved for future use
00110000 SVFTF_TextHeightReserved2 eTF_TextHeightReserved2 reserved for future use
01000000 SVFTF_Underline eTF_Underline underline

Bitmaps and other objects

Bitmaps can be displayed from an SVF file. The bitmap resides in an external file and is referenced using an absolute or relative URL. The lower left corner uses the current pen position. You are required to specify the width (in SVF coordinates) of the area the bitmap should be displayed into. If the height is 0, the aspect ratio of the bitmap is used to determine the actual height. If the height is specified, the bitmap is scaled to fit in the given box. If the port origin is in the lower left (the default), the current point is interpreted as the lower left of the rectangle. If the port origin is in the upper left, the current point becomes the upper left corner of the rectangle.

A MIME type can be specified to describe what type of object is embedded. An SVF viewer must a least support image/jpeg for JPEG bitmaps but may support others. A MIME type doesn't have to be specified for common bitmap formats.

If the object can't be display for some reason (the file isn't found or the SVF viewer doesn't support the given MIME type), alternate text can be displayed instead. It will be displayed from the current point using the current text properties.

Object (body)
type token number number string string string
value 40 width height URL of object MIME type alternate text
uses current point
added with SVF2

Graphic object properties

Graphic objects in SVF are drawn using the idea of a current state. Instead of specifying a color, layer, etc. for every object, you only specify when the current value changes. The objects that are drawn use whatever value was last set.

Hyperlinks

Hyperlinks are regions defined in the image where the user can click in order to perform an action, similar to clicking on links in a Web document to bring up different information. Hyperlinks are enabled or disabled based on the layer they are on.

Links are defined in the main body. You set whether the following link regions will be 1 dimension or 2 dimension, the link action, and optional explanatory text. The Link command also allows information about where on the image the user picked. The link regions are displayed like any other entity unless the current color is invisible. On the Web, the action would be a URL which will be activated by the link. If this text is an empty string, the associated link is inactive. The explanatory text may be used by a browser to give the user more information about the link. If the associated layer is turned off, the link is deactivated.

A 1 dimensional link means that the user would select the line or curve. A 2 dimensional link is chosen by picking inside the region (as for a circle or polygon region). A point link is selected by picking close to the point. Text links are defined as the bounding box around the text.

Note that all objects after a 1dLink, 2dLink or Link command are hyperlinks until another link definition or an empty link is found. If both the URL and alternate text are empty, subsequent objects are not hyperlinks.

SVF Script allows links to activate a URL to bring up another document or toggle layers.

Link regions are checked in the reverse order they are defined so the image display matches how links are activated. If regions overlap, the first region found will be the activated link.

1dLink (body)
type token string string
value 35 link action title

2dLink (body)
type token string string
value 36 link action title

If you wish to specify the target or have information about the location of where the user picked in a hyperlink area, use the Link command. This is essentially an extended version of the 1dLink and 2dLink commands; the link action and title parameters have the same meaning. If the SVFLF_IsQuery flag is set, this link command will cause a query string of the form url?<x>,<y> or url?svflink=x:<x>,y:<y> to be passed back to a server (e.g. http://whatever.com/file.html?43,50 or http://whatever.com/file.html?svflink=x:43.23,y:50.98), where url is the link action and x,y is the point the user picked.

If the scale and basepoint are 0 for this command, the coordinates are passed back as SVF Transformed Coordinates. If scale and basepoint are specified, SVF Transformed Coordinates are run through the additional transformation: (x',y') = ( (x + basex) * xscale, (y + basey) * yscale ). The current view width and pixel width are likewise considered to be in SVF Transformed Coordinates. If the additional transformation is specified, width' = (width + basex) * xscale.

Optionally, you can specify the target of where the hyperlinked file will be put. This can be _self, _parent, _top, _blank, or the name of an HTML frame. target may be a null string. See frame targets in the HTML documentation for more information.

Link (body)
type token number number number number byte string string string
value 47 xscale yscale basex basey flags link action title target
added with SVF2

The flags parameter is summarized in the following table. If the low bit is set, it's a 2 dimensional link - otherwise it's 1 dimensional. If the second bit is set, a query string will be added on to the URL passed back to the server. If the third bit is set, all coordinates should be rounded to the nearest integer and the query string will look like url?<x>,<y>. If the third bit is not set, the query string will look like url?svflink=x:<x>,y:<y>.

bit C constant Java constant meaning
00000001 SVFLF_2D eLF_2D 2D if set, 1D if not
00000010 SVFLF_IsQuery eLT_IsQuery add query string to URL
00000100 SVFLF_ShortForm eLT_ShortForm round coordinates to nearest integer

Layers

Layers give you the ability to group objects together so the user can turn on or off the display of portions of the drawing. For example, if you drew a map with coastlines, rivers, and cities, you may want to allow the user to turn on and off the display of the city names so they can more easily view the information they are interested in. Each of these groups could be placed on separate layers. Hyperlinks are enabled or disabled based on the layer they are on.

The first step in using layers is to specify a layer table in the header section. This is simply a list of layer names and the initial display status (on or off) of each layer. The status can be changed when the user views the image.

In the main body you can switch layers as often as you like. After you switch layers, all subsequent objects are part of that layer until you switch layers again. Layer numbers used for SetLayer start referencing the layer table from 0.

Note that the status of layers has no affect on commands which change settings: SetColor, SetLayer, TextHeight, and FillMode. The current point is updated by the appropriate commands regardless of whether the object is on a layer which is displayed or not.

LayerTable (header)
type token count { byte string }
value 5 count on or off layer name


SetLayer (body)
type token number
value 30 layer table index

Colors

There is a default color table consisting of 256 colors which will be reasonable for most images. Alternately, you can specify your own color table which allows any number of colors, or simply reference all colors as RGB values.

If you work with the default colors, the following constants can be used for the basic colors:

SVFC_Black		0
SVFC_White		255
SVFC_LightGray		219
SVFC_Gray		146
SVFC_DarkGray		73
SVFC_Red		224
SVFC_Green		28
SVFC_Blue		3
SVFC_Yellow		252
SVFC_Cyan		31
SVFC_Magenta		227

The color definition can be thought of as the byte rrrgggbb where each color specification (red, green, or blue) is the most significant bits of the desired intensity. For example, if you want the RGB value 34,200,145 (00100010, 11001000, 10010001 in binary), where each value ranges form 0 (black) to 255 (pure color) the appropriate color index would be 00111010 in binary, or 58 in decimal.

SetColor sets the current color for drawing objects until the next color change. Background defines which color is used for the background. The default background color is black (index 0 in the default color table) and the default drawing color is white (index 255 in the default color table). Transparent sets a color to be transparent (objects drawn with that color are drawn with the background color of the target window). This overrides the definition for that color in the color table. Note that these commands use a color index into the image's color table. There can only be a single background color and a single transparent color.

Alternately, you can use RGB values when setting colors using the 4 byte versions of SetColor and Background. The upper byte is reserved for future use and should be set to 255. The next byte is the red component, followed by the green component with the blue component in the lower byte. (Note that this also puts a theoretical limit on the size of a color table, but having more than 64k worth of color entries wouldn't be very practical anyway.) Because SVF is designed so it can be displayed as it's loaded without having to make an initial pass through the file, an SVF viewer may choose to use the default palette and simply find the closest match for any RGB value specified if display is on a palette system.

In order to define an object which doesn't appear (useful for hyperlink regions which don't display), you can set the current color to invisible using Invisible. Subseqent objects will not be drawn until the next SetColor.

ColorTable (header)
type token count { byte byte byte }
value 3 count red (0-255) green (0-255) blue (0-255)

Background (header)
type token number
value 4 color table index or RGB value

Transparent (header)
type token number
value 9 color table index

SetColor (body)
type token number
value 29 color table index or RGB value

Invisible (body)
type token
value 37

Filled regions

To display filled regions, you can turn the fill mode on (the default is off). This affects polylines, rectangles, circles, arcs, ellipses, elliptical arcs, and bezier curves. All regions are displayed filled until the fill mode is turned off.

FillMode (body)
type token number
value 32 0 - off, 1 - on

Pen width

By default, the pen width is 0, which means that all lines will be drawn 1 pixel wide. You can specify a width in SVF coordinates so that it will scale with the image by using SetPenWidth. Or you can have the pen width remain fixed by using SetFixedWidth and specifying the width in hundredths of a millimeter. Note that filled regions and link regions are unaffected by pen width.

SetPenWidth (body)
type token number
value 31 width in svf coordinates


SetFixedWidth (body)
type token number
value 45 width in hundredths of a millimeter
added with SVF2

Linetypes

SVF linetypes are used for lines, polylines, circles, arcs, ellipses, elliptical arcs and bezier curves. They do not change scale when zooming in or out on the drawing. The actual length in pixels of the dashes and spaces may vary per platform. Note that filled regions and link regions are unaffected by linetypes.

value C enum Java constant
0 SVFL_Solid eLT_Solid
1 SVFL_Dash eLT_Dash
2 SVFL_Dot eLT_Dot
3 SVFL_DashDot eLT_DashDot
4 SVFL_DashDotDot eLT_DashDotDot

SetLineType (body)
type token number
value 44 linetype
added with SVF2

Object IDs

Object identifiers (or object IDs) can be assigned to an object or group of objects for linking information to a database or the original graphic information. It could also be used for grouping objects together. Object IDs can be up to 8 bytes; the 8 byte version of the command is interpreted as an integer not a floating point double. This information does not affect display in any way.

SetObjectID sets the object id that is inherited by subsequent objects. NextObjectID is a header command which sets the id to be used when a new object is created.

NextObjectID (header)
type token id
value 13 object id
added with SVF2


SetObjectID (body)
type token id
value 39 object id
added with SVF2

Fonts

Text can be displayed with different fonts. A table of fonts is placed in the header, then text can reference those fonts using an index into the table. Due to the fact that different systems support different fonts, you can list alternate fonts to use if a font isn't found as well as the general font type, or font "family". Multiple fonts in a single font table entry are separated by a comma.

value C enum Java constant meaning
0 SVFF_Other eFF_Other Font family other than built in SVF types
1 SVFF_Serif eFF_Serif Font with serifs, e.g. Times New Roman
2 SVFF_SansSerif eFF_SansSerif Font with no serifs, e.g. Arial or Helvetica
3 SVFF_Monospaced eFF_Monospaced Fixed width font, e.g. Courier
4 SVFF_Symbol eFF_Symbol Symbol font, e.g. Dingbats
5 SVFF_Cursive eFF_Cursive Cursive font e.g. Zapf-Chancery
6 SVFF_Decorative eFF_Decorative Decorative font, e.g. Old English

FontTable (header)
type token count { byte string }
value 12 count font family font names
added with SVF2

Clipping

SVF has support for any arbitrary objects serving as clipping boundaries. You specify how many boundary objects there will be in the ClippingObjects command, then follow that with the SVF objects that will serve as the boundary. After the boundary objects, all further objects will be clipped to the boundary until you change boundaries or specify 0 clipping objects, which effectively turns off clipping. Note: currently viewers are only required to support a single rectangular boundary.

Clipping objects are displayed the same as other objects. If you don't wish to have them display, use the Invisible token first. Once you have finished with the clipping objects, call SetColor to turn display back on.

ClippingObjects (body)
type token count
value 50 number of objects

Image properties

Extents

You should describe the image's size (or extents) in the header section so the program viewing it will know how to display it initially. The extents should include everything in the image. The default is (0,0)-(255,255). Extents information is required if your extents differ from the default.

Extents (header)
type token number number number number
value 2 xmin ymin xmax ymax

Transformations

Scale and base point can be stored in an image which describe how to convert integer SVF coordinates back to the coordinate system of the original drawing or to the double coordinates stored in the SVF file. If (sx,sy) is a point in SVF integer coordinates and (ox,oy) is the corresponding point in the original coordinates (or SVF double coordinates), then (ox,oy) = ( (sx + basex) * scale, (sy + basey) * scale ). The base point corresponds to the origin (0,0) of the SVF file.

Transform (header)
type token number number number
value 10 scale basex basey

Notifications

With notifications, actions can be performed when a certain magnification has been reached. These actions are the same as hyperlink actions and have the same syntax. So, for example, when the user has zoomed in a ways, layers could be turned on so extra information could be displayed. Or information describing the current view can be passed back so a new image could be sent based on where the user was examining in the original image.

A notification can be triggered by zooming in or zooming out. This is specified by the width of the view. If, for example, a file was 1000 units on a side and you wanted to turn on the "Cities" layer after the current view was less than or equal to 300 units on a side, and have the layer turned back off if they zoomed out again, you would use a link action of "svfscript:layers.visible(true, Cities)" and a threshhold of 300 for the zoomin notification. The zoomout notification would have a link action of "svfscript:layers.visible(false, Cities)" and a threshhold of 300.

Note that when you start the notify table, the two numbers you pass indicate the number of entries in the zoomin portion of the table and the the zoomout portion respectively.

Notifications get executed before the image is redisplayed. If more than one notification gets triggered, the first one defined in the table is called first, then the others in order.

NotifyTable (header)
type token count count { Name Width } { Name Width }
value 8 zoomin count zoomout count link action threshhold link action threshhold

View descriptions

By default, an SVF image is displayed to its extents. Alternately, you can specify an intial view to be used. The view is described using the opposite corners of the view window.

InitialView (header)
type extended token number number number number
value 15,2 xmin ymin xmax ymax
added with SVF2

View information can be stored in the header which can later be used to easily change the view of the image. A view is given a name which can be used to identify it later. The opposite corners of the desired view are stored in the view table.

ViewTable (header)
type token count { string Extents }
value 14 count name size
added with SVF2

Miscellaneous

An image can contain a suggestion for how big it would like to appear. You can specify the suggested width of the image in millimeters. The display program is not required to honor the request.

Width (header)
type token number
value 7 millimeters

The SVF image can be given a name (in the header section).

Name (header)
type token string
value 1 name

A flag can be specified which indicates that a display program is free to rearrange entities within a layer. This is useful for certain display optimizations. Note that it is still valid to display entities in the order they occur in the file. 0 is the default. 1 indicates you can rearrange within a layer.

By default, the origin in considered to be the lower left corner and coordinates increase as you move up or to the right. This is how Cartesion coordinates work. Alternately you can specify a flag which indicates that the origin will be in the upper left corner, with coordinates increasing as you move down or to the right.

Flags (header)
type token number
value 11 flag

value C constant Java constant meaning
1 SVFF_RearrangeWithinLayer eF_RearrangeWithinLayer can rearrange objects within a layer
2 SVFF_OriginUpperLeft eF_OriginUpperLeft origin for coordinates in upper left

If a BaseURL is specified, it is used to resolve all relative URLs in the file. This applies to notifications, hyperlinks, bitmaps, and other objects.

BaseURL (header)
type extended token string
value 15,3 URL

Extensions

Custom user data

Arbitrary data can be added to an SVF file. First a general description of the application is placed in the header section. Later, the arbitrary data can reference this table. An entry in the data type table consists of four strings: the company name, a description of the data type, comments and a URL which can point to a web page (this could be used to supply extra information on the data, for example). The data type description is the only required information; the other strings are optional.

DataTypes table entries are then referenced by Data2 when you store arbitrary data in the file. It allows your application to identify data that it knows how to interpret.

The company name SVF is reserved for standard SVF extension data types.

DataTypes (header)
type extended token count { string string string string }
value 15, 1 count company type comments URI
added with SVF2

Data2 (body)
type token number count { byte }
value 46 data type table index byte count user data
added with SVF2

SVF 1.1 had custom user data but did not have a data types table. For simple backwards compatibility, Data can be used to store arbitrary data that doesn't have an associated data type.

Data (body)
type token count { byte }
value 34 byte count user data

Supporting future commands

The Extension command allows future versions of SVF to add commands that can be skipped by an older SVF reader. It simply consists of the Extension token followed by the number of bytes in the following command. If the SVF reader recognizes the token, it can interpret the command, otherwise it knows how many bytes to skip to get to the next valid command. Thus if SVF3 adds a new command, it could wrap it in an Extension to write it back to SVF2 without having to throw away data. An SVF3 reader would then be able to properly read the new command even though it's stored in an SVF2 file. Note that versions of SVF prior to 2.0 do not support the Extension command.

Extension
type token count { byte }
value 0 byte count future command
added with SVF2

Syntax differences between SVF1.1 and SVF2

In general, SVF2 is simply SVF1.1 with additional commands added, making a program which needs to read both versions easy to write. The only situation where you need to know the version to read information properly is text strings. SVF2 stores all text (layer names, graphical text, etc.) in UTF-8 encoded Unicode but SVF1.1 only used ASCII. If all the text is simply lower ASCII, the difference isn't noticeable, but for other characters this is important. See strings for more information.

In SVF2, the 4 byte version of the SetColor and Background commands specify an RGB value. The 1 and 2 byte versions indicate an index into the color table. In SVF1.1, these commands always specified a color index.

See Changes to SVF for a complete description of the changes between SVF1.1 and SVF2.

Stream Status

The stream status flags affect how a reader treats the incoming SVF stream. They don't directly affect display. Once a reader encounters the End flag, it can close the file or connection. Note that this is optional, so readers should not rely on it being present. The Reset flag indicates that all previous data should be discarded. Entirely new content will be sent.

StreamStatus (body)
type token number
value 49 flag

value C constant Java constant meaning
1 eSVFS_End eS_End end of file
2 eSVFS_Reset eS_Reset discard previous data and start over

MIME type

The MIME type for SVF files is image/vnd.svf. The standard file extension is .svf or .SVF.

A MIME (Multipurpose Internet Mail Extensions) type is a string which describes data types such as JPEG bitmaps (image/jpeg), HTML (text/html), SVF (image/vnd.svf) or XML (text/xml).