Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.17k stars 1.17k forks source link

measureText is different between browser and node #801

Open minzojian opened 8 years ago

minzojian commented 8 years ago

image i render a simple text in fabric.js(which use node-canvas to render objects in node side) same font,same texts,but the measureText("i").width is different the left side is run in chrome,and the width is (just as we can see) 32px, right side is render in node-canvas,and the character width become 60,so that make a text wrap.cause my textbox width is limited. is any clue to make node-canvas get a right character width?

LinusU commented 8 years ago

Duplicate of #782 I think

Basically there is no way to fix this, since different browsers and OSes can use different text rendering, and measureText must reflect what will actually be drawn...

chearon commented 8 years ago

the left side is run in chrome,and the width is (just as we can see) 32px, right side is render in node-canvas,and the character width become 60

that does seem way more wrong than it should be though, I dunno if you're using the Pango build or the other one but maybe try another font and see if you still get the same issue?