@@ -23,14 +23,15 @@ import Html.Attributes
25type alias FontAdjustment =
25type alias FontAdjustment =
26− { capital : Adjustment
27+ , capital : Line
27− , lowercase : Adjustment
28+ , lowercase : Line
28− , baseline : Adjustment
29+ , baseline : Line
29− , descender : Adjustment
30+ , descender : Line
33−type alias Adjustment =
34+type alias Line =
@@ -42,20 +43,30 @@ edges =
42 { top = 0, right = 0, bottom = 0, left = 0 }
43 { top = 0, right = 0, bottom = 0, left = 0 }
46 { adjustment =
56 { adjustment =
47− { capital = 0.07
57+ default
48− , lowercase = 0.57
58+ , converted =
49− , baseline = 0.265
59+ convertAdjustment default
55update msg model =
63update msg model =
56 case msg of
64 case msg of
57 UpdateAdjustment adj ->
65 UpdateAdjustment adj ->
58− { model | adjustment = adj }
67+ | adjustment = adj
68+ , converted = convertAdjustment adj
@@ -71,15 +82,26 @@ view model =
71 [ Background.color (rgba 1 1 1 1)
82 [ Background.color (rgba 1 1 1 1)
72 , Font.color (rgba 0 0 0 1)
83 , Font.color (rgba 0 0 0 1)
73 , Font.family
84 , Font.family
74− [ Font.external
85+ [ -- Font.external
75− { url = "https://fonts.googleapis.com/css?family=EB+Garamond"
86+ -- { url = "https://fonts.googleapis.com/css?family=EB+Garamond"
76− , name = "EB Garamond"
87+ -- , name = "EB Garamond"
90+ { url = "https://fonts.googleapis.com/css?family=Catamaran"
78 , Font.sansSerif
93 , Font.sansSerif
97+ column [ width fill, height fill, spacing 128 ]
82− adjustor 240 model.adjustment
98+ [ adjustor 120 model.adjustment
99+ , adjusted 120 model.converted
104+ htmlAttribute (Html.Attributes.style name val)
85fontSize pixels lineHeight up =
107fontSize pixels lineHeight up =
@@ -103,9 +125,159 @@ charcoal =
103 rgb 0.7 0.7 0.7
125 rgb 0.7 0.7 0.7
128+adjustor size adjustment =
131+ [ viewAdjustment "Type Height" adjustment.capital size 180 adjustment.lineHeight (\capital -> { adjustment | capital = capital })
132+ , viewAdjustment "Lowercase Height" adjustment.lowercase size 60 adjustment.lineHeight (\lowercase -> { adjustment | lowercase = lowercase })
133+ , viewAdjustment "Baseline" adjustment.baseline size 120 adjustment.lineHeight (\baseline -> { adjustment | baseline = baseline })
134+ , viewAdjustment "Descender" adjustment.descender size 0 adjustment.lineHeight (\descender -> { adjustment | descender = descender })
140+ , Background.color (rgb 0 0.8 0.9)
141+ , style "line-height" (String.fromFloat adjustment.lineHeight)
147+ -- , height (px (round (toFloat size * (1 / 1.5))))
149+ , Background.color (rgb 0.9 0.8 0)
160+adjusted size adjustment =
168+ [ Background.color (rgb 0 0.8 0.9)
169+ , style "line-height" "normal"
170+ , above (el [ Font.size 12 ] (text "line-height: normal"))
174+ [ Background.color (rgb 0 0.8 0.9)
175+ , style "line-height" "1"
176+ , above (el [ Font.size 12 ] (text "line-height: 1"))
179+ , corrected adjustment.full "corrected"
180+ , corrected adjustment.capital "corrected capital"
181+ , paragraph [ Font.size 25, spacing 5, width (px 200) ]
182+ [ el [ Font.size 55, alignLeft ] (text "L")
183+ , text "orem Ipsum is simply dummy text of the printing and typesetting industry."
188+corrected converted label =
190+ [ Background.color (rgb 0 0.8 0.9)
191+ , style "display" "block"
192+ , above (el [ Font.size 12, moveUp 6 ] (text label))
193+ , style "line-height" (String.fromFloat converted.height)
195+ (column [ Font.size 12, spacing 5, moveDown 10 ]
196+ [ text ("height: " ++ String.left 5 (String.fromFloat converted.height))
197+ , text ("vertical: " ++ String.left 5 (String.fromFloat converted.vertical))
202+ [ style "display" "inline-block"
203+ , style "line-height" (String.fromFloat converted.height)
204+ , style "vertical-align" (String.fromFloat converted.vertical ++ "em")
210+convertAdjustment adjustment =
213+ adjustment.lineHeight
216+ (adjustment.lineHeight - 1)
220+ adjustment.lineHeight / 2
223+ ((ascender - newBaseline) / 2) + newBaseline
226+ ((ascender - descender) / 2) + descender
229+ [ adjustment.capital
230+ , adjustment.baseline
231+ , adjustment.descender
232+ , adjustment.lowercase
236+ Maybe.withDefault adjustment.capital (List.maximum lines)
239+ Maybe.withDefault adjustment.descender (List.minimum lines)
243+ |> List.filter (\x -> x /= descender)
245+ |> Maybe.withDefault adjustment.baseline
250+ (oldMiddle - newCapitalMiddle) * 2
253+ (oldMiddle - newFullMiddle) * 2
256+ { vertical = fullVertical
258+ (ascender - descender)
262+ { vertical = capitalVertical
263+ , height = (ascender - newBaseline) - abs capitalVertical
106−viewAdjustment label adjustment size left updateWith =
268+viewAdjustment label adjustment size left lineHeight updateWith =
277+ -- , moveUp (0.125 * toFloat size)
108− (el [ moveLeft left, moveUp (0.25 * toFloat size), height (px (round (toFloat size * 1.5))) ] <|
278+ , height (px (round (toFloat size * lineHeight)))
109 Input.slider
281 Input.slider
110 [ Font.size 24
282 [ Font.size 24
111 , Element.behindContent
283 , Element.behindContent
@@ -118,13 +290,32 @@ viewAdjustment label adjustment size left updateWith =
119 Element.none
291 Element.none
121− , height (px (round (toFloat size * 1.5)))
293+ , height (px (round fullHeight))
122 , width (px 1)
294 , width (px 1)
123 , Background.color charcoal
296 , Background.color charcoal
124 , below (el [ centerX ] (text (String.fromFloat adjustment)))
297 , below (el [ centerX ] (text (String.fromFloat adjustment)))
304+ , moveUp (fullHeight * (adjustment / lineHeight))
305+ , Border.color (rgb 0 0 0)
126 { label = Input.labelAbove [ Font.size 18 ] (text "")
317 { label = Input.labelAbove [ Font.size 18 ] (text "")
127− , max = 1.0
318+ , max = lineHeight
128 , min = 0
319 , min = 0
129 , onChange =
320 , onChange =
@@ -139,37 +330,24 @@ viewAdjustment label adjustment size left updateWith =
139 , Border.width 1
330 , Border.width 1
140 , Border.color (Element.rgb 0.5 0.5 0.5)
331 , Border.color (Element.rgb 0.5 0.5 0.5)
141 , Background.color (Element.rgb 1 1 1)
332 , Background.color (Element.rgb 1 1 1)
142− , onRight
334+ -- , onRight
144− [ height (px 0)
336+ -- [ height (px 0)
145− , width (px 1200)
337+ -- , width (px 1200)
146− , moveDown 8
338+ -- , moveDown 8
147− , Border.color charcoal
339+ -- , Border.color (rgb 0 0 0)
148− , Border.dashed
340+ -- , Border.dashed
149− , Border.widthEach
341+ -- , Border.widthEach
150− { top = 1
342+ -- { top = 1
151− , right = 0
343+ -- , right = 0
152− , bottom = 0
344+ -- , bottom = 0
153− , left = 0
345+ -- , left = 0
159 , value = adjustment
351 , value = adjustment
164−adjustor size adjustment =
167− [ viewAdjustment "Type Height" adjustment.capital size 180 (\capital -> { adjustment | capital = capital })
168− , viewAdjustment "Lowercase Height" adjustment.lowercase size 60 (\lowercase -> { adjustment | lowercase = lowercase })
169− , viewAdjustment "Baseline" adjustment.baseline size 120 (\baseline -> { adjustment | baseline = baseline })
170− , viewAdjustment "Descender" adjustment.descender size 0 (\descender -> { adjustment | descender = descender })
174− ([ centerX, centerY ] ++ labels ++ fontSize size "1.0" 0)