~alcinnz/harfbuzz-pure

ref: 8de69f1069d43cdc2f7895abf809a529821f2748 harfbuzz-pure/Data/Text/Glyphize/Buffer.hs -rw-r--r-- 1.5 KiB
8de69f10 — Adrian Cochrane FreeType integration is not threadsafe, not that in API design. 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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]