HP-GL/2 is a kernel of five groups that every HP-GL/2 device supports, and six
extensions that some devices add. Syntax is as in HP’s reference: square brackets
mark optional parameters, and coordinates are in current units (plotter units, or user
units after SC). How instructions are written and separated is on the
syntax page.
Kernel: configuration and status
| Syntax | Name | Meaning and values |
|---|---|---|
CO["text"] | Comment | A comment, ignored. |
DF | Default Values | Sets most programmable features to their defaults. |
IN[n] | Initialize | Sets all programmable features to their defaults (factory-set conditions). |
IP[p1x,p1y[,p2x,p2y]] | Input P1 and P2 | Places the scaling points, in plotter units. |
IR[p1x,p1y[,p2x,p2y]] | Input Relative P1 and P2 | Places them as percentages of the hard-clip limits (of the picture frame in PCL). |
IW[xll,yll,xur,yur] | Input Window | Sets the soft-clip window. |
PG[n]; | Advance Full Page | Ends the page or plot. |
RO[angle] | Rotate Coordinate System | 0, 90, 180 or 270 degrees. |
RP[n]; | Replot | Prints the last plot again n times. |
SC[xmin,xmax,ymin,ymax[,type[,left,bottom]]], or SCxmin,xfactor,ymin,yfactor,2 | Scale | Maps P1 and P2 to user units. Type 0 anisotropic (default), 1 isotropic (with left and bottom placement, 0–100%, default 50%), 2 point factor. |
Kernel: vector
| Syntax | Name | Meaning |
|---|---|---|
AAxcenter,ycenter,sweep_angle[,chord_angle] | Arc Absolute | An arc round an absolute centre. |
ARxincr,yincr,sweep_angle[,chord_angle] | Arc Relative | The same with a relative centre. |
ATxinter,yinter,xend,yend[,chord_angle] | Absolute Arc Three Point | An arc through an intermediate point to an end point. |
RTxincrinter,yincrinter,xincrend,yincrend[,chord_angle] | Relative Arc Three Point | The same, relative. |
CIradius[,chord_angle] | Circle | A circle round the current point; the pen goes down for it automatically. |
PA[x,y[,...]] | Plot Absolute | Absolute moves; sets absolute mode. |
PR[x,y[,...]] | Plot Relative | Relative moves; sets relative mode. |
PD[x,y[,...]] | Pen Down | Lowers the pen and draws to the points. |
PU[x,y[,...]] | Pen Up | Lifts the pen and moves. |
PE[flag][value/x,y]...; | Polyline Encoded | Compact coordinates: see PE. |
The chord angle (0–360°, usually 5° by default) is the angle of the straight segments
curves are drawn with; after CT1 it is a deviation distance instead.
Kernel: polygon
| Syntax | Name | Meaning and values |
|---|---|---|
PM[polygon_definition] | Polygon Mode | 0 enter polygon mode (clear the buffer, default), 1 close the current subpolygon, 2 close and exit. |
EP | Edge Polygon | Outlines the polygon in the buffer. |
FP[fill_method] | Fill Polygon | 0 even/odd (default), 1 non-zero winding. |
EAx,y, ERx,y | Edge Rectangle Absolute, Relative | Outlines a rectangle from the current point to a corner. |
RAx,y, RRx,y | Fill Rectangle Absolute, Relative | Fills a rectangle. |
EWradius,start_angle,sweep_angle[,chord_angle] | Edge Wedge | Outlines a pie slice. |
WGradius,start_angle,sweep_angle[,chord_angle] | Fill Wedge | Fills a pie slice. |
Kernel: line and fill attributes
| Syntax | Name | Meaning and values |
|---|---|---|
AC[x,y] | Anchor Corner | Where fill patterns start. |
FT[fill_type[,option1[,option2]]] | Fill Type | 1 solid bidirectional (default), 2 solid unidirectional, 3 hatched (spacing, angle), 4 cross-hatched (spacing, angle), 10 shading (level %), 11 user-defined from RF (index, pen flag), 21 predefined PCL or HP RTL pattern (type), 22 PCL or HP RTL user-defined pattern (ID). |
LA[kind,value[,kind,value[,kind,value]]] | Line Attributes | Kind 1 line ends: 1 butt (default), 2 square, 3 triangular, 4 round. Kind 2 joins: 1 mitred (default), 2 mitred/bevelled, 3 triangular, 4 round, 5 bevelled, 6 none. Kind 3 mitre limit, 1–32767 (default 5). |
LTline_type[,pattern_length[,mode]] | Line Type | Types −8 to 8 (positive fixed, negative adaptive); mode 0 relative (default, % of the P1–P2 diagonal) or 1 absolute (millimetres). |
PW[width[,pen]] | Pen Width | Line width, in the unit set by WU. |
WU[type] | Pen Width Unit Selection | 0 metric, millimetres (default); 1 relative, % of the P1–P2 diagonal. |
RF[index[,width,height,pen_number[,pen_number...]]] | Raster Fill Definition | Defines a user fill pattern, pixel by pixel. |
SM[character[character2]] | Symbol Mode | Draws the character at every plotted point. |
SP[pen_number] | Select Pen | Selects a pen; 0 (the default) is no pen, and nothing is drawn until a pen is selected. |
UL[index[,gap1,...gapn]] | User-Defined Line Type | Defines a dash pattern for a line type. |
Kernel: character
| Syntax | Name | Meaning and values |
|---|---|---|
LBtext...text + terminator | Label | Draws text, ended by the label terminator. |
DT[label_terminator[,mode]]; | Define Label Terminator | The character straight after DT becomes the terminator (default ETX, code 3; not NUL, LF or ESC). DT; restores ETX, non-printing. |
LO[position] | Label Origin | 1–9, 11–19 or 21: 1–3 and 11–13 left-justified, 4–6 and 14–16 centred, 7–9 and 17–19 right-justified; 11–19 offset the label from the pen position; 21 places it where PCL would. |
CP[spaces,lines] | Character Plot | Moves by character cells. |
DI[run,rise], DR[run,rise] | Absolute, Relative Direction | Label direction; relative to P1–P2 for DR. |
DV[path[,line]] | Define Variable Text Path | Path 0 right (default), 1 down, 2 left, 3 up; line 0 normal line feed (−90° to the path, default) or 1 (line feeds the other way). |
ES[width[,height]] | Extra Space | Extra space between characters and lines. |
SI[width,height], SR[width,height] | Absolute, Relative Character Size | In centimetres, or as % of P1–P2. |
SL[tangent_of_angle] | Character Slant | Slant. |
SD[kind,value...], AD[kind,value...] | Standard, Alternate Font Definition | Kinds 1–7: 1 character set (default 277, Roman-8), 2 spacing (0 fixed, 1 proportional), 3 pitch, 4 height, 5 posture, 6 stroke weight, 7 typeface. |
SS, SA | Select Standard, Alternate Font | Switch between the two fonts. |
CF[fill_mode[,edge_pen]] | Character Fill Mode | 0 solid fill (default), 1 edge only, 2 fill with the current fill type, 3 fill and edge. |
TD[mode] | Transparent Data | 0 normal: control codes act (default); 1 transparent: they print. |
Technical Graphics extension
| Syntax | Name | Meaning and values |
|---|---|---|
BP[kind,value...] | Begin Plot | Starts a plot (as PG plus IN). Kinds: 1 picture name (quoted string), 2 number of copies, 3 file disposition (0 keep for replot, 1 discard), 4 render last plot if unfinished (0 no, 1 yes), 5 autorotation (0 enable). |
CT[mode] | Chord Tolerance Mode | 0 chord angle in degrees (default), 1 deviation distance. |
DLcharacter_number[,up],X,Y... | Download Character | Defines a character from strokes. |
EC[n] | Enable Cutter | Turns the automatic cutter on (no parameter) or off. |
FR | Frame Advance | Advances the media to the next frame. |
MC[mode[,opcode]] | Merge Control | 0 off (opcode 252), 1 on (opcode 168 default): a raster operation 0–255 when graphics overlap. Also in Advanced Drawing. |
MG[message] | Message | Text on the front panel. |
MT[type] | Media Type | 0 paper, 1 transparency film, 2 vellum, 3 polyester film, 4 translucent paper, 5 special paper, 6 glossy paper. Picture header only. |
NR[timeout] | Not Ready | Takes the device off line. |
OE;, OH;, OI;, OP;, OS; | Output Error, Hard-Clip Limits, Identification, P1 and P2, Status | Report to the computer; must end with a semicolon. |
PS[length[,width]] | Plot Size | Sets the hard-clip limits. Picture header only. |
QL[quality_level] | Quality Level | 0–100. Picture header only. |
ST[switches] | Sort | −1, 0, or a sum of 1, 2 and 4: which kinds of sorting the device may do. |
VS[pen_velocity[,pen_number]] | Velocity Select | Pen speed. |
Palette extension
| Syntax | Name | Meaning and values |
|---|---|---|
NP[n] | Number of Pens | The palette size. |
PC[pen,primary1,primary2,primary3] | Pen Color Assignment | Sets a pen’s colour. |
CR[black_p1,white_p1,black_p2,white_p2,black_p3,white_p3] | Set Color Range for Relative Color Data | Each −32768 to 32767; defaults 0 (black) and 255 (white). |
SV[screen_type[,option1[,option2]]] | Screened Vectors | 0 no screening (default), 1 shading (0–100%), 2 HP-GL/2 user-defined raster fill (RF), 21 PCL or HP RTL cross-hatch 1–6, 22 PCL or HP RTL user-defined pattern. |
TR[n] | Transparency Mode | 0 off: white areas are opaque; 1 on (default): white areas are transparent. |
Dual-Context extension
| Syntax | Name | Meaning |
|---|---|---|
Esc%#A | Enter PCL (or HP RTL) Mode | 0 the PCL cursor goes back to its previous position, 1 to the HP-GL/2 pen position. |
Esc%#B | Enter HP-GL/2 Mode | From PCL: 0 the pen starts at its previous HP-GL/2 position, 1 at the PCL cursor. |
Esc E | Reset | Restores device defaults. |
FI font_ID, FN font_ID | Primary, Secondary Font Selection by ID | Use a PCL font by its ID. |
SB[n] | Scalable or Bitmap Fonts | 0 scalable fonts only (default), 1 bitmap fonts allowed. Also in Advanced Text. |
Digitising, Advanced Drawing and Advanced Text extensions
| Syntax | Name | Meaning and values |
|---|---|---|
DC, DP, OD; | Digitize Clear, Digitize Point, Output Digitized Point and Pen Status | Digitising: leave and enter digitise mode, and report the point. |
BZx1,y1,x2,y2,x3,y3..., BR... | Bezier Absolute, Relative | Cubic Bézier curves: two control points and an end point each. Advanced Drawing. |
PP[mode] | Pixel Placement | 0 grid intersection (default), 1 grid centred. Advanced Drawing. |
LM mode[,row_number] | Label Mode | 0 8-bit, one byte per character (default); 1 16-bit, two bytes per character. Advanced Text. |
Older HP-GL
The original HP-GL of HP’s pen plotters, before HP-GL/2, had further instructions that varied from model to model, documented only in each plotter’s programming manual; they are not covered here.
Sources
- HP, The HP-GL/2 and HP RTL Reference Guide (third edition, 1997) – the kernel and extension summaries and each instruction’s reference page