module Graphics.PDF.Text
(
drawText, clipText,fillAndDrawText,fillText,charSpacing,wordSpacing,textLeading
, pdfString
)
where
import Graphics.PDF.LowLevel
import Text.Regex
leftPar = mkRegex "[(]"
rightPar = mkRegex "[)]"
backslash = mkRegex "[\\]"
pdfString :: String -> [PdfString]
pdfString s = map (S . escape) . lines $ s
where
escape s = replace rightPar "\\)" . replace leftPar "\\(" . replace backslash "\\\\\\\\" $ s
replace reg repl s = subRegex reg s repl
drawText :: Float -> Float -> String -> PdfCmd
drawText px py s = (PdfText TextStroke px py (pdfString s),[])
fillAndDrawText :: Float -> Float -> String -> PdfCmd
fillAndDrawText px py s = (PdfText TextFillStroke px py (pdfString s),[])
fillText :: Float -> Float -> String -> PdfCmd
fillText px py s = (PdfText TextFill px py (pdfString s),[])
clipText :: Float -> Float -> String -> PdfCmd
clipText px py s = (PdfText TextClip px py (pdfString s),[])
charSpacing :: Float -> PdfCmd
charSpacing value = (PdfCharSpacing value,[])
wordSpacing :: Float -> PdfCmd
wordSpacing value = (PdfWordSpacing value,[])
textLeading :: Float -> PdfCmd
textLeading value = (PdfLeading value,[])