Hewlett-Packard Graphics Language 2 plug-in


HP-GL/2 is a vector graphics language used in a large number of Hewlett Packard products.  It is used in a large number of plotter products and forms a major part of PCL5, a printer control language used in HPs LaserJet family of products.

Last updated: 2 Mar 2001

This page will be updated with more useful information soon (we hope), but until then...

HP-GL/2 was a popular vector graphics format for a large number of years.  The graphics model is pretty much superseded these days, but it is a small, simple and effective way to represent vector images.  The web committees have been standardising SVG (scalable vector graphics) for quite a while now, and that promises to wipe out most existing vector graphics formats once it's released.  SVG however is so complex that the implementation task is huge, and although it is supposed to be applicable to portable devices, the size of the command set means you will need a lot of ROM to fit it in anything small.  HP-GL/2 on the other hand is a small simple vector language that would be better suited to portable devices.

Flash from Macromedia is another really nice vector language that is proprietary, but has a lot of nice implementation features.  It too will be superseded by SVG, but until then it's probably the best thing out there.

So why bother with another implementation?  Well, HP-GL/2 has been around for ages and there are a huge number of real products out there which use it, as well as a lot of design software that produces HP-GL/2 files.  The plug-in will let you view such files, or author compact vector graphics by hand for viewing.  There are a few implementations out on the web, but few with source.  The only one we've found is an HP-GL to other graphics format converter, and misses out on some important language features such as all polygon clip and fill commands.  Our implementation is pure HP-GL/2 - i.e. no decayed HP-GL commands (like XT and YT for example) that were dropped by HP.

If you don't care about the software and just want to load a plug-in to view HP-GL/2 files, then just download this HP-GL/2 plug in and place it in the Netscape\program\Plugins folder wherever you have installed Netscape.  Restart the browser and you should be able to see the cool  HP-GL/2 tiger. This tiger is of course a standard Adobe Illustrator drawing that is used to show Postscript off and the SVG people use it to show some of their implementations as well.  The version here is a bit wrong cause it was hand edited with errors into HP-GL/2, and so some mistakes were made, but it serves to illustrate the point.  By the way, the HP-GL/2 version is smaller than SVG, and if the HP-GL/2 command PE was implemented and used, it would be smaller again.  So what, you say?  Well, it just shows that for simple vector stuff, HP-GL/2 is just as useful as many other excessively complicated languages.

Anyway, out of the goodness of our hearts, we've chucked the source into the public domain without that restrictive GNU licence.  We only ask that if you add to or fix bugs then please send the changes back to us by mailing hpgl2@ishtek.com if you wish.  No one is under obligation to do so, but we just ask that as a small favour for giving you this stuff in the first place.  So anyway, the source code is  here  It contains a few directories which normally get unpacked into the Netscape plug-in SDK main directory.

So, to unpack, first grab the Netscape SDK and put it on your disk somewhere.  Then unpack the gl2-0_1.zip file inside the top level.  You will end up with a directory called 'gl-plugin'.  In there, there are two Microsoft Visual Studio 6 workspaces in the directory 'Viewer' and 'Winproject'.  The workspace in 'Winproject' builds the Netscape plug-in.  The workspace in 'Viewer' builds a Windows program which can be used stand-alone to view HP-GL/2 files (and us useful when debugging).
 

Why only Windows?

No reason.  Time is the thing.  Free software is done in free time, so no other platforms have been done.  There is one file 'windows.c' which contains the platform specific code.  All functions in there are prefixed by 'r_' which stands for render.  If you want to do an X11 port, then just create an X11.c, implement the functions in there and send it to everyone else to use - we're happy to place the binary here to download if some kind soul feels like doing that.

Why no Internet Explorer?

Same reason as why only Windows - time. This would have been done by now if there was any easy way to work out how to write an Explorer plug-in by reading the MSDN.  I tried, but it just took too long and I gave up.  If anyone out there has any idea how to write an IE plug-in, then please tell us or even better, do the port.  Man that MSDN is a black hole...

What's Missing?

Lots.  The hardest bits are done - the beziers are iterative rather than recursive, the line clipper is fast but lacks non-zero winding.  Most obvious deficiencies are dashed lines, no polyline encoded command (seldom used in drivers but important nonetheless), and the rest of the arc chars.  All stick chars are there for one character set and the implementation is there for the proportional arc characters but the data is still missing for most of those characters.

The file 'notes' in the base directory contains scribbled missing bits and pieces.  If you want another cool HP-GL/2 viewer (binary only) there used to be one at  http://www.splot.com.

This is really a work in progress and it needs a few man-weeks to finish it off to acceptable level.  Hopefully someone will find this useful for something.  Enjoy.