-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopentype_svg_fonts_test.go
More file actions
68 lines (52 loc) · 1.46 KB
/
opentype_svg_fonts_test.go
File metadata and controls
68 lines (52 loc) · 1.46 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//go:build linux
package freetype
import (
"testing"
"github.com/stretchr/testify/assert"
"modernc.org/libc"
"github.com/pekim/freetype/internal/font"
)
func TestLibrarySetSVGHooks(t *testing.T) {
initFuncCalled := false
var initFunc SVGLibInitFunc = func(_ *libc.TLS, _ uintptr) FTError {
initFuncCalled = true
return Err_Ok
}
freeFuncCalled := false
var freeFunc SVGLibFreeFunc = func(_ *libc.TLS, _ uintptr) {
freeFuncCalled = true
}
renderFuncCalled := false
var renderFunc SVGLibRenderFunc = func(_ *libc.TLS, _ GlyphSlot, _ uintptr) FTError {
renderFuncCalled = true
return Err_Ok
}
presetSlotFuncCalled := 0
var presetSlotFunc SVGLibPresetSlotFunc = func(_ *libc.TLS, _ GlyphSlot, _ Bool, _ uintptr) FTError {
presetSlotFuncCalled++
return Err_Ok
}
lib, err := Init()
assert.NoError(t, err)
err = lib.SetSVGHooks(SVGRendererHooks{
InitSVG: initFunc,
FreeSvg: freeFunc,
RenderSVG: renderFunc,
PresetSlot: presetSlotFunc,
})
assert.NoError(t, err)
face, err := lib.NewMemoryFace(font.NotoColorEmoji, 0)
assert.NoError(t, err)
err = face.SetPixelSizes(0, 32)
assert.NoError(t, err)
err = face.LoadGlyph(face.GetCharIndex('😀'), LOAD_COLOR)
assert.NoError(t, err)
err = face.RenderGlyph(RENDER_MODE_NORMAL)
assert.NoError(t, err)
err = lib.Done()
assert.NoError(t, err)
assert.True(t, initFuncCalled)
assert.True(t, freeFuncCalled)
assert.True(t, renderFuncCalled)
assert.Equal(t, 2, presetSlotFuncCalled)
}