diff options
author | Kurt Jung <kurt.w.jung@gmail.com> | 2015-07-09 12:39:35 -0400 |
---|---|---|
committer | Kurt Jung <kurt.w.jung@gmail.com> | 2015-07-09 12:39:35 -0400 |
commit | 6566b4c16726d1dd4cffad288685ab0b7201f7bc (patch) | |
tree | debef748dfa8de95b1fd537a039d32a16f033277 /fpdf.go | |
parent | a135cab5240a5744e44e4cb4522fc48db71c65e8 (diff) |
Add some font size and conversion methods that use document units rather than points
Diffstat (limited to 'fpdf.go')
-rw-r--r-- | fpdf.go | 32 |
1 files changed, 31 insertions, 1 deletions
@@ -1528,7 +1528,8 @@ func (f *Fpdf) SetFont(familyStr, styleStr string, size float64) { return } -// SetFontSize defines the size of the current font in points. +// SetFontSize defines the size of the current font. Size is specified in +// points (1/ 72 inch). See also SetFontUnitSize(). func (f *Fpdf) SetFontSize(size float64) { if f.fontSizePt == size { return @@ -1540,6 +1541,19 @@ func (f *Fpdf) SetFontSize(size float64) { } } +// SetFontUnitSize defines the size of the current font. Size is specified in +// the unit of measure specified in New(). See also SetFontSize(). +func (f *Fpdf) SetFontSize(size float64) { + if f.fontSize == size { + return + } + f.fontSizePt = size * f.k + f.fontSize = size + if f.page > 0 { + f.outf("BT /F%d %.2f Tf ET", f.currentFont.I, f.fontSizePt) + } +} + // GetFontSize returns the size of the current font in points followed by the // size in the unit of measure specified in New(). The second value can be used // as a line height value in drawing operations. @@ -2849,6 +2863,22 @@ func (f *Fpdf) outbuf(b *bytes.Buffer) { } } +// RawWriteStr writes a string directly to the PDF generation buffer. This is a +// low-level function that is not required for normal PDF construction. An +// understanding of the PDF specification is needed to use this method +// correctly. +func (f *Fpdf) RawWriteStr(str string) { + f.out(str) +} + +// RawWriteBuf writes the contents of the specified buffer directly to the PDF +// generation buffer. This is a low-level function that is not required for +// normal PDF construction. An understanding of the PDF specification is needed +// to use this method correctly. +func (f *Fpdf) RawWriteBuf(buf *bytes.Buffer) { + f.outbuf(buf) +} + // Add a formatted line to the document func (f *Fpdf) outf(fmtStr string, args ...interface{}) { f.out(sprintf(fmtStr, args...)) |