Banner

HPDF 1.1 teaser

Posté par alpheccar le08 Sep 2007 à 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.

Pas de tags

Commentaires

Ajouter un commentaire...

anina.net

Posté par anina le20 Oct 2007 à11:55 CEST

we love haskell....

Functional Metapost

Posté par sigfpe le12 Sep 2007 à02:20 CEST

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

Posté par alpheccar le08 Sep 2007 à18:28 CEST

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

Posté par Joachim Breitner le08 Sep 2007 à17: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

Posté par alpheccar le08 Sep 2007 à14: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.

Posté par chris le08 Sep 2007 à14:32 CEST

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