-
Notifications
You must be signed in to change notification settings - Fork 14
Text Metrics
Andy Gill edited this page Dec 6, 2019
·
7 revisions
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified Data.Text as Text
import Graphics.Blank
import Prelude.Compat
main :: IO ()
main = blankCanvas 3000 $ \ context -> do
send context $ do
let x = width context / 2
let y = height context / 2 - 10;
let text = "Hello World!"
font "30pt Calibri"
textAlign "center"
fillStyle "blue"
fillText(text, x, y)
TextMetrics w <- measureText text
font "20pt Calibri"
textAlign "center"
fillStyle "#555"
fillText("(" <> Text.pack (show w) <> "px wide)", x, y + 40)