Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert pt to sp?

I am a visual designer, working on an android design and I"m trying to spec my PSD file for our engineers. I cannot seem to find any documentation regarding the conversion of point size to SP for the type in any Android documentation. (Just that SP should be used for type).

like image 479
Megatallica Avatar asked Nov 15 '12 19:11

Megatallica


People also ask

How do you convert PT to SP?

There are 72 pts per inch, and 160 sp per inch (with standard font size in the device settings). this means there are 160sp per 72pts. 160sp/72pts simplifies to 20/9. So when converting pts to sp or dp use pts*20/9.

What is 1px in PT?

Both are fixed-sized units however with a pixel equal to one dot on your screen and a point equal to 1/72 of an inch. How many PX is a PT? One point is the equivalent of 1.333(3) pixels. On the other hand, one pixel is the equivalent of 0.75 points.

How many PT is 16px?

1 point (pt) is assumed to be 1/72nd of an inch. Therefore 16px = 12pt.

Is dp the same as PT?

pt Points - 1/72 of an inch based on the physical size of the screen. dp Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen.


2 Answers

The problem is that it depends on the density. Really, they're not good measurements to try to compare.

  • Points: There are 12 points in a pica, 6 picas per inch, so 72 (more accurately 72.27) points per inch.

  • Device-Independent Pixels (DP): These will be equal to the pixel size for MDPI displays, 1.5x the pixel size for HDPI displays, and 2x the pixel size for XHDPI displays. (e.g. 12dp = 12px MDPI, 18px HDPI, 24px XHDPI).

  • Scaled Pixels: These will be equivalent to the DP value, but scaled according to the user preference to be smaller or larger.

If you're designing at 72 dpi (Photoshop default DPI setting), an 8pt font would be equivalent to 8px, which would be 8px at MDPI, 12px at HDPI, and 16px at XHDPI, or more simply 8dp for all densities. I don't know how much scaling gets applied to different SP settings, so you'd have to hunt that out, but basically I would just give them the mockup and let them size it appropriately from there -- surely they can get it pretty close visually from that.

like image 103
Kevin Coppock Avatar answered Sep 29 '22 16:09

Kevin Coppock


In contrast to dp (and sp with minus the user text sizing factor), pt has pretty much the exact same physical measurement. Dp is more or less a rough approximation, since it uses the same factor for a wide dpi range.

You cannot convert pt to sp, like said by Flavio. You can, however convert pt to dp roughly (+/- 30% in extreme cases, but at least expect +/-10%).

Using the dpi buckets (ldp=120,mdpi=160,hdpi=240,xhdpi=320) the most generic conversion factor would be x0.45 (= 72/120*0.75 = 72/160*1 = 72/240*1,5 = 72/320*2) if using the exact dpi bucket values.

For more precise factors:

  • mdpi (scaling factor: 1.0) 10.1" WXGA Screen (149dpi) is 0.483076923 (= 72/149 * 1.0)
  • hdpi (scaling factor: 1.5) Nexus 7 (216dpi) is 0.5 (= 72/216 * 1.5)
  • xhdpi (scaling factor: 2.0) Nexus 10 (300dpi) is 0.48 (= 72/300 * 2)

So 12 pt would be on...

  • 10.1" WXGA: 24.84dp
  • Nexus 7: 24 dp
  • Nexus 10: 25dp
  • dpi bucket value: 26.666dp

You could use the same values for sp, but keep in mind, that these could be in/decreased by the users settings.

like image 39
Patrick Favre Avatar answered Sep 29 '22 16:09

Patrick Favre