summaryrefslogtreecommitdiff
path: root/Com/MusicMeetsComics/Look/Typography.hs
blob: 91e157af05361de73b6e5886ef265920aa7dc9d0 (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Com.MusicMeetsComics.Look.Typography where

import           Clay
import           Clay.Stylesheet (key)
import qualified Com.MusicMeetsComics.Assets as Assets
import           Com.Simatime.Alpha
import           Data.Semigroup ((<>))
import           Protolude

main :: Css
main = fonts

---------------------------------------------------------------------------------
-- font modifiers
---------------------------------------------------------------------------------

euro, slim, wide, thicc, thinn, norm, lean,
    smol, lower, upper :: Css

euro  = fontFamily ["Eurostile"] [sansSerif]

-- stretch
slim  = fontStretch condensed
wide  = fontStretch expanded

-- weight
thicc = fontWeight bold
thinn = fontWeight normal

-- style
norm  = fontStyle normal
lean  = fontStyle italic

-- "smallcaps" is already taken by Clay
smol  = fontVariant smallCaps

lower = textTransform lowercase
upper = textTransform uppercase

---------------------------------------------------------------------------------
-- font sizing
---------------------------------------------------------------------------------

-- | apparently "coat" is a synonym for "size"
coat :: Double -> Css
coat = fontSize . Clay.rem

---------------------------------------------------------------------------------
-- font faces
---------------------------------------------------------------------------------

fontRoot :: Text
fontRoot = Assets.cdnEdge <> "/old-assets/fonts/eurostile/Eurostile"

fonts :: Css
fonts = mconcat $ mkEuro /@
    [ ("-Reg.otf", OpenType, fontWeight normal <> fontStyle normal)
    , ("LTStd-Bold.otf", OpenType, thicc <> norm)
    , ("LTStd-Cn.otf", OpenType, slim <> norm)
    , ("LTStd-Ex2.otf", OpenType, wide <> norm)
    , ("LTStd-BoldCn.otf", OpenType, slim <> thicc)
    , ("LTStd-BoldEx2.otf", OpenType, wide <> thicc)
    ]
    where
        mkEuro :: (Text, FontFaceFormat, Css) -> Css
        mkEuro (sufx, fmt, extra) = fontFace $ do
            fontFamily ["Eurostile"] []
            fontFaceSrc [FontFaceSrcUrl (fontRoot <> sufx) $ Just fmt]
            extra


---------------------------------------------------------------------------------
-- TODO: add the below to Clay.Font upstream
---------------------------------------------------------------------------------

newtype FontStretch = FontStretch Value
    deriving (Val, Inherit, Normal, Other)

expanded :: FontStretch
expanded = FontStretch "expanded"

condensed :: FontStretch
condensed = FontStretch "condensed"

fontStretch :: FontStretch -> Css
fontStretch = key "font-stretch"