~alcinnz/harfbuzz-pure

ref: 6ae7e1b9cdedbcad2371f7343734569842304601 harfbuzz-pure/Main.hs -rw-r--r-- 856 bytes
6ae7e1b9 — Adrian Cochrane Fix reentrancy complaints from GHC, attempt to fix segfault. 2 years ago
                                                                                
f2772de8 Adrian Cochrane
5b7beb1f Adrian Cochrane
f2772de8 Adrian Cochrane
144c40db Adrian Cochrane
5b7beb1f Adrian Cochrane
843f6415 Adrian Cochrane
5b7beb1f Adrian Cochrane
f2772de8 Adrian Cochrane
843f6415 Adrian Cochrane
5b7beb1f Adrian Cochrane
843f6415 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
25
26
27
28
29
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where

import "harfbuzz-pure" Data.Text.Glyphize
import "harfbuzz-pure" Data.Text.Glyphize.Buffer
import "harfbuzz-pure" Data.Text.Glyphize.Font

import Control.Parallel.Strategies (parMap, rpar)

import System.Environment
import Data.ByteString.Lazy as LBS
import Data.ByteString as BS
import Data.ByteString.Char8 as UTF8

shapeStr font word = shape font $ defaultBuffer {
    text = Right $ LBS.fromStrict $ UTF8.pack word
  }

main :: IO ()
main = do
    print versionString
    words <- getArgs
    if Prelude.null words
    then print $ guessSegmentProperties $ defaultBuffer { text = Right "Testing, testing"}
    else do
      blob <- BS.readFile "assets/Lora-Regular.ttf"
      let font = createFont $ createFace blob 0
      print $ parMap rpar (shapeStr font) words