switch to vector text rendering in more cases

fixed text rendering test case
This commit is contained in:
Thomas Friedel 2020-05-28 11:12:55 +02:00
parent f36e11bdff
commit 5eb5dc34e1
2 changed files with 7 additions and 0 deletions

BIN
testdata/Text.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 825 B

View file

@ -153,10 +153,17 @@ func (cv *Canvas) FillText(str string, x, y float64) {
scale := (scaleX + scaleY) * 0.5 scale := (scaleX + scaleY) * 0.5
fontSize := fixed.Int26_6(math.Round(float64(cv.state.fontSize) * scale)) fontSize := fixed.Int26_6(math.Round(float64(cv.state.fontSize) * scale))
// if the font size is large or rotated or skewed in some way, use the
// triangulated font rendering
if fontSize > fixed.I(25) { if fontSize > fixed.I(25) {
cv.fillText2(str, x, y) cv.fillText2(str, x, y)
return return
} }
mat := cv.state.transform
if mat[1] != 0 || mat[2] != 0 || mat[0] != mat[3] {
cv.fillText2(str, x, y)
return
}
frc := cv.getFRContext(cv.state.font, fontSize) frc := cv.getFRContext(cv.state.font, fontSize)
fnt := cv.state.font.font fnt := cv.state.font.font