From 6566b4c16726d1dd4cffad288685ab0b7201f7bc Mon Sep 17 00:00:00 2001 From: Kurt Jung Date: Thu, 9 Jul 2015 12:39:35 -0400 Subject: Add some font size and conversion methods that use document units rather than points --- def.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'def.go') diff --git a/def.go b/def.go index 33eca47..15836d0 100644 --- a/def.go +++ b/def.go @@ -76,10 +76,23 @@ type ImageInfoType struct { // value expressed in the unit of measure specified in New(). Since font // management in Fpdf uses points, this method can help with line height // calculations and other methods that require user units. -func (f *Fpdf) PointConvert(pt float64) float64 { +func (f *Fpdf) PointConvert(pt float64) (u float64) { return pt / f.k } +// PointToUnitConvert is an alias for PointConvert. +func (f *Fpdf) PointToUnitConvert(pt float64) (u float64) { + return pt / f.k +} + +// UnitToPointConvert returns the value of u, expressed in the unit of measure +// specified in New(), as a value expressed in points (1/72 inch). Since font +// management in Fpdf uses points, this method can help with setting font sizes +// based on the sizes of other non-font page elements. +func (f *Fpdf) UnitToPointConvert(u float64) (pt float64) { + return u * f.k +} + // Extent returns the width and height of the image in the units of the Fpdf // object. func (info *ImageInfoType) Extent() (wd, ht float64) { -- cgit v1.2.1-24-ge1ad