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

using OpenType fonts results in non-selectable text on Windows #1539

Closed
mn4367 opened this Issue Feb 17, 2014 · 27 comments

Comments

Projects
None yet
4 participants
@mn4367
Contributor

mn4367 commented Feb 17, 2014

If I use an Opentype font on Windows 7 the text in the PDF is no longer selectable and the PDF gets very big. Reminds me of older versions on OS X.

Checked with wkhtmltox-win64_0.12.1-development-773cad3.exe from Sourceforge.

@pallymore

This comment has been minimized.

pallymore commented Feb 17, 2014

same issue in MacOSX. but works on heroku(linux amd64)

@mn4367

This comment has been minimized.

Contributor

mn4367 commented Feb 17, 2014

Hmm, I checked this again with wkhtmltox-macosx-10.9.1-x86_64-0.12.1-development-593ac96.tar.xz on OS X 10.8.5 and can't confirm this with the fonts on my system. With both Opentype and Truetype fonts I get selectable text on the Mac. Which fonts don't work for you?

@pallymore

This comment has been minimized.

pallymore commented Feb 17, 2014

I'm using a custom font called "Gotham"

@mn4367

This comment has been minimized.

Contributor

mn4367 commented Feb 17, 2014

Could you upload this font somewhere? I'd be willing to test it here.

@pallymore

This comment has been minimized.

pallymore commented Feb 17, 2014

sorry it's licensed, I don't think I'm allowed to do that :(

@mn4367

This comment has been minimized.

Contributor

mn4367 commented Feb 17, 2014

OK, no problem. Which variant do you use (medium, thin)? I'll try to get it elsewhere.

@pallymore

This comment has been minimized.

pallymore commented Feb 17, 2014

I used 'normal' (Gotham-Book), 'bold' (Gotham-Bold), and 'lighter' (Gotham-Light)
thanks.

@mn4367

This comment has been minimized.

Contributor

mn4367 commented Feb 17, 2014

Like this?
gotham

It works here. And Acrobat Reader says Gotham-Book is embedded.

@pallymore

This comment has been minimized.

pallymore commented Feb 17, 2014

Hm...weird. I'm using absolute positioning, I wonder if it is related. It's not selectable in my local environment, but works on heroku (w/ a different issue - everything becomes bolded.)

@mn4367

This comment has been minimized.

Contributor

mn4367 commented Feb 17, 2014

I don't think it has something to do with absolute positioning. Are you using the latest development snapshot? Also, CSS for font families with tons of different weights is sometimes tricky. So maybe wkhtmltopdf just uses a different font which doesn't work.

@pallymore

This comment has been minimized.

pallymore commented Feb 17, 2014

yes, it's the latest dev snapshot. I just checked the PDF file, the one generated on my machine has no font embedded, but the one generated on heroku has only the bold font embedded

@mn4367

This comment has been minimized.

Contributor

mn4367 commented Feb 17, 2014

Looking at #1542 I suspect that the font family definition and font weight in your CSS could be the reason. The font in "PDF - Local environment: Mac OSx 10.9 (wkhtmltopdf 0.12.1rc)" doesn't look like Gotham, the 'a' for example looks completely different. I'd say it is replaced by Arial or something similar. Can you use Acrobat Reader to check which font families are really embedded?

@pallymore

This comment has been minimized.

pallymore commented Feb 17, 2014

Yea I'm looking at the HTML version it seems only 2 fonts were downloaded. debugging my css right now.

@pallymore

This comment has been minimized.

pallymore commented Feb 17, 2014

It seems it has something to do with the comments I have in the css file...It's downloading all 3 fonts now after I removed all the comments. but the pdf is still having issues. (local: light font is missing, no font embedded in pdf; heroku: light and normal fonts are missing, only bold is embedded in the pdf)

@ashkulz

This comment has been minimized.

Member

ashkulz commented Feb 18, 2014

@mn4367, @pallymore: can you post the font, html and CSS somewhere so that it can be verified?

@mn4367

This comment has been minimized.

Contributor

mn4367 commented Feb 18, 2014

You can use https://gist.github.com/mn4367/9068693 and add font-family: "Gotham"; to the CSS in the body. This is what I did and it worked here, all fonts are embedded and text is selectable. For the font, as @pallymore said, it is licensed and I dare to upload it. Just a hint, the first search result with Where can I download the "Gotham" font/typeface? in Google may help ;-).

@mn4367

This comment has been minimized.

Contributor

mn4367 commented Feb 18, 2014

@pallymore, if I read your post correctly it seems that you are using fonts which are downloaded on demand from the internet, correct? Maybe this is the source of problems. With local Opentype fonts I always get selectable text and properly embedded fonts.

@pallymore

This comment has been minimized.

pallymore commented Feb 18, 2014

Actually I'm encoding them to base64. I wonder if that's causing problems (on heroku only bold font is being recognized). Since the part of the app runs on heroku worker dynos (mass generating pdf reports), downloading the font files (8different font files in one report, currently i'm only using three of them) doesn't seem to be optimal. I'm testing if I can load them locally when generating pdfs.

@pallymore

This comment has been minimized.

pallymore commented Feb 18, 2014

I just tested it again without using base64 encoding. Instead, I'm loading all the fonts into heroku (http://www.mobalean.com/blog/2011/08/02/pdf-generation-and-heroku) and use them locally. The pdf generated in heroku only embeds the bold font, and the pdf generated in my local machine doesn't embed any font.

Here's part of my css:

p {
    font-family: Gotham;
    font-weight: 400;
    font-style: normal; 
}

#cover .report-cover-info p.cover-info-title, #cover .report-cover-info p.school-name {
  font-family: Gotham;
  font-weight: lighter;
  font-style: normal; 
}

#cover .report-title h1, #cover .report-cover-info p.administration {
  font-family: Gotham;
  font-weight: bold;
  font-style: normal; 
}

html,
body {
  margin: 0;
  padding: 0;
  text-rendering: optimizeLegibility; 
}

#cover .report-title h1 {
    position: absolute;
    text-align: right;
    font-size: 25pt;
    line-height: 24pt; 
}

#cover .report-title p {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 1.4in;
    margin: 0;
    font-size: 11pt;
    line-height: 14pt;
    color: #A7A9AC; 
}

#cover .report-cover-info p.cover-info-title {
  font-size: 3.75em;
  line-height: 1em;
  margin: 0;
  color: #939598; 
}

#cover .report-cover-info p.prepared-for-title {
  margin-top: 0.27in;
  font-size: 15pt;
  line-height: 15pt;
  color: #BCBEC0;
  letter-spacing: 0.04em;
}

#cover .report-cover-info p.teacher-name {
  margin-top: 5pt;
  font-size: 28pt;
  line-height: 28pt;
  color: #f3773a; 
}
@pallymore

This comment has been minimized.

pallymore commented Feb 18, 2014

I've been testing different methods all day. the best i've got so far is to be able to embed two fonts (bold and 'book'), but still no luck with Light. and even with that, some text under the same font style appears differently in the PDF. Could you guys try it w/ Gotham Light?

Thanks

@ashkulz

This comment has been minimized.

Member

ashkulz commented Feb 19, 2014

can you try using a TrueType/WOFF font?

@mgaerber

This comment has been minimized.

mgaerber commented Feb 19, 2014

same here - using "TheSerif" from LucasFonts. It is a OTF/CFF Font. Maybe CFF is the problem here?

@pallymore

This comment has been minimized.

pallymore commented Feb 19, 2014

hello @ashkulz I tried both ttf & woff format of the same font, and both produced the same result.

@ashkulz

This comment has been minimized.

Member

ashkulz commented Jul 2, 2014

@mn4367: can you dig out the sample HTML/CSS you used for the initial bug report? I have a suspicion that QTBUG-10089 is the root cause and the patch in QTBUG-11387 will fix the issue. Also, #1620 may be related to this.

@ashkulz ashkulz changed the title from Windows 7 64: Using Opentype fonts results in non-selectable text. to using OpenType fonts results in non-selectable text on Windows Jul 2, 2014

@ashkulz ashkulz added this to the 0.12.2 milestone Jul 2, 2014

@ashkulz ashkulz added the NeedInfo label Jul 3, 2014

@ashkulz

This comment has been minimized.

Member

ashkulz commented Jul 4, 2014

OK, it looks like the patch in #1620 does fix this issue (file size goes down from 217kB to 20kB) and the fonts do get embedded.

@ashkulz ashkulz added the Fixed label Jul 4, 2014

@ashkulz ashkulz added HasPatch and removed Fixed labels Jul 4, 2014

@ashkulz ashkulz closed this in 834273b Oct 20, 2014

@ashkulz ashkulz added Fixed and removed HasPatch labels Oct 20, 2014

ashkulz added a commit that referenced this issue Oct 21, 2014

@ashkulz

This comment has been minimized.

Member

ashkulz commented Oct 22, 2014

Please test this with the latest 0.12.2 test release available from the downloads page and report back if you find any problems.

ashkulz added a commit that referenced this issue Jan 5, 2015

update Qt for improvements in OpenType rendering for Windows
Some patches were already merged for #1539 but now are cherry-picked
from the 4.8 branch, while others are fresh backports from Qt5.
@ashkulz

This comment has been minimized.

Member

ashkulz commented Jan 10, 2015

0.12.2 has been released, which includes changes related to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment