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

82 Commits

Author SHA1 Message Date
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
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
Alex Eftimie
93f497bf11 Replace utf8 with utf-8 for gettext compatibility 2015-11-25 09:38:01 +02:00
Guillaume Ayoub
4816788837 Merge pull request #224 from liZe/text-hack
Rely on the font size for rounding bug workaround
2015-04-25 19:13:43 +02:00
Guillaume Ayoub
bbb42f28c3 Rely on the font size for rounding bug workaround
Only relying on the line length is awful in real-life test cases when the
font size is big and the line short (ex. titles), causing the last word
of some lines to disappear.

This new workaround gives an 0.2em extra space for latest characters
(instead of line-height/10000).
2014-11-01 11:06:06 +01:00
Marco Mariani
0ae57ed81e more library aliases are needed when compiling from sources (i.e within SlapOS) 2014-05-22 10:28:01 +02:00
Simon Sapin
43d1e73e65 Fix code formatting. (Clean flake8!) 2014-04-27 12:29:55 +01:00
Christian Jurk
8b6f09c47f Added more alternative names for dlopen gobject, pango and pangocairo on Mac 2014-03-18 12:00:09 +01:00
Simon Sapin
c34221d215 2014. 2014-01-10 14:27:02 +00:00
Guillaume Ayoub
2c52dc0e93 Merge branch 'css3/overflow_wrap' of git://github.com/fdeslandes/WeasyPrint into fdeslandes-css3/overflow_wrap
Conflicts:
	weasyprint/text.py
2013-12-31 16:46:16 +01:00
Guillaume Ayoub
75a4241177 Don't crash whith documents with no lang attribute 2013-12-27 15:20:30 +01:00
Guillaume Ayoub
6315af3b8a Use pyphen's fallback mechanism for unknown languages (fix #40) 2013-12-27 01:23:15 +01:00
Frédérick Deslandes
f409ceeb25 Implemented CSS3 overflow-wrap property
Implemented the property as described by the W3C draft.  There is still a
bug with shaping characters which does not keep their shapes when wrapped
on new lines.  Implemented as overflow-wrap CSS property, but maybe it
should be refactored to -weasy-overflow-wrap.  Browser implementation is
inconsistent, so there was no clear answer.
2013-10-01 09:51:10 -04:00
Simon Sapin
ae6764143c Fix a possible use-after-free. 2013-06-19 10:04:37 +01:00
Guillaume Ayoub
1930bb1ffe Cut long lines 2013-06-03 18:35:37 +02:00
Andres Riofrio
1aea07a33f Read typographic hints from Pango for text decorations 2013-05-17 09:52:05 -07:00
Simon Sapin
1e3e96a8bd Fix unnecessary line break in floats. 2013-04-22 17:26:41 +02:00
Simon Sapin
ff98eca1bd Drop support for CFFI < 0.6 2013-04-11 10:39:47 +02:00
Simon Sapin
5965dc6bfd Merge remote-tracking branch 'origin/hyphenation'
Conflicts:
	weasyprint/text.py
2013-04-08 11:00:19 +02:00
Simon Sapin
43419f8225 More working around floating point errors when shrink-to-fit = max-content. 2013-04-08 10:54:59 +02:00
Simon Sapin
6bcc6edc0f Clean up ex/ch, add a test. 2013-04-05 12:22:28 +02:00
Guillaume Ayoub
50ac168b94 Clean code and fix tests 2013-04-04 04:39:25 +02:00
Guillaume Ayoub
9f18ce63c3 Handle ex and ch units 2013-04-04 02:38:39 +02:00
Simon Sapin
171438f48e 2013 2013-04-03 16:23:48 +02:00
Simon Sapin
8a28f0f08a Compat with cairocffi 0.4 / CFFI 0.6 2013-03-30 20:55:23 +01:00
Simon Sapin
7fbd46f734 Work around floating point errors when shrink-to-fit = max-content. 2013-03-21 15:51:16 +01:00
Guillaume Ayoub
0e62dd3fb1 Merge branch 'master' into hyphenation 2013-03-11 23:45:47 +01:00
Simon Sapin
e8581dbd09 Ooops. Fix g_type_init() call. 2013-03-11 15:32:29 +01:00
Simon Sapin
cbba64983d Try to make glib happy, call g_type_init() 2013-03-08 15:09:45 +01:00
Guillaume Ayoub
fe9382d716 Remove print() 2013-03-06 18:53:43 +01:00
Guillaume Ayoub
efc089aceb Add hyphenate-limit-chars 2013-03-02 04:41:32 +01:00
Guillaume Ayoub
10d917d1a2 Add hyphenate-limit-zone 2013-03-02 03:42:36 +01:00
Guillaume Ayoub
b5e1fafa5d Add hyphenate-character 2013-03-02 02:45:48 +01:00
Guillaume Ayoub
987feb6a84 Clean the line splitter 2013-03-02 01:33:37 +01:00
Simon Sapin
c49f060c9f Add support for -weasy-hyphens: none, cache hyphenation dictionaries 2013-02-27 13:44:57 +01:00
Simon Sapin
b7ed4a906f Tweak hyphenation and add a micro-test. 2013-02-26 19:45:00 +01:00
Simon Sapin
54df780ae7 Require Pyphen.
It is pure-python and self-contained (with dictionaries)
2013-02-26 18:50:57 +01:00
Simon Sapin
43489dec07 Merge branch 'master' into hyphenation
Conflicts:
	weasyprint/text.py
2013-02-26 18:16:59 +01:00
Simon Sapin
f7e78c488f Back to native strings for CFFI, still required on PyPy :( 2013-02-26 17:12:08 +01:00
Simon Sapin
46715ad7a2 Try alternative shared library names for Windows. 2013-02-26 15:05:53 +01:00
Simon Sapin
06a9ad8c91 Unicode strings are fine with CFFI 0.5 2013-02-25 16:38:54 +01:00
Simon Sapin
d310ffe47d Merge branch 'cffi'
Conflicts:
	weasyprint/text.py
2013-02-25 15:23:59 +01:00
Guillaume Ayoub
c789ba2c91 Don't strip leading non-breaking spaces 2013-02-01 01:57:12 +01:00
Simon Sapin
a1109346df Update for cairocffi changes. 2012-12-30 11:08:55 +01:00
Simon Sapin
294be548b0 All tests passsing with cffi!! 2012-12-29 14:55:59 +01:00
Simon Sapin
5baee96712 Use pixbuf through cffi. 2012-12-29 11:58:52 +01:00
Simon Sapin
c70b00b5b8 More WIP: cairocffi and pango cffi. 2012-12-29 01:36:06 +01:00