aboutsummaryrefslogtreecommitdiffstats
path: root/gui/widget/concurrent_face.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-01-17 15:38:33 -0500
committerSam Anthony <sam@samanthony.xyz>2024-01-17 15:38:33 -0500
commit29e2be59cc3d0f31241884087624ece7d35115e4 (patch)
tree07486ce8cebf9d7f9901f015c6ccd7803b8baa59 /gui/widget/concurrent_face.go
parent6a2e268df7e008579d1b6a0f2ef47597fcbe4862 (diff)
downloadvolute-29e2be59cc3d0f31241884087624ece7d35115e4.zip
add user input widget
Diffstat (limited to 'gui/widget/concurrent_face.go')
-rw-r--r--gui/widget/concurrent_face.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/gui/widget/concurrent_face.go b/gui/widget/concurrent_face.go
new file mode 100644
index 0000000..98db572
--- /dev/null
+++ b/gui/widget/concurrent_face.go
@@ -0,0 +1,51 @@
+package widget
+
+import (
+ "image"
+ "sync"
+
+ "golang.org/x/image/font"
+ "golang.org/x/image/math/fixed"
+)
+
+type concurrentFace struct {
+ mu sync.Mutex
+ face font.Face
+}
+
+func (cf *concurrentFace) Close() error {
+ cf.mu.Lock()
+ defer cf.mu.Unlock()
+ return cf.face.Close()
+}
+
+func (cf *concurrentFace) Glyph(dot fixed.Point26_6, r rune) (
+ dr image.Rectangle, mask image.Image, maskp image.Point, advance fixed.Int26_6, ok bool) {
+ cf.mu.Lock()
+ defer cf.mu.Unlock()
+ return cf.face.Glyph(dot, r)
+}
+
+func (cf *concurrentFace) GlyphBounds(r rune) (bounds fixed.Rectangle26_6, advance fixed.Int26_6, ok bool) {
+ cf.mu.Lock()
+ defer cf.mu.Unlock()
+ return cf.face.GlyphBounds(r)
+}
+
+func (cf *concurrentFace) GlyphAdvance(r rune) (advance fixed.Int26_6, ok bool) {
+ cf.mu.Lock()
+ defer cf.mu.Unlock()
+ return cf.face.GlyphAdvance(r)
+}
+
+func (cf *concurrentFace) Kern(r0, r1 rune) fixed.Int26_6 {
+ cf.mu.Lock()
+ defer cf.mu.Unlock()
+ return cf.face.Kern(r0, r1)
+}
+
+func (cf *concurrentFace) Metrics() font.Metrics {
+ cf.mu.Lock()
+ defer cf.mu.Unlock()
+ return cf.face.Metrics()
+}