// Copyright ©2021 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package font

import (
	
	
)

// Length is a unit-independent representation of length.
// Internally, the length is stored in postscript points.
type Length float64

// Dots returns the length in dots for the given resolution.
func ( Length) ( float64) float64 {
	return float64() / Inch.Points() * 
}

// Points returns the length in postscript points.
func ( Length) () float64 {
	return float64()
}

// Common lengths.
const (
	Inch       Length = 72
	Centimeter        = Inch / 2.54
	Millimeter        = Centimeter / 10
)

// Points returns a length for the given number of points.
func ( float64) Length {
	return Length()
}

// ParseLength parses a Length string.
// A Length string is a possible signed floating number with a unit.
// e.g. "42cm" "2.4in" "66pt"
// If no unit was given, ParseLength assumes it was (postscript) points.
// Currently valid units are:
//
//   - mm (millimeter)
//   - cm (centimeter)
//   - in (inch)
//   - pt (point)
func ( string) (Length, error) {
	var  Length = 1
	switch {
	case strings.HasSuffix(, "in"):
		 = [:len()-len("in")]
		 = Inch
	case strings.HasSuffix(, "cm"):
		 = [:len()-len("cm")]
		 = Centimeter
	case strings.HasSuffix(, "mm"):
		 = [:len()-len("mm")]
		 = Millimeter
	case strings.HasSuffix(, "pt"):
		 = [:len()-len("pt")]
		 = 1
	}
	,  := strconv.ParseFloat(, 64)
	if  != nil {
		return 0, 
	}
	return Length() * , nil
}