-
-
Notifications
You must be signed in to change notification settings - Fork 705
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
weasyprint.exe v61.0: cannot use unpack() on <cdata 'char *' NULL> #2079
Comments
Same here, WeasyPrint version 61.1 exe on Windows 10 x64, when I try to convert a local .html file to .pdf this also happens. |
Hi! We tried to render the first document on our Windows 11 VM, and everything worked correctly. @ealib @LukeBriton Do you have this problem with a simple document? Could you also test with Windows 11 to see if it works? |
(Maybe related to harfbuzz/harfbuzz#3752.) |
@liZe I tried a very simple html file as this one: Still the same runtime error it has got. |
Sorry that I don't have access to Win11 for the moment, this is still on Win10. |
One more question: are your Windows 10 versions up to date? |
Mine is not the newest, it's Windows 10 19042.1237. |
I suspect that the problem has been introduced and then fixed with a Windows update. The way it appeared and disappeared in harfbuzz/harfbuzz#3752, without anything changing in Harfbuzz code, may be the result of a change in the Windows version used to build Harfbuzz in MinGW, or on GitHub CI. Do you have the possibility to update your version of Windows 10? |
I'm using WeasyPrint 61.2 on Windows 11 with the latest Windows update 23H2 build: 22631.3296 and I have the same issue. Is there a fix for this? |
Then the problem doesn’t come from the Windows version… There’s no fix yet. We’ll probably have to generate debugging exe files to understand what’s going on. Until then, you can probably help. Could you please try to render files like this one: <html style="font-family: Arial">test</html> trying different well-known Microsoft font faces, and see if you can render at least some of them? That would be really helpful. |
That sample fails as well. I tried many different fonts and none worked. But I don't think it is the font that is the issue, as soon as you have any content in the document, it fails. For example:This renders a blank page without errors:
But this causes the error we've described:
This is the command I used, and the result is this error -- notice how step 2 it identified a CSS string even though I passed in an external stylesheet file (stylesheet.css):
Note: Both the sample.html and the stylesheet.css files were placed in the dist folder, but I also tried referencing the stylesheet with a concrete path and tried specifying the stylesheet in the html document directly. I've tried with a stylesheet and without. Nothing seems to make a difference. It fails if anything is in the body of the document. |
That’s another unrelated issue you can open! 😄
The problem happens when a font is loaded, but it’s not related to a specific font. Could you please try the executable generated here? It contains extra debugging information that could be helpful, and a minor change to check that the problem we have is not caused by this problem. |
Thanks for that quick turnaround. Here are the outputs from 4 different tests: No stylesheet and no internal styles:
Stylesheet and no internal styles:
Internal style only,
|
😒 Could you please try this document? <html style="font-family: claritycity">
<style>
@font-face {
font-family: claritycity;
src: url(https://www.courtbouillon.org/static/fonts/ClarityCity-Regular.woff2);
}
</style>
test
</html> |
That one failed as well:
Sorry, if you read the initial comment before I edited it, I had created the new html file in the wrong location -- this is the run after I moved it into the correct location. |
Are you sure that your sample2.html file is in |
Yeah sorry, as soon as I saved the comment I realize I had created it in the wrong location ... I just updated that comment with the proper output from the run. |
Is that 'b' in preceding the font description (in the output) just part of the trace statement you're printing or is it created by the conversion code and relating to the issue?
|
Thanks a lot for your patience.
It’s a bytestring and not a string, that’s why we have the 'b' before. There’s no problem here. One last question: could you please try the executable from this action? You can just test one sample, there’s no need to test them all. The next step will probably be to write some C code to see if we can reproduce with simple Pango/Harfbuzz code. To be honest, I don’t know if/when I’ll be able to do this. I have no idea why I can’t reproduce this error on my Windows VM. It’s probably not related to the executable, as it was already seen in harfbuzz/harfbuzz#3752. If you have any idea why your Windows installation is different from mine, or why it appeared/disappeared for WeasyPrint’s tests on Windows, that may help. |
Here's the results of the same file run with the executable you provided in that link:
To answer your question, I don't know why it worked for you but not for me. I'm running the following:
I am running under normal user privileges, not an administrator account. But yes, I did try running from a command prompt with elevated privileges and it made no difference ... same errors. Let me know if there's anything else I can do to help (other than loading the Python source, I think I have Python installed but haven't written anything with it and no plans to do so at this point). UPDATE: I doubt this has any effect on the Windows executable, but I do have Python 3.9.13 (64-bit) installed on this machine. |
The only thing I can think of that may be different is if your VM instance is a 32-bit operating system instead of 64-bit or maybe an earlier build of Windows 11 ?? |
@liZe As far as why the tests appeared to run fine, I don't know. But I have a question. in the version I'm looking at, it appears as: or does the |
We test valid and invalid HTML and CSS, and invalid doesn’t mean undefined behaviour. For this specific case, |
My VM is 64-bit. We’ve asked other Windows users to try and it works for them too. |
Here’s a small C program: #include <harfbuzz/hb.h>
#include <fontconfig/fontconfig.h>
#include <pango/pango.h>
#include <pango/pangoft2.h>
int main() {
unsigned int *length;
FcConfig *config = FcInitLoadConfigAndFonts();
PangoFontMap *font_map = pango_ft2_font_map_new();
pango_fc_font_map_set_config((PangoFcFontMap *)font_map, config);
FcConfigDestroy(config);
PangoFontDescription *font_description = pango_font_description_new();
pango_font_description_set_family(font_description, "Arial");
pango_font_description_set_style(font_description, PANGO_STYLE_NORMAL);
pango_font_description_set_stretch(font_description, PANGO_STRETCH_NORMAL);
pango_font_description_set_weight(font_description, PANGO_WEIGHT_NORMAL);
pango_font_description_set_absolute_size(font_description, 20);
PangoContext *context = pango_font_map_create_context(font_map);
PangoLayout *layout = pango_layout_new(context);
pango_layout_set_font_description(layout, font_description);
pango_layout_set_text(layout, "test", -1);
PangoLayoutLine *line = pango_layout_get_line_readonly(layout, 0);
PangoGlyphItem *data = line->runs[0].data;
PangoFont *pango_font = data->item->analysis.font;
hb_font_t *hb_font = pango_font_get_hb_font(pango_font);
hb_face_t *hb_face = hb_font_get_face(hb_font);
hb_blob_t *hb_blob = hb_face_reference_blob(hb_face);
const unsigned char *blob_data = hb_blob_get_data(hb_blob, length);
printf("blob:\n");
for (unsigned int i = 0; i < *length; ++i) {
printf("%02X ", blob_data[i]);
}
printf("\n");
printf("length: %u", *length);
printf("\n");
} If someone could compile and launch it on Windows, that would be wonderful. You can probably use MSYS2 for that. |
Please try the executable generated here: https://github.com/Kozea/WeasyPrint/actions/runs/8638522705 |
I tried this, it's runable, yet it didn't output anything. I suppose this isn't the expected output. |
You should get the blob (a lot of hexadecimal characters) and the length printed. Does it crash? |
Could you please try the latest version? You’ll also need to download and unzip these dlls in the same folder as the executable file. |
… and try this new executable too. |
|
|
Thanks for taking the time to test everything. I’ve used a new strategy to retrieve the content of fonts, and it looks like it works everywhere. Please test the latest exe files like this one and report if there’s anything wrong! |
Ça va bien. Merci beaucoup. btw, I suppose these warnings I met are due to the concrete html file? Seems unrelated to this issue, then it's OK. |
Yes, that’s just warnings for unsupported CSS properties, you can use the So… It finally works! 🔥 |
This way seems to work everywhere, including strange Windows computers. Fix Kozea#2079.
End user who is not familiar with WeasyPrint and has only tried it because a handy
weasyprint.exe
is available.The test was done with a very complex input (on Windows 10):
C:\weasyprint\dist>weasyprint.exe https://nodejs.org/docs/latest/api/all.html Node_v21.6.2_documentation.pdf
but it died prematurely with a fatal error:
The text was updated successfully, but these errors were encountered: