module FRP.Helm.Text (
plainText,
asText,
text,
defaultText,
toText,
light,
bold,
italic,
oblique,
color,
monospace,
typeface,
header,
height
) where
import FRP.Helm.Color (Color, black)
import FRP.Helm.Graphics (Element(TextElement), Text(..), FontWeight(..), FontStyle(..))
defaultText :: Text
defaultText = Text {
textUTF8 = "",
textColor = black,
textTypeface = "sans-serif",
textHeight = 14,
textWeight = NormalWeight,
textStyle = NormalStyle
}
toText :: String -> Text
toText utf8 = defaultText { textUTF8 = utf8 }
plainText :: String -> Element
plainText utf8 = text $ toText utf8
asText :: Show a => a -> Element
asText val = text $ monospace $ toText $ show val
text :: Text -> Element
text = TextElement
bold :: Text -> Text
bold txt = txt { textWeight = BoldWeight }
light :: Text -> Text
light txt = txt { textWeight = LightWeight }
italic :: Text -> Text
italic txt = txt { textStyle = ItalicStyle }
oblique :: Text -> Text
oblique txt = txt { textStyle = ObliqueStyle }
color :: Color -> Text -> Text
color col txt = txt { textColor = col }
monospace :: Text -> Text
monospace txt = txt { textTypeface = "monospace" }
typeface :: String -> Text -> Text
typeface face txt = txt { textTypeface = face }
header :: Text -> Text
header = height 32
height :: Double -> Text -> Text
height size txt = txt { textHeight = size }