@@ -375,25 +375,46 @@ function ResolveFont(css_font_family_string){
375375// return ratio to "normal" font size. in other words, it's fraction of 16 pixels.
376376function ResolveUnitedNumber ( css_line_height_string ) {
377377 var undef
378+ , normal = 16.00
378379 , value = UnitedNumberMap [ css_line_height_string ]
379380 if ( value ) {
380381 return value
381382 }
382383
384+ // not in cache, ok. need to parse it.
385+
386+ // Could it be a named value?
387+ // we will use Windows 94dpi sizing with CSS2 suggested 1.2 step ratio
388+ // where "normal" or "medium" is 16px
389+ // see: http://style.cleverchimp.com/font_size_intervals/altintervals.html
390+ value = ( {
391+ 'xx-small' :9
392+ , 'x-small' :11
393+ , 'small' :13
394+ , 'medium' :16
395+ , 'large' :19
396+ , 'x-large' :23
397+ , 'xx-large' :28
398+ , 'auto' :0
399+ } ) [ css_line_height_string ]
400+ if ( value !== undef ) {
401+ // caching, returning
402+ return UnitedNumberMap [ css_line_height_string ] = value / normal
403+ }
404+
383405 // not in cache, ok. need to parse it.
384406 // is it int?
385- value = parseFloat ( css_line_height_string )
386- if ( value ) {
407+ if ( value = parseFloat ( css_line_height_string ) ) {
387408 // caching, returning
388- return UnitedNumberMap [ css_line_height_string ] = value / 16.00
409+ return UnitedNumberMap [ css_line_height_string ] = value / normal
389410 }
390411
391412 // must be a "united" value ('123em', '134px' etc.)
392413 // most browsers convert it to px so, only handling the px
393414 value = css_line_height_string . match ( / ( [ \d \. ] + ) ( p x ) / )
394415 if ( value . length === 3 ) {
395416 // caching, returning
396- return UnitedNumberMap [ css_line_height_string ] = parseFloat ( value [ 1 ] ) / 16.00
417+ return UnitedNumberMap [ css_line_height_string ] = parseFloat ( value [ 1 ] ) / normal
397418 }
398419
399420 return UnitedNumberMap [ css_line_height_string ] = 1
0 commit comments