1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 16:37:47 +03:00
Commit Graph

135 Commits

Author SHA1 Message Date
Guillaume Ayoub
975586c24f Set an infinite layout width when the lines have already been split
Fix #449.
2017-06-03 15:14:27 +02:00
Guillaume Ayoub
78f0d7f8a2 Move the shrink-to-fit hack from text.py to inline.py
The hack had been added to remove extra line breaks caused by floating point
errors when the shrink-to-fit width was coming from Pango and had a slightly
higher value when re-calculated in split_first_line.

The same problem appears when we split a line contaning inline-blocks (instead
of letters in the previous case), as the shrink-to-fit width may also inderctly
come from Pango and hit the same re-calculation floating point errors.

This commit moves the hack at a higher level, increasing the max width before
calling split_first_line when the line contains letters (same result as
before), but also before splitting lines containing inline-blocks.

Fix #467.
2017-05-14 15:07:28 +02:00
Simon Sapin
0aa62e249e Switch to tinycss2 2017-03-26 18:44:21 +02:00
Guillaume Ayoub
c1accaa58e Use warnings instead of logs to advertise about old libraries 2017-03-25 15:57:06 +01:00
Guillaume Ayoub
4f4b4ed598 Use isort in tests 2017-03-25 00:33:36 +01:00
Guillaume Ayoub
b2282dd6f8 Try to use WRAP_CHAR instead of WRAP_WORD_CHAR
And add some comments to explain why it doesn't work. Related to #410.
2017-01-11 13:45:24 +01:00
Martin Natano
4919f3a643 Fix AssertionError in layout.inlines.split_text_box().
Traceback (most recent call last):
  [...]
  File "/app/env/lib/python3.5/site-packages/weasyprint/layout/inlines.py", line 718, in split_text_box
    'Expected nothing or a preserved line break' % (between,))
AssertionError: Got '1,' between two lines. Expected nothing or a preserved line break

The Assertion Error can be triggered with following minimal test case
(Adobe's Source Sans Pro font must be installed):

	<style type="text/css">
	    p {
		font-family: 'Source Sans Pro';
		font-size: 24pt;
		width: 275pt;
		overflow-wrap: break-word;
	    }
	</style>
	<p>W1D1,W1D7,W2D14,W3D21,W4D28</p>

With the Adobe Source Sans Font the pango line wrapping algorithm
sometimes produces sporadic results. The wrapping seems to be dependent
on the following text, so that a short text doesn't "fit" on a line, but
does if it is followed by more text. This can be worked around in the
split_first_line() function by computing the resume offset at a later
point, so it is in sync with the actual wrapping behaviour.

See https://bugzilla.gnome.org/show_bug.cgi?id=777093.
2017-01-11 12:14:03 +01:00
Guillaume Ayoub
eb08c46489 Use second line's index instead of first line length 2016-11-22 02:37:04 +01:00
Guillaume Ayoub
8cb093c021 Always update resume_at when splitting lines
As Pango keeps the extra trailing spaces when it splits lines, we try to
add the next word of the second line to the first line without its
trailing spaces and see if it fits. If it doesn't, we have to update
resume_at as we have split the first line at a position that may be
different from what Pango did earlier.

Fix #389.
2016-11-22 01:11:02 +01:00
Guillaume Ayoub
f401eb7f62 Don't unref attribute lists for text features
Tried many times at many places of the code, it always segfaults. Keep
them for now.
2016-11-05 19:02:54 +01:00
Guillaume Ayoub
72022e421d Merge remote-tracking branch 'origin/master' into perf 2016-11-03 12:55:14 +01:00
Guillaume Ayoub
cff44522fc Don't recreate new text layouts when not needed 2016-11-02 01:48:58 +01:00
Guillaume Ayoub
b680963c91 Don't store dummy context in Layout
This has an amazing results on memory: -15% when rendering the first page
of the HTML5 spec.
2016-11-02 01:02:10 +01:00
Guillaume Ayoub
ade095ad88 Break long line 2016-10-30 21:17:15 +01:00
Simon Sapin
fd69b3656d Cache Pango font-features attributes to avoid leaking too many of them. 2016-10-30 14:04:11 +01:00
Guillaume Ayoub
95c76ad4a9 Don't free pango attribute lists
Using the garbage collector to free them makes WeasyPrint segfault,
let's keep them in memory forever for now.
2016-10-28 18:35:26 +02:00
Guillaume Ayoub
308aaab526 Merge branch 'master' into font-face 2016-10-27 17:43:49 +02:00
Guillaume Ayoub
152193cf77 Add the font configuration in LayoutContext
The font configuration is available (almost) everywhere it's needed,
@font-face doesn't rely on a global state anymore.
2016-10-27 17:36:24 +02:00
Guillaume Ayoub
f215a67ba4 Fix the "requires" decorator 2016-10-26 19:11:21 +02:00
Guillaume Ayoub
489163e927 Clean FFI declarations and fix some memory leaks 2016-10-26 18:15:32 +02:00
Guillaume Ayoub
b5103d349f Create a new font config for each document 2016-10-26 17:17:00 +02:00
Guillaume Ayoub
f77f883dc6 Check that white-space is used for shrink-to-fit
Fix #368
2016-10-07 15:57:56 +02:00
Guillaume Ayoub
5c84906309 Warn when a font is corrupted 2016-10-07 14:06:25 +02:00
Guillaume Ayoub
947f2fde0d Remove unused import 2016-10-07 13:55:32 +02:00
Guillaume Ayoub
b54233c8bf Use the default url fetcher to fetch fonts 2016-10-07 13:54:12 +02:00
Guillaume Ayoub
4c0fcfe44f Support font-variant and font-feature-settings descriptors 2016-10-07 13:42:05 +02:00
Guillaume Ayoub
38a0a1a097 Allow multiple and local values in src descriptor 2016-10-01 20:38:33 +02:00
Guillaume Ayoub
fc5eb6c92a Use the descriptors when adding @font-face fonts 2016-09-26 20:14:27 +02:00
Guillaume Ayoub
f8f586a8c4 Cut long line 2016-09-26 12:22:52 +02:00
Guillaume Ayoub
dfbe409ae0 WIP: Support @font-face 2016-09-26 12:15:12 +02:00
Guillaume Ayoub
49cff975a1 Parse @font-face rules 2016-09-23 19:00:14 +02:00
Guillaume Ayoub
f780cc033e Support font-language-override 2016-09-13 05:02:36 +02:00
Guillaume Ayoub
4156febcbf Support CSS Fonts level3 2016-09-12 00:23:52 +02:00
Guillaume Ayoub
3ecf7972ee Small fix for tab-size 2016-08-20 23:37:24 +02:00
Guillaume Ayoub
c2b9a6fe1a Support tab-size 2016-08-20 20:11:03 +02:00
Guillaume Ayoub
a09be6e198 Move the letter-spacing fix in get_size 2016-08-20 16:23:22 +02:00
Guillaume Ayoub
5a05c0a9d9 Revert letter-spacing added in #266 2016-08-20 15:38:54 +02:00
Guillaume Ayoub
24cc2b2f49 Merge branch 'letter-spacing-workaround' of https://github.com/jasco/WeasyPrint into jasco-letter-spacing-workaround 2016-08-20 15:37:33 +02:00
Guillaume Ayoub
ee60caa810 Fix letter-spacing handling at block boundaries
Fix #266 without adding extra chacarcters. The specification is not
clear about how letter-spacing must be implemented, but the browsers
seem to add an extra space after each character. Pango does this too,
but it doesn't do it at the end of the last character. This commit adds
this extra space after the last character.
2016-08-20 15:26:16 +02:00
Guillaume Ayoub
a0b70d1153 Add more and more u'' 2016-08-19 17:50:24 +02:00
Guillaume Ayoub
11a84b4f6f Force unicode strings 2016-08-19 17:24:27 +02:00
Guillaume Ayoub
a43d5fc0bb Cut long lines 2016-08-19 16:57:01 +02:00
Guillaume Ayoub
b1307dfee2 Merge branch 'manual-hyphenation' of https://github.com/jdus/WeasyPrint into jdus-manual-hyphenation 2016-08-19 16:42:52 +02:00
Joel Steres
9620c71c13 Merge upstream master release 0.30 into letter-spacing-workaround patch branch 2016-08-04 11:23:30 -07:00
Guillaume Ayoub
902f5e20da Re-add hack to avoid floating points errors
Fix #325 and shouldn't reopen #288. Now that fac5ee9 fixes line-cutting
bug when drawing, we can use a much lower relative tolerance inspired
from PEP 485 (1e-9 instead of 1e-3).

Tests have been added with random values, as results highly depend on
the version of Pango used and on hinting properties depending on the
system used to launch the tests. They are probably longer than required,
but they try hard to prevent #288 and #325 from coming back.
2016-06-25 03:29:15 +02:00
Joel Steres
87c3de7ee5 Merge upstream master release 0.29 into letter-spacing-workaround patch branch 2016-06-17 11:48:03 -07:00
Guillaume Ayoub
f0912e4f2d Don't use no-break spaces to avoid text wrapping
Fix #189
2016-05-08 16:44:57 +02:00
Guillaume Ayoub
b617122af0 Clean some code about inline and text
- Fix some unicode/utf-8 TODOs
- Change hyphenation tests to use non-ASCII characters
- Use better variable names
- Use a simpler code for overflow-wrap: break-word
2016-01-01 19:20:45 +01:00
Guillaume Ayoub
fac5ee94e5 Don't split a line when drawing it
To draw a text line, the previous behaviour didn't rely only on the text
actually set on the layout, but also relied on the fact that the line
was cut again when drawn. This change removes the line cutting when
drawing, and thus only relies on the line splitting done during the
layout. This fixes a bug causing some words not being displayed at the
end of a text line drawn with hinting, and the actual drawing size with
hinting was bigger than the size calculated during the layout.

The text included in the drawn layout object was sometimes not cut at
the right position, it was longer but cut when actually drawn. This
commit also fixes this, by always setting the right text in the layout
object.

Fixing this bug enables us to remove a hack introduced to fight against
an "accumulation of floating point errors". I now think that "it wasn't
our war"™. I think that the real reasons of this hack were probably:

- a problem with trailing spaces in the shrink-to-fit functions fixed in
  commit 3a620db, and
- this line-cutting bug while drawing, fixed now.

I've tried hard to reproduce the shink-to-fit problem without this hack,
with no success. I don't see anymore how it can theorically happen with
the current code of the "preferred" module. The only bug fixed by this
hack that I've been able to reproduce is the hinting problem explained
in the first paragraph, and this bug is now really fixed.

Moreover, this hack used to cause another problem: as the maximum size
allowed to an inline block was actually bigger than the real size
available in the line, an inline block whose size was between the real
and the allowed sizes was put on a new line by the split_inline_box
function. This commit fixes #288, the bug reported about this problem.
2016-01-01 16:48:15 +01:00
Guillaume Ayoub
e06d44d0d3 Fix a dirty bug in line splitting (fix #285) 2015-12-16 19:04:53 +01:00