SFML-2.3.2: SFML bindings

Safe HaskellNone
LanguageHaskell98

SFML.Graphics.Text

Synopsis

Documentation

module SFML.Utils

data TextStyle Source

Text styles.

Constructors

TextRegular

Regular characters, no style

TextBold

Characters are bold

TextItalic

Characters are in italic

TextUnderlined

Characters are underlined

TextStrikeThrough

Strike through characters

createText :: IO (Either SFException Text) Source

Create a new text.

copy :: SFCopyable a => a -> IO a Source

Copy the given SFML resource.

destroy :: SFResource a => a -> IO () Source

Destroy the given SFML resource.

setTextString :: Text -> String -> IO () Source

Set the string of a text (from an ANSI string).

A text's string is empty by default.

setTextStringU :: Text -> String -> IO () Source

Set the string of a text (from a unicode string).

setTextFont :: Text -> Font -> IO () Source

Set the font of a text.

The font argument refers to a texture that must exist as long as the text uses it. Indeed, the text doesn't store its own copy of the font, but rather keeps a pointer to the one that you passed to this function. If the font is destroyed and the text tries to use it, the behaviour is undefined.

setTextCharacterSize Source

Arguments

:: Text 
-> Int

New character size, in pixels

-> IO () 

Set the character size of a text.

The default size is 30.

setTextStyle :: Text -> [TextStyle] -> IO () Source

Set the style of a text.

You can pass a combination of one or more styles, for example [TextBold, sfTextItalic].

The default style is TextRegular.

setTextColor :: Text -> Color -> IO () Source

Set the global color of a text.

By default, the text's color is opaque white.

getTextString :: Text -> IO String Source

Get the string of a text as an ANSI string.

getTextUnicodeString :: Text -> IO String Source

Get the string of a text as a UTF-32 string.

getTextFont :: Text -> IO (Maybe Font) Source

Get the font used by a text.

If the text has no font attached, Nothing is returned.

The returned pointer is const, which means that you can't modify the font when you retrieve it with this function.

getTextCharacterSize :: Text -> IO Int Source

Get the size of the characters of a text.

getTextStyle :: Text -> IO TextStyle Source

Get the style of a text

getTextColor :: Text -> IO Color Source

Get the global color of a text.

findTextCharacterPos Source

Arguments

:: Text 
-> Int

Index of the character

-> IO Vec2f 

Return the position of the ith character in a text.

This function computes the visual position of a character from its index in the string. The returned position is in global coordinates (translation, rotation, scale and origin are applied).

If the index is out of range, the position of the end of the string is returned.

getTextLocalBounds :: Text -> IO FloatRect Source

Get the local bounding rectangle of a text.

The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity.

In other words, this function returns the bounds of the entity in the entity's coordinate system.

getTextGlobalBounds :: Text -> IO FloatRect Source

Get the global bounding rectangle of a text.

The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity.

In other words, this function returns the bounds of the text in the global 2D world's coordinate system.