@@ -5,6 +5,7 @@ module Element.Font exposing
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, disable, feature, indexed
8 , glow, shadow
9 , glow, shadow
@@ -70,6 +71,11 @@ module Element.Font exposing
70@docs heavy, extraBold, bold, semiBold, medium, regular, light, extraLight, hairline
71@docs heavy, extraBold, bold, semiBold, medium, regular, light, extraLight, hairline
76+@docs Variant, variant, smallCaps, slashedZero, ligatures, ordinal, tabularNumbers, stackedFractions, diagonalFractions, swash, disable, feature, indexed
75@docs glow, shadow
81@docs glow, shadow
@@ -151,6 +157,7 @@ with :
151 { name : String
157 { name : String
152 , adjustment : Adjustment
158 , adjustment : Adjustment
153 , url : Maybe String
159 , url : Maybe String
160+ , variants : List Variant
@@ -333,3 +340,138 @@ glow clr i =
334 Internal.StyleClass Flag.txtShadows <|
341 Internal.StyleClass Flag.txtShadows <|
335 Internal.Single (Internal.textShadowName shade) "text-shadow" (Internal.formatTextShadow shade)
342 Internal.Single (Internal.textShadowName shade) "text-shadow" (Internal.formatTextShadow shade)
353+{-| You can use this to set a single variant on an element itself such as:
356+ [ Font.variant Font.smallcaps
358+ (text "rendered with smallcaps")
360+**Note** These will **not** stack. If you want multiple variants, you should use `Font.with`.
363+variant : Variant -> Attribute msg
366+ Internal.VariantActive name ->
367+ Internal.Class Flag.fontVariant ("v-" ++ name)
369+ Internal.VariantOff name ->
370+ Internal.Class Flag.fontVariant ("v-" ++ name ++ "-off")
372+ Internal.VariantIndexed name index ->
373+ Internal.StyleClass Flag.fontVariant <|
374+ Internal.Single ("v-" ++ name ++ "-" ++ String.fromInt index)
375+ "font-feature-settings"
376+ ("\"" ++ name ++ "\" " ++ String.fromInt index)
379+{-| Less often you might want to disable an active variant.
382+ [ Font.variant (Font.disable Font.smallCaps)
384+ (text "Is not smallcaps")
386+**Note** Generally try to set yourself up so that this isn't really necessary.
389+disable : Variant -> Variant
392+ Internal.VariantActive name ->
393+ Internal.VariantOff name
395+ Internal.VariantIndexed name index ->
396+ Internal.VariantOff name
398+ Internal.VariantOff name ->
402+{-| [Small caps](https://en.wikipedia.org/wiki/Small_caps) are rendered using uppercase glyphs, but at the size of lowercase glyphs.
406+ Internal.VariantActive "smcp"
409+{-| Add a slash when rendering `0`
411+slashedZero : Variant
413+ Internal.VariantActive "zero"
419+ Internal.VariantActive "liga"
422+{-| Oridinal markers like `1st` and `2nd` will receive special glyphs.
426+ Internal.VariantActive "ordn"
429+{-| Number figures will each take up the same space, allowing them to be easily aligned, such as in tables.
431+tabularNumbers : Variant
433+ Internal.VariantActive "tnum"
436+{-| Render fractions with the numerator stacked on top of the denominator.
438+stackedFractions : Variant
440+ Internal.VariantActive "afrc"
445+diagonalFractions : Variant
447+ Internal.VariantActive "frac"
451+swash : Int -> Variant
453+ Internal.VariantIndexed "swsh"
456+{-| Set a feature by name and whether it should be on or off.
458+Feature names are four-letter names as defined in the [OpenType specification](https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist).
461+feature : String -> Bool -> Variant
464+ Internal.VariantIndexed name 1
467+ Internal.VariantIndexed name 0
470+{-| A font variant might have multiple versions within the font.
472+In these cases we need to specify the index of the version we want.
475+indexed : String -> Int -> Variant
477+ Internal.VariantIndexed name on