# Units#

The basic typesetting unit is a “scaled point” (sp) and the Go type is `bag.ScaledPoint`

. One DTP point (1/72 inch) consists of 65535 scaled points.
There are two methods (`bag.Sp()`

and `bag.MustSp()`

) to convert from other units to sp.

The known units are

Name | Unit |
---|---|

`pt` (DTP point) |
There are 65535 scaled points in one DTP point. For conversion, always use the constant `bag.Factor` and never the value 65535 itself, as it is subject to change. |

`in` |
Inch – 72 DTP points are one inch. |

`mm` |
Millimeter (1/1000 of one meter) |

`cm` |
Centimeter (1/100 of one meter) |

`m` |
Meter |

`px` |
Pixel - 96 Pixes are one inch |

`pc` |
Pica – twelve DTP points or 1/6 inch |

## Conversion#

These two functions convert strings such as `"1cm"`

or `"12.4in"`

to scaled points. The `MustSP`

function panics if it cannot convert the unit.

To convert from scaled points to other units use

For example

To convert to DTP points use

## Convenience functions#

There are a few convenience functions:

and

if you need to multiply a scaled point with a float.

## String#

The `ScaledPoint`

type implements the `Stringer`

interface which returns a string suitable for the PDF file.