git.iko.soy/typeable/elm-ui
on master help sign in
Reduce needed rules for font adjustment
commit73dcc6e940d5204e4fed0224b5eedde5b3b1791f authorMatthew Griffith <mdg.griffith@gmail.com> dateSat 22 Sep 2018, 08:48 (8 years ago) parentd94a2b5
1 file changed+23−66
src/Internal/Model.elm+23−66
src/Internal/Model.elm+23−66
@@ -2173,67 +2173,6 @@ toStyleSheet options styleSheet =
21732173 VirtualDom.node "style" [] [ VirtualDom.text (toStyleSheetString options styleSheet) ]
21742174
21752175
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−
22372176renderTopLevelValues rules =
22382177 let
22392178 withImport font =
@@ -2369,12 +2308,17 @@ bracket selector rules =
23692308
23702309fontAdjustmentRules converted =
23712310 ( [ ( "display", "block" )
2372− , ( "line-height", String.fromFloat converted.height )
2311+
2312+ -- , ( "line-height", String.fromFloat converted.height )
2313+ -- , ( "font-size", String.fromFloat (1 + converted.height + converted.vertical) ++ "em" )
23732314 ]
23742315 , [ ( "display", "inline-block" )
23752316 , ( "line-height", String.fromFloat converted.height )
23762317 , ( "vertical-align", String.fromFloat converted.vertical ++ "em" )
2318+ , ( "font-size", String.fromFloat converted.size ++ "em" )
23772319 ]
2320+ -- , [ ( "font-size", String.fromFloat converted.size ++ "em" )
2321+ -- ]
23782322 )
23792323
23802324
@@ -3339,7 +3283,11 @@ convertAdjustment adjustment =
33393283 |> Maybe.withDefault adjustment.baseline
33403284
33413285 capitalVertical =
3342− (oldMiddle - newCapitalMiddle) * 2
3286+ 1 - ascender
3287+
3288+
3289+ capitalSize =
3290+ 1 / (ascender - newBaseline)
33433291
33443292 fullVertical =
33453293 (oldMiddle - newFullMiddle) * 2
@@ -3349,9 +3297,18 @@ convertAdjustment adjustment =
33493297 , height =
33503298 (ascender - descender)
33513299 - abs fullVertical
3300+ , size = 1.0
33523301 }
33533302 , capital =
3354− { vertical = capitalVertical
3355− , height = (ascender - newBaseline) - abs capitalVertical
3356− }
3303+ adjust capitalSize (ascender - newBaseline) capitalVertical
3304+ }
3305+
3306+
3307+adjust size height vertical =
3308+ { vertical = vertical
3309+ , height =
3310+ height / size
3311+
3312+ -- vertical
3313+ , size = size
33573314 }