HPDF-0.3: Graphics/PDF/Font.hs
-- | Function used to control the fonts in a PDF document
module Graphics.PDF.Font
(-- * Font
-- * Font type
Font(..)
-- ** Font selection
,chooseFont
)
where
import Graphics.PDF.LowLevel
-- | List of supported fonts
data Font = TimesRoman
| TimesBold
| TimesItalic
| Helvetica
| HelveticaBold
| HelveticaOblique
| HelveticaBoldOblique
| Courier
| CourierBold
| CourierOblique
| CourierBoldOblique
| Symbol
| ZapfDingbats
instance Show Font where
show TimesRoman = "Times-Roman"
show TimesBold = "Times-Bold"
show TimesItalic = "Times-Italic"
show Helvetica = "Helvetica"
show HelveticaBold = "Helvetica-Bold"
show HelveticaOblique = "Helvetica-Oblique"
show HelveticaBoldOblique = "Helvetica-BoldOblique"
show Courier = "Courier"
show CourierBold = "Courier-Bold"
show CourierOblique = "Courier-Oblique"
show CourierBoldOblique = "Courier-BoldOblique"
show Symbol = "Symbol"
show ZapfDingbats = "ZapfDingbats"
type Size = Int
-- | Create a new font dictionary
newFont :: String -> PdfObject
newFont name= pdfDictionary [("Type",PdfName "FontDescriptor"),
("Subtype",PdfName "Type1"),
("BaseFont",PdfName name)
]
-- | Select new font in the document
chooseFont :: Font -> Size -> PdfCmd
chooseFont font fontSize = (PdfBT fontName fontSize,[(PdfFont,fontName,PdfUnknownPointer fontName),
(PdfAnyObject, fontName, newFont fontName)
])
where
fontName = show font