diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-05-09 17:32:54 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-05-09 17:32:54 -0400 |
| commit | d463bb90ad629dfc8f1cd4f4b6b9590b0008832d (patch) | |
| tree | bf8763649c6a2f1af1fe46821216e327c094dcfa /gui/text/concurrent_face.go | |
| parent | 76980fe3014b5c133c4e30590e92bd922aa9b9c1 (diff) | |
| download | volute-d463bb90ad629dfc8f1cd4f4b6b9590b0008832d.zip | |
tree widget
Diffstat (limited to 'gui/text/concurrent_face.go')
| -rw-r--r-- | gui/text/concurrent_face.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/gui/text/concurrent_face.go b/gui/text/concurrent_face.go new file mode 100644 index 0000000..c865251 --- /dev/null +++ b/gui/text/concurrent_face.go @@ -0,0 +1,51 @@ +package text + +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() +} |