module Data.Text.Glyphize.Buffer where
import Data.Text.Lazy as Lazy
import Data.ByteString.Lazy as Lazy
import Data.Text.Short
data Buffer = Buffer {
text :: Either Lazy.Text Lazy.ByteString,
contentType :: Maybe ContentType,
direction :: Maybe Direction,
script :: Maybe ShortText,
language :: Maybe ShortText,
beginsText :: Bool,
endsText :: Bool,
preserveDefaultIgnorables :: Bool,
removeDefaultIgnorables :: Bool,
don'tInsertDottedCircle :: Bool,
clusterLevel :: ClusterLevel,
invisibleGlyph :: Char,
notFoundGlyph :: Char,
replacementCodepoint :: Char
}
data ContentType = ContentTypeUnicode | ContentTypeGlyphs deriving (Eq, Show)
data Direction = DirLTR | DirRTL | DirTTB | DirBTT deriving (Eq, Show)
data ClusterLevel = ClusterMonotoneGraphemes | ClusterMonotoneChars | ClusterChars deriving (Eq, Show)
data GlyphInfo = GlyphInfo {
codepoint :: Int,
cluster :: Int
}
data GlyphPos = GlyphPos {
x_advance :: Int, y_advance :: Int,
x_offset :: Int, y_offset :: Int
}
-- guessSegmentProperties :: Buffer -> Buffer
-- glyphInfo & glyphPositions to be zipped & return from shape function
-- scriptHorizontalDir :: ShortText -> Direction
dirReverse DirLTR = DirRTL
dirReverse DirRTL = DirLTR
dirReverse DirTTB = DirBTT
dirReverse DirBTT = DirTTB
dirBackward dir = dir `Prelude.elem` [DirRTL, DirBTT]
dirForward dir = dir `Prelude.elem` [DirLTR, DirTTB]
dirHorizontal dir = dir `Prelude.elem` [DirLTR, DirRTL]
dirVertical dir = dir `Prelude.elem` [DirTTB, DirBTT]