Introduction
HP-GL, the Hewlett-Packard Graphics Language, is the command language of HP’s pen
plotters. A plot file holds the commands that move a pen across the paper, so it
describes a drawing as lines rather than pixels. CAD programs still write HP-GL and its
successor HP-GL/2 for large-format plotters and printers, and for vinyl and laser
cutters, usually with the extension .plt, .hpgl or
.hgl.
The extension .plt is also used by other programs, for example for
AutoCAD plot files and gnuplot scripts.
Structure
The syntax, units and PE
encoding and the full instruction
set have their own pages.
An HP-GL file is plain text. Each command is two letters followed by optional
numbers separated by commas, and ended by a semicolon. IN initialises the
plotter, SP selects a pen, PU and PD lift and
lower the pen while moving to the points given, and PA sets absolute
coordinates. Coordinates are in plotter units of 0.025 mm, 40 to the millimetre.
IN;SP1;
PU0,0;PD4000,0,4000,4000,0,4000,0,0;
PU;SP0;
Divergence from spec
Where the programs that read HP-GL files differ from HP’s HP-GL/2 and HP RTL Reference Guide, from their source files (read 2026-11-27, saved in the project’s research folder):
- GhostPCL (GhostPDL
pcl/pcl/pg*.c, theHPGL_COMMANDtables): the guide has 89 instructions; GhostPCL has no entry forCT DC DP MG MT NR OD OE OH OI OP OS QL ST VS, so it never answersOEand posts no error numbers (the guide’s error 7 does not exist there), and ignores chord tolerance mode.PSis accepted only in its HP RTL personality, and the parameters ofBPare ignored (“BP command value pair is currently ignored”,pgconfig.c). When the guide says that entering lost mode raises the pen, GhostPCL’shpgl_set_lost_modehas that code switched off; it does skip the instructions that need lost mode cleared. The viewer follows the guide here. - Inkscape (extensions
hpgl_parser.py,hpgl_input_sm.py,hpgl2_input.py): the HP-GL import reads only the configuration (CO IN IP IR IW RO SC), vector, polygon and line and fill instructions (PA PR PD PU CI AA AR AT BR BZ PE PM EA ER RA RR FP EP EW WG SP LA LT PW FT TR UL WU) and keeps any other two-letter instruction as unknown, so labels, fonts, palettes and plot size are not imported; its default frame is 8 by 10 inches at 1016 plotter units per inch, the same as the 8128 by 10160 units this page gives. The viewer’s line geometry for Inkscape’s own test filetest.hpglequals Inkscape’s import point for point. Inkscape’s HP-GL export writesFSandVSafterIN;PU;SP1;. It fills every polygon solid whateverFTsays (hpgl_input_sm.py: “Currently, only solid fill is supported”). - Where they differ on a detail, the pages say so at the place: labels (GhostPCL’s stick font cell, typeface 49 and original HP-GL labels from the 7596A firmware), fills (
FTrange errors and option 2 ofFT 11, GhostPCL’s zero spacing rule) and HP-GL/2 inside PCL (PSandBP). - Labels of original HP-GL and typeface 49: the guide, the programs and the firmware. The guide describes the HP-GL drafting font (typeface 49, character set 99) only in words (“the letter B and the digit 8 have a wider bottom than top part…”) and the HP 7580B manual only lists its characters; GhostPCL has no data for it and draws labels with its stick and arc fonts whatever the dialect; Inkscape imports no labels at all. The viewer draws typeface 49, and every label in a file with no HP-GL/2-only instruction (no
PE PW RF UL TR SV NP PC BP WU BR BZ SD AD LA MC MT CO IR PG AT RT AC CF DV FI FN LM SB TD PP MG QL ST CR, the instructions of the HP-GL/2 guide that neither the 7475A nor the 7580B manual has under an “Instruction, XX” heading;RP,WG,PS,CC,SGandDLare in those manuals and do not count; a file of instructions both dialects share is read as original HP-GL, which is a rule of thumb: a plainIN;SP1;PU;PA;PD;LBfile from an HP-GL/2 plotter gets the plotter font of the 7596A, not the stick font, because nothing in it tells the two apart), from the font ROMs of the HP 7596A DraftPro firmware (Licences): font 7 is typeface 49 (its character set matches the DraftPro chart cell for cell at 35 cent, 92 o-slash, 123 micro, 124 degree and 125 infinity, and B and 8 are wider at the bottom, as the 7580B manual says); font 1 is the plotter’s standard font, whose character-set programs (twenty in the ROM) give each set 0 to 7, 9 and 30 to 39 its glyphs, agreeing with the DraftPro chart on 1741 readable cells and differing on 44, all of them cells the chart scan shows too damaged to read, blank cells, or the twentieth program, a French variant with a blank grave accent that no set number selects (not used); set 8 is the katakana font 2; fonts 4 and 6 are further katakana variants and fonts 3 and 5 arc fonts, none of which a character set selects, so they are not drawn. One reading is a choice: the accent glyphs of set 1 to 4 (the DraftPro chart shades them: “automatically backspaced one character before it is drawn”) are stored in the ROM with offsets that already lie a cell to the left of the origin, so the viewer draws them where the ROM stores them and does not advance the pen, which puts the accent over the previous character; the alternative reading, to centre each accent on its cell by the centre recorded in the glyph header, would move it by up to a cell and is not drawn. The ROM glyphs were read statically (never run); no emulator output was compared, so their stroke positions rest on the decoded data and the chart. - Checked against GhostPDL’s output (GhostPDL 10.09.0 built from source and run on the same HP-GL, 2026-11-27, the cases in the project’s
scripts/hpgl/oracle.mjs): rectangles, solid, hatch and cross-hatch fills, line types 1, 2, 4 and user-defined line types, and stick-font labels at several sizes, weights, slants, directions at equal width and height scales, and in Roman-8 draw pixel for pixel the same at 150 dpi. Three differences the guide does not decide are followed as GhostPDL does them, and the viewer now draws them pixel for pixel the same (cases label_dir, label_arc_p, label_lo, label_lo2, label_lo9, label_lo13, label_lo18, label_lo_rot, label_lo_slant, label_slant): (1) a label turned byDIis rotated by the angle rounded to whole degrees and then scaled by 1.875 × theSIwidth and 1.5 × theSIheight, so with unequal scales it is sheared and its advance is stretched (pglabel.clines 805 to 850; the guide says nothing about unequal scales); (2) a space in the proportional arc font (typeface 50 with spacing 1, or typeface 48 with spacing 1) advances by 66.67 centipoints × 12 per ten × theSD/ADheight in points, about 9.41 plotter units per point, whatever theSIwidth is (pglabel.clines 887 to 911), not by the width table; (3)LOfor the stick and fixed arc fonts with anSIsize on the normal text path puts the origin at (characters ×SIwidth) across and at 1.5 × height × 1.28 (stick) or 1.2 (arc) ÷ 1.6 (÷ 1.4 more for the stick font) up, with 0.33 of that height as the offset forLO11 to 19, rotated and slanted by the label’s direction and slant (pglabel.clines 1056 to 1187), whereas the drawn cells are 1.25 × theSIwidth wide, so a centred label is not centred on its ink. Where the two still differ, the viewer keeps the guide and the difference is: GhostPDL draws typeface 50 with fixed spacing with the stick shapes, where the guide has a fixed arc font; and itsFT 10shading puts ink on 24.9%, 43.7% and 65.7% of a solid test rectangle at 25, 50 and 75 percent where the manual’s eight patterns, which the viewer draws, give 24.9%, 50.0% and 75.1%, and its PCL cross-hatchFT 21lines (pattern 1) are about 4 dots thick and 32 dots (0.107 inch) apart at 300 dpi where the manual’s figure has 2 dots and 1/16 inch, which the viewer draws. GhostPDL’s tiles are the 16 by 16 dot arrays ofpcl/pcl/pcbiptrn.c(bi_data_array); the project’sscripts/hpgl/compare-pcl-patterns.mjsshows that none of the seven shading tiles equals the viewer’s tile at any shift (the dots sit in other places, in the same density bands), and the manual’s figure remains the specification the viewer follows, so these two fills are a standing divergence, not a defect. (The rectangle, solid fill,FT 3andFT 4hatch and the line types were compared with a 3 by 3 pixel tolerance, so thin lines and dither patterns count as equal when they land within a pixel.) The stick stroke width uses the guide’s “device-dependent” formula in the form GhostPDL uses: (0.06 + 0.01 × weight, or 0.005 for a negative weight) × the smaller of 1.875 × theSIwidth and 1.5 × theSIheight, with round caps and joins; one stick cell is 1.25 times theSIwidth. Typeface 48 with proportional spacing is the arc font (a comment inpglabel.ccalls this the prescription).
Not described
HP-GL/2 is documented in HP’s PCL 5 Printer Language Technical Reference Manual, Part II and the PCL 5 Color Technical Reference Manual,
which the pages follow; the line types, labels and
HP-GL/2 inside PCL pages give the details of those parts. The viewer reads these files in the
explorer: it explains every instruction and draws the plot. The plotter-only instructions (BP CT DL EC FR MG MT NR OE OH OI OP OS PS QL ST VS DC DP OD) were read in HP’s
HP-GL/2 and HP RTL Reference Guide (third edition, a public mirror at ftp.icm.edu.pl): the viewer explains each with its parameter ranges, applies CT (the deviation distance) and PS
(the plot size), says per instruction that the rest (VS, QL, ST, MT, NR, EC, MG, OH, OI, OP, OS, DC, DP, OD) do not change the picture, and works out the error number each
OE would answer: 1 unrecognised instruction, 2 wrong number of parameters, 3 out-of-range parameter, as the manual defines them. The eight shading patterns (FT 10, SV 1) and the six
cross-hatch patterns (FT 21) are HP’s own, read from the figures of the PCL 5 manual. A plot with no PCL job around it takes the manual’s default picture frame: “the current top and
bottom margins and the left and right edges of the logical page” of the default Letter page, 2400 by 3000 dots at 300 dpi, which is 8128 by 10160 plotter units, P1 at 0,0 and P2 at 8128,10160.
Known, not yet covered
- Reference: the original HP-GL is described from the HP 7475A and the HP 7580B/7585B/7586B manuals only (instructions page): the 7580A/7585A and 7470A operator’s manuals (archive.org text) and the HP DraftPro Programmer’s Reference were read as well, but only the DraftPro one gives instruction syntax beyond those two manuals (
APvalues 8 and 16); the 7550A and DraftMaster programming manuals and the 7470A programming manual have not been found, so an instruction only they define is not described, and the chart of the original HP-GL character sets is the DraftPro one (sets 0 to 9, 30 to 39 and 99, Appendix B, which the viewer reads: see the Viewer item); the 7475A and 7580B charts, the sets 10 to 29 and 40 to 59 of the 7580B and the Kanji sets 100 and 101 are not reproduced; the PJL commands HP RTL devices take are in the PJL page; the HP RTL raster commands beyond the cursor move, negative motion and context switching are in the PCL pages’ command table (HP RTL). - Viewer: error 7 (buffer overflow) is never raised: the polygon and downloaded-character buffer sizes are the device’s (the guide gives only “at least 512 vertices” and “94 characters of at least 20 points”); labels of HP-GL/2 files are drawn with the stick and arc fonts of GhostPDL’s data (Licences) and labels of original HP-GL files and typeface 49 with the 7596A firmware fonts (see Divergence from spec); in an HP-GL/2 file the original HP-GL character-set instructions
CA CS DS IVare applied from the DraftPro chart (sets 0, 6, 7, 9, 30 to 39 and the readable codes of 2, 3, 4 and 99; the glyph is the Roman-8 shape the chart shows; math symbols, katakana, arrows and the Kanji sets have no glyph in those fonts and draw as blank cells; set 1, codes 94 to 96 and 123 to 126 of sets 2 to 4 draw as ASCII), in an original HP-GL file from the firmware’s own character-set programs, which have every glyph;CM(modes 0 to 3, the slots and their shifts, single shifts 142 and 143, and the fallback box; see labels) is modelled for both dialects, and symbol sets other than ASCII and Roman-8 are not applied in HP-GL/2 (a code is drawn as the Roman-8 shape of the same number); the Kanji sets 100 and 101 are not drawn (searched 2026-11-27: the 7596A ROM has no Kanji font, GhostPDL and Inkscape have no HP-GL Kanji data, the HP-GL/2 guide and the DraftPro reference give no glyphs, and the Canon HP-GL emulation manual only names JIS Kanji-1 and 2); bitmap and 16-bit fonts are explained but not drawn differently (except the downloadable set, symbol set 531, which draws the characters ofDL); merge control (MC) combines the mark with the page as in GhostPCL (see the next sentence) and pixel placement has no effect on the picture; BP acts as IN and FR draws one frame (GhostPDL does the same: pgconfig.c runs IN after parsing BP’s command and value pairs, which it ignores, and FR as PG); in GhostPDL merge control (MC) sets the one logical operation of the page device (pglfill.c: mode 0 is 252, mode 1 takes the operation, 168 when none is given, a mode other than 0 and 1 or an operation above 255 is a range error), and for pen lines and hatch lineshpgl_ropinpgdraw.clets only 0, 160, 170, 240, 250 and 255 through and uses 252 for the others, while characters and polygon fills take any value; the viewer does the same, against a white page or the PCL page. Pixel placement (PP) changes the rounding of pixel centres, which a vector viewer does not have, so it is explained, not drawn.
Round 3 added: the error table of each of the 37 instructions that has one, errors 6 and 7 with “lost” mode (position overflow) implemented, the HP RTL cursor, negative motion and context rules, and downloaded characters drawn on the 32-unit grid. In lost mode inside a polygon, PM2 clears it and PM1 does not (“Lost Mode (continued)” in the guide).
Error 7 (buffer overflow) is device-dependent: the guide promises only a polygon buffer of “at least 512 vertices” (OE and PM pages) and room for 94 downloaded characters of at least 20 points, so the viewer does not post it, and no limit above those minima is documented. What the other manuals say: the HP 7475A Interfacing and Programming Manual (archive.org text, read) lists error 4 and error 7 as “Not used”, error 6 as “Position overflow”, and treats a parameter below −32 768 or above 32 767 as error 3 with the instruction ignored (SC and PA pages); its input-buffer overflow is a device error (extended error code 16, answered by ESC . E; framing, parity and overrun errors are code 15), not an HP-GL error number; its error 8 is “Vector received while pinch wheels raised”. The 7550A (07550-90001) and DraftMaster programming manuals could not be found in a second search (2026-11-27: archive.org, bitsavers, hpmuseum.org forum thread 1947 only names the part number; netlib.org/apollo/hp7550 is a print-server source that cites the manual without reproducing it), so what they say about errors and the lost-mode limit is Unknown. The guide’s list of instructions was compared with the viewer’s instruction table: all of them are present.
Unknown
- Reference: where “lost” mode begins: the guide says only that scaled parameters can exceed the device’s internal range (7200 or 9600 units per inch) and gives no limit, so the viewer uses its minimum integer range of 223 plotter units; and the guide prints the error number of the
LAtable as 0 where its text says error 3. - Viewer: the physical sheet of a plot sent straight to a plotter is not in the file; the viewer fits the picture to the drawing, and the sizes of the shading and cross-hatch patterns are taken as one dot of the figure = one 300 dpi dot (the 1/16 inch hatch spacing was measured from the figure).
Links
Software
Licences
Everything on this page and the instruction pages is written for this site from the sources listed on them, with two exceptions: the data of the fonts below.
- Stick and arc font data (GNU Affero General Public License, version 3 or later). The explorer draws labels with the HP-GL/2 stick and arc fonts. Their vector data are the numbers of
pcl/pcl/pgfdata.cin GhostPDL 10.09.0 (Copyright © 2001–2026 Artifex Software, Inc.), re-encoded as text without any glyph being changed, in the fileexplorer/formats/shared/hpgl2-stickarc-data.js. GhostPDL’s licence file says that the files in itspcldirectory are part of GPL Ghostscript, which is distributed under the GNU Affero General Public License version 3 or, at the user’s option, any later version (LICENSE, doc/COPYING). The data file carries that notice at its top. The code that reads the data (hpgl2-fonts.js) and the rest of the viewer are not taken from GhostPDL. - What the AGPL asks of anyone who reuses that data file (read in the licence text, version 3): pass on the copyright notice, the notices that the licence applies and that there is no warranty, and a copy of the licence (section 4); if the file is changed, state that it was changed and when, say that it is released under the AGPL, and license the whole work that contains it as a whole under the AGPL (section 5); and if a modified version is offered to users over a network, offer those users its complete source from a network server at no charge (section 13). The header of the GhostPDL file itself also points to Artifex’s licensing information (artifex.com) for other terms; this site relies on the AGPL only.
- Plotter font data (Hewlett-Packard firmware). Labels of original HP-GL and typeface 49 are drawn with the vector fonts and character-set programs of the HP 7596A DraftPro firmware: the ROM images 07595-18095 (U28) and 07595-18096 (U37), from the public copy at bitsavers.org/pdf/hp/plotter/7596A/HP7596A_firmware/. The two images are the two byte lanes of a 68000 ROM; merged they are 128 KB. The ROM was only read, never run. The shapes in
explorer/formats/shared/hpgl-rom-font.jswere decoded from font 1 (index at 0x18c88, data at 0x18e7c, 250 glyphs), font 2 (0x1a296 and 0x1a316, 63 glyphs), font 7 (0x1f688 and 0x1f746, 94 glyphs) and the character-set programs (table at 0x189da) withscripts/hpgl/rom-export.mjs, only as a table of shapes; the copyright of the firmware is Hewlett-Packard’s, and the table is kept as a reference for the shapes the viewer draws. - Read, not copied: GhostPDL’s other
pg*.cfiles, Inkscape’shpgl_*.pyextension files (GPL version 2 or later) and the HP manuals were read for this reference; no text or code of them is on the site. The sample files from Inkscape’s test folder are in the project’s sample folder only.