never executed always true always false
    1 {-|
    2 Module: Flaw.Graphics.Font
    3 Description: Fonts.
    4 License: MIT
    5 -}
    6 
    7 module Flaw.Graphics.Font
    8   ( Glyphs(..)
    9   , GlyphInfo(..)
   10   , FontShaper(..)
   11   , ShapedGlyph(..)
   12   , FontScript(..)
   13   , fontScriptUnknown
   14   ) where
   15 
   16 import qualified Data.ByteString as B
   17 import qualified Data.HashMap.Strict as HM
   18 import qualified Data.Text as T
   19 import qualified Data.Vector as V
   20 import Data.Word
   21 
   22 import Flaw.Graphics.Texture
   23 import Flaw.Math
   24 
   25 data Glyphs = Glyphs
   26   { glyphsTextureInfo :: !TextureInfo
   27   , glyphsTextureData :: !B.ByteString
   28   , glyphsInfos :: !(HM.HashMap Int GlyphInfo)
   29   , glyphsScaleX :: {-# UNPACK #-} !Int
   30   , glyphsScaleY :: {-# UNPACK #-} !Int
   31   }
   32 
   33 data GlyphInfo = GlyphInfo
   34   {
   35   -- Size of glyph on texture.
   36     glyphWidth :: {-# UNPACK #-} !Int
   37   , glyphHeight :: {-# UNPACK #-} !Int
   38   -- Coordinates of left-top corner on texture.
   39   , glyphLeftTopX :: {-# UNPACK #-} !Int
   40   , glyphLeftTopY :: {-# UNPACK #-} !Int
   41   -- Offset from pen point to left-top corner.
   42   , glyphOffsetX :: {-# UNPACK #-} !Int
   43   , glyphOffsetY :: {-# UNPACK #-} !Int
   44   }
   45 
   46 class FontShaper a where
   47   -- | Shape multiple text parts and return lists of glyphs (position, glyph index) with final positions.
   48   shapeText :: a -> [T.Text] -> FontScript -> IO [(V.Vector ShapedGlyph, Float2)]
   49 
   50 data ShapedGlyph = ShapedGlyph
   51   { shapedGlyphPosition :: {-# UNPACK #-} !Float2
   52   , shapedGlyphIndex :: {-# UNPACK #-} !Int
   53   }
   54 
   55 -- | Font script.
   56 -- Contains 4-letter script code (according to http://unicode.org/iso15924/iso15924-codes.html),
   57 -- big-endian encoded.
   58 newtype FontScript = FontScript Word32
   59 
   60 fontScriptUnknown :: FontScript
   61 fontScriptUnknown = FontScript 0