font: add some comments for the XxxBytes methods.

Change-Id: I391b539e79d7e35f80d9ee0b8c7c70c2f42e2e99
Reviewed-on: https://go-review.googlesource.com/34095
Reviewed-by: Dave Day <djd@golang.org>
This commit is contained in:
Nigel Tao 2016-12-08 12:05:43 +11:00
parent e2d0a9f0e6
commit ae63d5d566

View File

@ -126,6 +126,8 @@ type Drawer struct {
// vertical line? Should DrawString return the number of runes drawn? // vertical line? Should DrawString return the number of runes drawn?
// DrawBytes draws s at the dot and advances the dot's location. // DrawBytes draws s at the dot and advances the dot's location.
//
// It is equivalent to DrawString(string(s)) but may be more efficient.
func (d *Drawer) DrawBytes(s []byte) { func (d *Drawer) DrawBytes(s []byte) {
prevC := rune(-1) prevC := rune(-1)
for len(s) > 0 { for len(s) > 0 {
@ -168,6 +170,8 @@ func (d *Drawer) DrawString(s string) {
} }
// MeasureBytes returns how far dot would advance by drawing s. // MeasureBytes returns how far dot would advance by drawing s.
//
// It is equivalent to MeasureString(string(s)) but may be more efficient.
func (d *Drawer) MeasureBytes(s []byte) (advance fixed.Int26_6) { func (d *Drawer) MeasureBytes(s []byte) (advance fixed.Int26_6) {
return MeasureBytes(d.Face, s) return MeasureBytes(d.Face, s)
} }
@ -178,6 +182,8 @@ func (d *Drawer) MeasureString(s string) (advance fixed.Int26_6) {
} }
// MeasureBytes returns how far dot would advance by drawing s with f. // MeasureBytes returns how far dot would advance by drawing s with f.
//
// It is equivalent to MeasureString(string(s)) but may be more efficient.
func MeasureBytes(f Face, s []byte) (advance fixed.Int26_6) { func MeasureBytes(f Face, s []byte) (advance fixed.Int26_6) {
prevC := rune(-1) prevC := rune(-1)
for len(s) > 0 { for len(s) > 0 {