packages feed

FTGL 1.2 → 1.4

raw patch · 2 files changed

+52/−44 lines, 2 filesdep −GLUTdep −OpenGLdep ~basenew-uploaderPVP ok

version bump matches the API change (PVP)

Dependencies removed: GLUT, OpenGL

Dependency ranges changed: base

API changes (from Hackage documentation)

- Graphics.Rendering.FTGL: data Font_Opaque
- Graphics.Rendering.FTGL: data Glyph_Opaque
- Graphics.Rendering.FTGL: data Layout_Opaque
+ Graphics.Rendering.FTGL: data FontOpaque
+ Graphics.Rendering.FTGL: data GlyphOpaque
+ Graphics.Rendering.FTGL: data LayoutOpaque
+ Graphics.Rendering.FTGL: getFontCharMapList :: Font -> Ptr CInt
+ Graphics.Rendering.FTGL: getLayoutError :: Layout -> IO CInt
+ Graphics.Rendering.FTGL: getLayoutFont :: Layout -> IO Font
+ Graphics.Rendering.FTGL: marshalCharMap :: CharMap -> CInt
+ Graphics.Rendering.FTGL: renderLayout :: Layout -> String -> IO ()
+ Graphics.Rendering.FTGL: setLayoutAlignment :: Layout -> TextAlignment -> IO ()
- Graphics.Rendering.FTGL: getFontAdvance :: Font -> String -> Float
+ Graphics.Rendering.FTGL: getFontAdvance :: Font -> String -> IO Float
- Graphics.Rendering.FTGL: getFontBBox :: Font -> String -> [Float]
+ Graphics.Rendering.FTGL: getFontBBox :: Font -> String -> IO [Float]
- Graphics.Rendering.FTGL: getFontError :: Font -> Int
+ Graphics.Rendering.FTGL: getFontError :: Font -> IO Int
- Graphics.Rendering.FTGL: getFontFaceSize :: Font -> Int
+ Graphics.Rendering.FTGL: getFontFaceSize :: Font -> IO Int
- Graphics.Rendering.FTGL: getLayoutAlignment :: Layout -> TextAlignment
+ Graphics.Rendering.FTGL: getLayoutAlignment :: Layout -> IO TextAlignment
- Graphics.Rendering.FTGL: getLayoutLineLength :: Layout -> Float
+ Graphics.Rendering.FTGL: getLayoutLineLength :: Layout -> IO Float
- Graphics.Rendering.FTGL: type Font = Ptr Font_Opaque
+ Graphics.Rendering.FTGL: type Font = Ptr FontOpaque
- Graphics.Rendering.FTGL: type Glyph = Ptr Glyph_Opaque
+ Graphics.Rendering.FTGL: type Glyph = Ptr GlyphOpaque
- Graphics.Rendering.FTGL: type Layout = Ptr Layout_Opaque
+ Graphics.Rendering.FTGL: type Layout = Ptr LayoutOpaque

Files

FTGL.cabal view
@@ -1,10 +1,10 @@ Name:           FTGL-Version:        1.2-Cabal-Version:  >= 1.2+Version:        1.4+Cabal-Version:  >= 1.6 License:        BSD3 License-File:   LICENSE Author:         J.R. Heard-Maintainer:     J.R. Heard+Maintainer:     Santtu Keskinen <laquendi@gmail.com> Category:       Graphics Description:       A Haskell binding for the portable TrueType to OpenGL font rendering library FTGL.@@ -14,8 +14,14 @@ Build-Type:     Simple  Library-   Build-Depends: OpenGL, GLUT, base-   Exposed-Modules:-      Graphics.Rendering.FTGL-   extra-libraries: ftgl+  Build-Depends: base >= 4 && < 5+  Exposed-Modules:+    Graphics.Rendering.FTGL+  extra-libraries: ftgl+  other-extensions: ForeignFunctionInterface, EmptyDataDecls+  ghc-options: -Wall -O2++source-repository head+  type:     git+  location: https://github.com/Laquendi/FTGL.git 
Graphics/Rendering/FTGL.hs view
@@ -1,6 +1,4 @@-{-# INCLUDE <FTGL/ftgl.h> #-}-{-# LANGUAGE ForeignFunctionInterface #-}-{-# OPTIONS_GHC -O2 -fglasgow-exts #-}+{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls #-} -- | * Author: Jefferson Heard (jefferson.r.heard at gmail.com) -- --   * Copyright 2008 Renaissance Computing Institute < http://www.renci.org > @@ -23,10 +21,11 @@ -- -- Fonts are rendered so that a single point is an OpenGL unit, and a point is 1:72 of -- an inch.+ module Graphics.Rendering.FTGL  where -import Foreign (unsafePerformIO)+import System.IO.Unsafe(unsafePerformIO) import Foreign.C import Foreign.Ptr import Foreign.Marshal.Alloc@@ -34,8 +33,6 @@ import Data.Bits  import Data.Char (ord) -import qualified Graphics.Rendering.OpenGL.GL as GL- import Control.Applicative ((<$>))  foreign import ccall unsafe "ftglCreateBitmapFont" fcreateBitmapFont :: CString -> IO Font@@ -51,7 +48,7 @@ -- | a string in a texture, "buffering" it before rendering.  Very fast if you -- | will be repeatedly rendering the same strings over and over. createBufferFont :: String -> IO Font-createBufferFont file = withCString file $ \p -> fcreateBufferFont p+createBufferFont file = withCString file fcreateBufferFont   foreign import ccall unsafe "ftglCreateOutlineFont" fcreateOutlineFont :: CString -> IO Font@@ -59,7 +56,7 @@ -- | and will scale independently without loss of quality.  Faster than polygons -- | but slower than texture or buffer fonts. createOutlineFont :: String -> IO Font-createOutlineFont file = withCString file $ \p -> fcreateOutlineFont p+createOutlineFont file = withCString file fcreateOutlineFont   foreign import ccall unsafe "ftglCreatePixmapFont" fcreatePixmapFont  :: CString -> IO Font@@ -67,7 +64,7 @@ -- | font without losing any performance.  Use this if you don't mind using -- | set and get RasterPosition. createPixmapFont :: String -> IO Font-createPixmapFont file = withCString file $ \p -> fcreatePixmapFont p+createPixmapFont file = withCString file fcreatePixmapFont   foreign import ccall unsafe "ftglCreatePolygonFont" fcreatePolygonFont :: CString -> IO Font@@ -77,7 +74,7 @@ -- | Additionally, they do not, unlike the textured fonts, create artifacts -- | within the square formed at the edge of each character. createPolygonFont :: String -> IO Font-createPolygonFont file = withCString file $ \p -> fcreatePolygonFont p+createPolygonFont file = withCString file fcreatePolygonFont   foreign import ccall unsafe "ftglCreateTextureFont" fcreateTextureFont :: CString -> IO Font@@ -87,7 +84,7 @@ -- | well to text that changes with most frames, because it doesn't incur the -- | (normally helpful) overhead of buffering. createTextureFont :: String -> IO Font-createTextureFont file = withCString file $ \p -> fcreateTextureFont p+createTextureFont file = withCString file fcreateTextureFont   foreign import ccall unsafe "ftglCreateExtrudeFont" fcreateExtrudeFont :: CString -> IO Font@@ -96,7 +93,7 @@ -- | effects by warping the otherwise square nature of the font.  Polygonal. -- | Scales without losing quality.  Slower than all other fonts. createExtrudeFont :: String -> IO Font-createExtrudeFont file = withCString file $ \p -> fcreateExtrudeFont p+createExtrudeFont file = withCString file fcreateExtrudeFont   @@ -110,7 +107,8 @@  foreign import ccall unsafe "ftglGetLayoutFont" fgetLayoutFont :: Layout -> IO Font -- | Get the embedded font from the Layout-getLayoutFont f = unsafePerformIO $ fgetLayoutFont f +getLayoutFont :: Layout -> IO Font+getLayoutFont = fgetLayoutFont    -- | Set the line length, I believe in OpenGL units, although I'm not sure.@@ -119,19 +117,20 @@  foreign import ccall unsafe "ftglGetLayoutLineLength" fgetLayoutLineLength :: Layout -> IO CFloat -- | Get the line length in points (1:72in) of lines in the layout-getLayoutLineLength :: Layout -> Float-getLayoutLineLength f = realToFrac . unsafePerformIO $ fgetLayoutLineLength f+getLayoutLineLength :: Layout -> IO Float+getLayoutLineLength f = realToFrac <$> fgetLayoutLineLength f   foreign import ccall unsafe "ftglSetLayoutAlignment" fsetLayoutAlignment :: Layout -> CInt -> IO () -- | Set the layout alignment+setLayoutAlignment :: Layout -> TextAlignment -> IO () setLayoutAlignment layout alignment = fsetLayoutAlignment layout (marshalTextAlignment alignment)   foreign import ccall unsafe "ftglGetLayoutAlignement" fgetLayoutAlignment :: Layout -> IO CInt -- | Get the alignment of text in this layout.-getLayoutAlignment :: Layout -> TextAlignment-getLayoutAlignment f = readTextAlignment . unsafePerformIO $ fgetLayoutAlignment f+getLayoutAlignment :: Layout -> IO TextAlignment+getLayoutAlignment f = readTextAlignment <$> fgetLayoutAlignment f   foreign import ccall unsafe "ftglSetLayoutLineSpacing" fsetLayoutLineSpacing :: Layout -> CFloat -> IO ()@@ -168,6 +167,7 @@  foreign import ccall unsafe "ftglGetFontCharMapList" fgetFontCharMapList  :: Font -> IO (Ptr CInt) -- | Get the different character mappings available in this font.+getFontCharMapList :: Font -> Ptr CInt getFontCharMapList f = unsafePerformIO $ fgetFontCharMapList f  @@ -177,8 +177,8 @@  foreign import ccall unsafe "ftglGetFontFaceSize" fgetFontFaceSize :: Font -> IO CInt -- | Get the current font face size in points.-getFontFaceSize :: Font -> Int-getFontFaceSize f = fromIntegral . unsafePerformIO $ fgetFontFaceSize f+getFontFaceSize :: Font -> IO Int+getFontFaceSize f = fromIntegral <$> fgetFontFaceSize f   foreign import ccall unsafe "ftglSetFontDepth" fsetFontDepth :: Font -> CFloat -> IO ()@@ -193,9 +193,8 @@  foreign import ccall unsafe "ftglGetFontBBox" fgetFontBBox :: Font -> CString -> Int -> Ptr CFloat -> IO ()  -- | Get the text extents of a string as a list of (llx,lly,lly,urx,ury,urz)-getFontBBox :: Font -> String -> [Float]-getFontBBox f s = unsafePerformIO $ -                   allocaBytes 24 $ \pf -> +getFontBBox :: Font -> String -> IO [Float]+getFontBBox f s = allocaBytes 24 $ \pf ->                       withCString s $ \ps -> do                         fgetFontBBox f ps (-1) pf                        map realToFrac <$> peekArray 6 pf@@ -219,21 +218,20 @@ foreign import ccall unsafe "ftglGetFontAdvance" fgetFontAdvance :: Font -> CString -> IO CFloat -- | Get the horizontal span of a string of text using the current font.  Input as the xcoord -- | in any translate operation-getFontAdvance :: Font -> String -> Float-getFontAdvance font str = realToFrac . unsafePerformIO $ withCString str $ \p -> fgetFontAdvance font p +getFontAdvance :: Font -> String -> IO Float+getFontAdvance font str = realToFrac <$> withCString str (fgetFontAdvance font)   foreign import ccall unsafe "ftglRenderFont" frenderFont :: Font -> CString -> CInt -> IO () -- | Render a string of text in the current font. renderFont :: Font -> String -> RenderMode -> IO ()-renderFont font str mode = withCString str $ \p -> do -	frenderFont font p (marshalRenderMode mode)+renderFont font str mode = withCString str $ \p -> frenderFont font p (marshalRenderMode mode)   foreign import ccall unsafe "ftglGetFontError" fgetFontError :: Font -> IO CInt -- | Get any errors associated with loading a font. FIXME return should be a type, not an Int.-getFontError :: Font -> Int-getFontError f = fromIntegral . unsafePerformIO $ fgetFontError f+getFontError :: Font -> IO Int+getFontError f = fromIntegral <$> fgetFontError f   @@ -243,12 +241,14 @@  foreign import ccall unsafe "ftglRenderLayout" frenderLayout :: Layout -> CString -> IO () -- | Render a string of text within a layout.-renderLayout layout str = withCString str $ \strPtr -> do frenderLayout layout strPtr+renderLayout :: Layout -> String -> IO ()+renderLayout layout str = withCString str $ \strPtr -> frenderLayout layout strPtr   foreign import ccall unsafe "ftglGetLayoutError" fgetLayoutError :: Layout -> IO CInt -- | Get any errors associated with a layout.-getLayoutError f = unsafePerformIO $ fgetLayoutError f+getLayoutError :: Layout -> IO CInt+getLayoutError = fgetLayoutError   @@ -278,19 +278,20 @@ readTextAlignment 1 = AlignCenter readTextAlignment 2 = AlignRight readTextAlignment 3 = Justify+readTextAlignment _ = undefined  -- | An opaque type encapsulating a glyph in C.  Currently the glyph functions are unimplemented in Haskell.-data Glyph_Opaque +data GlyphOpaque   -- | An opaque type encapsulating a font in C.-data Font_Opaque+data FontOpaque  -- | An opaque type encapsulating a layout in C-data Layout_Opaque+data LayoutOpaque -type Glyph = Ptr Glyph_Opaque-type Font = Ptr Font_Opaque-type Layout = Ptr Layout_Opaque+type Glyph = Ptr GlyphOpaque+type Font = Ptr FontOpaque+type Layout = Ptr LayoutOpaque   data CharMap = @@ -314,8 +315,9 @@     (fromIntegral (ord a) `shift` 24)      .|. (fromIntegral (ord b) `shift` 16)      .|. (fromIntegral (ord c) `shift` 8) -    .|. (fromIntegral (ord d))+    .|. fromIntegral (ord d) +marshalCharMap :: CharMap -> CInt marshalCharMap EncodingNone = 0 marshalCharMap EncodingMSSymbol = encodeTag 's' 'y' 'm' 'b' marshalCharMap EncodingUnicode =encodeTag 'u' 'n' 'i' 'c'