1package gofpdf
2
3// Adapted from http://www.fpdf.org/en/script/script61.php by Wirus and released with the FPDF license.
4
5// SubWrite prints text from the current position in the same way as Write().
6// ht is the line height in the unit of measure specified in New(). str
7// specifies the text to write. subFontSize is the size of the font in points.
8// subOffset is the vertical offset of the text in points; a positive value
9// indicates a superscript, a negative value indicates a subscript. link is the
10// identifier returned by AddLink() or 0 for no internal link. linkStr is a
11// target URL or empty for no external link. A non--zero value for link takes
12// precedence over linkStr.
13//
14// The SubWrite example demonstrates this method.
15func (f *Fpdf) SubWrite(ht float64, str string, subFontSize, subOffset float64, link int, linkStr string) {
16	if f.err != nil {
17		return
18	}
19	// resize font
20	subFontSizeOld := f.fontSizePt
21	f.SetFontSize(subFontSize)
22	// reposition y
23	subOffset = (((subFontSize - subFontSizeOld) / f.k) * 0.3) + (subOffset / f.k)
24	subX := f.x
25	subY := f.y
26	f.SetXY(subX, subY-subOffset)
27	//Output text
28	f.write(ht, str, link, linkStr)
29	// restore y position
30	subX = f.x
31	subY = f.y
32	f.SetXY(subX, subY+subOffset)
33	// restore font size
34	f.SetFontSize(subFontSizeOld)
35}
36