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

Custom fonts not rendering properly #53

Closed
kalius opened this issue Mar 16, 2017 · 4 comments
Closed

Custom fonts not rendering properly #53

kalius opened this issue Mar 16, 2017 · 4 comments

Comments

@kalius
Copy link

kalius commented Mar 16, 2017

I tried to put some custom fonts in HTML. It seems to work in general, but it doesn't work when italic style is desired. Italic style works for standard fonts but not for custom.

Font face declaration:

@font-face {
    font-family: 'FontBI';
    src: url('FontBI.TTF') format('truetype'); 
    font-weight: 400;
    font-style: italic;
}

HTML:

<div style="font-family:'FontBI'; font-style:italic; font-weight:bold;">
Italic Font test
</div>

Font-weight:bold is working, but font-style:italic isn't!

Any ideas how to solve this or it is a bug in phantomjs?

@bjrmatos
Copy link
Collaborator

hmm just note that in order to have italic support in a font, the font itself needs to have italic support in it, if you have confirmed that your font has support for italic, maybe the font file that you have downloaded is not the full version of the font (with italic support on it). also, you can also use fonts in phantomjs using assets extensions as described here.

@pofider
Copy link
Owner

pofider commented Mar 16, 2017

I would recommend to try the phantomjs2, see here. The font support in the default phantomjs included in this package is not very good.

https://github.com/pofider/phantom-html-to-pdf#phantomjs2

@kalius
Copy link
Author

kalius commented Mar 16, 2017

@bjrmatos font has italic support.

But in the meantime I found the solution for that (or workaround). It seems that if I add properties

font-weight: normal;
font-style: normal;

to every font-face declaration and then use font-style:italic in CSS style prop that italic does work.

Here is also one suggestion for solution if others have similar problems: ariya/phantomjs#13561 (comment) but for me it worked for ttf as well.

By using that workaround it works in 1.9 and 2.x.

Thanks for quick response btw!

@kalius kalius changed the title Fonts not rendering properly Custom fonts not rendering properly Mar 16, 2017
@bjrmatos
Copy link
Collaborator

great, thnks for posting your solution!

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