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

javascript - Optimize text rendering in the canvas - the rendering speed of truetype versus bitmap fonts - Stack Overflow

programmeradmin4浏览0评论

I profiled a canvas-based app I'm working on (linkurious.js) and I discovered than the main bottleneck is the text rendering currently.

So, for now I use fillText() to render the text but:

  • Would it be more efficient to use bitmap fonts ?
  • Distance fields ?
  • Do the browser already optimize font rendering enough that I shouldn't try to beat them ?

I profiled a canvas-based app I'm working on (linkurious.js) and I discovered than the main bottleneck is the text rendering currently.

So, for now I use fillText() to render the text but:

  • Would it be more efficient to use bitmap fonts ?
  • Distance fields ?
  • Do the browser already optimize font rendering enough that I shouldn't try to beat them ?
Share Improve this question edited Jul 10, 2015 at 8:31 Mikko Ohtamaa 84k61 gold badges288 silver badges468 bronze badges asked Jul 9, 2015 at 15:24 damiodamio 6,3113 gold badges42 silver badges58 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

First of all rendering text, especially vector-based, is hard. You probably couldn't beat the browser even with WebGL based implementation, as the browser font rendering is pretty optimized (browsers have been rendering fonts since 1994).

In theory, if the text doesn't change, the browser / font engine should recreate and cache all rendered glyphs in GPU memory and then just blit them out from there as bitmaps.

So if the text is the performance bottleneck bitmap fonts bee an option. There are plenty of downsides, but speed is not one of them. After all, this was how the puters of 90s managed to produce any text on the screen at all.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论