本文整理汇总了Golang中golang.org/x/image/font.Face.Metrics方法的典型用法代码示例。如果您正苦于以下问题:Golang Face.Metrics方法的具体用法?Golang Face.Metrics怎么用?Golang Face.Metrics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类golang.org/x/image/font.Face
的用法示例。
在下文中一共展示了Face.Metrics方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Measure
func Measure(r io.RuneReader, f font.Face) (size fixed.Point26_6, err error) {
var char rune
var prev rune
w := fixed.Int26_6(0)
m := f.Metrics()
size.Y = m.Height + m.Descent
for {
if char, _, err = r.ReadRune(); err != nil {
if err == io.EOF {
err = nil
}
size.X = maxInt26_6(size.X, w)
return
}
if char == '\n' {
size.X = maxInt26_6(size.X, w)
size.Y += m.Height
w, prev = 0, 0
continue
}
if prev != 0 {
w += f.Kern(prev, char)
}
w += advance(f, char)
prev = char
}
}
示例2: Advance
func (self rightToLeft) Advance(face font.Face, origin fixed.Point26_6, dot fixed.Point26_6, prev rune, char rune) (begin fixed.Point26_6, end fixed.Point26_6) {
if char == '\n' {
dot.X = origin.X
dot.Y += face.Metrics().Height
return dot, dot
}
if prev != 0 {
dot.X -= face.Kern(prev, char)
}
dot.X -= advance(face, char)
return dot, dot
}
示例3: Origin
func (self rightToLeft) Origin(face font.Face, bounds fixed.Rectangle26_6) fixed.Point26_6 {
return fixed.Point26_6{
X: bounds.Max.X,
Y: bounds.Min.Y + face.Metrics().Ascent,
}
}
示例4: MeasureString
// MeasureString returns the rendered width and height of the specified text
// given the current font face.
func MeasureString(ff font.Face, s string) (w float64, h float64) {
d := &font.Drawer{Face: ff}
return float64(d.MeasureString(s) >> 6),
float64(ff.Metrics().Height>>6) * 96.0 / 72.0
}