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

Cutting lines is broken in page margin boxes #325

Closed
Kodiologist opened this issue Jun 18, 2016 · 4 comments
Closed

Cutting lines is broken in page margin boxes #325

Kodiologist opened this issue Jun 18, 2016 · 4 comments
Labels
bug Existing features not working as expected

Comments

@Kodiologist
Copy link

With WeasyPrint 0.28, rendering the valid HTML5 document

<!DOCTYPE html>
<html><head><title>foo</title><meta charset="utf-8">

<style type="text/css">
@page
   {margin-top: 1in;
    margin-bottom: 1in;
    margin-left: .9in;
    margin-right: .9in;
    size: 6in 9in;
    @top-center
       {content: "this parrot is dead";}}
</style>

</head><body><p>hello world</p></body></html>

makes a PDF that looks like this:

Screenshot

Note the extra line break after the first word of the header. Whatever the header text, the line break seems to still occur after the first word. Different margin and page sizes can make the line break disappear, but it's not obvious to me what the logic is.

@SimonSapin
Copy link
Member

SimonSapin commented Jun 18, 2016

I don’t remember the details of the layout algorithm, but my guess is that the contents of @top-center is measured to determine its width, and then layout happens with that available width. Somehow, these two phases get slightly different results and the width is just too small for the entire content. I don’t understand why the break is after the first word rather than before the last, though.

This is a bug. But as a work-around, try adding width: 100% to @top-center?

@Kodiologist
Copy link
Author

Try adding width: 100% to @top-center?

Seems to work! Thanks.

@SimonSapin SimonSapin changed the title Extraneous line break in header Shrink-to-fit sizing(?) gives a width slightly too small Jun 18, 2016
@liZe liZe added the bug Existing features not working as expected label Jun 24, 2016
@liZe
Copy link
Member

liZe commented Jun 24, 2016

I can reproduce the bug with different font families and sizes, so it's probably not a shrink-to-fit problem as the "famous" one explained in fac5ee9 (and that's good news).

The word alone on the first line is really strange, it's probably a dirty bug only happening to page margin boxes.

@liZe liZe changed the title Shrink-to-fit sizing(?) gives a width slightly too small Cutting lines is broken in page margin boxes Jun 24, 2016
@liZe
Copy link
Member

liZe commented Jun 24, 2016

Unfortunately, that's a shrink-to-fit problem, exactly the case given in fac5ee9. I can now reproduce it with Ahem, I hope you can too:
<p style="float: left; margin-left: 0.9in; font-size: 0.6em; font-family: ahem">this parrot is dead

The reason why it's cut after the first word or before the last word is just an implementation detail, it's actually the same bug. I'll fix it and test it.

@liZe liZe closed this as completed in 902f5e2 Jun 25, 2016
jsonn referenced this issue in jsonn/pkgsrc Jan 15, 2017
Version 0.34
------------

Released on 2016-12-21.

Bug fixes:

* `#398 <https://github.com/Kozea/WeasyPrint/issues/398>`_:
  Honor the presentational_hints option for PDFs.
* `#399 <https://github.com/Kozea/WeasyPrint/pull/399>`_:
  Avoid CairoSVG-2.0.0rc* on Python 2.
* `#396 <https://github.com/Kozea/WeasyPrint/issues/396>`_:
  Correctly close files open by mkstemp.
* `#403 <https://github.com/Kozea/WeasyPrint/issues/403>`_:
  Cast the number of columns into int.
* Fix multi-page multi-columns and add related tests.


Version 0.33
------------

Released on 2016-11-28.

New features:

* `#393 <https://github.com/Kozea/WeasyPrint/issues/393>`_:
  Add tests on MacOS.
* `#370 <https://github.com/Kozea/WeasyPrint/issues/370>`_:
  Enable @font-face on MacOS.

Bug fixes:

* `#389 <https://github.com/Kozea/WeasyPrint/issues/389>`_:
  Always update resume_at when splitting lines.
* `#394 <https://github.com/Kozea/WeasyPrint/issues/394>`_:
  Don't build universal wheels.
* `#388 <https://github.com/Kozea/WeasyPrint/issues/388>`_:
  Fix logic when finishing block formatting context.


Version 0.32
------------

Released on 2016-11-17.

New features:

* `#28 <https://github.com/Kozea/WeasyPrint/issues/28>`_:
  Support @font-face on Linux.
* Support CSS fonts level 3 almost entirely, including OpenType features.
* `#253 <https://github.com/Kozea/WeasyPrint/issues/253>`_:
  Support presentational hints (optional).
* Support break-after, break-before and break-inside for pages and columns.
* `#384 <https://github.com/Kozea/WeasyPrint/issues/384>`_:
  Major performance boost.

Bux fixes:

* `#368 <https://github.com/Kozea/WeasyPrint/issues/368>`_:
  Respect white-space for shrink-to-fit.
* `#382 <https://github.com/Kozea/WeasyPrint/issues/382>`_:
  Fix the preferred width for column groups.
* Handle relative boxes in column-layout boxes.

Documentation:

* Add more and more documentation about Windows installation.
* `#355 <https://github.com/Kozea/WeasyPrint/issues/355>`_:
  Add fonts requirements for tests.


Version 0.31
------------

Released on 2016-08-28.

New features:

* `#124 <https://github.com/Kozea/WeasyPrint/issues/124>`_:
  Add MIME sniffing for images.
* `#60 <https://github.com/Kozea/WeasyPrint/issues/60>`_:
  CSS Multi-column Layout.
* `#197 <https://github.com/Kozea/WeasyPrint/pull/197>`_:
  Add hyphens at line breaks activated by a soft hyphen.

Bux fixes:

* `#132 <https://github.com/Kozea/WeasyPrint/pull/132>`_:
  Fix Python 3 compatibility on Windows.

Documentation:

* `#329 <https://github.com/Kozea/WeasyPrint/issues/329>`_:
  Add documentation about installation on Windows.


Version 0.30
------------

Released on 2016-07-18.

WeasyPrint now depends on html5lib-0.999999999.

Bux fixes:

* Fix Acid2
* `#325 <https://github.com/Kozea/WeasyPrint/issues/325>`_:
  Cutting lines is broken in page margin boxes.
* `#334 <https://github.com/Kozea/WeasyPrint/issues/334>`_:
  Newest html5lib 0.999999999 breaks rendering.


Version 0.29
------------

Released on 2016-06-17.

Bug fixes:

* `#263 <https://github.com/Kozea/WeasyPrint/pull/263>`_:
  Don't crash with floats with percents in positions.
* `#323 <https://github.com/Kozea/WeasyPrint/pull/323>`_:
  Fix CairoSVG 2.0 pre-release dependency in Python 2.x.


Version 0.28
------------

Released on 2016-05-16.

Bug fixes:

* `#189 <https://github.com/Kozea/WeasyPrint/issues/189>`_:
  ``white-space: nowrap`` still wraps on hyphens
* `#305 <https://github.com/Kozea/WeasyPrint/issues/305>`_:
  Fix crashes on some tables
* Don't crash when transform matrix isn't invertible
* Don't crash when rendering ratio-only SVG images
* Fix margins and borders on some tables


Version 0.27
------------

Released on 2016-04-08.

New features:

* `#295 <https://github.com/Kozea/WeasyPrint/pull/295>`_:
  Support the 'rem' unit.
* `#299 <https://github.com/Kozea/WeasyPrint/pull/299>`_:
  Enhance the support of SVG images.

Bug fixes:

* `#307 <https://github.com/Kozea/WeasyPrint/issues/307>`_:
  Fix the layout of cells larger than their tables.

Documentation:

* The website is now on GitHub Pages, the documentation is on Read the Docs.
* `#297 <https://github.com/Kozea/WeasyPrint/issues/297>`_:
  Rewrite the CSS chapter of the documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing features not working as expected
Projects
None yet
Development

No branches or pull requests

3 participants