Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

measureText results (not width) differs on different Ubuntu release #782

Closed
huttli opened this issue Jun 10, 2016 · 2 comments
Closed

measureText results (not width) differs on different Ubuntu release #782

huttli opened this issue Jun 10, 2016 · 2 comments

Comments

@huttli
Copy link

huttli commented Jun 10, 2016

The following code:
ctx.textAlign='center';
ctx.textBaseLine='middle';
ctx.font=helpers.fontString(this.baseFontSize, 'normal', Base.defaultFontFamily);
ctx.fillStyle=Base.defaultForegroundColor;
var m = ctx.measureText(this.text);
console.log('measured text', this.text, 'm: ', m, 'fontsize:', this.baseFontSize);
produces different output on Ubuntu 15.10 and Ubuntu 14.04.
14.04:
measured text $135  m: { width: 40,
  actualBoundingBoxLeft: 20,
  actualBoundingBoxRight: 60,
  actualBoundingBoxAscent: 6.5,
  actualBoundingBoxDescent: 8.5,
  emHeightAscent: 9.5,
  emHeightDescent: 9.5,
  alphabeticBaseline: 5.5 } fontsize: 16
15.10:
measured text $135 m: { width: 40,
actualBoundingBoxLeft: 18,
actualBoundingBoxRight: 20,
actualBoundingBoxAscent: 6.5,
actualBoundingBoxDescent: 8.5,
emHeightAscent: 9.5,
emHeightDescent: 9.5,
alphabeticBaseline: 5.5 } fontsize: 16

node-canvas: 1.3.12
Specifically the difference is the actualBoundingBoxLeft and actualBoundingBoxRight.

I noticed that there were these measureText related issues:
#472
#331

But this one (wrong left right values) has never been mentioned. It could well be another pango difference.

@chearon
Copy link
Collaborator

chearon commented Jun 11, 2016

It could well be another pango difference.

It is, those numbers get pulled from Pango. They'll be different across platforms too. I don't think there's anything that could be done about it, would be nice though because I currently have pixel-based tests that fail on Windows for that same reason.

@LinusU
Copy link
Collaborator

LinusU commented Jun 12, 2016

Yeah, as far as I understand it it won't ever be the same on all platforms. I don't think that that is the case for the browser implemented canvas either.

In fact, it's not really supposed to be the same on all platforms since font-rendering isn't done the same on all platforms. I'm not even sure that you want the same font-rendering on all platforms, or if you actually want to match how the OS is rendering fonts.

Anyhow, unfortunately there isn't much we can do about it, and since the web implementation has the same problem I don't think it's worth keeping this issue open. Sorry about that, maybe you can figure out another way do to what you are trying to accomplish?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants