~alcinnz/harfbuzz-pure

harfbuzz-pure/Main.hs -rw-r--r-- 807 bytes
4fd909d1 — Adrian Cochrane Fix & expand type signatures. 7 months ago
                                                                                
c0f7026e Adrian Cochrane
f2772de8 Adrian Cochrane
b7564ba8 Adrian Cochrane
843f6415 Adrian Cochrane
c0f7026e Adrian Cochrane
5b7beb1f Adrian Cochrane
c0f7026e Adrian Cochrane
f2772de8 Adrian Cochrane
843f6415 Adrian Cochrane
5b7beb1f Adrian Cochrane
843f6415 Adrian Cochrane
c0f7026e Adrian Cochrane
843f6415 Adrian Cochrane
c0f7026e Adrian Cochrane
b7564ba8 Adrian Cochrane
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{-# LANGUAGE PackageImports, OverloadedStrings #-}
module Main where

import "harfbuzz-pure" Data.Text.Glyphize
import Control.Parallel.Strategies (parMap, rdeepseq)

import Data.Text.Lazy (pack)
import qualified Data.ByteString as BS
import System.Environment (getArgs)

shapeStr font word = shape font defaultBuffer { text = pack word } []

main :: IO ()
main = do
    print versionString
    words <- getArgs
    if Prelude.null words
    then print $ guessSegmentProperties $ defaultBuffer { text = "Testing, testing"}
    else do
      blob <- BS.readFile "assets/Lora-Regular.ttf"
      let font = createFont $ createFace blob 0
      case words of
        "!":words' -> print $ shape font (defaultBuffer { text = pack $ unwords words' }) []
        _ -> print $ parMap rdeepseq (shapeStr font) words