How do I convert pt to sp?

前端 未结 6 1824
孤街浪徒
孤街浪徒 2020-12-08 02:02

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

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 02:55

    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.

提交回复
热议问题