1module Main exposing (main)
3{-| Line Height as its specified through CSS doesn't make a whole lot of sense typographically.
5We also run into issues with sizing a font. The font size generally refers to the full type size (from the top of ascendors to the bottom of descenders)
7However, sometimes we might want to size things from the top of the Capital to the baseline.
9Or from the top of the x-height to the baseline.
11The main place this shows up is for dropped capitals, and for text on buttons.
16import Element exposing (..)
17import Element.Background as Background
18import Element.Border as Border
19import Element.Font as Font
20import Element.Input as Input
25type alias FontAdjustment =
39 = UpdateAdjustment FontAdjustment
63 convertAdjustment default
69 UpdateAdjustment adj ->
72 , converted = convertAdjustment adj
86 [ Background.color (rgba 1 1 1 1)
87 , Font.color (rgba 0 0 0 1)
90 -- { url = "https://fonts.googleapis.com/css?family=EB+Garamond"
91 -- , name = "EB Garamond"
94 { url = "https://fonts.googleapis.com/css?family=Catamaran"
101 column [ width fill, height fill, spacing 128 ]
102 [ adjustor 120 model.adjustment
103 , adjusted 120 model.converted
108 htmlAttribute (Html.Attributes.style name val)
111fontSize pixels lineHeight up =
114 -- , htmlAttribute (Html.Attributes.style "line-height" lineHeight)
115 -- , Background.color (rgb 0 0.8 0.9)
118 -- [ Background.color (rgb 0 0 0)
120 -- , height (px pixels)
132adjustor size adjustment =
135 [ viewAdjustment "Type Height" adjustment.capital size 180 adjustment.lineHeight (\capital -> { adjustment | capital = capital })
136 , viewAdjustment "Lowercase Height" adjustment.lowercase size 60 adjustment.lineHeight (\lowercase -> { adjustment | lowercase = lowercase })
137 , viewAdjustment "Baseline" adjustment.baseline size 120 adjustment.lineHeight (\baseline -> { adjustment | baseline = baseline })
138 , viewAdjustment "Descender" adjustment.descender size 0 adjustment.lineHeight (\descender -> { adjustment | descender = descender })
144 , Background.color (rgb 0 0.8 0.9)
145 , style "line-height" (String.fromFloat adjustment.lineHeight)
151 -- , height (px (round (toFloat size * (1 / 1.5))))
153 , Background.color (rgb 0.9 0.8 0)
164adjusted size adjustment =
176 [ Background.color (rgb 0 0.8 0.9)
177 , style "line-height" "normal"
178 , above (el [ Font.size 12 ] (text "line-height: normal"))
182 [ Background.color (rgb 0 0.8 0.9)
183 , style "line-height" "1"
184 , above (el [ Font.size 12 ] (text "line-height: 1"))
192 [ corrected adjustment.full "corrected"
193 , corrected adjustment.capital "corrected capital"
195 , paragraph [ Font.size 25, spacing 5, width (px 200) ]
196 [ el [ Font.size 55, alignLeft ] (text "L")
197 , text "orem Ipsum is simply dummy text of the printing and typesetting industry."
202corrected converted label =
204 [ Background.color (rgb 0 0.8 0.9)
205 , style "display" "block"
206 , above (el [ Font.size 12, moveUp 6 ] (text label))
207 , style "line-height" (String.fromFloat converted.height)
209 (column [ Font.size 12, spacing 5, moveDown 10 ]
210 [ text ("height: " ++ String.left 5 (String.fromFloat converted.height))
211 , text ("vertical: " ++ String.left 5 (String.fromFloat converted.vertical))
216 [ style "display" "inline-block"
217 , style "line-height" (String.fromFloat converted.height)
218 , style "vertical-align" (String.fromFloat converted.vertical ++ "em")
224convertAdjustment adjustment =
227 adjustment.lineHeight
230 (adjustment.lineHeight - 1)
234 adjustment.lineHeight / 2
237 ((ascender - newBaseline) / 2) + newBaseline
240 ((ascender - descender) / 2) + descender
244 , adjustment.baseline
245 , adjustment.descender
246 , adjustment.lowercase
250 Maybe.withDefault adjustment.capital (List.maximum lines)
253 Maybe.withDefault adjustment.descender (List.minimum lines)
257 |> List.filter (\x -> x /= descender)
259 |> Maybe.withDefault adjustment.baseline
262 (oldMiddle - newCapitalMiddle) * 2
265 (oldMiddle - newFullMiddle) * 2
268 { vertical = fullVertical
270 (ascender - descender)
274 { vertical = capitalVertical
275 , height = (ascender - newBaseline) - abs capitalVertical
280viewAdjustment label adjustment size left lineHeight updateWith =
289 -- , moveUp (0.125 * toFloat size)
290 , height (px (round (toFloat size * lineHeight)))
295 , Element.behindContent
297 [ Element.width (Element.px 1)
298 , Element.height Element.fill
300 , Background.color charcoal
305 , height (px (round fullHeight))
308 , Background.color charcoal
309 , below (el [ centerX ] (text (String.fromFloat adjustment)))
316 , moveUp (fullHeight * (adjustment / lineHeight))
317 , Border.color (rgb 0 0 0)
329 { label = Input.labelAbove [ Font.size 18 ] (text "")
339 [ Element.width (Element.px 16)
340 , Element.height (Element.px 16)
343 , Border.color (Element.rgb 0.5 0.5 0.5)
344 , Background.color (Element.rgb 1 1 1)
351 -- , Border.color (rgb 0 0 0)
353 -- , Border.widthEach
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list