-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
font-family ignored #1
Comments
I now also tried with your base image and the following HTML. The font is rendered as sans-serif. There are serif fonts installed and fontconfig finds them. So I'd say it must have to do with wkhtmltopdf: <!DOCTYPE html>
<html>
<head>
<style>
p {
font-family: "Times New Roman", Times, serif;
}
</style>
</head>
<body>
<div style="font-face: serif; font-size: 12px">
A little test.
</div>
<p>Another paragraph.</p>
</body>
</html> |
@chdanielmueller Any idea here? I think this bug is quite essential. If font rendering does not work correctly most generated PDFs will look pretty weird. |
Hi @mikehaertl, Thank you for bringing this issue to my attention. I am sorry that I can not help at the moment. Regards, |
Ok, thanks for the update. I don't really have time either - but as I'll need a solution soon, maybe I'll be forced to take the time. 😄 If you have any suggestion or if anything comes to mind where I could start looking, please let me know. I'm completely new to compiling wkhtmltopdf from scratch. |
I took a look at your posted fontconfig outputs. The serif fonts (e.g. Times New Roman) are not listed in the new app. |
fontconfig seems to be working fine
|
Yeah, well, that's exactly the problem. So somehow wkhtmltopdf does not ask fontconfig for "Times New Roman" (or any other serif font) even though I've used a serif font in The question is: why? It should do so, as you see from the output of the old app (from wkhtmltopdf on Debian). |
Yeah why is a good question. At least I was able to confirm it is a wkhtmltopdf (probably build related) issue. fontconfig itself and the installed fonts are working as expected within the container |
Opened an issue with wkthmltopdf. Maybe they have some input. I'm not sure if the project is much maintained lately, though. |
@mikehaertl Please try the command |
@chdanielmueller Did you try to set |
@mikehaertl I did not manage to set |
I think, nzz.ch uses embedded fonts or something. Maybe this bypasses fontconfig matching. To get
|
What's striking: The fontconfig matchpattern from wkhtmltopdf for ncc.ch is almost always the same as in my top post. Only some patterns differ:
I don't know, how wkhtmltopdf creates these match patterns. But what we know:
If you should reverse-engineer this, I would say: wkhtmltopdf has an internal list of all the font names it knows. If it finds a CSS And this list is missing some very common font names like "Times New Roman", etc. Could it be, that it uses whatever fonts are available on the system during compile time? |
This seems to be true.
This should not be true since I have a buildconfig for qt specifying
I suppose not since all fonts are installed together with the build dependencies and before building qt and wkhtmltopdf I did check the
This was not fullfilled during build time... |
Had no luck either... Still the same issue. Again fonts included on the page (fontawesome) were rendered correctly. |
Confirmed the correct rendering of web loaded fonts by using: |
@chdanielmueller On a sidenote, maybe you could help creating an "official" Alpine build? They now have a repository to collect the distribution specific build/packaging scripts: https://github.com/wkhtmltopdf/packaging |
@ashkulz Do you have an idea on this? |
Did you push the version you used with |
@ashkulz No I did not push it because it did not work. What I found out is that it does not use the installed fontconfig. I moved the fontconfig executables to another directory and wkhtmltopdf was still able to function properly. That seems currently like the most possible issue to me. |
@mikehaertl Don't know if this is still an issue for you. apk add --no-cache --virtual .build-deps msttcorefonts-installer \
&& update-ms-fonts \
&& fc-cache -f \
&& apk del .build-deps Currently building docker images |
@chdanielmueller Very interesting. But did you also see my issue report above? I found that |
@mikehaertl I did see your issue report. I am still a bit confused why my fix works at all. |
I've included your
wkhtmltopdf
binary into one of my Alpine 3.7 based images like this:It works fine so far, except for one nasty issue: It seems to ignore any
font-family
settings in the generated PDF. Is this a known problem? If not, any idea what I'm doing wrong or what else I could try?More background:
I'm migrating an older Debian based application with wkhtmltopdf 0.11 to an Alpine based image. The old app works just fine, whereas the new one fails to render the correct font. The relevant part of the CSS is:
As I understand it, wkhtmltopdf asks fontconfig to deliver a matching font file. So far I found out, that in the end the old app uses the
n021004l.pfb
font file. This is the font recommended by fontconfig. The font is also available under the new app and listed there underfc-list
. So I used FC_DEBUG=1 to see what wkhtmltopdf asks for and what fontconfig sends back in return.The output is listed below. The top block seems to be the "query part" (AKA what wkhtmltopdf asks for). And the lower block (Best score ...) is, what fontconfig thinks is the best match for this query.
The weird thing is, that with 0.12.4 it always queries the same list of font families (family: "Helvetica"(s) "TeX Gyre Heros"(s) "Arial"(w)...) , no matter what I set in CSS. Whereas in the old app the query is much more in line with my CSS (family: "Times New Roman"(s) "Tinos"(s)..).
Any feedback is appreciated.
Fontconfig output from the old app
Fontconfig output from the new app
The text was updated successfully, but these errors were encountered: