git.iko.soy/typeable/elm-ui
on master help sign in
render `font-variant` if it's smallcaps.
b975f51Matthew Griffith
src/Internal/Model.elm+31−3
@@ -249,10 +249,31 @@ renderVariant var =
249renderVariants typeface =
249renderVariants typeface =
250 case typeface of
250 case typeface of
251 FontWith font ->
251 FontWith font ->
252− String.join ", " (List.map renderVariant font.variants)
252+ Just (String.join ", " (List.map renderVariant font.variants))
253
253
254 _ ->
254 _ ->
255− ""
255+ Nothing
256+
257+
258+isSmallCaps var =
259+ case var of
260+ VariantActive name ->
261+ name == "smcp"
262+
263+ VariantOff name ->
264+ False
265+
266+ VariantIndexed name index ->
267+ name == "smcp" && index == 1
268+
269+
270+hasSmallCaps typeface =
271+ case typeface of
272+ FontWith font ->
273+ List.any isSmallCaps font.variants
274+
275+ _ ->
276+ False
256
277
257
278
258type Property
279type Property
@@ -2505,7 +2526,7 @@ toStyleSheetString options stylesheet =
2505 let
2526 let
2506 features =
2527 features =
2507 typefaces
2528 typefaces
2508− |> List.map renderVariants
2529+ |> List.filterMap renderVariants
2509 |> String.join ", "
2530 |> String.join ", "
2510
2531
2511 families =
2532 families =
@@ -2515,6 +2536,13 @@ toStyleSheetString options stylesheet =
2515 |> String.join ", "
2536 |> String.join ", "
2516 )
2537 )
2517 , Property "font-feature-settings" features
2538 , Property "font-feature-settings" features
2539+ , Property "font-variant"
2540+ (if List.any hasSmallCaps typefaces then
2541+ "small-caps"
2542+
2543+ else
2544+ "normal"
2545+ )
2518 ]
2546 ]
2519 in
2547 in
2520 String.join " "
2548 String.join " "