Xfig
Xfig is a free and open-source vector graphics editor designed for the X Window System, enabling users to interactively draw, manipulate, and edit technical illustrations and diagrams on Unix-like operating systems.[1][2] It operates as a menu-driven tool within an X window, where objects such as lines, arcs, splines, polygons, circles, boxes, and text can be created and modified using geometric primitives, with support for grouping, layering, and color selection.[3] The resulting figures can be saved in its native .fig format or exported to various vector and raster formats, including PostScript, EPS, SVG, PNG, JPEG, and TIFF, as well as text-based formats like LaTeX, PSTricks, and Metapost via the companion transfig package.[2][1] Originally developed between 1985 and 1988 by Supoj Sutanthavibul as the Facility for Interactive Generation (FIG) of figures under X11, Xfig saw significant enhancements from 1989 to at least 2012 by Brian V. Smith, who integrated it with the TransFig utilities for format conversion, and contributions from Paul R. King starting in 1991.[3][4] Maintained for many years at Lawrence Berkeley National Laboratory, the project transitioned to open-source hosting on platforms like SourceForge, where it remains actively maintained with community contributions as of 2025.[3][5] As of 2025, Xfig version 3.2.9a supports modern builds via CMake and is compatible with X11R6 or later, though it lacks native support for contemporary graphical environments like Wayland without additional configuration such as XWayland.[3][2][6] Key features include built-in object libraries for specialized symbols—such as electrical components, arrows, and block diagrams—along with tools for alignment, rotation, scaling, and depth management to facilitate precise technical drawing.[3] It is particularly valued in academic and engineering contexts for generating publication-ready figures integrable with document preparation systems like LaTeX, and its lightweight design makes it suitable for older hardware or minimal installations.[5] Despite its age, Xfig continues to be packaged in major Linux distributions, such as Debian and FreeBSD, underscoring its enduring utility for vector-based illustration in open-source ecosystems.[7][2]Overview
Introduction
Xfig is a free and open-source vector graphics editor that operates under the X Window System on most UNIX-like platforms.[5] It enables users to create and manipulate scalable illustrations interactively through a menu-driven interface. The tool's core purpose is to facilitate the production of technical diagrams, drawings, flowcharts, and schematics by employing fundamental geometric primitives, including lines, arcs, ellipses, splines, and polygons. Licensed under the permissive Xfig License—a BSD-like agreement that grants broad rights for use, modification, and distribution—Xfig has been maintained as an accessible option for precise vector-based artwork.[8] Originally developed in 1985, Xfig endures as a lightweight, mature application particularly suited to scientific and engineering workflows, with its current stable release, version 3.2.9a, supported through ongoing updates on SourceForge.[9][4]Purpose and Capabilities
Xfig serves primarily as a vector graphics editor tailored for creating technical illustrations and diagrams in academic, engineering, and scientific environments. It is widely used for generating figures in research papers, technical manuals, circuit schematics, and modeling diagrams such as UML, where precise, scalable graphics are essential for documentation and publication. Its integration with LaTeX and PostScript workflows makes it particularly suitable for environments requiring high-quality, printable outputs without reliance on commercial software.[10][11] Key capabilities of Xfig include support for layers, implemented as depths to manage the drawing order of overlapping objects in complex diagrams, enabling users to organize elements hierarchically for better control. Precision is facilitated by grid snapping, which aligns drawing points to a configurable grid for accurate positioning, alongside tools for object manipulation like scaling and rotation. The software provides undo functionality, limited to a single level for most operations, allowing quick reversal of recent actions. Color management features a palette of 32 standard colors plus user-defined options, supporting additional user-defined colors beyond the 32 standard palette, and a configurable number of colors (defaulting to 64) for imported images, though practical use often centers on the core set for compatibility.[12][13][14][15][16] As an open-source tool running under the X Window System on Unix-like platforms, Xfig offers advantages in resource efficiency, consuming minimal system resources compared to modern GUI alternatives, and supports command-line integration via its native Fig format and companion tools like fig2dev for automated processing in scripts. This makes it ideal for server-based or lightweight Unix workflows in research and development settings. However, its interface reflects older design principles, appearing dated relative to contemporary vector editors, though this simplicity enhances its scriptability and ease of use for focused technical tasks.[11][10]History and Development
Origins and Early Versions
Xfig originated in 1985 when Supoj Sutanthavibul, a student at the University of Texas at Austin, developed the initial version as a SunView application specifically for generating simple technical drawings on Sun Microsystems workstations.[17] This creation addressed the demand in academic Unix environments for an accessible, non-proprietary tool to facilitate diagram production without reliance on commercial software.[18] Shortly thereafter, in 1986, Ken Yap, based in Rochester, New York, undertook the first port of the application to the X Window System (X11), enabling broader compatibility beyond the proprietary SunView framework and allowing use on various Unix systems supporting X11.[17] This transition marked a pivotal step in expanding Xfig's reach within the growing X11 ecosystem, which was becoming the standard for graphical interfaces in open Unix computing. By 1989, early enhancements had introduced basic object libraries—encompassing fundamental elements like lines, ellipses, and polygons—along with the capability to export drawings to PostScript format, enhancing print quality and integration with document preparation systems such as TeX.[17] These additions laid the groundwork for more versatile figure generation, solidifying Xfig's role as a foundational tool for technical illustration in research settings.Key Milestones and Contributors
In 1989, Brian V. Smith enhanced Xfig by improving spline handling and refining the user interface, including additions like multiple fonts, line thickness, and area fill patterns.[19] During Smith's tenure, Xfig was maintained at Lawrence Berkeley National Laboratory, where significant enhancements were developed until the mid-2010s.[3][10] The release of version 2.0 in 1991, led by Paul King at the University of Manchester, introduced a modern graphical user interface featuring pop-up panels and menu-driven operations, significantly improving usability.[19] In 1997, Tom Sato contributed Japanese language support, along with a spell checker and search/replace functionality for text objects, expanding Xfig's internationalization and text editing capabilities.[17] Version 3.0, released in 1998, added support for layers to manage object drawing order and rotation tools for precise object manipulation.[20] The 3.2 series, beginning in the early 2000s, incorporated SVG import and export capabilities through integration with the fig2dev tool, enabling better compatibility with web and vector standards.[21] More recent developments include version 3.2.9a, released in late December 2024, which introduced fractional font sizes for finer text control. A security vulnerability (CVE-2025-46398) was later identified in this version and addressed in subsequent updates.[4][22] Brian V. Smith served as the primary maintainer through the 2010s, overseeing numerous enhancements until handing over development in 2015 to Thomas Loimer, who manages the project under the MCJ umbrella on SourceForge.[10] Since the 2020s, the open-source community has sustained active maintenance via the SourceForge MCJ project, applying patches for contemporary Unix-like platforms, including security-focused updates in 2025.[5]Core Features
Drawing and Object Manipulation
Xfig provides a suite of tools for creating vector-based geometric elements, enabling users to construct diagrams through interactive mouse operations and precise input methods. The primary drawing tools include straight lines and polylines, which connect multiple points to form open paths; arcs, available in open or closed (pie-wedge) configurations; circles and ellipses, defined by center and radius or diameter; rectangular boxes and arc boxes with rounded corners; polygons, including regular variants; and splines, which can be open or closed, approximated (using arcs and lines for smooth curves) or interpolated (passing through specified points). Additionally, bitmaps such as EPS, GIF, JPEG, and other raster images can be imported as picture objects by specifying opposite corners.[23] Object manipulation in Xfig supports flexible editing of these elements post-creation. Resizing is achieved by scaling objects proportionally via corner drags or unidimensionally via edge drags, with options to scale about the center; rotating occurs at arbitrary angles set via a rotation panel, allowing clockwise or counterclockwise adjustments with copying for multiples; flipping is performed horizontally or vertically relative to an anchor point. Objects can be grouped into compounds by tagging and gluing multiple elements, treating them as a single unit for unified manipulation, while alignment features distribute or align objects vertically or horizontally within compounds or across the canvas. Depth layering assigns values from 0 to 999 to control overlap visibility, with lower numbers appearing in the foreground.[24] Attributes enhance the visual properties of drawn objects. Line styles encompass solid, dashed, dotted, and compound variants like dash-dot, with customizable dash lengths, dot spacing, cap styles (butt, round, projecting), and join styles (miter, rounded, bevel); thicknesses range from 0 (invisible) to several pixels, approximating 1/80 inch per pixel. Fill patterns include various densities and hatches, applied with selectable colors from 32 standard or custom palettes; arrows can be added to endpoints of open objects like polylines or splines, in forward, backward, or both directions, with adjustable types, sizes, and thicknesses relative to line width. These attributes are set via dedicated panels before or after drawing.[25] Precision during drawing and editing is facilitated by several aids. Snap-to-grid aligns points and objects to a configurable virtual grid, with modes for dots, lines, or tiles and adjustable spacing in inches or metric units; rubberbanding provides real-time visual previews of shapes during drags. Coordinate input allows keyboard entry of exact positions in Fig units (1/1200 inch) via the edit panel, supplemented by rulers along the top and side for measurement and panning.[24][23]Text Handling and Styling
Xfig supports the insertion of text objects through a dedicated text mode, where users select a position on the canvas and enter content via an editable popup panel. It provides 35 built-in fonts, encompassing Hershey vector fonts for scalable rendering and standard PostScript fonts for high-quality output.[26] Point sizes range from small to large values, with fractional sizes enabled starting in version 3.2.9a to allow precise scaling.[27] Alignment options include left-justified, centered, and right-justified text, facilitating flexible layout within figures.[11] Styling capabilities for text include bold and italic formatting achieved via special escape sequences in the special text mode, such as \bf for bold and \it for italic, which integrate seamlessly with LaTeX processing.[28] Text rotation is adjustable by specifying an angle in degrees, enabling angled labels or annotations relative to drawn elements.[26] Additionally, users can embed LaTeX mathematical formulas directly within text strings using standard LaTeX syntax, such as for inline math or display equations, which are preserved and rendered during export to formats supporting LaTeX. For example, a formula like \int_a^b f(x) \, dx can be inserted by enclosing it in dollar signs within special text mode.[29] Advanced text features encompass multi-line support, where pressing Enter within the text editor creates line breaks with adjustable interline spacing via the text step parameter.[30] The Edit menu provides search and replace functionality to locate and modify strings across all text objects in the figure.[19] Spell checking is integrated for English and Japanese, invoking an external program like ispell or aspell to highlight and correct errors in selected text.[31] For outline editing, text can be converted to editable path representations, such as splines, allowing manipulation of individual letter shapes as vector components.[32] Despite these capabilities, Xfig's text handling has limitations in Unicode support; while UTF-8 encoding is used internally and in file saves since version 3.2.9, rendering of complex scripts beyond basic Latin characters often requires external tools for full fidelity.[27] Text objects can be aligned with geometric elements using the object's positioning tools, and styled text exports reliably to vector formats like PDF or EPS.[11]File Formats and Interoperability
Native Fig Format
The native Fig format, used by Xfig for saving and sharing diagrams, is a plain-text based file format with the .fig extension that is fully human-readable and structured into distinct sections for objects, colors, and scales.[33] It has supported versioning since the introduction of format 3.2 in the late 1990s, which remains the current standard and includes enhancements like paper size specifications and X-spline support.[34][33] A key advantage of the Fig format is its accessibility for manual editing using any text editor, allowing users to directly modify figure elements without the graphical interface, while maintaining a compact file size due to its efficient ASCII representation.[33] Additionally, it provides lossless storage of all drawing attributes, including layers, depths, line styles, fill patterns, and object-specific properties, ensuring no data degradation upon repeated saves or loads.[33] The format's structure begins with a header section that defines essential figure metadata, such as bounds (minimum and maximum x/y coordinates), resolution (typically 1200 pixels per inch), orientation (Landscape or Portrait), units (Metric or Inches), paper size (e.g., A4 or Letter), magnification percentage, and the coordinate system origin (upper-left by default).[33] Following the header, the body consists of sequential lines describing individual objects, each prefixed by an object type number—such as 1 for ellipses (specifying center x/y coordinates, radii, style, and sub-type like circle or pie wedge), 2 for polylines (including polygons and boxes with point lists and line styles), 3 for splines (with control points, shape factors, and sub-types for open/closed approximations), 4 for text (position, font, size, and string), 5 for arcs, and 6 for compounds (grouping other objects).[33] Color definitions appear as special type-0 pseudo-objects, supporting 32 standard colors (0=Black to 31=Gold) plus user-defined RGB values (e.g., in hexadecimal for depths 32–543), with fill styles ranging from -1 (no fill) to patterned tints.[33] Xfig maintains backward compatibility in the Fig format, enabling older versions to load newer files by automatically converting unsupported features—like X-splines to approximated polylines—and issuing warnings for any potential data loss, which preserves usability across software iterations.[33]Import and Export Capabilities
Xfig supports importing a variety of raster and vector image formats as picture objects, enabling users to embed external graphics within drawings. Raster formats include JPEG, PNG, GIF, and TIFF, with support contingent on compiling Xfig with appropriate flags and linking to libraries such as the Independent JPEG Group's libjpeg for JPEG handling, libpng for PNG, and libtiff for TIFF. Vector formats encompass Encapsulated PostScript (EPS) and PostScript files, which are rasterized using Ghostscript during import. The fig2dev utility assists in these conversions where needed, ensuring imported images are stored as bitmaps in the native Fig format.[35][36][37] Export capabilities in Xfig are handled primarily through the fig2dev utility from the TransFig package, which transforms Fig files into numerous output formats for diverse applications. Vector exports feature PostScript and EPS for high-quality printing and document embedding, full SVG for scalable web graphics, and PDF derived from PostScript intermediates via Ghostscript. Raster exports produce PNG and JPEG images through rasterization, suitable for bitmap needs. LaTeX-oriented outputs generate code for PSTricks and, since version 3.2.6, PGF/TikZ, allowing direct inclusion of figures in LaTeX documents with preserved vector quality. As of version 3.2.9a (released December 2024), the supported formats remain unchanged.[38][29][39] The fig2dev tool supports over 20 output languages, including HPGL for legacy plotters, CGM, and pic for troff/groff integration, facilitating batch processing via command-line operations without launching the graphical interface. This enables automated workflows, such as converting multiple Fig files to a single format. Xfig demonstrates seamless interoperability with groff for man page creation through pic exports, where figures are embedded as inline graphics in formatted text.[38][5]Technical Implementation
System Requirements and Platforms
Xfig operates primarily under the X Window System (X11), requiring X11 Release 4 (X11R4) or later, and is compatible with most UNIX-like operating systems. Supported platforms include major Linux distributions such as Debian, Ubuntu, Fedora, CentOS, SUSE, and Arch Linux, as well as FreeBSD and Solaris. On Windows, it runs through Cygwin, which emulates a UNIX environment with X11 support, while on macOS, it requires XQuartz to provide the necessary X11 server. There is no native support for Windows or mobile platforms, limiting its use to desktop environments with X11 compatibility.[35][40][41][42][43][44] The software's system requirements are modest, reflecting its origins as a lightweight tool suitable for hardware dating back to the 1990s, with minimal CPU and RAM needs for basic operation. As of November 2025, version 3.2.9a is the latest release. Core dependencies include X11 libraries such as libX11, libXt, libXaw (or libXaw3d), libXi, and libXpm for graphical rendering and interaction. For PostScript (PS) and Encapsulated PostScript (EPS) output, as well as bitmap exports like GIF or JPEG, Ghostscript is essential, often paired with the netpbm package for image processing. These requirements ensure broad accessibility on resource-constrained systems without demanding modern hardware acceleration.[45][46][47] Installation on supported platforms is facilitated through native package managers; for instance, on Debian or Ubuntu, the commandsudo apt install xfig retrieves the binary along with essential dependencies like fig2dev for format conversions. Source compilation, suitable for custom builds or less common distributions, necessitates a C compiler (e.g., gcc) and the corresponding X11 development headers and libraries, with build instructions available in the official documentation. Recent Linux distributions, including those on ARM architectures like Raspberry Pi OS, support Xfig via X11, enabling its use on devices such as the Raspberry Pi without specialized modifications. For Wayland-based sessions, Xfig functions through XWayland compatibility layers provided by modern desktop environments, maintaining usability as X11 support persists.[40][45][48][49]
Architecture and Dependencies
Xfig is implemented in the C programming language, leveraging the Xlib library for core graphics rendering and event handling under the X Window System.[3] This foundational design enables interactive manipulation of vector graphics within an X11 environment, where Xlib provides the low-level interface to the X11 protocol for display server communication and input processing.[37] The software depends on several X11-related libraries, including libX11 for fundamental window management, libXt and libXaw (or libXaw3d) for widget toolkit functionality, libXi for input extensions, and libXpm for handling pixmap image formats such as those used in imported pictures.[40] Optional integration with Tcl/Tk is supported for specific extensions, particularly in the companion fig2dev utility for generating Tk-compatible output.[50] fig2dev itself acts as an essential backend tool, converting native Fig files to diverse formats like PostScript, PDF, and SVG, thereby extending Xfig's interoperability without altering its core runtime.[51] Architecturally, Xfig operates as an event-driven, single-window application centered on a main drawing canvas, augmented by modal pop-up panels for tasks like file operations, object editing, and attribute selection.[37] It lacks multi-threading, relying instead on the X11 event loop for responsiveness, and employs a modular object model that represents drawings as collections of discrete elements—such as lines, ellipses, splines, polygons, arcs, boxes, text, and embedded images—each with configurable attributes like style, color, and depth.[52][53] The codebase remains largely monolithic, comprising around 75,000 lines of C code in its analyzed structure, though modern distributions may vary slightly due to patches.[52] Community-maintained forks, such as the one by hhoeflin on GitHub, introduce modern build systems like CMake to simplify compilation across platforms while preserving the original Imake-based setup.[3] In 2025, critical security updates addressed multiple vulnerabilities in fig2dev, including stack-based buffer overflows in functions like bezier_spline and read_objects (CVE-2025-46397 and CVE-2025-46398), as well as heap overflows and floating-point exceptions, enhancing overall stability.[54][55]Usage and Integration
User Interface and Workflow
Xfig's user interface centers around a main drawing canvas, which serves as the primary workspace for creating and editing vector-based diagrams. Surrounding the canvas are several specialized panels that facilitate interaction. The drawing mode panel, typically positioned on the left side of the window, contains buttons for selecting tools to create objects such as lines, arcs, circles, ellipses, polylines, polygons, splines, and text. Below it lies the editing mode panel, offering tools for manipulating existing objects, including options to move, rotate, scale, delete, or convert between object types. Additional elements include top and side rulers for precise measurements, a message window at the bottom for status updates and instructions, and indicator panels that display current mouse functions, coordinates, and units. Attribute panels at the bottom allow real-time adjustment of line styles, widths, colors, and fill patterns during drawing or editing. This layout promotes an efficient workflow by keeping essential controls accessible without cluttering the canvas.[56][57][58] Interaction in Xfig relies heavily on a three-button mouse for precise control, with the left button used for selecting objects, placing points, or dragging to define shapes; the middle button for panning the canvas, fixing object positions, or entering freehand drawing modes; and the right button for opening context-sensitive pop-up menus, canceling operations, or accessing object-specific edits. For users with two-button mice, the middle button can be emulated by holding the Meta key while pressing the right button. Keyboard accelerators enhance efficiency, particularly for menu navigation and common actions; for instance, underlined letters in menus (e.g., 'O' for Open after accessing the File menu) serve as shortcuts, while modifiers like Meta or Ctrl enable direct commands such as Meta-G for global settings or Ctrl-L for landscape orientation. Examples include 'o' to open a file directly in some configurations and arrow keys for fine adjustments in text entry. The mouse function indicator, located in the upper right, dynamically shows the current role of each button based on the active mode, aiding user orientation.[56][59][60] The operational workflow for creating diagrams in Xfig typically starts with launching the application and selecting New from the File menu (or using the keyboard accelerator) to initialize a blank canvas, optionally setting page size and orientation via the global settings panel. Users then switch to drawing mode, choose a tool from the left panel—such as the polyline tool for straight or spline-based curves—and interact with the canvas by left-clicking to set initial points, dragging to define segments, and middle-clicking to complete the object. For example, drawing a spline involves selecting the tool, placing control points with left clicks, and closing or opening the shape as needed. Once objects are placed, transitioning to editing mode allows selection via left-click (highlighting the object), followed by right-click for a context menu to adjust properties or by using editing tools to move, scale, or align multiple selected objects. Coloring and styling occur concurrently through the bottom attribute panel, where users pick from a palette or specify styles before or after drawing. Zooming is achieved via the View menu for preset levels (e.g., full view or area zoom by Ctrl+left-drag to define a rectangle), enabling detailed work, while panning with the middle button or Shift+wheel (on supported mice) maintains navigation. Multiple views can be managed by opening additional Xfig instances for the same file or using the canvas's layered display for complex figures. Editing concludes with right-click context options for fine-tuning, such as converting lines to arcs. Finally, the figure is saved in native .fig format via the File menu or exported to other formats like PDF using integrated tools, completing the cycle. This iterative process supports rapid prototyping of technical illustrations.[56][57][61][62] Xfig operates in distinct modes to streamline tasks: drawing mode for object creation, editing mode for modifications (including aligning and distributing selected objects via dedicated buttons), and specialized submodes like coloring, accessed through the color palette panel for applying fills, lines, or transparency. Point positioning aids, such as rubberbanding for previews, and grid snapping (toggleable in 0-3 levels) enhance accuracy across modes. An undo feature in the Edit menu supports reversion of the most recent action, such as a copy or rotate operation, though multi-level undo is not available—double-clicking undo reverts to the pre-undo state. Redo is similarly limited. For broader navigation, large figures can be exported or printed split across multiple pages if they exceed the paper size. Accessibility is enhanced through user-specific configuration in the ~/.xfigrc file, which stores preferences like the number of recent files in the menu (default 10, adjustable up to 20), default zoom, grid settings, and balloon help delays. However, as a legacy X11 application, Xfig offers no native touch support and partial keyboard-only navigation, with mouse dependency for most canvas interactions; users can mitigate this via customizable resources in .Xdefaults for key bindings.[56][60][14][63]Integration with Document Preparation Tools
Xfig integrates with LaTeX document preparation workflows primarily through the fig2dev utility, which converts native Fig files into formats suitable for inclusion in technical publications.[29] One standard approach involves exporting diagrams as Encapsulated PostScript (EPS) files, which can then be embedded using the\includegraphics command from the graphicx package, ensuring high-resolution rendering in compiled PDFs.[64] For deeper integration, Xfig supports direct export to PSTricks, generating LaTeX code enclosed in \begin{pspicture} ... \end{pspicture} environments that allows figures to be typeset alongside document text with uniform fonts and precise positioning.[51] Similarly, export to PGF/TikZ produces editable TikZ code that can be inserted inline, supporting complex diagrams with native LaTeX math and styling capabilities.[29]
To optimize compatibility, Xfig provides a dedicated LaTeX text mode where users input special-flagged text objects containing LaTeX markup, such as mathematical expressions delimited by $...$, which fig2dev processes into properly formatted output during export.[65] This mode requires launching Xfig with the -specialtext flag or enabling it via preferences to recognize and handle LaTeX commands accurately.[66] Scaling considerations are crucial for consistent rendering; Xfig's internal units default to 1/1200 inch per unit, so figures should be sized accordingly in LaTeX to match document dimensions without distortion.[67]
Integration extends to other markup-based tools, such as groff and troff, where Xfig exports to TPIC format for use with pic preprocessor macros, enabling diagrams in traditional Unix typesetting environments.[68] For web-oriented documents, SVG export via fig2dev facilitates scalable embedding in HTML, preserving vector quality across devices.[69] The command-line nature of fig2dev supports batch scripting for automated workflows, such as generating multiple figures from Fig templates in report compilation pipelines.[51]
In scientific publishing, Xfig excels for vector-based illustrations like circuit diagrams in IEEE-formatted papers or theses, where export to EPS or TikZ ensures scalability and editability superior to raster alternatives, avoiding pixelation upon resizing or reprinting.[70] This approach maintains professional quality in peer-reviewed journals, leveraging Xfig's precision for technical accuracy.[66]