module FRP.Helm.Text (
plainText,
asText,
text,
defaultText,
toText,
bold,
italic,
color,
monospace,
typeface,
header,
height
) where
import FRP.Helm.Color (Color, black)
import FRP.Helm.Graphics (Element(TextElement), Text(..))
import qualified Graphics.Rendering.Cairo as Cairo
defaultText :: Text
defaultText = Text {
textUTF8 = "",
textColor = black,
textTypeface = "sans-serif",
textHeight = 14,
textWeight = Cairo.FontWeightNormal,
textSlant = Cairo.FontSlantNormal
}
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 = Cairo.FontWeightBold }
italic :: Text -> Text
italic txt = txt { textSlant = Cairo.FontSlantItalic }
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 }