git.iko.soy/typeable/elm-ui
on master help sign in
add Font.full
fb68f5bMatthew Griffith
src/Element/Font.elm+8−2
@@ -1,7 +1,7 @@
1module Element.Font exposing
1module Element.Font exposing
2 ( color, size
2 ( color, size
3 , family, Font, typeface, serif, sansSerif, monospace
3 , family, Font, typeface, serif, sansSerif, monospace
4− , external, with, sizeByCapital
4+ , external, with, sizeByCapital, full
5 , alignLeft, alignRight, center, justify, letterSpacing, wordSpacing
5 , alignLeft, alignRight, center, justify, letterSpacing, wordSpacing
6 , underline, strike, italic, unitalicized
6 , underline, strike, italic, unitalicized
7 , heavy, extraBold, bold, semiBold, medium, regular, light, extraLight, hairline
7 , heavy, extraBold, bold, semiBold, medium, regular, light, extraLight, hairline
@@ -36,7 +36,7 @@ module Element.Font exposing
36
36
37@docs family, Font, typeface, serif, sansSerif, monospace
37@docs family, Font, typeface, serif, sansSerif, monospace
38
38
39−@docs external, with, sizeByCapital
39+@docs external, with, sizeByCapital, full
40
40
41`Font.external` can be used to import font files. Let's say you found a neat font on <http://fonts.google.com>:
41`Font.external` can be used to import font files. Let's say you found a neat font on <http://fonts.google.com>:
42
42
@@ -170,6 +170,12 @@ sizeByCapital =
170 Internal.htmlClass classes.sizeByCapital
170 Internal.htmlClass classes.sizeByCapital
171
171
172
172
173+{-| -}
174+full : Attribute msg
175+full =
176+ Internal.htmlClass classes.fullSize
177+
178+
173{-| -}
179{-| -}
174external : { url : String, name : String } -> Font
180external : { url : String, name : String } -> Font
175external { url, name } =
181external { url, name } =
src/Internal/Model.elm+60−60
@@ -1561,13 +1561,12 @@ createElement context children rendered =
1561 -- , existingStyles
1561 -- , existingStyles
1562 -- )
1562 -- )
1563 -- else
1563 -- else
1564− ( textElement
1565− (if context == asParagraph then
1564+ ( (if context == asEl then
1566− str
1565+ textElementFill str
1567
1566
1568− else
1567+ else
1569− str
1568+ textElement str
1570− )
1569+ )
1571 :: htmls
1570 :: htmls
1572 , existingStyles
1571 , existingStyles
1573 )
1572 )
@@ -1627,8 +1626,11 @@ createElement context children rendered =
1627 -- )
1626 -- )
1628 -- else
1627 -- else
1629 ( ( key
1628 ( ( key
1629+ , if context == asEl then
1630+ textElementFill str
1631+
1632+ else
1630− , textElement
1633+ textElement str
1631− str
1632 )
1634 )
1633 :: htmls
1635 :: htmls
1634 , existingStyles
1636 , existingStyles
@@ -1963,14 +1965,13 @@ textElement str =
1963textElementFill : String -> VirtualDom.Node msg
1965textElementFill : String -> VirtualDom.Node msg
1964textElementFill str =
1966textElementFill str =
1965 VirtualDom.node "div"
1967 VirtualDom.node "div"
1966− [ VirtualDom.property "className"
1968+ [ Html.Attributes.class
1967− (Json.string <|
1968− String.join " "
1969+ (String.join " "
1969− [ classes.any
1970+ [ classes.any
1970− , classes.text
1971+ , classes.text
1971− , classes.widthFill
1972+ , classes.widthFill
1972− , classes.heightFill
1973+ , classes.heightFill
1973− ]
1974+ ]
1974 )
1975 )
1975 ]
1976 ]
1976 [ VirtualDom.text str ]
1977 [ VirtualDom.text str ]
@@ -2308,7 +2309,38 @@ renderNullAdjustmentRule fontToAdjust otherFontName =
2308 ]
2309 ]
2309
2310
2310
2311
2312+fontRule name modifier ( parentAdj, textAdjustment ) =
2313+ [ bracket
2314+ ("."
2315+ ++ name
2316+ ++ "."
2317+ ++ modifier
2318+ ++ ", "
2319+ ++ "."
2320+ ++ name
2321+ ++ " ."
2322+ ++ modifier
2323+ )
2324+ parentAdj
2325+ , bracket
2326+ ("."
2327+ ++ name
2328+ ++ "."
2329+ ++ modifier
2330+ ++ "> ."
2331+ ++ Internal.Style.classes.text
2332+ ++ ", ."
2333+ ++ name
2334+ ++ " ."
2335+ ++ modifier
2336+ ++ " > ."
2337+ ++ Internal.Style.classes.text
2338+ )
2339+ textAdjustment
2340+ ]
2341+
2342+
2311−renderFontAdjustmentRule fontToAdjust ( parentAdj, textAdjustment ) otherFontName =
2343+renderFontAdjustmentRule fontToAdjust ( full, capital ) otherFontName =
2312 let
2344 let
2313 name =
2345 name =
2314 if fontToAdjust == otherFontName then
2346 if fontToAdjust == otherFontName then
@@ -2318,34 +2350,7 @@ renderFontAdjustmentRule fontToAdjust ( parentAdj, textAdjustment ) otherFontNam
2318 otherFontName ++ " ." ++ fontToAdjust
2350 otherFontName ++ " ." ++ fontToAdjust
2319 in
2351 in
2320 String.join " "
2352 String.join " "
2321− [ bracket
2322− ("."
2323− ++ name
2324− ++ "."
2325− ++ classes.sizeByCapital
2326− ++ ", "
2327− ++ "."
2328− ++ name
2329− ++ " ."
2330− ++ classes.sizeByCapital
2353+ (fontRule name classes.sizeByCapital capital ++ fontRule name classes.fullSize full)
2331− )
2332− parentAdj
2333− , bracket
2334− ("."
2335− ++ name
2336− ++ "."
2337− ++ classes.sizeByCapital
2338− ++ "> ."
2339− ++ Internal.Style.classes.text
2340− ++ ", ."
2341− ++ name
2342− ++ " ."
2343− ++ classes.sizeByCapital
2344− ++ " > ."
2345− ++ Internal.Style.classes.text
2346− )
2347− textAdjustment
2348− ]
2349
2354
2350
2355
2351bracket selector rules =
2356bracket selector rules =
@@ -2358,17 +2363,12 @@ bracket selector rules =
2358
2363
2359fontAdjustmentRules converted =
2364fontAdjustmentRules converted =
2360 ( [ ( "display", "block" )
2365 ( [ ( "display", "block" )
2361−
2362− -- , ( "line-height", String.fromFloat converted.height )
2363− -- , ( "font-size", String.fromFloat (1 + converted.height + converted.vertical) ++ "em" )
2364 ]
2366 ]
2365 , [ ( "display", "inline-block" )
2367 , [ ( "display", "inline-block" )
2366 , ( "line-height", String.fromFloat converted.height )
2368 , ( "line-height", String.fromFloat converted.height )
2367 , ( "vertical-align", String.fromFloat converted.vertical ++ "em" )
2369 , ( "vertical-align", String.fromFloat converted.vertical ++ "em" )
2368 , ( "font-size", String.fromFloat converted.size ++ "em" )
2370 , ( "font-size", String.fromFloat converted.size ++ "em" )
2369 ]
2371 ]
2370− -- , [ ( "font-size", String.fromFloat converted.size ++ "em" )
2371− -- ]
2372 )
2372 )
2373
2373
2374
2374
@@ -2380,7 +2380,9 @@ typefaceAdjustment typefaces =
2380 case face of
2380 case face of
2381 FontWith with ->
2381 FontWith with ->
2382 Just
2382 Just
2383+ ( fontAdjustmentRules
2384+ (.full (convertAdjustment with.adjustment))
2383− (fontAdjustmentRules
2385+ , fontAdjustmentRules
2384 (.capital (convertAdjustment with.adjustment))
2386 (.capital (convertAdjustment with.adjustment))
2385 )
2387 )
2386
2388
@@ -3352,16 +3354,16 @@ convertAdjustment adjustment =
3352 capitalSize =
3354 capitalSize =
3353 1 / (ascender - newBaseline)
3355 1 / (ascender - newBaseline)
3354
3356
3357+ fullSize =
3358+ 1 / (ascender - descender)
3359+
3355 fullVertical =
3360 fullVertical =
3361+ 1 - ascender
3362+
3356− (oldMiddle - newFullMiddle) * 2
3363+ -- (oldMiddle - newFullMiddle) * 2
3357 in
3364 in
3358 { full =
3365 { full =
3359− { vertical = fullVertical
3360− , height =
3361− (ascender - descender)
3366+ adjust fullSize (ascender - descender) fullVertical
3362− - abs fullVertical
3363− , size = 1.0
3364− }
3365 , capital =
3367 , capital =
3366 adjust capitalSize (ascender - newBaseline) capitalVertical
3368 adjust capitalSize (ascender - newBaseline) capitalVertical
3367 }
3369 }
@@ -3371,7 +3373,5 @@ adjust size height vertical =
3371 { vertical = vertical
3373 { vertical = vertical
3372 , height =
3374 , height =
3373 height / size
3375 height / size
3374−
3375− -- vertical
3376 , size = size
3376 , size = size
3377 }
3377 }