Pt->sp
Based on the Applydimension method in Typedvalue.java:
public static float applydimension (int unit, float value, displaymetrics metrics) { switch (unit) { Case COMPLEX_UNIT_PX: return value; Case COMPLEX_UNIT_DIP: return value * metrics.density; Case COMPLEX_UNIT_SP: return value * metrics.scaleddensity; Case COMPLEX_UNIT_PT: return value * metrics.xdpi * (1.0F/72); Case COMPLEX_UNIT_IN: return value * METRICS.XDPI; Case COMPLEX_UNIT_MM: return value * metrics.xdpi * (1.0f/25.4f); } return 0; }
conversion of Complex_unit_pt to COMPLEX_UNIT_SP:
Value * metrics.xdpi * (1.0F/72))/metrics.scaleddensity = value * metrics.xdpi/(72*metrics.scaleddensity))
so 1 PT = metrics.xdpi/(* metrics.scaleddensity) SP
(where xdpi and metrics.scaleddensity can be obtained from the system, note that the PT of the UI callout is first converted to the PT corresponding to the system. Depending on the dimensions of the UI callout)
The value depends on the machine, approximately equal to 2.22, and part of the machine is 2.15.
Android Unit conversion