~alcinnz/fontconfig-pure

ref: 866ea3d2d38b232014081d67c198a73620f1414c fontconfig-pure/fontconfig-harfbuzz/app/Main.hs -rw-r--r-- 1.0 KiB
866ea3d2 — Adrian Cochrane Start implementing a seperate bridge module to Harfbuzz. 1 year, 10 months 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
{-# LANGUAGE OverloadedStrings #-}
module Main where

import Graphics.UI.GLUT
import Graphics.GL.Core32

import FreeType.Core.Base
import FreeType.FontConfig

import Graphics.Text.Font.Choose as Font

import System.Environment (getArgs)
import System.Exit (exitFailure)
import Data.Function (fix)
import Control.Monad (unless)
import Data.Maybe (fromMaybe)

main :: IO ()
main = do
    (progName, args) <- getArgsAndInitialize

    w <- createWindow progName

    args <- getArgs
    let query = nameParse $ case args of
            [] -> "serif"
            (q:_) -> q
    let query' = defaultSubstitute $ configSubstitute' query MatchPattern
    font <- case fontSort' query' False of
        Just (f:_, _) -> return f
        _ -> do
            putStrLn ("Failed to locate font " ++ show query)
            exitFailure

    ft_With_FreeType $ \ft -> do
        inst <- instantiatePattern ft font (fromMaybe 12 $ getValue' "size" font, 20)
        let text = shape 

        displayCallback $= do
            clear [ ColorBuffer ]
            flush
        mainLoop