balkon-1.3.0.0: Text layout engine built on top of HarfBuzz.
Safe HaskellNone
LanguageHaskell2010

Data.Text.ParagraphLayout

Description

Generic functions for manipulating paragraph layout.

In order to create such paragraph layout in the first place, see Data.Text.ParagraphLayout.Rich for the rich text interface, or Data.Text.ParagraphLayout.Plain for the legacy plain text interface.

Positions and distances are represented as 32-bit integers. Their unit must be defined by the caller, who must calculate the desired dimensions of the EM square of the input font and set them using optionScale.

For example, if 1em = 20px, if the output pixels are square, and if the output coordinates are in 1/64ths of a pixel, you should set the scale to Just (1280, 1280).

X coordinates increase from left to right.

Y coordinates increase from bottom to top.

Synopsis

Documentation

data PageContinuity #

Represents the best place to place a chunk of paginated content.

Constructors

Continue

The content is split so that a given chunk can continue on the same page as its preceding context.

This may be because all constraints were met, or because adding a page break would have no benefit.

Break

The content is split so that a given chunk should begin on a new page.

This may be because the current page does not have enough space to preserve orphan/widow constrains, or because it does not have space for any content at all.

data PageOptions #

Defines options for breaking a layout into pages.

Constructors

PageOptions 

Fields

  • pageCurrentHeight :: Int32

    Amount of vertical space available for the paragraph on the current page.

  • pageNextHeight :: Int32

    Expected amount of vertical space available for the paragraph on the next page.

    If this is greater than pageCurrentHeight, the paragraph may be pushed onto the next page in order to better satisfy orphan/widow constraints.

  • pageOrphans :: Word

    If a page break is required inside the paragraph, this will be the minimum number of lines to keep at the bottom of this page, if possible.

  • pageWidows :: Word

    If a page break is required inside the paragraph, this will be the minimum number of lines to keep at the top of the next page, if possible.

class Paginable pl #

Typeclass for layouts that can be broken into pages.

Minimal complete definition

paginate

Instances

Instances details
LineHeight a => Paginable [a]

Internal implementation of paginating a simple list of generic lines.

Instance details

Defined in Data.Text.ParagraphLayout.Internal.Paginable

Methods

paginate :: PageOptions -> [a] -> (PageContinuity, [a], Maybe [a]) #

Paginable (ParagraphLayout d)

Implementation of paginating a plain text paragraph layout. Breaks the layout on page boundaries and automatically adjusts coordinates.

Instance details

Defined in Data.Text.ParagraphLayout.Internal.Paginable

Paginable (ParagraphLayout d)

Implementation of paginating a rich text paragraph layout. Breaks the layout on page boundaries and automatically adjusts coordinates.

Instance details

Defined in Data.Text.ParagraphLayout.Internal.Paginable

paginate :: Paginable pl => PageOptions -> pl -> (PageContinuity, pl, Maybe pl) #

Break a chunk of content from the given layout, to be placed together on a page.

Explanation of return values:

  • (Continue, p, Nothing) means that p is the entire layout and fits best on the current page.
  • (Break, p, Nothing) means that p is the entire layout and fits best on a new page. In other words, p should be preceded by a page break.
  • (Continue, p, Just rest) means that p is a part of the layout that fits best on the current page, and rest should be passed to this function again. In other words, p should be followed by a page break.
  • (Break, p, Just rest) means that p is a part of the layout that fits best on a new page, and rest should be passed to this function again. In other words, p should be surrounded by page breaks on both sides.