2024-02-07 10:40:00 +01:00
|
|
|
|
{- This Source Code Form is subject to the terms of the Mozilla Public License,
|
|
|
|
|
v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
|
|
|
obtain one at https://mozilla.org/MPL/2.0/. -}
|
|
|
|
|
|
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
|
|
|
|
|
module Graphics.Fountainhead.MetricsSpec
|
|
|
|
|
( spec
|
|
|
|
|
) where
|
|
|
|
|
|
|
|
|
|
import Graphics.Fountainhead.Metrics
|
|
|
|
|
import Test.Hspec (Spec, describe, it, shouldBe)
|
2024-02-11 18:50:25 +01:00
|
|
|
|
import qualified Data.ByteString as ByteString
|
2024-02-07 10:40:00 +01:00
|
|
|
|
|
|
|
|
|
spec :: Spec
|
|
|
|
|
spec =
|
|
|
|
|
describe "collectMetrics" $
|
|
|
|
|
it "collects information from the name table" $ do
|
2024-02-11 18:50:25 +01:00
|
|
|
|
let fontPath = "./fonts/OpenSans-Bold.ttf"
|
|
|
|
|
expected = FontDescriptor
|
|
|
|
|
{ fontName = "OpenSans−Bold"
|
|
|
|
|
, flags = [] -- 4
|
|
|
|
|
, ascender = 1068
|
|
|
|
|
, descender = -292
|
|
|
|
|
, fontBBox = FontBBox (-548) (-271) 1201 1047
|
|
|
|
|
, italicAngle = 0
|
|
|
|
|
, capHeight = 714
|
|
|
|
|
, stemV = 105
|
|
|
|
|
, missingWidth = 600
|
2024-02-07 10:40:00 +01:00
|
|
|
|
}
|
2024-02-11 18:50:25 +01:00
|
|
|
|
openSansBoldItalic <- ByteString.readFile fontPath
|
|
|
|
|
collectMetrics fontPath openSansBoldItalic `shouldBe` Right expected
|