最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to prevent ugly spikes in canvas font rendering? - Stack Overflow

programmeradmin2浏览0评论

When I draw text in canvas, I get ugly spikes, like this:

Try it here: /

While for example in photoshop, I get this:

The code is just a classic strokeText:

ctx.font = '20px Arial';
ctx.lineWidth = 15;
ctx.strokeStyle = '#fff';
ctx.strokeText('How to prevent ugly spikes?');

If it isn't possible to fix this, is there any workaround?

When I draw text in canvas, I get ugly spikes, like this:

Try it here: http://jsfiddle/48m4B/

While for example in photoshop, I get this:

The code is just a classic strokeText:

ctx.font = '20px Arial';
ctx.lineWidth = 15;
ctx.strokeStyle = '#fff';
ctx.strokeText('How to prevent ugly spikes?');

If it isn't possible to fix this, is there any workaround?

Share Improve this question asked Nov 14, 2013 at 20:51 psycho brmpsycho brm 7,6741 gold badge45 silver badges42 bronze badges 1
  • 1 +1 for the awesome spiky effect... – rodrigo-silveira Commented Nov 14, 2013 at 21:02
Add a ment  | 

1 Answer 1

Reset to default 10

Try to set line join to:

ctx.lineJoin = 'round';

you can also adjust the miter limit:

ctx.miterLimit = 2;

Modified working fiddle

发布评论

评论列表(0)

  1. 暂无评论