Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- data Paragraph d = Paragraph Array Int [Span d] ParagraphOptions
- data LineHeight
- data ParagraphOptions
- defaultParagraphOptions :: ParagraphOptions
- paragraphFont :: ParagraphOptions -> Font
- paragraphLineHeight :: ParagraphOptions -> LineHeight
- paragraphMaxWidth :: ParagraphOptions -> Int32
- data Span d = Span {
- spanUserData :: d
- spanLength :: Int
- spanOptions :: SpanOptions
- data SpanOptions
- defaultSpanOptions :: SpanOptions
- spanLanguage :: SpanOptions -> String
- paragraphSpanBounds :: Paragraph d -> NonEmpty Int
- paragraphSpanTexts :: Paragraph d -> [Text]
- paragraphText :: Paragraph d -> Text
- layoutPlain :: Paragraph d -> ParagraphLayout d
- data ParagraphLayout d = ParagraphLayout {
- paragraphRect :: Rect Int32
- spanLayouts :: [SpanLayout d]
- data SpanLayout d = SpanLayout [Fragment d]
- data Fragment d = Fragment d Int [AncestorBox d] (Rect Int32) (Rect Int32) (Int32, Int32) [(GlyphInfo, GlyphPos)]
- data AncestorBox d = AncestorBox {
- boxUserData :: d
- boxLeftEdge :: BoxEdge
- boxRightEdge :: BoxEdge
- boxStartEdge :: BoxEdge
- boxEndEdge :: BoxEdge
- data BoxEdge
- = NoEdge
- | SpacedEdge Int32
Documentation
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.
Paragraph | |
|
data LineHeight #
Determines the preferred line height of text in the resulting layout.
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
Eq LineHeight | |
Defined in Data.Text.ParagraphLayout.Internal.LineHeight (==) :: LineHeight -> LineHeight -> Bool (/=) :: LineHeight -> LineHeight -> Bool | |
Read LineHeight | |
Defined in Data.Text.ParagraphLayout.Internal.LineHeight readsPrec :: Int -> ReadS LineHeight readList :: ReadS [LineHeight] readPrec :: ReadPrec LineHeight readListPrec :: ReadPrec [LineHeight] | |
Show LineHeight | |
Defined in Data.Text.ParagraphLayout.Internal.LineHeight 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
Eq ParagraphOptions | |
Defined in Data.Text.ParagraphLayout.Internal.ParagraphOptions (==) :: ParagraphOptions -> ParagraphOptions -> Bool (/=) :: ParagraphOptions -> ParagraphOptions -> Bool |
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
A paragraph is broken into spans by the caller.
Each span could have a different font family, size, style, text decoration, colour, language, etc.
Span | |
|
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
Eq SpanOptions | |
Defined in Data.Text.ParagraphLayout.Internal.Span (==) :: SpanOptions -> SpanOptions -> Bool (/=) :: SpanOptions -> SpanOptions -> Bool |
defaultSpanOptions :: SpanOptions #
SpanOptions
with default values.
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 #
paragraphSpanTexts :: Paragraph d -> [Text] #
paragraphText :: Paragraph d -> Text #
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.
ParagraphLayout | |
|
Instances
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.
SpanLayout [Fragment d] |
Instances
Eq d => Eq (SpanLayout d) | |
Defined in Data.Text.ParagraphLayout.Internal.Span (==) :: SpanLayout d -> SpanLayout d -> Bool (/=) :: SpanLayout d -> SpanLayout d -> Bool | |
Read d => Read (SpanLayout d) | |
Defined in Data.Text.ParagraphLayout.Internal.Span readsPrec :: Int -> ReadS (SpanLayout d) readList :: ReadS [SpanLayout d] readPrec :: ReadPrec (SpanLayout d) readListPrec :: ReadPrec [SpanLayout d] | |
Show d => Show (SpanLayout d) | |
Defined in Data.Text.ParagraphLayout.Internal.Span showsPrec :: Int -> SpanLayout d -> ShowS show :: SpanLayout d -> String showList :: [SpanLayout d] -> ShowS |
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.
Instances
Eq d => Eq (Fragment d) | |
Read d => Read (Fragment d) | |
Defined in Data.Text.ParagraphLayout.Internal.Fragment | |
Show d => Show (Fragment d) | |
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.
AncestorBox | |
|
Instances
Eq d => Eq (AncestorBox d) | |
Defined in Data.Text.ParagraphLayout.Internal.AncestorBox (==) :: AncestorBox d -> AncestorBox d -> Bool (/=) :: AncestorBox d -> AncestorBox d -> Bool | |
Read d => Read (AncestorBox d) | |
Defined in Data.Text.ParagraphLayout.Internal.AncestorBox readsPrec :: Int -> ReadS (AncestorBox d) readList :: ReadS [AncestorBox d] readPrec :: ReadPrec (AncestorBox d) readListPrec :: ReadPrec [AncestorBox d] | |
Show d => Show (AncestorBox d) | |
Defined in Data.Text.ParagraphLayout.Internal.AncestorBox showsPrec :: Int -> AncestorBox d -> ShowS show :: AncestorBox d -> String showList :: [AncestorBox d] -> ShowS |
Describes either the absence, or the presence and size, of a box edge at a given position.
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 |