minitypeset-opengl-0.3.0.0: Layout and render text with TrueType fonts using OpenGL

Safe HaskellSafe
LanguageHaskell2010

Graphics.Rendering.MiniTypeset.Box

Contents

Description

Boxes are rectangular shapes used for layouting. They are consisting of several quads having a relative position to each other:

  • "inner boxes" are used for aligning several boxes together
  • "outer boxes" describe the logical extent
  • "bounding boxes" are the bounding boxes of the actual content abstracted by the box
  • "gap boxes" control the gap between boxes placed next to each other.

Relative boxes has their origin at the top-left corner of their inner box. Absolute boxes has an absolute offset.

We use screen-space coordinate system (Y increase downwards).

In case of font glyphs, the inner box has height 0, and it coincides with the base line of the glyph; while the outer box is defined by the ascent and the descent. Both have horizontal dimensions equal to the advance width.

Synopsis

Quads

data Quad Source #

A quad is a rectangular region, defined by its top-left and bottom-right corner

Constructors

Quad 
Instances
Eq Quad Source # 
Instance details

Defined in Graphics.Rendering.MiniTypeset.Box

Methods

(==) :: Quad -> Quad -> Bool #

(/=) :: Quad -> Quad -> Bool #

Show Quad Source # 
Instance details

Defined in Graphics.Rendering.MiniTypeset.Box

Methods

showsPrec :: Int -> Quad -> ShowS #

show :: Quad -> String #

showList :: [Quad] -> ShowS #

Semigroup Quad Source # 
Instance details

Defined in Graphics.Rendering.MiniTypeset.Box

Methods

(<>) :: Quad -> Quad -> Quad #

sconcat :: NonEmpty Quad -> Quad #

stimes :: Integral b => b -> Quad -> Quad #

Monoid Quad Source # 
Instance details

Defined in Graphics.Rendering.MiniTypeset.Box

Methods

mempty :: Quad #

mappend :: Quad -> Quad -> Quad #

mconcat :: [Quad] -> Quad #

Translate Quad Source # 
Instance details

Defined in Graphics.Rendering.MiniTypeset.Box

Methods

translate :: Pos -> Quad -> Quad Source #

quadLUB :: Quad -> Quad -> Quad Source #

Least upper bounding quad

quadsLUB :: [Quad] -> Quad Source #

Because it really should be a semigroup and not a monoid, it's important that it's not implemented with foldl..

ofsLUB :: (Pos, Quad) -> (Pos, Quad) -> Quad Source #

marginQuad :: Margin -> Quad -> Quad Source #

Extend a quad with margins

Boxes

data Box Source #

A (relative) box

Constructors

Box 
Instances
Show Box Source # 
Instance details

Defined in Graphics.Rendering.MiniTypeset.Box

Methods

showsPrec :: Int -> Box -> ShowS #

show :: Box -> String #

showList :: [Box] -> ShowS #

shiftBox :: Pos -> Box -> Box Source #

Translates the quads relative to the inner quad.

realignBox :: WhichQuad -> Box -> (Pos, Box) Source #

Replace the inner box by the given box. Since the inner box is used for alignment, this amounts to changing the alignment

trimBox :: Box -> Box Source #

Replace the outer and gap boxes by the bounding box

Absolute boxes

data AbsBox Source #

An absolute box

Constructors

AbsBox 

Fields

Instances
Show AbsBox Source # 
Instance details

Defined in Graphics.Rendering.MiniTypeset.Box

Translate AbsBox Source # 
Instance details

Defined in Graphics.Rendering.MiniTypeset.Box

Methods

translate :: Pos -> AbsBox -> AbsBox Source #

Concatenating boxes

hcatBox :: VAlign -> Box -> Box -> (Box, (Pos, Pos)) Source #

Concatantes two boxes horizontally, using the inner boxes to align them. The two positions we return are relative positions of the two boxes from the origin (top-left inner corner) of the concatenated box.

vcatBox :: HAlign -> Box -> Box -> (Box, (Pos, Pos)) Source #

Concatantes two boxes vertically, using the inner boxes to align them. The two positions we return are relative positions of the two boxes from the origin (top-left inner corner) of the concatenated box.

Overlay boxes

overlayBox :: HAlign -> VAlign -> Box -> Box -> (Box, (Pos, Pos)) Source #

Overlay two boxes (so the corners given by the alignments coincide)

Subscripts and superscripts

subSupScriptBox :: Box -> (Double, Box) -> (Double, Box) -> (Box, (Pos, Pos)) Source #

Subscripts/superscripts are special enough that it seems simpler to just add a specific combinator for them.

Above and below

aboveBelowBox :: Box -> (Pos, Box) -> (Pos, Box) -> (Box, (Pos, Pos)) Source #

Positions are relative!

Fraction

fractionBox :: Double -> Box -> Box -> (Box, (Pos, Pos)) Source #

delimiters

delimiterBox :: (Box, Box, Box) -> [Box] -> (Box, [Pos]) Source #

interleave :: [a] -> [a] -> [a] Source #

odds :: [a] -> [a] Source #

evens :: [a] -> [a] Source #