HPDF 1.5.0 → 1.5.1
raw patch · 13 files changed
+114/−94 lines, 13 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Paths_HPDF: getBinDir :: IO FilePath
- Paths_HPDF: getDataDir :: IO FilePath
- Paths_HPDF: getDataFileName :: FilePath -> IO FilePath
- Paths_HPDF: getDynLibDir :: IO FilePath
- Paths_HPDF: getLibDir :: IO FilePath
- Paths_HPDF: getLibexecDir :: IO FilePath
- Paths_HPDF: getSysconfDir :: IO FilePath
- Paths_HPDF: version :: Version
Files
- Graphics/PDF/Annotation.hs +3/−3
- Graphics/PDF/Coordinates.hs +4/−2
- Graphics/PDF/Documentation.hs +45/−44
- Graphics/PDF/Fonts/Encoding.hs +15/−15
- Graphics/PDF/Fonts/FontTypes.hs +9/−8
- Graphics/PDF/Fonts/Type1.hs +3/−3
- Graphics/PDF/Image.hs +16/−6
- Graphics/PDF/LowLevel/Types.hs +3/−3
- Graphics/PDF/Typesetting.hs +2/−2
- HPDF.cabal +4/−5
- NEWS.txt +0/−1
- changelog +0/−2
- changelog.md +10/−0
Graphics/PDF/Annotation.hs view
@@ -66,9 +66,9 @@ -- --inverse :: Matrix -> Matrix --inverse m@(Matrix a b c d e f) = (Matrix (d/de) (-b/de) (-c/de) (a/de) 0 0) * (Matrix 1 0 0 1 (-e) (-f))--- where--- de = det m- +-- where+-- de = det m+ applyMatrixToRectangle :: Matrix -> [PDFFloat] -> [PDFFloat] applyMatrixToRectangle m [xa,ya,xb,yb] = let (xa',ya') = m `applyTo` (xa,ya)
Graphics/PDF/Coordinates.hs view
@@ -69,8 +69,10 @@ -- e f 1 -- @ -data Matrix = Matrix !PDFFloat !PDFFloat !PDFFloat !PDFFloat !PDFFloat !PDFFloat deriving (Eq, Show)- +data Matrix+ = Matrix !PDFFloat !PDFFloat !PDFFloat !PDFFloat !PDFFloat !PDFFloat+ deriving (Eq, Show)+ instance Num Matrix where -- Matrix addition (+) (Matrix ma mb mc md me mf ) (Matrix na nb nc nd ne nf) =
Graphics/PDF/Documentation.hs view
@@ -4,39 +4,40 @@ test.hs in folder Test. -}-module Graphics.PDF.Documentation(- -- * Creating a document- -- $creating-- -- * Adding pages- -- $pages-- -- * Creating the page content - -- $content-- -- * Text - -- $text-- -- ** MonadStyle - -- $monadstyle-- -- * Geometry - -- $geometry-- -- * X Form - -- $xform-- -- * Image - -- $image-- -- * Annotations - -- $annotations-- -- * Warning - -- $warning- ) where +module Graphics.PDF.Documentation (+ -- * Creating a document+ -- $creating+ + -- * Adding pages+ -- $pages+ + -- * Creating the page content+ -- $content+ + -- * Text+ -- $text+ + -- ** MonadStyle+ -- $monadstyle+ + -- * Geometry+ -- $geometry+ + -- * X Form+ -- $xform+ + -- * Image+ -- $image+ + -- * Annotations+ -- $annotations+ + -- * Warning+ -- $warning+ )+where -{- $creating +{- $creating When you create a document, you must give some information for the PDF file like the author, the default size (the pages can use different sizes if specified) and if the document is compressed.@@ -61,7 +62,7 @@ of how you could add some pages and specify the table of contents: @-myDocument :: 'PDF' () +myDocument :: 'PDF' () myDocument = do page1 <- 'addPage' Nothing 'newSection' ('toPDFString' \"Section\") Nothing Nothing $ do@@ -84,8 +85,8 @@ Element of the 'Draw' monad are built with geometry, text and color primitives. @-createPageContent :: 'PDFReference' 'PDFPage' -> Draw () -createPageContent page = 'drawWithPage' page $ do +createPageContent :: 'PDFReference' 'PDFPage' -> Draw ()+createPageContent page = 'drawWithPage' page $ do 'strokeColor' 'red' 'setWidth' 0.5 'stroke' $ 'Rectangle' 10 0 200 300@@ -117,7 +118,7 @@ Displaying a formatted text is done with 'displayFormattedText' and using a typesetting monad value: @-'displayFormattedText' ('Rectangle' (10 :+ 0) (110 :+ 300)) 'NormalPara' 'Normal' $ do +'displayFormattedText' ('Rectangle' (10 :+ 0) (110 :+ 300)) 'NormalPara' 'Normal' $ do 'paragraph' $ do 'txt' $ \"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor \" 'txt' $ \"incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \"@@ -157,7 +158,7 @@ A 'Style' class used for sentence style. And a 'ParagraphStyle' to group together the paragraph style and the sentence style that can be used in this paragraph. -Why the 'ComparableStyle' is used instead of the class Eq ? A style is containing information +Why the 'ComparableStyle' is used instead of the class Eq ? A style is containing information used for the font (size etc ...) but it can also contain additional information used by styling function (a styling function may draw a decoration). In that latter case, the additional information is changing the look of the sentence but not its layout : the font size is not changed. So, from a text point of view, the PDF text is drawn using the same@@ -193,7 +194,7 @@ additional function is provided : 'drawTextBox' -} -{- $monadstyle +{- $monadstyle The typesetting is similar to the TeX one with kern, glues and boxes. So, it means that any drawing can be used as a letter since any drawing can be contained in a box. The operators to draw boxes, glues are@@ -252,13 +253,13 @@ 'fillAndStroke' $ 'Ellipse' 0 0 300 300 'setColoredFillPattern' cp 'fillAndStroke' $ 'Ellipse' 300 300 600 400- - where ++ where pattern = do 'stroke' ('Ellipse' 0 0 100 50) 'cpattern' = do 'strokeColor' ('Rgb' 0 0 1)- 'stroke' ('Ellipse' 0 0 100 50) + 'stroke' ('Ellipse' 0 0 100 50) @ -} @@ -299,7 +300,7 @@ The 'JpegFile' value must be created in the 'IO' monad with: @-Right jpg <- 'readJpegFile' \"logo.jpg\" +Right jpg <- 'readJpegFile' \"logo.jpg\" @ Alternatively, jpegs can be compiled into your code. After converting a jpeg to a data URL, a 'JpegFile' can be created with:@@ -312,7 +313,7 @@ -} -{- $annotations +{- $annotations A pdf page can contain several kind of annotations like links, notes etc ... For instance, to define and display a link:@@ -329,7 +330,7 @@ The PDF format is full of extensions. Depending on the viewer that you use some extensions may not be supported. It is always a good thing to test on a few viewers if you use complex features. -Mobile viewers (tablets and phones) are generally focusing on a more portable and more restricted set of features. +Mobile viewers (tablets and phones) are generally focusing on a more portable and more restricted set of features. So, you may not be able to display you document on a mobile device if you use complex features. So, I repeat : test.
Graphics/PDF/Fonts/Encoding.hs view
@@ -17,30 +17,30 @@ , Encodings(..) , PostscriptName , parseMacEncoding- ) where + ) where import Graphics.PDF.LowLevel.Types import qualified Data.Map.Strict as M-import System.FilePath +import System.FilePath import Paths_HPDF-import qualified Data.ByteString.Char8 as C +import qualified Data.ByteString.Char8 as C import Data.Char(digitToInt) import Data.Maybe(mapMaybe) -type PostscriptName = String +type PostscriptName = String -data Encodings = AdobeStandardEncoding +data Encodings = AdobeStandardEncoding | ZapfDingbatsEncoding deriving(Eq) -isLine :: C.ByteString -> Bool +isLine :: C.ByteString -> Bool isLine c | not (C.null c) = C.head c /= '#' | otherwise = False -from4Hexa :: C.ByteString -> Int +from4Hexa :: C.ByteString -> Int from4Hexa a = sum . map (\(x,y) -> x * y) $ zip (map digitToInt . C.unpack $ a) (map (\x -> 16^x) ([3,2,1,0] :: [Integer])) -from3Octal:: C.ByteString -> Int +from3Octal:: C.ByteString -> Int from3Octal a = sum . map (\(x,y) -> x * y) $ zip (map digitToInt . C.unpack $ a) (map (\x -> 8^x) ([2,1,0] :: [Integer])) @@ -54,15 +54,15 @@ toMacData _ = Nothing parseGlyphListEncoding :: String -> IO (M.Map PostscriptName Char)-parseGlyphListEncoding name = do - path <- getDataFileName name - l <- C.readFile path - return (M.fromList . mapMaybe (toData . C.split ';') . filter isLine . C.lines $ l)+parseGlyphListEncoding name = do+ path <- getDataFileName name+ l <- C.readFile path+ return (M.fromList . mapMaybe (toData . C.split ';') . filter isLine . C.lines $ l) parseMacEncoding :: IO (M.Map PostscriptName GlyphCode)-parseMacEncoding = do - path <- getDataFileName "Encodings/pdfencodings.txt" - l <- C.readFile path +parseMacEncoding = do+ path <- getDataFileName "Encodings/pdfencodings.txt"+ l <- C.readFile path return . M.fromList . mapMaybe (toMacData . C.split '\t') . tail . C.lines $ l
Graphics/PDF/Fonts/FontTypes.hs view
@@ -11,14 +11,15 @@ -- Private types for the fonts --------------------------------------------------------- -- #hide-module Graphics.PDF.Fonts.FontTypes(- GlyphSize- , FontSize - , FontStructure(..)- , GlyphPair(..)- , FontData(..)- , mkFlags- ) where+module Graphics.PDF.Fonts.FontTypes+ ( GlyphSize+ , FontSize + , FontStructure(..)+ , GlyphPair(..)+ , FontData(..)+ , mkFlags+ )+where import Graphics.PDF.LowLevel.Types import qualified Data.Map.Strict as M
Graphics/PDF/Fonts/Type1.hs view
@@ -65,7 +65,7 @@ instance PdfResourceObject Type1Font where toRsrc (Type1Font f ref) = - AnyPdfObject . PDFDictionary . M.fromList $+ AnyPdfObject . PDFDictionary . M.fromList $ [(PDFName "Type",AnyPdfObject . PDFName $ "Font") , (PDFName "Subtype",AnyPdfObject . PDFName $ "Type1") , (PDFName "BaseFont",AnyPdfObject . PDFName $ baseFont f)@@ -82,7 +82,7 @@ widths = map findWidth [firstChar .. lastChar] bbox = map AnyPdfObject .fontBBox $ f descriptor = PDFDictionary . M.fromList $ - [ (PDFName "Type",AnyPdfObject . PDFName $ "Font")+ [ (PDFName "Type",AnyPdfObject . PDFName $ "Font") , (PDFName "Subtype",AnyPdfObject . PDFName $ "Type1") , (PDFName "BaseFont",AnyPdfObject . PDFName $ baseFont f) , (PDFName "FontFile", AnyPdfObject ref)@@ -92,4 +92,4 @@ , (PDFName "Ascent",AnyPdfObject . PDFInteger . fromIntegral $ ascent f) , (PDFName "Descent",AnyPdfObject . PDFInteger . fromIntegral $ descent f) , (PDFName "CapHeight",AnyPdfObject . PDFInteger . fromIntegral $ capHeight f)- ]+ ]
Graphics/PDF/Image.hs view
@@ -78,8 +78,8 @@ m_sof0 = 0xc0 m_sof1 :: Int m_sof1 = 0xc1 ---m_sof2 :: Int ---m_sof2 = 0xc2 +m_sof2 :: Int +m_sof2 = 0xc2 m_sof3 :: Int m_sof3 = 0xc3 m_sof5 :: Int @@ -126,8 +126,8 @@ m_soi = 0xd8 m_eoi :: Int m_eoi = 0xd9 ---m_sos :: Int ---m_sos = 0xda+m_sos :: Int +m_sos = 0xda --m_dqt :: Int --m_dqt = 0xdb --m_dnl :: Int @@ -247,14 +247,24 @@ case sof of a | a `elem` [m_sof5,m_sof6,m_sof7,m_sof9,m_sof10,m_sof11,m_sof13,m_sof14,m_sof15] -> EXC.throwError "Unuspported compression mode"- | a `elem` [m_sof0,m_sof1,m_sof3] -> do+ | a `elem` [m_sof0,m_sof1,m_sof2,m_sof3] -> do _ <- readWord16 h bits_per_component <- readWord8 h height <- readWord16 h width <- readWord16 h color_space <- readWord8 h return (bits_per_component,height,width,color_space) - | a `elem` [m_soi,m_eoi,m_tem,m_rst0,m_rst1,m_rst2,m_rst3,m_rst4,m_rst5,m_rst6,m_rst7] -> parseJpegContent h+ | a `elem` [m_soi,m_tem,m_rst0,m_rst1,m_rst2,m_rst3,m_rst4,m_rst5,m_rst6,m_rst7] -> parseJpegContent h+ | a == m_sos -> let+ loop = do+ x <- readWord8 h+ if x /= 0xff then loop else do+ y <- readWord8 h+ if y == 0x00 then loop else do+ io $ hSeek h RelativeSeek (-2)+ parseJpegContent h+ in loop+ | a == m_eoi -> EXC.throwError "parseJpegContent: hit end of image (EOI) marker before getting JPEG metadata" | otherwise -> do l <- readWord16 h io $ hSeek h RelativeSeek (fromIntegral (l-2))
Graphics/PDF/LowLevel/Types.hs view
@@ -373,9 +373,9 @@ modifyStrict :: (MonadState s m) => (s -> s) -> m () modifyStrict f = do- s <- get- put $! (f s)- + s <- get+ put $! (f s)+ -- | A monad where paths can be created class MonadWriter Builder m => MonadPath m
Graphics/PDF/Typesetting.hs view
@@ -451,8 +451,8 @@ N -> (x - wc/2.0,y) S -> (x - wc/2.0,y + hc) box = withNewContext $ do- applyMatrix $ translate (dx :+ dy)- d+ applyMatrix $ translate (dx :+ dy)+ d r = Rectangle ((xa + dx) :+ (ya + dy)) ((xb + dx) :+ (yb + dy)) in (r,box)
HPDF.cabal view
@@ -1,5 +1,5 @@ Name: HPDF-Version: 1.5.0+Version: 1.5.1 cabal-version: >=1.10 License: BSD3 License-file:LICENSE@@ -18,9 +18,8 @@ Test/Penrose.hs Test/test.hs README.md- NEWS.txt TODO.txt- changelog+ changelog.md data-files: Core14_AFMs/Courier-Bold.afm Core14_AFMs/Helvetica-BoldOblique.afm@@ -91,7 +90,7 @@ hyphenation Default-language: Haskell2010 - ghc-options: -Wall -fno-warn-tabs -funbox-strict-fields -O2+ ghc-options: -Wall -funbox-strict-fields -O2 C-Sources: c/conversion.c@@ -117,8 +116,8 @@ Graphics.PDF.Shading Graphics.PDF.Typesetting Graphics.PDF.Documentation- Paths_HPDF Other-Modules:+ Paths_HPDF Graphics.PDF.LowLevel.Types Graphics.PDF.Fonts.FontTypes Graphics.PDF.Data.PDFTree
− NEWS.txt
@@ -1,1 +0,0 @@-
− changelog
@@ -1,2 +0,0 @@--
+ changelog.md view
@@ -0,0 +1,10 @@+# Changelog for [`HPDF` package](http://hackage.haskell.org/package/HPDF)++## 1.5.1++ * Fix JPEG support++## 1.5.0++ * Fix build with recent compilers+ * Use hyphenation package