Banner

HPDF 1.1 teaser

Posted by alpheccar - Sep 08 2007 at 12:37 CEST

The text operators of the release 1.0 of my Haskell PDF library are very low level. You have access to most of the PDF text operators but it means you can just specify where to put a line of text. So, it is difficult to do more than displaying some labels on a chart. The styles are also very limited : you can use bold and italic if it is supported by the standard PDF fonts.

For the 1.1 release of my library, I have decided to improve this and write something cool.

First, I have implemented the TeX line breaking algorithm with glues and penalties. Contrary to the real TeX algorithm, there is no looseness parameter and the hyphenation algorithm is not implemented (will be for another release).

Second, for the style, I have concluded that a style has to be a triple of Haskell functions in the Draw monad. So, text style can be anything !

Now, I am working on the next step : implementing the vertical mode to split a text into pages. And, I am thinking about cross reference (perhaps I'll use something similar to the galley idea from Lout).

Here is a screen shot:

image

Currently, a style is a type of class:

Haskell Code by HsColour
class Style a where
    sentenceStyle :: a -> Rectangle -> Draw ()
    wordStyle :: a -> Maybe (Rectangle -> StyleFunction -> Draw b -> Draw ())
    textStyle :: a -> TextStyle
    styleCode :: a -> Int
    updateStyle :: a -> a
    wordTransform :: a -> [B] -> [B]
    styleHeight :: a -> PDFFloat
    styleDescent :: a -> PDFFloat

StyleFunction is:

Haskell Code by HsColour
data StyleFunction = DrawWord
                   | DrawGlue
                   deriving(Eq)

and TextStyle is:

Haskell Code by HsColour
data TextStyle = TextStyle { textFont :: !PDFFont
                           , textStrokeColor :: !Color
                           , textFillColor :: !Color
                           , textMode :: !TextMode
                           , penWidth :: !PDFFloat
                           , scaleSpace :: !PDFFloat
                           , scaleDilatation :: !PDFFloat
                           , scaleCompression :: !PDFFloat
                           }
                           deriving(Eq)

Be patient for the 1.1 release. I have lot of work to do on it.

Tags |

Comments

Add a comment...

anina.net

Posted by anina - Oct 20 2007 at11:55 CEST

we love haskell....

Functional Metapost

Posted by sigfpe - Sep 12 2007 at02:20 CEST

Don't miss http://cryp.to/funcmp/

Posted by alpheccar - Sep 08 2007 at18:28 CEST

Yes. It is in the module Graphics.PDF.Typesetting which is totally separate from Graphics.PDF.Text.

Posted by Joachim Breitner - Sep 08 2007 at17:54 CEST

Are these additional functions (e.g. vertical mode) in a separate module? From a User POV I think I’d like to have a clear separation between what is basic PDF and what is your added functionality.

Greetings, nomeata

Posted by alpheccar - Sep 08 2007 at14:35 CEST

Don't think I am building a TeX in Haskell :-) TeX is much more powerful and better. I just want to be able to generate some simple documents.

Posted by chris - Sep 08 2007 at14:32 CEST

Cool stuff! Looks very promising. It would be pretty cool to have a haskell-only TeX-implementation ;)