2023-03-28 00:04:53 +00:00
|
|
|
package d2fonts
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2023-03-28 20:58:53 +00:00
|
|
|
"github.com/jung-kurt/gofpdf"
|
|
|
|
|
|
2023-03-28 00:04:53 +00:00
|
|
|
"oss.terrastruct.com/util-go/assert"
|
|
|
|
|
"oss.terrastruct.com/util-go/diff"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestCutFont(t *testing.T) {
|
|
|
|
|
f := Font{
|
|
|
|
|
Family: SourceCodePro,
|
2023-03-28 20:58:53 +00:00
|
|
|
Style: FONT_STYLE_BOLD,
|
2023-03-28 00:04:53 +00:00
|
|
|
}
|
2023-03-28 20:58:53 +00:00
|
|
|
fontBuf := make([]byte, len(FontFaces[f]))
|
|
|
|
|
copy(fontBuf, FontFaces[f])
|
|
|
|
|
fontBuf = gofpdf.UTF8CutFont(fontBuf, " 1")
|
2023-03-28 00:04:53 +00:00
|
|
|
err := diff.Testdata(filepath.Join("testdata", "d2fonts", "cut"), ".txt", fontBuf)
|
|
|
|
|
assert.Success(t, err)
|
|
|
|
|
}
|