Skip to content


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


These two functions convert strings such as "1cm" or "12.4in" to scaled points. The MustSP function panics if it cannot convert the unit.

func Sp(unit string) (ScaledPoint, error)
func MustSp(unit string) ScaledPoint

To convert from scaled points to other units use

func (s ScaledPoint) ToUnit(unit string) (float64, error)

For example

twelvept := bag.MustSP("12pt")
twelveFloat, err := twelvept.ToUnit("pt")
// twelveFloat = 12.0

To convert to DTP points use

func (s ScaledPoint) ToPT() float64

Convenience functions#

There are a few convenience functions:

func Max(a, b ScaledPoint) ScaledPoint
func Min(a, b ScaledPoint) ScaledPoint


func MultiplyFloat(a ScaledPoint, f float64) ScaledPoint

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


The ScaledPoint type implements the Stringer interface which returns a string suitable for the PDF file.