nanovg-0.2.0.0: Haskell bindings for nanovg

Safe HaskellSafe
LanguageHaskell2010

NanoVG.Internal.Text

Synopsis

Documentation

newtype Font

Newtype to avoid accidental use of ints

Constructors

Font 

Fields

fontHandle :: CInt
 

Instances

data TextRow

Constructors

TextRow 

Fields

start :: !(Ptr CChar)

Pointer to the input text where the row starts.

end :: !(Ptr CChar)

Pointer to the input text where the row ends (one past the last character).

next :: !(Ptr CChar)

Pointer to the beginning of the next row.

width :: !CFloat

Logical width of the row.

textRowMinX :: !CFloat

Actual bounds of the row. Logical with and bounds can differ because of kerning and some parts over extending.

textRowMaxX :: !CFloat
 

data GlyphPosition

Constructors

GlyphPosition 

Fields

str :: !(Ptr CChar)

Pointer of the glyph in the input string.

glyphX :: !CFloat

The x-coordinate of the logical glyph position.

glyphPosMinX :: !CFloat

The left bound of the glyph shape.

glyphPosMaxX :: !CFloat

The right bound of the glyph shape.

createFont :: Context -> Text -> FileName -> IO (Maybe Font)

Creates font by loading it from the disk from specified file name. Returns handle to the font.

createFontMem :: Context -> Text -> ByteString -> IO (Maybe Font)

Creates image by loading it from the specified memory chunk. Returns handle to the font.

findFont :: Context -> Text -> IO (Maybe Font)

Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found.

fontSize :: Context -> CFloat -> IO ()

Sets the font size of current text style.

fontBlur :: Context -> CFloat -> IO ()

Sets the blur of current text style.

textLetterSpacing :: Context -> CFloat -> IO ()

Sets the letter spacing of current text style.

textLineHeight :: Context -> CFloat -> IO ()

Sets the proportional line height of current text style. The line height is specified as multiple of font size.

textAlign :: Context -> Set Align -> IO ()

Sets the text align of current text style, see NVGalign for options.

fontFaceId :: Context -> Font -> IO ()

Sets the font face based on specified id of current text style.

fontFace :: Context -> Text -> IO ()

Sets the font face based on specified name of current text styl

text :: Context -> CFloat -> CFloat -> Ptr CChar -> Ptr CChar -> IO ()

Draws text string at specified location. If end is specified only the sub-string up to the end is drawn.

textBox :: Context -> CFloat -> CFloat -> CFloat -> Text -> IO ()

Draws multi-line text string at specified location wrapped at the specified width. If end is specified only the sub-string up to the end is drawn. | White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered. | Words longer than the max width are slit at nearest character (i.e. no hyphenation).

newtype Bounds

Constructors

Bounds (V4 CFloat) 

allocaBounds :: (Ptr CFloat -> IO b) -> IO b

textBounds :: Context -> CFloat -> CFloat -> Text -> IO Bounds

Measures the specified text string. Parameter bounds should be a pointer to float[4], if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax] Returns the horizontal advance of the measured text (i.e. where the next character should drawn). Measured values are returned in local coordinate space.

textBoxBounds :: Context -> CFloat -> CFloat -> CFloat -> Text -> IO Bounds

Measures the specified multi-text string. Parameter bounds should be a pointer to float[4], if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax] Measured values are returned in local coordinate space.

textGlyphPositions :: Context -> CFloat -> CFloat -> Ptr CChar -> Ptr CChar -> GlyphPositionPtr -> CInt -> IO CInt

Calculates the glyph x positions of the specified text. If end is specified only the sub-string will be used. Measured values are returned in local coordinate space.

textMetrics :: Context -> IO (CFloat, CFloat, CFloat)

Returns the vertical metrics based on the current text style. Measured values are returned in local coordinate space.

textBreakLines :: Context -> Ptr CChar -> Ptr CChar -> CFloat -> TextRowPtr -> CInt -> IO CInt

Breaks the specified text into lines. If end is specified only the sub-string will be used. White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered. Words longer than the max width are slit at nearest character (i.e. no hyphenation).