Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8114265

Em to pixel conversion in CSS results in numbers like 6.000001

    XMLWordPrintable

    Details

      Description

      The issue is when we specify a value for padding in CSS using the 'em' unit it will be something like:

       -fx-padding: 0.42857em; // 6px

      which means to specify 6px at the default font size of 14px in this case. Now the value is really something more like 0.428571428571429 but that is a bit much to type in the css file. So when its converted back to pixels we get a value of 5.99998px not 6px this causes issues when mixed with layouts snap-to-pixel code which rounds up or down. The result is off by 1 pixel issues.

      So what I think we need to do is round the result to the nearest 1/10th of a pixel to avoid any accuracy issues. I can't see when we need to be more exact than a 1/10th of a pixel so rounding should simplify things.

        Attachments

          Activity

            People

            Assignee:
            dgrieve David Grieve
            Reporter:
            jasper Jasper Potts (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: