无论是使用gdi还是freetype生成的描边字都有明显的锯齿。aardio封装的web.blink库能够直接调用js、支持html5。 因此我们可以利用html5的canvas绘制描边字,并保存下来
import win.ui; /*DSG{{*/ mainForm = win.form(text="描边字生成";right=1108;bottom=716) mainForm.add( picturebox={cls="plus";left=1030;top=616;right=1272;bottom=679;edge=1;foreRepeat="stretch";transparent=1;z=1} ) /*}}*/ import web.blink.form; var mb = web.blink.form(mainForm); mainForm.show(); html = /* <!doctype html> <html> <body> <img id='test'></img> </body> </html> */ mb.write(html) var img = mb.getEle("test"); var canvas = mb.document.createElement("canvas"); canvas.width = 50; canvas.height = 50; var ctx = canvas.getContext("2d"); //设置文字字体和大小 ctx.font = "bold 50px 黑体"; //设置画笔(绘制线条)操作的线条宽度,非必须;如果不写这句,那就是默认1 ctx.lineWidth = 8; ctx.strokeStyle = 'red'; ctx.strokeText('初',0, 42); ctx.fillStyle = 'black'; ctx.fillText('初', 0, 42); var base64 = canvas.toDataURL("image/png"); base64 = string.replace(base64,"^data\:image\/(\w+);base64,", ""); import crypt.bin; var bmp = crypt.bin.decodeBase64(base64); string.save("\my.png",bmp ) win.loopMessage();