Formulas for measurement units conversion
The different mobile platforms use different measurement units, and these are usually relative and depend on the device's pixel density. In the guidelines there are success criteria and tests that require size reference, this page contains conversion formulas that should help users convert the units defined in the tests or success criteria. Each success criterion page that requires dealing with size or area has a link to this page.The formulas in this page were created based on data from the Android and iOS developer documentation and with the assistance of ChatGPT.
Warning
The formulas on this page have not been sufficiently tested and may not be accurate. They are presented here as an idea of how to normalize the many units of measure from the different platforms to show them uniformly in the success criteria.
Scaled Pixels (sp) to Points (pt)
To calculate points from scaled pixels, use this formula:
points = scaledPixels / displayDensity
Where scaledPixels is the text size in "sp", and displayDensity is the device's screen density.
Used in: 1.4.1 Text Color Contrast
Density-Independent Pixels (dp) to Millimeters (mm)
Converting density-independent pixels (dp) to millimeters (mm) must consider the device's screen density or dots per inch (dpi).
To convert dp to mm, you divide the number of dp by the product of the screen density (dpi) and the conversion factor (25.4). This conversion helps in dealing with different screen densities and provides a rough estimation of size in millimeters based on the device's density-independent pixels.
mm = dpi × 25.4 / dp
dp
is the value in dp that you want to convert to millimeters.dpi
is the screen density of the device in dots per inch.25.4
is the conversion factor from inches to millimeters.
Used in: 2.1.1 Touch target Size
Scalable Pixels (sp) to Millimeters (mm)
Converting Scalable Pixels pixels (sp) to millimeters (mm) must consider the device's screen density or dots per inch (dpi).
mm = sp / (dpi × font-size × 25.4)
sp
is the value in sp that you want to convert to millimeters.dpi
is the screen density of the device in dots per inch.font-size
is the user's preferred font scale factor.25.4
is the conversion factor from inches to millimeters.
Used in: 2.1.1 Touch target Size
Points (pt) to Millimeters (mm)
Converting points (pt) to millimeters (mm) must consider the device's screen density or dots per inch (dpi).
However, to accurately convert points to millimeters, requires the exact points per inch (PPI) of the specific device you're targeting, which can vary based on the device model and its screen specifications.
mm = pt / (PPI × 25.4)
pt
is the value in points that you want to convert to millimeters.PPI
(points per inch) represents the screen density of the device in points per inch.25.4
is the conversion factor from inches to millimeters.
Used in: 2.1.1 Touch target Size