WeasyPrint: Table style "width" property ignored in latest version

I use for “table” tag this CSS properties:

  width:-moz-fit-content;
  width:-webkit-fit-content;
  width:-ms-fit-content;
  width:fit-content;

All was working fine till I changed to Debian Stretch and upgraded to latest WeasyPrint. Now, tables doesn’t adapt its width to the page+margin width, overflowing and being cropped at right margin.

Edit: In the terminal, weasyprint shows:

WARNING: Ignored `width:unset` at 268:3, invalid value.
WARNING: Ignored `width:-moz-fit-content` at 273:3, invalid value.
WARNING: Ignored `width:-webkit-fit-content` at 274:3, invalid value.
WARNING: Ignored `width:-ms-fit-content` at 275:3, invalid value.

Please, could you fix it??

imagen

In the image you can see in the left how it should be displayed / printed (in fact, is printed right directly from the browser) and in the right, the output from WeasyPrint nowadays.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 28 (14 by maintainers)

Commits related to this issue

Most upvoted comments

This Issue appears as one of the first results when searching “weasyprint fit-content”, so I’m writing this post in case anyone needs an alternative to fit-content. First of all, Weasyprint does NOT support fit-content, a way to replace it is with display: table, because this uses tables, which were (or are) a way to organize HTML content in the old days.

Say for example that you want to center and fit to content your paragraphs, the <p> elements. This will do

p
{
    display: table
    margin: 0 auto;
}

If you just want to fit to content the same as fit-content does, then delete the line that says margin: 0 auto;.

YOU DID IT!!! I didn’t believe it (cause I’m sure it was not easy for you as you told me), so I created the PDF file at least three times, and it works perfectly!!!

Now I need to find out what where is my mistake in CSS fonts code, cause curiously now I have not condensed font in the browser!!! But for sure is something I’m doing wrong, so I’m going to find what is just now.

Then I’ll test with similar (even larger) and a little more complex tables, but I’m sure all will work like a charm with weasyprint!! I’ll report you next news!

However, it seems weasyprint is ignoring the fonts, but don’t know why

I finally know why: WeasyPrint doesn’t support woff2 fonts, because it relies on fontconfig that doesn’t support woff2. Using another format will work.