aboutsummaryrefslogtreecommitdiffstats
path: root/gui/text/text.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-05-10 15:12:40 -0400
committerSam Anthony <sam@samanthony.xyz>2024-05-10 15:12:40 -0400
commit2a75e404af43ca8fa6e707d4506b41dad0ba1b83 (patch)
treef0eb127c39720302f2a496ccf0f01529dd749c3f /gui/text/text.go
parentf81e4a813766980c6e837893e19cc10bf6d7c41e (diff)
downloadvolute-2a75e404af43ca8fa6e707d4506b41dad0ba1b83.zip
unicode support
Diffstat (limited to 'gui/text/text.go')
-rw-r--r--gui/text/text.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/gui/text/text.go b/gui/text/text.go
index 942dce2..7dc4928 100644
--- a/gui/text/text.go
+++ b/gui/text/text.go
@@ -46,11 +46,11 @@ const (
)
func Size(text string) image.Point {
- bounds := textBounds([]byte(text), font.Drawer{Face: face})
+ bounds := textBounds(text, font.Drawer{Face: face})
return image.Point{bounds.Max.X - bounds.Min.X + 2*PAD, bounds.Max.Y - bounds.Min.Y + 2*PAD}
}
-func Draw(text []byte, dst draw.Image, r image.Rectangle, fg, bg color.Color, align Align) {
+func Draw(text string, dst draw.Image, r image.Rectangle, fg, bg color.Color, align Align) {
drawer := font.Drawer{
Src: &image.Uniform{fg},
Face: face,
@@ -65,7 +65,7 @@ func Draw(text []byte, dst draw.Image, r image.Rectangle, fg, bg color.Color, al
textImg := image.NewRGBA(bounds)
draw.Draw(textImg, bounds, &image.Uniform{bg}, image.ZP, draw.Src)
drawer.Dst = textImg
- drawer.DrawBytes(text)
+ drawer.DrawString(text)
leftCentre := image.Pt(bounds.Min.X, (bounds.Min.Y+bounds.Max.Y)/2)
var target image.Point
@@ -79,8 +79,8 @@ func Draw(text []byte, dst draw.Image, r image.Rectangle, fg, bg color.Color, al
draw.Draw(dst, bounds.Add(delta).Intersect(r), textImg, bounds.Min, draw.Src)
}
-func textBounds(text []byte, drawer font.Drawer) image.Rectangle {
- b, _ := drawer.BoundBytes(text)
+func textBounds(text string, drawer font.Drawer) image.Rectangle {
+ b, _ := drawer.BoundString(text)
return image.Rect(
b.Min.X.Floor(),
b.Min.Y.Floor(),