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

unexpected justification #1023

Closed
tomek1024 opened this issue Jan 9, 2020 · 16 comments
Closed

unexpected justification #1023

tomek1024 opened this issue Jan 9, 2020 · 16 comments

Comments

@tomek1024
Copy link

In very seldom cases (combination of margin values, text, text settings and fonts) weasyprint incorrectly breaks the line. I attach the source as well the result. I use manual hyphenation.

html:

<!doctype html>
<html lang='pl'>
  <head>
    <meta charset="UTF-8">
    <link href='style.css' rel='stylesheet' type='text/css'>
  </head>
  <body>
    <p><strong>LIS&shy;BETH SALAN&shy;DER</strong> &amp; Aga wyszła spod prysz&shy;nica.</p>
  </body>
</html>

CSS:

@font-face {
  font-family: "BookmanOld";
  src: url("https://zecer.elibri.com.pl/lte/fonts/BookmanOld/BookmanOld_R.ttf");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "BookmanOld";
  src: url("https://zecer.elibri.com.pl/lte/fonts/BookmanOld/BookmanOld_RB.ttf");
  font-weight: bold;
  font-style: normal;
}


@page {
  size: 160mm 235mm;
  margin-left: 21mm;
  margin-right: 21mm;
}


html { hyphens: manual; }

body {
  margin: 0;
  font-size: 14pt;
  font-family: BookmanOld;
}

p {
  text-align: justify;
  text-indent: 7mm;
  letter-spacing: -0.02em;
}

test.pdf

@liZe
Copy link
Member

liZe commented Jan 9, 2020

Hello, and thank you for this issue.

I can’t reproduce the bug 😒. Could you please give the output of weasyprint -i?

@tomek1024
Copy link
Author

Sure:

System: Linux
Machine: x86_64
Version: #40~18.04.1-Ubuntu SMP Thu Nov 14 12:06:39 UTC 2019
Release: 5.0.0-37-generic

WeasyPrint version: 50
Python version: 3.6.9
Cairo version: 11510
Pango version: 14014
CairoSVG version: 2.4.2

@Tontyna
Copy link
Contributor

Tontyna commented Jan 10, 2020

@liZe too bad that weasyprint -i fails on Windows due to the availability of os.uname(): recent flavors of Unix.

@liZe
Copy link
Member

liZe commented Jan 11, 2020

@liZe too bad that weasyprint -i fails on Windows due to the availability of os.uname(): recent flavors of Unix.

That’s why I should write tests for the features I add 😒.

liZe added a commit that referenced this issue Jan 11, 2020
@liZe
Copy link
Member

liZe commented Jan 13, 2020

I’m pretty sure that it’s a duplicate of #1025, could you please try the current master branch and see if it’s fixed?

@liZe
Copy link
Member

liZe commented Jan 13, 2020

I’m pretty sure that it’s a duplicate of #1025

(Having line-break problems when using soft hyphens and justification, I really hope that it’s the same bug.)

@tomek1024
Copy link
Author

I'm afraid the problem still exists :( I have put the test file on-line for you convenience: https://zecer.elibri.com.pl/lte/unexpected-justification.html

@liZe
Copy link
Member

liZe commented Jan 14, 2020

I'm afraid the problem still exists

😢

I have put the test file on-line for you convenience

Thanks, but it also works for me… I suppose that it’s a problem in older versions of Pango, I’ll try your version as soon as I can.

@liZe
Copy link
Member

liZe commented Jan 14, 2020

I’ll try your version as soon as I can.

I have the bug with your version of Pango. I’ll try various versions to know which one fixes the bug.

@liZe
Copy link
Member

liZe commented Jan 14, 2020

It’s broken with 1.42.x versions too.

@tomek1024
Copy link
Author

Thank you checking. Can you give me a hint how to upgrade pango?

@liZe
Copy link
Member

liZe commented Jan 14, 2020

It’s at least fixed with Pango 1.44.4. Older 1.44.x versions don’t compile anymore for me.

Thank you checking. Can you give me a hint how to upgrade pango?

On Ubuntu, Pango is too old, even with the latest released version of Ubuntu. There’s a package in the next version you can try to install, but I suppose that upgrading only Pango can break your system (at least your graphical interface).

If you don’t know how to get back to your version of Pango using your terminal, you shouldn’t try this.

If it’s a virtual machine or anything you can break safely, you can try. This tutorial seems to be OK. You have to install the Pango package from the focal version on your bionic version (example is from xenial, to trusty).

⚠️ Please don’t do this if you don’t want to break your system. ⚠️

@tomek1024
Copy link
Author

thank you for your advice :) using a virtual machine for testing seems to be the right idea. Thank you!

@tomek1024
Copy link
Author

@liZe - I finally have a new virtual machine:

> weasyprint -i

System: Linux
Machine: x86_64
Version: #49~18.04.2-Ubuntu SMP Wed Aug 26 16:29:02 UTC 2020
Release: 5.4.0-45-generic

WeasyPrint version: 50
Python version: 3.6.9
Cairo version: 11510
Pango version: 14014
CairoSVG version: 2.4.2

As you wrote, the line is broken correctly, although there is no hyphen at the end of line. Could you please have a look at this?

https://zecer.elibri.com.pl/lte/unexpected-justification.html

image

@liZe
Copy link
Member

liZe commented Sep 15, 2020

I can reproduce, but I don’t have the problem with another font. Now trying to know why…

@liZe
Copy link
Member

liZe commented Sep 15, 2020

OK, the problem comes from a line break that shouldn’t happen. For some reason (spoiler alert: a floating point rounding error), the hyphen that was fine during the layout doesn’t doesn’t fit during the display, and the line breaks after the (invisible) soft hyphen.

@tomek1024 Could you please open a new issue with this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants