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

Data.Text.ParagraphLayout.Plain

Description

Deprecated: Use Data.Text.ParagraphLayout.Rich instead.

Legacy interface for laying out paragraphs of plain text.

This interface only allows one font with a fixed line height to be used for the entire paragraph. As a consequence, all lines will have the same height.

Synopsis

Documentation

data Paragraph d #

Text to be laid out as a single paragraph.

May be divided into any number of neighbouring spans, each of which will be represented as a separate SpanLayout in the resulting layout.

The input text must be encoded as UTF-8 in a contiguous byte array.

You may need to use Data.Text.Internal in order to determine the byte array and the necessary offsets to construct the paragraph without copying data.

For simple use cases, it may be sufficient to construct paragraphs using ParagraphConstruction.

Constructors

Paragraph 

Fields

  • Array

    A byte array containing the whole text to be laid out, in UTF-8.

    This array will be passed to Data.Text.Glyphize, which passes it to hb_buffer_add_utf8().

    In the output, cluster will be a byte offset of the corresponding input character from this array.

  • Int

    Byte offset of the first span from the start of the byte array. Any characters preceding this offset will not be shaped, but may still be used to influence the shape of neighbouring characters.

  • [Span d]

    Parts of the text to be laid out, in logical order. The initial offset plus total length of all spans must not exceed the bounds of the byte array. Any characters following the last span will not be shaped, but may still be used to influence the shape of neighbouring characters.

  • ParagraphOptions

    Options applying to the paragraph as a whole.

data LineHeight #

Determines the preferred line height of text in the resulting layout.

Constructors

Normal

The amount of vertical space taken up by the text in the layout will be exactly the distance between its font's ascender and descender line, with no further adjustment.

Absolute Int32

The amount of vertical space taken up by the text in the layout will be exactly the provided value. If this value is different from the distance between the font's ascender and descender line, the difference will be split in two equal parts (within a rounding error) and applied as half-leading both above and below the glyphs.

Instances

Instances details
Eq LineHeight 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.LineHeight

Methods

(==) :: LineHeight -> LineHeight -> Bool

(/=) :: LineHeight -> LineHeight -> Bool

Read LineHeight 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.LineHeight

Methods

readsPrec :: Int -> ReadS LineHeight

readList :: ReadS [LineHeight]

readPrec :: ReadPrec LineHeight

readListPrec :: ReadPrec [LineHeight]

Show LineHeight 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.LineHeight

Methods

showsPrec :: Int -> LineHeight -> ShowS

show :: LineHeight -> String

showList :: [LineHeight] -> ShowS

data ParagraphOptions #

Defines options relevant to the entire paragraph.

This record type is likely to be extended in the future. Use defaultParagraphOptions and update it with specific record selectors instead of constructing ParagraphOptions directly.

In order to get CSS defaults, use:

defaultParagraphOptions { paragraphAlignment = AlignStart }

Instances

Instances details
Eq ParagraphOptions 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.ParagraphOptions

defaultParagraphOptions :: ParagraphOptions #

ParagraphOptions with backwards-compatible values.

Note that this sets paragraphAlignment to AlignLeft, whereas the CSS default should be AlignStart.

Paragraph options

These are record selectors that can be used for reading as well as updating specific option fields.

paragraphFont :: ParagraphOptions -> Font #

Font to be used for shaping and measurement. Make sure to set its scale (see optionScale) using the same units that you want in the output.

paragraphLineHeight :: ParagraphOptions -> LineHeight #

Preferred line height of the resulting fragments.

paragraphMaxWidth :: ParagraphOptions -> Int32 #

Line width at which line breaking should occur. Lines will be broken at language-appropriate boundaries. If a line still exceeds this limit then, it will be broken at character boundaries, and if it already consists of a single cluster that cannot be further broken down, it will overflow.

Text spans

data Span d #

A paragraph is broken into spans by the caller.

Each span could have a different font family, size, style, text decoration, colour, language, etc.

Constructors

Span 

Fields

Instances

Instances details
Eq d => Eq (Span d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Span

Methods

(==) :: Span d -> Span d -> Bool

(/=) :: Span d -> Span d -> Bool

data SpanOptions #

Defines options relevant to the layout of a single span of text.

This record type is likely to be extended in the future. Use defaultSpanOptions and update it with specific record selectors instead of constructing SpanOptions directly.

Instances

Instances details
Eq SpanOptions 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Span

Methods

(==) :: SpanOptions -> SpanOptions -> Bool

(/=) :: SpanOptions -> SpanOptions -> Bool

Span options

These are record selectors that can be used for reading as well as updating specific option fields.

spanLanguage :: SpanOptions -> String #

IETF BCP 47 language tag, such as the value expected to be found in the HTML lang attribute, specifying the primary language for the span's text content. An empty string explicitly means "language unknown".

Used for selecting the appropriate glyphs and line breaking rules, primarily in East Asian languages.

Verification

paragraphSpanBounds :: Paragraph d -> NonEmpty Int #

Calculate the offsets into the Paragraph's underlying Array where each span starts and ends, in ascending order. The resulting list will be one larger than the list of input spans.

You can use this function to verify that Balkón will slice the input text correctly.

paragraphSpanTexts :: Paragraph d -> [Text] #

Turn each span of the input Paragraph into a Text.

You can use this function to verify that Balkón will slice the input text correctly.

paragraphText :: Paragraph d -> Text #

Turn all spans of the input Paragraph into one combined Text.

You can use this function to verify that Balkón will slice the input text correctly.

Output layout

layoutPlain :: Paragraph d -> ParagraphLayout d #

Lay out a paragraph of plain text using a single font.

data ParagraphLayout d #

The resulting layout of the whole paragraph.

Constructors

ParagraphLayout 

Fields

Instances

Instances details
Eq d => Eq (ParagraphLayout d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout

Methods

(==) :: ParagraphLayout d -> ParagraphLayout d -> Bool

(/=) :: ParagraphLayout d -> ParagraphLayout d -> Bool

Read d => Read (ParagraphLayout d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout

Methods

readsPrec :: Int -> ReadS (ParagraphLayout d)

readList :: ReadS [ParagraphLayout d]

readPrec :: ReadPrec (ParagraphLayout d)

readListPrec :: ReadPrec [ParagraphLayout d]

Show d => Show (ParagraphLayout d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout

Methods

showsPrec :: Int -> ParagraphLayout d -> ShowS

show :: ParagraphLayout d -> String

showList :: [ParagraphLayout d] -> ShowS

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

LineHeight (ParagraphLayout d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout

Methods

lineHeight :: ParagraphLayout d -> Int32 #

LineNumbers (ParagraphLayout d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout

data SpanLayout d #

The resulting layout of each span, which may include multiple fragments as required by line breaking, text writing direction, and changes of script.

Constructors

SpanLayout [Fragment d] 

Instances

Instances details
Eq d => Eq (SpanLayout d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Span

Methods

(==) :: SpanLayout d -> SpanLayout d -> Bool

(/=) :: SpanLayout d -> SpanLayout d -> Bool

Read d => Read (SpanLayout d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Span

Methods

readsPrec :: Int -> ReadS (SpanLayout d)

readList :: ReadS [SpanLayout d]

readPrec :: ReadPrec (SpanLayout d)

readListPrec :: ReadPrec [SpanLayout d]

Show d => Show (SpanLayout d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Span

Methods

showsPrec :: Int -> SpanLayout d -> ShowS

show :: SpanLayout d -> String

showList :: [SpanLayout d] -> ShowS

data Fragment d #

A unit of text laid out in a rectangular area.

Roughly equivalent to the term text fragment as used in CSS Display Module Level 3.

An input span (or text sequence in CSS terms) can be broken into multiple fragments because of line breaking, because of bidirectional ordering, or because it contains glyphs from multiple scripts.

Constructors

Fragment d Int [AncestorBox d] (Rect Int32) (Rect Int32) (Int32, Int32) [(GlyphInfo, GlyphPos)] 

Instances

Instances details
Eq d => Eq (Fragment d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Fragment

Methods

(==) :: Fragment d -> Fragment d -> Bool

(/=) :: Fragment d -> Fragment d -> Bool

Read d => Read (Fragment d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Fragment

Methods

readsPrec :: Int -> ReadS (Fragment d)

readList :: ReadS [Fragment d]

readPrec :: ReadPrec (Fragment d)

readListPrec :: ReadPrec [Fragment d]

Show d => Show (Fragment d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Fragment

Methods

showsPrec :: Int -> Fragment d -> ShowS

show :: Fragment d -> String

showList :: [Fragment d] -> ShowS

data AncestorBox d #

Describes the relationship of a fragment to an inline box that contains it.

A box can have many fragments, and a fragment contained by a box is also contained by all ancestors of that box.

The root inline box, which forms the basis of each paragraph, is implied and not described by this type of record.

Constructors

AncestorBox 

Fields

  • boxUserData :: d

    User-defined data associated with the inline box.

  • boxLeftEdge :: BoxEdge

    Describes the left edge of the inline box. Typically applied to the leftmost fragment in the box, and set to NoEdge for all other fragments.

    Equal to boxStartEdge for LTR boxes.

    Equal to boxEndEdge for RTL boxes.

  • boxRightEdge :: BoxEdge

    Describes the right edge of the inline box. Typically applied to the rightmost fragment in the box, and set to NoEdge for all other fragments.

    Equal to boxStartEdge for RTL boxes.

    Equal to boxEndEdge for LTR boxes.

  • boxStartEdge :: BoxEdge

    Describes the start edge of the inline box. Typically applied to the startmost fragment in the box, and set to NoEdge for all other fragments.

    Equal to boxLeftEdge for LTR boxes.

    Equal to boxRightEdge for RTL boxes.

  • boxEndEdge :: BoxEdge

    Describes the end edge of the inline box. Typically applied to the endmost fragment in the box, and set to NoEdge for all other fragments.

    Equal to boxLeftEdge for RTL boxes.

    Equal to boxRightEdge for LTR boxes.

Instances

Instances details
Eq d => Eq (AncestorBox d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.AncestorBox

Methods

(==) :: AncestorBox d -> AncestorBox d -> Bool

(/=) :: AncestorBox d -> AncestorBox d -> Bool

Read d => Read (AncestorBox d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.AncestorBox

Methods

readsPrec :: Int -> ReadS (AncestorBox d)

readList :: ReadS [AncestorBox d]

readPrec :: ReadPrec (AncestorBox d)

readListPrec :: ReadPrec [AncestorBox d]

Show d => Show (AncestorBox d) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.AncestorBox

Methods

showsPrec :: Int -> AncestorBox d -> ShowS

show :: AncestorBox d -> String

showList :: [AncestorBox d] -> ShowS

data BoxEdge #

Describes either the absence, or the presence and size, of a box edge at a given position.

Constructors

NoEdge

The given box does not have an edge here.

This typically means that the box was fragmented and that the given edge is associated with another fragment.

SpacedEdge Int32

The given box has an edge here, adding a given amount of empty space from the fragmentRect outward.

Instances

Instances details
Eq BoxEdge 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.AncestorBox

Methods

(==) :: BoxEdge -> BoxEdge -> Bool

(/=) :: BoxEdge -> BoxEdge -> Bool

Read BoxEdge 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.AncestorBox

Methods

readsPrec :: Int -> ReadS BoxEdge

readList :: ReadS [BoxEdge]

readPrec :: ReadPrec BoxEdge

readListPrec :: ReadPrec [BoxEdge]

Show BoxEdge 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.AncestorBox

Methods

showsPrec :: Int -> BoxEdge -> ShowS

show :: BoxEdge -> String

showList :: [BoxEdge] -> ShowS