textToSVG :: Bool -> ShapeType -> Double -> Text -> S.Svg
textToSVG styled type_ xPos' text =
    S.text_ ! A.x (stringValue $ show $
                      if type_ == Region
                      then xPos
                      else xPos')
            ! A.y (stringValue $ show yPos)
            ! (if styled then allStyles else baseStyles)
            $ toMarkup $ textText text
    where
        (xPos, yPos) = textPos text
        align = case type_ of
                       Region -> textAlign text
                       _ -> "middle"

        fontSize = case type_ of
            Hybrid -> hybridFontSize
            BoolNode -> boolFontSize
            Region -> regionFontSize
            _ -> nodeFontSize

        fill =
            if type_ == Hybrid
            then A.fill "white"
            else
                if null $ textFill text
                then mempty
                else A.fill $ stringValue $ textFill text

        baseStyles = mconcat
            [A.stroke "none",
             fill,
             A.textAnchor $ stringValue align]

        allStyles = mconcat
            [A.fontFamily "'Trebuchet MS', 'Arial', sans-serif",
             A.fontSize (stringValue $ show fontSize ++ "pt")] `mappend`
            baseStyles


-- | Converts a path to SVG.
textToSVG :: Bool -> ShapeType -> Double -> Text -> S.Svg
textToSVG styled type_ xPos' text =
    S.text_ ! A.x (stringValue $ show $
                      if type_ == Region
                      then xPos
                      else xPos')
            ! A.y (stringValue $ show yPos)
            ! (if styled then allStyles else baseStyles)
            $ toMarkup $ textText text
    where
        (xPos, yPos) = textPos text
        align = case type_ of
                       Region -> textAlign text
                       _ -> "middle"

        fontSize = case type_ of
            Hybrid -> hybridFontSize
            BoolNode -> boolFontSize
            Region -> regionFontSize
            _ -> nodeFontSize

        fill =
            if type_ == Hybrid
            then A.fill "white"
            else
                if null $ textFill text
                then mempty
                else A.fill $ stringValue $ textFill text

        baseStyles = mconcat
            [A.stroke "none",
             fill,
             A.textAnchor $ stringValue align]

        allStyles = mconcat
            [A.fontFamily "'Trebuchet MS', 'Arial', sans-serif",
             A.fontSize (stringValue $ show fontSize ++ "pt")] `mappend`
            baseStyles


-- | Converts a path to SVG.
textToSVG styled type_ xPos' text =
    S.text_ ! A.x (stringValue $ show $
                      if type_ == Region
                      then xPos
                      else xPos')
            ! A.y (stringValue $ show yPos)
            ! (if styled then allStyles else baseStyles)
            $ toMarkup $ textText text
    where
        (xPos, yPos) = textPos text
        align = case type_ of
                       Region -> textAlign text
                       _ -> "middle"

        fontSize = case type_ of
            Hybrid -> hybridFontSize
            BoolNode -> boolFontSize
            Region -> regionFontSize
            _ -> nodeFontSize

        fill =
            if type_ == Hybrid
            then A.fill "white"
            else
                if null $ textFill text
                then mempty
                else A.fill $ stringValue $ textFill text

        baseStyles = mconcat
            [A.stroke "none",
             fill,
             A.textAnchor $ stringValue align]

        allStyles = mconcat
            [A.fontFamily "'Trebuchet MS', 'Arial', sans-serif",
             A.fontSize (stringValue $ show fontSize ++ "pt")] `mappend`
            baseStyles


-- | Converts a path to SVG.