git.iko.soy/typeable/elm-ui
on master help sign in
render `font-variant` if it's smallcaps.
commitb975f51ee7fea18f1c2c69c620efd192590ccb91 authorMatthew Griffith <mdg.griffith@gmail.com> dateSat 22 Sep 2018, 18:45 (8 years ago) parent9865c99
1 file changed+31−3
src/Internal/Model.elm+31−3
src/Internal/Model.elm+31−3
@@ -249,10 +249,31 @@ renderVariant var =
249249renderVariants typeface =
250250 case typeface of
251251 FontWith font ->
252− String.join ", " (List.map renderVariant font.variants)
252+ Just (String.join ", " (List.map renderVariant font.variants))
253253
254254 _ ->
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
256277
257278
258279type Property
@@ -2505,7 +2526,7 @@ toStyleSheetString options stylesheet =
25052526 let
25062527 features =
25072528 typefaces
2508− |> List.map renderVariants
2529+ |> List.filterMap renderVariants
25092530 |> String.join ", "
25102531
25112532 families =
@@ -2515,6 +2536,13 @@ toStyleSheetString options stylesheet =
25152536 |> String.join ", "
25162537 )
25172538 , 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+ )
25182546 ]
25192547 in
25202548 String.join " "