@@ -1,11 +1,11 @@
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, full
4+ , external
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
8− , Variant, variant, smallCaps, slashedZero, ligatures, ordinal, tabularNumbers, stackedFractions, diagonalFractions, swash, feature, indexed
8+ , Variant, variant, variantList, smallCaps, slashedZero, ligatures, ordinal, tabularNumbers, stackedFractions, diagonalFractions, swash, feature, indexed
9 , glow, shadow
9 , glow, shadow
@@ -36,24 +36,7 @@ module Element.Font exposing
37@docs family, Font, typeface, serif, sansSerif, monospace
37@docs family, Font, typeface, serif, sansSerif, monospace
39−@docs external, with, sizeByCapital, full
39+@docs external
41−`Font.external` can be used to import font files. Let's say you found a neat font on <http://fonts.google.com>:
44− import Element.Font as Font
51− , url = "https://fonts.googleapis.com/css?family=Roboto"
56− (Element.text "Woohoo, I'm stylish text")
59## Alignment and Spacing
42## Alignment and Spacing
@@ -73,7 +56,7 @@ module Element.Font exposing
74## Variants
57## Variants
76−@docs Variant, variant, smallCaps, slashedZero, ligatures, ordinal, tabularNumbers, stackedFractions, diagonalFractions, swash, feature, indexed
59+@docs Variant, variant, variantList, smallCaps, slashedZero, ligatures, ordinal, tabularNumbers, stackedFractions, diagonalFractions, swash, feature, indexed
@@ -96,7 +79,13 @@ type alias Font =
97color : Color -> Attr decorative msg
80color : Color -> Attr decorative msg
98color fontColor =
81color fontColor =
99− Internal.StyleClass Flag.fontColor (Internal.Colored ("fc-" ++ Internal.formatColorClass fontColor) "color" fontColor)
85+ ("fc-" ++ Internal.formatColorClass fontColor)
@@ -116,7 +105,12 @@ color fontColor =
117family : List Font -> Attribute msg
106family : List Font -> Attribute msg
118family families =
107family families =
110+ (Internal.FontFamily
119− Internal.StyleClass Flag.fontFamily <| Internal.FontFamily (List.foldl Internal.renderFontClassName "ff-" families) families
111+ (List.foldl Internal.renderFontClassName "ff-" families)
@@ -155,8 +149,7 @@ type alias Adjustment =
157 { name : String
151 { name : String
158− , adjustment : Adjustment
152+ , adjustment : Maybe Adjustment
159− , url : Maybe String
160 , variants : List Variant
153 , variants : List Variant
@@ -176,7 +169,30 @@ full =
176 Internal.htmlClass classes.fullSize
169 Internal.htmlClass classes.fullSize
172+{-| **Note** it's likely that `Font.external` will cause a flash on your page on loading.
174+To bypass this, import your fonts using a separate stylesheet and just use `Font.typeface`.
176+It's likely that `Font.external` will be removed or redesigned in the future to avoid the flashing.
178+`Font.external` can be used to import font files. Let's say you found a neat font on <http://fonts.google.com>:
181+ import Element.Font as Font
188+ , url = "https://fonts.googleapis.com/css?family=Roboto"
193+ (Element.text "Woohoo, I'm stylish text")
180external : { url : String, name : String } -> Font
196external : { url : String, name : String } -> Font
181external { url, name } =
197external { url, name } =
182 Internal.ImportFont name url
198 Internal.ImportFont name url
@@ -364,9 +380,7 @@ type alias Variant =
365 (text "rendered with smallcaps")
381 (text "rendered with smallcaps")
367−**Note** These will **not** stack. If you want multiple variants, you should use `Font.with`.
383+**Note** These will **not** stack. If you want multiple variants, you should use `Font.variantList`.
369−If you specify a font variant on an element, then it will override all variants listed in `Font.with`.
372variant : Variant -> Attribute msg
386variant : Variant -> Attribute msg
@@ -385,6 +399,54 @@ variant var =
385 ("\"" ++ name ++ "\" " ++ String.fromInt index)
399 ("\"" ++ name ++ "\" " ++ String.fromInt index)
404+ Internal.VariantActive feat ->
412+variantList : List Variant -> Attribute msg
417+ |> List.map Internal.renderVariant
420+ List.any isSmallCaps vars
423+ if hasSmallCaps then
425+ |> List.map Internal.variantName
427+ |> (\x -> x ++ "-sc")
431+ |> List.map Internal.variantName
435+ String.join ", " features
437+ Internal.StyleClass Flag.fontVariant <|
438+ Internal.Style ("v-" ++ name)
439+ [ Internal.Property "font-feature-settings" featureString
440+ , Internal.Property "font-variant"
441+ (if hasSmallCaps then
388{-| [Small caps](https://en.wikipedia.org/wiki/Small_caps) are rendered using uppercase glyphs, but at the size of lowercase glyphs.
450{-| [Small caps](https://en.wikipedia.org/wiki/Small_caps) are rendered using uppercase glyphs, but at the size of lowercase glyphs.
390smallCaps : Variant
452smallCaps : Variant