~jaro/balkon

b70211f9925a8c50fddb8099aebda5d3c4fcfc5c — Jaro 1 year, 6 months ago b7687d6
Add public Rich interface.
4 files changed, 75 insertions(+), 4 deletions(-)

M CHANGELOG.md
M balkon.cabal
M lib/Data/Text/ParagraphLayout.hs
A lib/Data/Text/ParagraphLayout/Rich.hs
M CHANGELOG.md => CHANGELOG.md +5 -0
@@ 2,6 2,11 @@

## 1.0.0.0 -- TBD

* Added new `Data.Text.ParagraphLayout.Rich` interface to support rich text.

    * Supports multiple fonts in the same paragraph. Where line height varies,
      text will be aligned by its top edge.

* Separated plain text layout interface into `Data.Text.ParagraphLayout.Plain`
  submodule, in anticipation of a rich text interface.


M balkon.cabal => balkon.cabal +6 -2
@@ 26,12 26,15 @@ description:
    .
    Given an input text and formatting options, Balkón produces an inline
    layout with defined glyph positions and box coordinates, all within a
    containing unit called a paragraph.
    containing unit called a paragraph. See "Data.Text.ParagraphLayout.Rich".
    .
    Internally, HarfBuzz is used to shape individual runs of text, each of
    which fits within one line and has a constant script, direction, language,
    and formatting. Balkón abstracts this so that you can provide text with any
    mix of these attributes and a desired line width for line breaking.
    .
    Additionally, Balkón can be used for breaking an inline layout into pages.
    See "Data.Text.ParagraphLayout".

-- URL for the project homepage or repository.
homepage:           https://argonaut-constellation.org/


@@ 151,7 154,8 @@ library
        Data.Text.ParagraphLayout,
        Data.Text.ParagraphLayout.ParagraphConstruction,
        Data.Text.ParagraphLayout.Plain,
        Data.Text.ParagraphLayout.Rect
        Data.Text.ParagraphLayout.Rect,
        Data.Text.ParagraphLayout.Rich

    -- Other library packages from which modules are imported.
    build-depends:

M lib/Data/Text/ParagraphLayout.hs => lib/Data/Text/ParagraphLayout.hs +2 -2
@@ 1,8 1,8 @@
-- | Generic functions for manipulating paragraph layout.
--
-- In order to create such paragraph layout in the first place, see
-- "Data.Text.ParagraphLayout.Plain". Only a plain text interface is
-- currently available.
-- "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

A lib/Data/Text/ParagraphLayout/Rich.hs => lib/Data/Text/ParagraphLayout/Rich.hs +62 -0
@@ 0,0 1,62 @@
-- | Interface for laying out paragraphs of rich text.
--
-- The main entry point is the function `layoutRich`.
module Data.Text.ParagraphLayout.Rich
    -- * Input paragraph
    ( Paragraph (Paragraph)
    , BoxSpacing (BoxSpacingLeftRight)
    , LineHeight (Absolute, Normal)
    , ParagraphOptions
    , defaultParagraphOptions
    -- ** Paragraph options
    -- | These are record selectors that can be used for reading
    -- as well as updating specific option fields.
    , paragraphLineHeight
    , paragraphMaxWidth
    -- NOTE: `paragraphFont` is only used by the legacy plain text interface,
    --       and is therefore not exported here.
    -- ** Content tree
    , RootNode (RootBox)
    , InnerNode (InlineBox, TextSequence)
    , Box (Box)
    , BoxOptions
    , defaultBoxOptions
    , TextOptions
    , defaultTextOptions
    -- ** Box options
    -- | These are record selectors that can be used for reading
    -- as well as updating specific option fields.
    , boxSpacing
    -- ** Text options
    -- | These are record selectors that can be used for reading
    -- as well as updating specific option fields.
    , textFont
    , textLineHeight
    , textLanguage
    -- ** Verification
    , paragraphSpanBounds
    , paragraphSpanTexts
    , paragraphText
    -- * Output layout
    , layoutRich
    , ParagraphLayout (ParagraphLayout, paragraphRect, paragraphFragments)
    , Fragment
        ( Fragment
        , fragmentUserData
        , fragmentLine
        , fragmentRect
        , fragmentPen
        , fragmentGlyphs
        )
    )
where

import Data.Text.ParagraphLayout.Internal.BoxOptions
import Data.Text.ParagraphLayout.Internal.Fragment
import Data.Text.ParagraphLayout.Internal.LineHeight
import Data.Text.ParagraphLayout.Internal.ParagraphOptions
import Data.Text.ParagraphLayout.Internal.Rich
import Data.Text.ParagraphLayout.Internal.Rich.Paragraph
import Data.Text.ParagraphLayout.Internal.Rich.ParagraphLayout
import Data.Text.ParagraphLayout.Internal.TextOptions
import Data.Text.ParagraphLayout.Internal.Tree