Fetch the repository succeeded.
package gopdf
import (
"math/big"
"strings"
)
// StrHelperGetStringWidth get string width
func StrHelperGetStringWidth(str string, fontSize int, ifont IFont) float64 {
return StrHelperGetStringWidthPrecise(str, float64(fontSize), ifont)
}
// StrHelperGetStringWidthPrecise get string width with real number fontSize
func StrHelperGetStringWidthPrecise(str string, fontSize float64, ifont IFont) float64 {
w := 0
bs := []byte(str)
i := 0
max := len(bs)
for i < max {
w += ifont.GetCw()[bs[i]]
i++
}
return float64(w) * (float64(fontSize) / 1000.0)
}
// CreateEmbeddedFontSubsetName create Embedded font (subset font) name
func CreateEmbeddedFontSubsetName(name string) string {
name = strings.Replace(name, " ", "+", -1)
name = strings.Replace(name, "/", "+", -1)
return name
}
// ReadShortFromByte read short from byte array
func ReadShortFromByte(data []byte, offset int) (int64, int) {
buff := data[offset : offset+2]
num := big.NewInt(0)
num.SetBytes(buff)
u := num.Uint64()
var v int64
if u >= 0x8000 {
v = int64(u) - 65536
} else {
v = int64(u)
}
return v, 2
}
// ReadUShortFromByte read ushort from byte array
func ReadUShortFromByte(data []byte, offset int) (uint64, int) {
buff := data[offset : offset+2]
num := big.NewInt(0)
num.SetBytes(buff)
return num.Uint64(), 2
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。