[gl2ps] Font Changes

Christophe Geuzaine geuzaine at acm.caltech.edu
Fri Jul 16 01:35:33 CEST 2004


Shai Ayal wrote:

> Hi
> 
> first, thank you for the alignment code. Now OctPlot's hardcopy is 
> in-par with it's screen output (not very nice, but it works :) ).
> 
> My future plans are to implement TeX like support. This means the I will 
> have to change font/size in the middle of a string. Do you have any 
> ideas on how this could be implemented in gl2ps? I understand that 
> currently gl2ps has no knowledge of the font metrics, all is done by the 
> ps/pdf/tex parser. Can you think of any way to implement this (i.e. 
> gl2psText returning the new raster position?).
> 
> The easiest way I can think of (easy for gl3ps) is add a 
> gl2psRawPS(char*) function which will allow you to emit raw postscript 
> at the current raster position. This approach has a major drawback: It 
> will break the abstraction of gl2ps in respect to which back-end is used.
> 
> I am eager to hear your thoughts on this
> 

It's a complicated issue... The main question is: do we only want to 
reproduce what's on screen, or do we want to have additional features in 
the printed output?

In the first case, I like the approach followed by the folks that
develop FLTK (http://www.fltk.org). They have routines that compute the 
font metrics on all platforms (X11, Win32 and Carbon) and you can use 
that to position the text accurately in the OpenGL window. All gl2ps has 
to do is use a font that is "close enough", and you're all set--you 
don't even need the new "align" flags... (I use this approach in my 
code: http://geuz.org/gmsh/.)

In the second case, you are right: there is no easy way to abstract the 
text handling anymore (unless we parse some higher level markup 
language!), and we need some mechanism to let users manipulate the 
underlying output stream directly. This is in fact what we already do 
for LaTeX output, and what a gl2psRawPS(char*) function would do for 
PostScript. Not sure if we need a new interface for this, though: we 
could for example just use a special font name ("RawPostScript"?) in 
gl2psText()...

Best,

Christophe

-- 
Christophe Geuzaine
Applied and Computational Mathematics, Caltech
geuzaine at acm.caltech.edu - http://geuz.org