~alcinnz/harfbuzz-pure

ref: 5b7beb1fa0df5d230a736b8a7eda0fd0d66ef854 harfbuzz-pure/Data/Text/Glyphize.hs -rw-r--r-- 708 bytes
5b7beb1f — Adrian Cochrane Add, test, & fix shaping function. 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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