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
module Data.Text.ParagraphLayout.FontLoader
(arabicFont
,devanagariFont
,latinFont
,loadFont
)
where
import Data.ByteString (readFile)
import Data.Text.Glyphize
(Font
,FontOptions
,createFace
,createFontWithOptions
)
import Data.Word (Word)
import Prelude (return)
import System.FilePath (FilePath, (</>))
import System.IO (IO)
arabicFont :: FilePath
arabicFont = "assets" </> "fonts" </> "plex" </> "IBMPlexSansArabic-Regular.ttf"
devanagariFont :: FilePath
devanagariFont = "assets" </> "fonts" </> "sarala" </> "Sarala-Regular.ttf"
latinFont :: FilePath
latinFont = "assets" </> "fonts" </> "ubuntu" </> "Ubuntu-R.ttf"
loadFont :: FilePath -> Word -> FontOptions -> IO Font
loadFont path index opts = do
ttf <- readFile path
let face = createFace ttf index
let font = createFontWithOptions opts face
return font