@@ 142,9 142,16 @@ instance Storable GlyphPos where
pokeElemOff q 2 xoff
pokeElemOff q 3 yoff
--- guessSegmentProperties :: Buffer -> Buffer
--- glyphInfo & glyphPositions to be zipped & return from shape function
--- scriptHorizontalDir :: ShortText -> Direction
+guessSegmentProperties :: Buffer -> Buffer
+guessSegmentProperties = thaw . freeze
+scriptHorizontalDir :: ShortText -> Maybe Direction
+scriptHorizontalDir script =
+ case hb_script_get_horizontal_direction $ hb_script_from_txt script of
+ 4 -> Just DirLTR
+ 5 -> Just DirRTL
+ 6 -> Just DirTTB
+ 7 -> Just DirBTT
+ _ -> Nothing
dirReverse DirLTR = DirRTL
dirReverse DirRTL = DirLTR
@@ 306,6 313,8 @@ hb_script_from_string str = hb_tag_from_string $ case titlecase str of
hb_script_from_txt txt = hb_script_from_string $ Short.toString txt
foreign import ccall "hb_buffer_set_script" hb_buffer_set_script
:: Ptr Buffer'' -> Word32 -> IO ()
+foreign import ccall "hb_script_get_horizontal_direction" hb_script_get_horizontal_direction
+ :: Word32 -> Int
foreign import ccall "hb_language_from_string" hb_language_from_string
:: Ptr Word8 -> Int -> Int
hb_language_from_txt txt = let Strict.PS ptr offset size = toByteString txt