FIG Format 3.2


This is a description of the Fig Format 3.2, the native file format of XFig.

The new components in protocol 3.2 are the paper size, magnification, single/multiple page indicator and transparent color for GIF export in the header.

The other modification between version 3.1 and version 3.2 of the protocol is the mathematical model used for splines. The new version uses X-splines which allows the user to mix interpolation and approximation points in a same curve. More precisely, it means that an X-spline curve is neither an interpolated spline nor an approximated one, it is BOTH (the behavior of each point is controlled by one single parameter called "shape factor").

For additional information about X-splines, see:

"X-Splines: A Spline Model Designed for the End User"
C. Blanc and C. Schlick,
Proceedings of SIGGRAPH'95

Caveat: Because spline models of previous versions (quadratic B-splines and Bezier with hidden points) are no longer supported, curves that are present in version 3.1 and older files are automatically converted to X-splines. This translation is only an approximation process. It means that the converted curves are not exactly the same as the original ones. Though the translation usually provides almost identical curves, some hand-fitting may be needed in some pathological cases.

Description of the Fig Format

(1) The very first line is a comment line containing the name and version:

#FIG 3.2
The character # at the first column of a line indicates that the line is a comment line which will be preserved when the Fig file is read in. The user may edit them with the popup editor.

The comment line(s) must immediately precede the object to which they are associated. In the case of the "whole figure comments" mentioned below, they immediately precede the (resolution,coord_system) line.

(2) The first non-comment line consists of the following:
TypeNameValues
stringorientation"Landscape" or "Portrait"
stringjustification"Center" or "Flush Left"
stringunits"Metric" or "Inches"
stringpapersize"Letter", "Legal", "Ledger", "Tabloid", "A", "B", "C", "D", "E", "A4", "A3", "A2", "A1", "A0" and "B5"
floatmagnification(export and print magnification, %)
stringmultiple-page"Single" or "Multiple" pages
inttransparent colorcolor number for transparent color for GIF export. -3=background, -2=None, -1=Default, 0-31 for standard colors or 32- for user colors
stringoptional commentAn optional set of comment lines, each beginning with a "#", may be here. These are associated with the whole figure
int + intFig_resolution + coord_system Fig units per inch, and and indicator of the coordinate system, with 1 being the origin at lower left corner (NOT USED), and 2 being the origin at upper left

Fig_resolution is the resolution of the figure in the file. Xfig will always write the file with a resolution of 1200ppi, so it will scale the figure upon reading it in if its resolution is different from 1200ppi. Pixels are assumed to be square.

Xfig will read the orientation string and change the canvas to match either the Landscape or Portrait mode of the figure file.

The coordinate_system variable is ignored - the origin is ALWAYS the upper-left corner.

Notes:

The rest of the file contains various objects. An object can be one of six classes (or types).

In the following elaboration on object formats, every value of fig output are separated by blank characters or new line ('\n'). The value of the unused parameters will be -1.

Some fields are described as "enumeration type" or "bit vector"; the values which these fields can take are defined in the header file object.h. The pen_style field is unused. These values may be defined in some future version of Fig.

The two color fields (pen and fill; pen only, for texts) are defined as follows:
ValueColor
-1 Default
0 Black
1 Blue
2 Green
3 Cyan
4 Red
5 Magenta
6 Yellow
7 White
8 Very dark blue
9 Dark blue
10 Light blue
11 Very light blue
12 Dark green
13 Green
14 Light green
15 Dark cyan
16 Cyan
17 Light cyan
18 Dark red
19 Red
20 Light red
21 Dark magenta
22 Magenta
23 Light magenta
24 Dark brown
25 Brown
26 Light brown
27 Very dark pink
28 Dark pink
29 Light pink
30 Very light pink
31 Gold
32-543user definable colors
A particular X server may limit the number of colors a user can define.

For WHITE color, the area fill field is defined as follows:
ValuePattern
-1 not filled
0 black
1 to 19 shades of gray, from darker to lighter
20 white
21-40 not used
41-56 see patterns for colors, below

For BLACK or DEFAULT color, the area fill field is defined as follows:
ValuePattern
-1 not filled
0 white
1 to 19 shades of gray, from lighter to darker
20 black
21-40 not used
41-56 see patterns for colors, below

For all other colors, the area fill field is defined as follows:
ValuePattern
-1 not filled
0 black
1 to 19 "shades" of the color, from darker to lighter. A shade is defined as the color mixed with black
20 full saturation of the color
21 to 39 "tints" of the color from the color to white. A tint is defined as the color mixed with white
40 white
41 30 degree left diagonal pattern
42 30 degree right diagonal pattern
43 30 degree crosshatch
44 45 degree left diagonal pattern
45 45 degree right diagonal pattern
46 45 degree crosshatch
47 horizontal bricks
48 vertical bricks
49 horizontal lines
50 vertical lines
51 crosshatch
52 horizontal "shingles" skewed to the right
53 horizontal "shingles" skewed to the left
54 vertical "shingles" skewed one way
55 vertical "shingles"skewed the other way
56 fish scales
57 small fish scales
58 circles
59 hexagons
60 octagons
61 horizontal "tire treads"
62 vertical "tire treads"

The depth field is defined as follows:
ValueMeaning
0 ... 999 a larger value means the object is deeper than (under) objects with smaller depth

The line_style field is defined as follows:
ValuePattern
-1 Default
0 Solid
1 Dashed
2 Dotted
3 Dash-dotted
4 Dash-double-dotted
5 Dash-triple-dotted

The style_val field is defined as the length, in 1/80 inches, of the on/off dashes for dashed lines, and the distance between the dots, in 1/80 inches, for dotted lines.

The join_style field is defined FOR LINES only as follows:
ValueMeaning
0Miter
1Round
2Bevel

The cap_style field is defined FOR LINES, OPEN SPLINES and ARCS only as follows:
ValueMeaning
0Butt
1Round
2Projecting

The arrow_type field is defined for LINES, ARCS and OPEN SPLINES only as follows:
ValueMeaning
0Stick type
1Closed Triangle
2Closed Triangle with indented butt
3Closed Triangle with exdented butt

Stick-type arrow:

                  \
                   \
      ______________\
                    /
                   /
                  /
      

Closed triangle arrow:

              |\
              | \
      ________|  \
              |  /
              | /
              |/
      

Closed arrow with "indented" butt:

             |\
             \ \
              \ \
      _________\ \
               / /
              / /
             / /
             |/
      

Closed with "pointed" butt:

                 /\
                /  \
               /    \
      ________/      \
              \      /
               \    /
                \  /
                 \/
      

The arrow_style field is defined for LINES, ARCS and OPEN SPLINES only as follows:
ValueMeaning
0Hollow (filled with white)
1Filled with pen color

COLOR PSEUDO OBJECTS:

Color Pseudo-objects define arbitrary colors beyond the 32 standard colors. The color objects must be defined before any other Fig objects.

TypeNameDescription
intobject_code0
intcolor_numberfrom 32 to 543 (512 total indices available)
hex stringrgb_valuethe RGB values, as in #330099

ARC OBJECTS:

TypeNameDescription
int object_code (always 5)
int sub_type (1=open arc, 2 = closed wedge )
int line_style (enumeration type)
int line_thickness (1/80 inch)
int pen_color (enumeration type, pen color)
int fill_color (enumeration type, fill color)
int depth (enumeration type)
int pen_style (pen style, not used)
int area_fill (enumeration type, -1 = no fill)
float style_val (1/80 inch)
int cap_style (enumeration type)
int direction (0: clockwise, 1: counterclockwise)
int forward_arrow (0: no forward arrow, 1: on)
int backward_arrow (0: no forward arrow, 1: on)
float center_x, center_y (center of the arc)
int x1, y1 (Fig units, the 1st point the user entered)
int x2, y2 (Fig units, the 2nd point)
int x3, y3 (Fig units, the last point)

Forward arrow line (Optional; absent if forward_arrow is 0):
TypeNameDescription
intarrow_typeenumeration type
intarrow_styleenumeration type
floatarrow_thickness1/80 inch
floatarrow_widthin Fig units
floatarrow_heightin Fig units

Backward arrow line (Optional; absent if backward_arrow is 0):
TypeNameDescription
intarrow_typeenumeration type
intarrow_styleenumeration type
floatarrow_thickness1/80 inch
floatarrow_widthin Fig units
floatarrow_heightin Fig units

COMPOUND OBJECTS:

A line with object code 6 signifies the start of a compound. There are four more numbers on this line which indicate the upper left corner and the lower right corner of the bounding box of this compound. A line with object code -6 signifies the end of the compound. Compound objects may be nested.

TypeNameDescription
intobject_code6
intupperleft_corner_xin Fig units
intupperleft_corner_yin Fig units
intlowerright_corner_xin Fig units
intlowerright_corner_yin Fig units

Immediately succeeding lines define objects that make up the compound object. The compound object is terminated with a line containing the single value "-6".

ELLIPSE OBJECTS:

TypeNameDescription
intobject_code1
intsub_type1: ellipse defined by radii 2: ellipse defined by diameters 3: circle defined by radius 4: circle defined by diameter)
intline_styleenumeration type
intthickness1/80 inch
intpen_colorenumeration type
intfill_colorenumeration type
intdepthenumeration type
intpen_style(not used!)
intarea_fillenumeration type, -1=no fill
floatstyle_val1/80 inch
intdirectionalways set this to 1
floatangleradians, the angle of the x-axis of the ellipse
intcenter_x, center_yFig units
intradius_x, radius_yFig units
intstart_x, start_yFig units, first point entered
intend_x, end_yFig units, last point entered

POLYLINE OBJECTS:

TypeNameDescription
intobject_code2
int sub_type1: polyline, 2: box, 3: polygon, 4: arc-box, 5: imported picture bounding box
intline_style(enumeration type)
intthickness(1/80 inch)
intpen_color(enumeration type, pen color)
intfill_color(enumeration type, fill color)
intdepth(enumeration type)
intpen_style(pen style, not used)
intarea_fill(enumeration type, -1 = no fill)
floatstyle_val(1/80 inch)
intjoin_style(enumeration type)
intcap_style(enumeration type, only used for POLYLINE)
intradius(1/80 inch, radius of arc-boxes)
intforward_arrow(0: off, 1: on)
intbackward_arrow(0: off, 1: on)
intnpoints(number of points in line)

Forward arrow line: same as for an ARC object

Backward arrow line: same as for an ARC object

Points line:
TypeNameDescription
intx1,y1(Fig units)
intx2,y2(Fig units)
.........
intxn,yn(Fig units)
For polygons and boxes, the last point should be the same as the first one, so that the polyline closes.

PIC line:
TypeNameDescription
booleanflippedorientation, normal = 0, flipped = 1
charfile[]name of picture file to import

SPLINE OBJECTS:

The first line:
TypeNameDescription
intobject_code3
intsub_type0: open approximated spline, 1: closed approximated spline, 2: open interpolated spline, 3: closed interpolated spline, 4: open x-spline, 5: closed x-spline
intline_stylesee end of this section
intthickness1/80 inch
intpen_colorenumeration type
intfill_colorenumeration type
intdepthenumeration type
intpen_style(not used!)
intarea_fillenumeration type, -1=no fill
floatstyle_val1/80 inch
intcap_styleenumeration type, only used for open splines
intfoward_arrow0=off, 1=on
intbackward_arrow0=off, 1=on
intnpointsthe number of control or data points

Forward arrow line: same as for an ARC object

Backward arrow line: same as for an ARC object

Points line: same as for a POLYLINE object

Control points line : There is one shape factor for each point. The value of this factor must be between -1 (which means that the spline is interpolated at this point) and 1 (which means that the spline is approximated at this point). The spline is always smooth in the neighborhood of a control point, except when the value of the factor is 0 for which there is a first-order discontinuity (i.e. angular point).

TEXT OBJECTS:

TypeNameDescription
intobject_code4
intjustification0: Left, 1: Center, 2: Right
intcolorenumeration type
intdepthenumeration type
intpen_style(not used!)
intfontenumeration type
floatfont_sizemeasured in points
floatanglemeasured in radians
intfont_flagsbit vector, see next paragraph
floatheightFig units
floatlengthFig units
intx, yFig units, origin of the string
charstring[]ASCII string terminated with '\001'.

If justification = 0, then the (x,y) origin of the string is the lower left corner of the string. If sub_type = 1, it is the lower center. Otherwise it is the lower right corner of the string.

The sequence '\001' is not part of the string. Characters above octal 177 are represented by \xxx where xxx is the octal value. This permits Fig files to be edited with 7-bit editors and sent by e-mail without data loss. Note that the string may contain '\n'.

The font_flags field is defined as follows:
BitDescription
0Rigid text (text doesn't scale when scaling compound objects)
1Special text (for LaTeX)
2PostScript font (otherwise LaTeX font is used)
3Hidden text

For font_flags bit 2 = 0 (LaTeX fonts), the font field is defined as:
ValueMeaning
0Default font
1Roman
2Bold
3Italic
4Sans Serif
5Typewriter

For font_flags bit 2 = 1 (PostScript fonts), the font field is defined as:
ValueFont
-1 Default font
0 Times Roman
1 Times Italic
2 Times Bold
3 Times Bold Italic
4 AvantGarde Book
5 AvantGarde Book Oblique
6 AvantGarde Demi
7 AvantGarde Demi Oblique
8 Bookman Light
9 Bookman Light Italic
10 Bookman Demi
11 Bookman Demi Italic
12 Courier
13 Courier Oblique
14 Courier Bold
15 Courier Bold Oblique
16 Helvetica
17 Helvetica Oblique
18 Helvetica Bold
19 Helvetica Bold Oblique
20 Helvetica Narrow
21 Helvetica Narrow Oblique
22 Helvetica Narrow Bold
23 Helvetica Narrow Bold Oblique
24 New Century Schoolbook Roman
25 New Century Schoolbook Italic
26 New Century Schoolbook Bold
27 New Century Schoolbook Bold Italic
28 Palatino Roman
29 Palatino Italic
30 Palatino Bold
31 Palatino Bold Italic
32 Symbol
33 Zapf Chancery Medium Italic
34 Zapf Dingbats

You can return to the HTML web page.


Last revised on 26 June 2006.