HPDF 1.1 teaser

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:

Currently, a style is a type of class:

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:

data StyleFunction = DrawWord
                   | DrawGlue

and TextStyle is:

data TextStyle = TextStyle { textFont :: !PDFFont
                           , textStrokeColor :: !Color
                           , textFillColor :: !Color
                           , textMode :: !TextMode
                           , penWidth :: !PDFFloat
                           , scaleSpace :: !PDFFloat
                           , scaleDilatation :: !PDFFloat
                           , scaleCompression :: !PDFFloat

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

(This post was imported from my old blog. The date is the date of the import. The comments where not imported.)

blog comments powered by Disqus