blob: 98db572757a5e906eec22ca2070bc5793fdb07bf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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()
}
|