git.iko.soy/typeable/elm-ui
on master help sign in
Reduce needed rules for font adjustment
73dcc6eMatthew Griffith
src/Internal/Model.elm+23−66
@@ -2173,67 +2173,6 @@ toStyleSheet options styleSheet =
2173 VirtualDom.node "style" [] [ VirtualDom.text (toStyleSheetString options styleSheet) ]
2173 VirtualDom.node "style" [] [ VirtualDom.text (toStyleSheetString options styleSheet) ]
2174
2174
2175
2175
2176−
2177−-- case typefaceAdjustment typefaces of
2178−-- Nothing ->
2179−-- ""
2180−-- Just ( parentAdj, textAdjustment ) ->
2181−-- String.join " "
2182−-- [ renderStyle
2183−-- maybePseudo
2184−-- ("."
2185−-- ++ name
2186−-- ++ "."
2187−-- ++ classes.sizeByCapital
2188−-- ++ ", "
2189−-- ++ "."
2190−-- ++ name
2191−-- ++ " ."
2192−-- ++ classes.sizeByCapital
2193−-- )
2194−-- parentAdj
2195−-- , renderStyle
2196−-- maybePseudo
2197−-- ("."
2198−-- ++ name
2199−-- ++ "."
2200−-- ++ classes.sizeByCapital
2201−-- ++ "> ."
2202−-- ++ Internal.Style.classes.text
2203−-- ++ ", ."
2204−-- ++ name
2205−-- ++ " ."
2206−-- ++ classes.sizeByCapital
2207−-- ++ " > ."
2208−-- ++ Internal.Style.classes.text
2209−-- )
2210−-- textAdjustment
2211−-- ]
2212−-- renderTopLevels rule =
2213−-- case rule of
2214−-- FontFamily name typefaces ->
2215−-- let
2216−-- getImports font =
2217−-- case font of
2218−-- ImportFont _ url ->
2219−-- Just ("@import url('" ++ url ++ "');")
2220−-- FontWith { url } ->
2221−-- case url of
2222−-- Just x ->
2223−-- Just ("@import url('" ++ x ++ "');")
2224−-- Nothing ->
2225−-- Nothing
2226−-- _ ->
2227−-- Nothing
2228−-- in
2229−-- typefaces
2230−-- |> List.filterMap getImports
2231−-- |> String.join "\n"
2232−-- |> Just
2233−-- _ ->
2234−-- Nothing
2235−
2236−
2237renderTopLevelValues rules =
2176renderTopLevelValues rules =
2238 let
2177 let
2239 withImport font =
2178 withImport font =
@@ -2369,12 +2308,17 @@ bracket selector rules =
2369
2308
2370fontAdjustmentRules converted =
2309fontAdjustmentRules converted =
2371 ( [ ( "display", "block" )
2310 ( [ ( "display", "block" )
2311+
2372− , ( "line-height", String.fromFloat converted.height )
2312+ -- , ( "line-height", String.fromFloat converted.height )
2313+ -- , ( "font-size", String.fromFloat (1 + converted.height + converted.vertical) ++ "em" )
2373 ]
2314 ]
2374 , [ ( "display", "inline-block" )
2315 , [ ( "display", "inline-block" )
2375 , ( "line-height", String.fromFloat converted.height )
2316 , ( "line-height", String.fromFloat converted.height )
2376 , ( "vertical-align", String.fromFloat converted.vertical ++ "em" )
2317 , ( "vertical-align", String.fromFloat converted.vertical ++ "em" )
2318+ , ( "font-size", String.fromFloat converted.size ++ "em" )
2377 ]
2319 ]
2320+ -- , [ ( "font-size", String.fromFloat converted.size ++ "em" )
2321+ -- ]
2378 )
2322 )
2379
2323
2380
2324
@@ -3339,7 +3283,11 @@ convertAdjustment adjustment =
3339 |> Maybe.withDefault adjustment.baseline
3283 |> Maybe.withDefault adjustment.baseline
3340
3284
3341 capitalVertical =
3285 capitalVertical =
3342− (oldMiddle - newCapitalMiddle) * 2
3286+ 1 - ascender
3287+
3288+
3289+ capitalSize =
3290+ 1 / (ascender - newBaseline)
3343
3291
3344 fullVertical =
3292 fullVertical =
3345 (oldMiddle - newFullMiddle) * 2
3293 (oldMiddle - newFullMiddle) * 2
@@ -3349,9 +3297,18 @@ convertAdjustment adjustment =
3349 , height =
3297 , height =
3350 (ascender - descender)
3298 (ascender - descender)
3351 - abs fullVertical
3299 - abs fullVertical
3300+ , size = 1.0
3352 }
3301 }
3353 , capital =
3302 , capital =
3354− { vertical = capitalVertical
3355− , height = (ascender - newBaseline) - abs capitalVertical
3303+ adjust capitalSize (ascender - newBaseline) capitalVertical
3356− }
3304+ }
3305+
3306+
3307+adjust size height vertical =
3308+ { vertical = vertical
3309+ , height =
3310+ height / size
3311+
3312+ -- vertical
3313+ , size = size
3357 }
3314 }