module Data.Text.Glyphize where
import Data.Text.Glyphize.Buffer
import Data.Text.Glyphize.Font
import Foreign.Ptr
import Foreign.ForeignPtr
import System.IO.Unsafe (unsafePerformIO)
foreign import ccall "hb_shape" hb_shape :: Font_ -> Buffer_ -> Ptr () -> Int -> IO ()
shape :: Font -> Buffer -> [(GlyphInfo, GlyphPos)]
shape font buf = unsafePerformIO $ do
buf_ <- freeze' buf
withForeignPtr font $ \font' -> withForeignPtr buf_ $ \buf' ->
hb_shape font' buf' nullPtr 0
infos <- glyphInfos' buf_
pos <- glyphsPos' buf_
return $ zip infos pos
-- Defer implementing font features...
-- version :: (Int, Int, Int)
-- versionAtLeast :: (Int, Int, Int) -> Bool
-- versionString :: ShortString