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

Safe HaskellNone
LanguageHaskell2010

Graphics.Rendering.MiniTypeset.Layout

Contents

Description

A simple layout engine to render text (and later also mathematics).

Synopsis

Relative position and size constants (mathematical coordinate system!)

Subscript size indexing

data SizeIndex Source #

0 is the default size, 1 is smaller, 2 is even smaller, etc (each subscript

Constructors

NormalSize

normal text size

FractionSize

first-level fraction

ScriptSize1

first-level subscript

ScriptSize2

second-level subscript

ScriptSize3

third-level subscript

CustomSize !(Double, Double) !SizeIndex

temporary hack

The layout data type

data Layout ident style Source #

This data type is the output of the layout engine. The `identifying' part is retained, because everything is still relative, and only during the rendering will positions become absolute. See dryrunLayout

Constructors

LoutGlyph !Pos !style !Col !Char !MultiFontGlyph 
LoutGroup !Box [Layout ident style] 
LoutBox !Box (Layout ident style) 
LoutOfs !Pos (Layout ident style) 
LoutIdent !ident (Layout ident style) 
LoutDecor !LayoutDecoration (Layout ident style) 
LoutEmpty 
Instances
(Show style, Show ident) => Show (Layout ident style) Source # 
Instance details

Defined in Graphics.Rendering.MiniTypeset.Layout

Methods

showsPrec :: Int -> Layout ident style -> ShowS #

show :: Layout ident style -> String #

showList :: [Layout ident style] -> ShowS #

Translate (Layout ident style) Source # 
Instance details

Defined in Graphics.Rendering.MiniTypeset.Layout

Methods

translate :: Pos -> Layout ident style -> Layout ident style Source #

translateLayout :: Pos -> Layout ident style -> Layout ident style Source #

reboxLayout :: Box -> Layout ident style -> Layout ident style Source #

The box of a glyph

Rendering a layout

renderLayout :: Ord ident => Layout ident style -> Pos -> IO () Source #

Renders the layout to the OpenGL framebuffer.

Note: you should set up the OpenGL coordinate transformation matrices so that the coordinate system is screen-space, measured in pixels. For example something like

matrixMode $= Projection
loadIdentity
ortho 0 xres yres 0 (-1) 1 
matrixMode $= Modelview 0
loadIdentity

should do.

dryrunLayout :: Ord ident => Layout ident style -> Pos -> IO (Map ident AbsBox) Source #

Does not actually render, but computes the bounding boxes of the identified parts of the layout.

renderLayout' Source #

Arguments

:: Ord ident 
=> Bool

True = dryrun (do not render); False = do the rendering

-> Layout ident style 
-> Pos 
-> IO (Map ident AbsBox) 

Creating a layouting

createLayout :: forall fontfile style ident. (Ord fontfile, Ord ident) => MultiFont fontfile style -> Height -> Document ident -> IO (Layout ident style) Source #

Creates a layout from a document. Then you can render the resulting layout with renderLayout

data Cfg Source #

A type used by createLayout

createLayout' :: forall fontfile style ident. (Ord fontfile, Ord ident) => MultiFont fontfile style -> Height -> Document ident -> IO (Box, Layout ident style) Source #