2
在下面的程序中,我使用cairo-0.12.2
来绘制一些带有字母的小框。不幸的是,当我使用translate
函数来移动用户空间原点时,该矩形被翻译,但文本不是。为什么不cairo翻译文本?
import Graphics.Rendering.Cairo
main = withSVGSurface "test.svg" 600 600
(`renderWith` draw)
draw = do
color white
rectangle 0 0 600 600
fill
newPath
color black
translate 300 300
drawSortBox
translate 200 200
drawSortBox
stroke
drawSortBox = do
showText "V Ʌ"
a <- textExtents "V Ʌ"
rectangle (textExtentsXbearing a - 2) (textExtentsYbearing a - 2) (textExtentsWidth a/2 + 2) (textExtentsHeight a + 4)
rectangle (textExtentsXbearing a - 2) (textExtentsYbearing a - 2) (textExtentsWidth a + 4) (textExtentsHeight a + 4)
color (a,b,c) = setSourceRGB a b c
white = (255,255,255)
black =(0,0,0)