Skip to content

the property font is not compatiable with HTML5 canvas font #566

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

Closed
zwzw911 opened this issue Jun 17, 2015 · 6 comments
Closed

the property font is not compatiable with HTML5 canvas font #566

zwzw911 opened this issue Jun 17, 2015 · 6 comments

Comments

@zwzw911
Copy link

zwzw911 commented Jun 17, 2015

HTML5 canvas font accept: font-style/font-variant/font-weight/font-size/font-family, for example, context.font="italic small-caps bold 12px arial", but node-canvas only accept font-style/font-size/font-family, it set font-variant or font-weight, the property font change to default value "10px sans-serfi"

@keverw
Copy link

keverw commented Oct 28, 2015

Interesting. I posted about this here #53 (comment)

but noticed bold isn't working in my case. I guess it's not supported yet?

@kaivi
Copy link

kaivi commented Feb 26, 2016

Yep, all options other than font-size and font-family are being ignored by node-canvas. When one specifies both font-style and font-variant, context.font gets reset to a default one:

Chrome 48.0.2564.116 on OS X

chrome-osx

canvas v1.3.10 on OS X

node-canvas-osx

Here is an in-browser JSFiddle, this code attempts to auto-fit font size to fill a rectangle.

@lulu-berlin
Copy link
Contributor

@zwzw911, the issue with not parsing the font style correctly (especially when it includes the variant) was fixed in #891. In the meantime, I can't get pango to actually render small-caps. Most fonts don't support it and I'm not sure that pango is capable of using this feature when it does exist. I opened an issue for this: #894.

I think that the "font reset" problem is fixed, so should this issue be closed now?

@jleclanche
Copy link

I'm not sure if line-height (16px/1em) is being taken into account right now, I don't think it is, but it doesn't error anymore in the 2.0 alpha, so yay. :)

jleclanche added a commit to HearthSim/Sunwell that referenced this issue Jul 17, 2017
@chearon
Copy link
Collaborator

chearon commented Jul 18, 2017

There is no line height on canvas since there's no layout functionality in the font APIs, it just draws one line of text. It might parse OK but would be ignored.

@zbjornson
Copy link
Collaborator

I think since #944 landed, this is as good as we can get. Please comment if you find any other discrepancies.

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

7 participants