1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 08:27:22 +03:00
Commit Graph

2318 Commits

Author SHA1 Message Date
Guillaume Ayoub
ebe958e2cc Prefer while True to while 1 2020-05-22 00:14:15 +02:00
Guillaume Ayoub
6ccb269945 Merge branch 'master' of github.com:Kozea/WeasyPrint 2020-05-21 18:21:25 +02:00
Guillaume Ayoub
9746b2dc76 Improve rtl text test 2020-05-21 18:20:53 +02:00
Guillaume Ayoub
faf19cbcde
Merge pull request #1106 from kalekseev/fix-dlopen
dlopen shared library symlink using major version name.
2020-05-21 14:55:03 +02:00
Tontyna
2867f21230 create a TargetLookupItem for each anchor 2020-05-20 02:33:10 +02:00
Guillaume Ayoub
35f27b0afa Use subprocess.run
It’s just more simple than Popen.
2020-05-18 23:53:19 +02:00
Guillaume Ayoub
04449a0fa1 Fix comment in PNG generation function
Using GhostScript as a library seems to be awful. Let’s forget this idea.
2020-05-18 22:45:35 +02:00
Guillaume Ayoub
d06f081af6 Fix x position of RTL characters with trailing space
When a line has an unwanted trailing space, the space is removed and the
textbox’ width (and its ancestor’s) is recalculated.

If the line characters have a main RTL Unicode direction (not the CSS box
direction, the text direction), the trailing space is at the left of the
box. Recalculating the width is not enough, we also need to fix the x position.

Testing would be better with Arabic characters, but none is included in
Ahem. Forcing the text direction works well too.

Fix #1111.
2020-05-18 21:36:41 +02:00
Guillaume Ayoub
32f0f22ac2 Clean return condition in document.py 2020-05-18 11:54:37 +02:00
Guillaume Ayoub
e019278d9f Don’t make write_png return size 2020-05-18 01:36:48 +02:00
Guillaume Ayoub
58599d325e Don’t crash when trying to display images 2020-05-18 01:29:59 +02:00
Guillaume Ayoub
c422c1b77e Disable antialiasing by default 2020-05-18 01:29:37 +02:00
Guillaume Ayoub
0ecb246501 Use less code to compare PNG files in tests 2020-05-18 00:49:21 +02:00
Guillaume Ayoub
57fd7f3f0c Don’t return useless document in html_to_pixels 2020-05-17 23:54:25 +02:00
Guillaume Ayoub
e2700082fc Don’t write GhostScript renderings on disk 2020-05-17 23:48:41 +02:00
Guillaume Ayoub
15035f8c97 Mark some tests are failing
These tests were failing with Cairo too, but the rendering was OK because Cairo
was lucky
2020-05-17 23:37:35 +02:00
Guillaume Ayoub
7686fbd4ae Always end path when clipping 2020-05-17 23:11:19 +02:00
Guillaume Ayoub
fee0f91c56 Save layout max width to avoid calling unavailable clip_extents 2020-05-17 22:48:38 +02:00
Guillaume Ayoub
23dccecc3a Set some optional arguments as needed as they are always given 2020-05-17 22:47:52 +02:00
Guillaume Ayoub
38dae61b23 Fix box drawing tests 2020-05-17 20:11:22 +02:00
Guillaume Ayoub
c85d58a86e Linting 2020-05-17 20:01:49 +02:00
Guillaume Ayoub
b8749863d1 Fix all PDF tests not relying on images 2020-05-17 18:59:31 +02:00
Guillaume Ayoub
d1dcea7b1c Fix anchors 2020-05-17 17:12:23 +02:00
Guillaume Ayoub
7e9f80e7a2 Add comment for outlines 2020-05-17 17:12:16 +02:00
Guillaume Ayoub
f7ce6a6db0 Don’t use references for states and xobjects dicts 2020-05-17 17:04:45 +02:00
Guillaume Ayoub
e1e3974d00 Fix typo 2020-05-17 16:59:58 +02:00
Guillaume Ayoub
522b240474 Don’t set links on lineboxes 2020-05-17 15:54:02 +02:00
Guillaume Ayoub
b0da0290ba Disable antialiasing for tests 2020-05-17 15:06:45 +02:00
Guillaume Ayoub
e711363490 Add an option to enable antialiasing for PNG generation 2020-05-17 15:06:17 +02:00
Guillaume Ayoub
3de277ce0e Handle opacity 2020-05-17 14:46:41 +02:00
Guillaume Ayoub
bf3c7324cb Fix many tests 2020-05-16 17:06:30 +02:00
Guillaume Ayoub
8d2ea802f0 Add various dictionaries only when needed 2020-05-16 17:05:48 +02:00
Guillaume Ayoub
07ac9e855f Fix attachments name discovery 2020-05-16 17:05:11 +02:00
Guillaume Ayoub
5f2107fde8 Remove embedded files dictionary when empty 2020-05-16 16:25:06 +02:00
Guillaume Ayoub
9e486a345a Fix outlines 2020-05-16 16:19:28 +02:00
Guillaume Ayoub
0c9312167e Don’t remove seconds when timezone is set 2020-05-16 15:23:20 +02:00
Guillaume Ayoub
b2797dafe1 Fix lint 2020-05-16 14:27:03 +02:00
Guillaume Ayoub
ae2f6ed3b8 Remove @requires decorator 2020-05-16 00:25:11 +02:00
Guillaume Ayoub
feb25b479d Remove pango_cairo_* definitions 2020-05-16 00:20:31 +02:00
Guillaume Ayoub
efd231ea15 Remove useless cairo import 2020-05-16 00:19:41 +02:00
Guillaume Ayoub
70e195f464 Use transform instead of scale and translate 2020-05-16 00:19:25 +02:00
Guillaume Ayoub
47b8f80695 Don’t use Cairo for tests 2020-05-16 00:04:18 +02:00
Guillaume Ayoub
1383592243 Fix multi-page PNG generation 2020-05-16 00:04:09 +02:00
Guillaume Ayoub
9733cb1718 Handle WOFF fonts 2020-05-15 16:12:45 +02:00
Guillaume Ayoub
dc443ab30d Remove naughty comma
Fix #1114.
2020-05-15 11:54:00 +02:00
Guillaume Ayoub
5b4bbb22e7 Fix many tests 2020-05-13 01:02:43 +02:00
Guillaume Ayoub
cad749b93e Lint 2020-05-12 23:54:42 +02:00
Guillaume Ayoub
e4aab188f9 Use a reference for ToUnicode 2020-05-12 23:47:22 +02:00
Guillaume Ayoub
b3fb006184 Improve readibility 2020-05-12 23:06:18 +02:00
Guillaume Ayoub
90843ac4a1 Fix cmap letters for multiple runs 2020-05-12 22:37:40 +02:00
Guillaume Ayoub
00110952bb Merge branch 'pydyf' of gitlab.com:courtbouillon/weasyprint into pydyf 2020-05-12 21:54:07 +02:00
Guillaume Ayoub
cd5f178409 Fix outlines 2020-05-12 21:53:54 +02:00
Lucie Anglade
12272f50e4 Cmaps into font 2020-05-12 18:38:12 +02:00
Guillaume Ayoub
c42bbf1fae Fix embedded OpenType fonts 2020-05-12 13:11:52 +02:00
Guillaume Ayoub
21226efbe1 Fix zlib compression 2020-05-12 02:03:39 +02:00
Guillaume Ayoub
099347ce94 Fix arrays in char widths 2020-05-12 02:00:07 +02:00
Lucie Anglade
c4fb5324b5 Use pydyf text methods 2020-05-12 00:24:20 +02:00
Guillaume Ayoub
c7acb05b63 Improve readability 2020-05-10 18:22:13 +02:00
Guillaume Ayoub
53caa99a50 Use a smaller array for characters widths 2020-05-10 18:09:06 +02:00
Guillaume Ayoub
36cc7c6f68 Fix insconsistent kerning and font metrics values 2020-05-10 17:51:37 +02:00
Guillaume Ayoub
e1b458e174 Handle TTF and OTF font files with dedicated PDF syntaxes 2020-05-10 00:14:56 +02:00
Guillaume Ayoub
24c81ad99e Simplify kerning and font size management 2020-05-09 22:23:33 +02:00
Guillaume Ayoub
d25527351b Always store 1pt fonts to get metrics 2020-05-09 18:06:20 +02:00
Guillaume Ayoub
e9122c989e Fix units used for characters widths and kerning 2020-05-09 15:52:43 +02:00
Guillaume Ayoub
aa7c9e3aa8 Add kerning values 2020-05-09 01:35:43 +02:00
Guillaume Ayoub
46a1524af6 Fix text size and position 2020-05-09 00:00:07 +02:00
Guillaume Ayoub
d53b86053d Use font codepoints instead of Unicode codepoints 2020-05-08 17:14:45 +02:00
Lucie Anglade
6e3214eea8 Fix widths 2020-05-08 15:14:10 +02:00
Lucie Anglade
a6ff868094 First and last characters, and widths 2020-05-08 15:07:51 +02:00
Guillaume Ayoub
d4b7f242c3 Remove useless variable 2020-05-08 02:13:44 +02:00
Guillaume Ayoub
8f640237e5 Remove useless font name prefix 2020-05-08 01:58:43 +02:00
Guillaume Ayoub
954dcc03b4 Fix font name 2020-05-08 01:55:50 +02:00
Guillaume Ayoub
aa2030d737 Change some font attributes names 2020-05-08 01:50:41 +02:00
Guillaume Ayoub
05bc5eed17 Don’t use the 3/4 ratio, as Pango and PDF both use points 2020-05-08 01:39:42 +02:00
Guillaume Ayoub
3342386a28 Fix font bounding box 2020-05-08 01:30:07 +02:00
Lucie Anglade
36ed176a36 Use computed values 2020-05-08 00:40:01 +02:00
Guillaume Ayoub
c1f95ab8f7 Remove useless parenthesis 2020-05-08 00:31:50 +02:00
Guillaume Ayoub
6f44d18b81 Merge branch 'pydyf' of gitlab.com:courtbouillon/weasyprint into pydyf 2020-05-08 00:31:00 +02:00
Guillaume Ayoub
0dcddc7a4e Display some text 2020-05-08 00:29:46 +02:00
Lucie Anglade
a8eb334f9d Release memory 2020-05-08 00:28:30 +02:00
Lucie Anglade
088e06da0e Use the saved pango_font 2020-05-08 00:24:30 +02:00
Lucie Anglade
0a412542d9 Fix parameters 2020-05-08 00:23:13 +02:00
Lucie Anglade
18e10631f9 Set flags always to 4, symbolic 2020-05-08 00:19:07 +02:00
Lucie Anglade
f306418cfd Get FontBBox and CapHeight 2020-05-08 00:11:19 +02:00
Guillaume Ayoub
590c0c57ce Fully describe PangoGlyphInfo 2020-05-07 23:39:21 +02:00
Lucie Anglade
7dab88c3ad Font name, and save glyphs 2020-05-07 23:27:43 +02:00
Guillaume Ayoub
1129f82cea Don’t import pango twice 2020-05-07 22:37:11 +02:00
Lucie Anglade
e64e98a56a Move getting font informations from text to document 2020-05-07 19:33:54 +02:00
Lucie Anglade
aab07099a9 Start retrieving font descriptor info 2020-05-06 20:10:18 +02:00
Guillaume Ayoub
5ed840fc7d Include font streams 2020-05-06 07:42:45 +02:00
Konstantin Alekseev
1571528da3 dlopen shared library symlink using major version name.
cffi.dlopen should use .so.N symlinks instead of .so to
make sure we load ABI compatible version of the library and
the same library used by the rest of the system.

cffi uses `ctypes.util.find_library` to search for libraries
and the docs for `find_library` states that
"The exact functionality is system dependent."
so different system may expect different names for the same library.

To overcome that problem we try to load several names until success
among these names exact file name with `.so` suffix
eg. `libcairo.so` but .so symlink is not always safe to use.

Shared library usually consist of two of three files:
- libcairo.so.N.M - N.M exact version number
- libcairo.so.N - symlink to library.so.N.M with major ABI version
- libcairo.so - symlink to library.so.N

When -lcairo flag is used linker search for libcairo.so,
but when the programm loaded it loads libcairo.so.N where N
is the version that it was linked with.

Some downsides of .so usage:
- .so may point to the wrong ABI version, e.g. we expect libcairo
  version 2 but libcairo.so points at libcairo.so.1
- usually .so files are shipped with development packages `-dev`
  in debian and `-devel` in centos and they are just symlinks
  to the .so.N files. So it safer to search for .so.N files they
  will exist even if dev package is not installed.
- hard symlink .so -> .so.N not always preserved, eg. if we zip
  them we get two copies of the library and while the rest of the
  system will use .so.N file we will load .so files that may lead
  to crash
2020-05-03 22:01:41 +03:00
Guillaume Ayoub
67b104d8ab Get fonts data 2020-04-26 00:48:38 +02:00
Guillaume Ayoub
bbc1355df6 Force FontConfig use 2020-04-26 00:48:32 +02:00
Guillaume Ayoub
7de2e45f55 Fix crash when there’s no outline 2020-04-21 23:07:35 +02:00
Guillaume Ayoub
44c21b7f31 Go through PDF pages only once during generation 2020-04-21 22:47:55 +02:00
Guillaume Ayoub
d02bc1bde1 Add inline attachments 2020-04-21 22:30:38 +02:00
Guillaume Ayoub
3bee463e83 Remove resolve_links from Document class 2020-04-19 18:26:49 +02:00
Guillaume Ayoub
9752142959 Merge document and pdf modules 2020-04-19 16:49:37 +02:00
Guillaume Ayoub
cbf010952d Fix transformation matrix with bleed box 2020-04-19 14:40:30 +02:00
Guillaume Ayoub
f353a16cf5 Call finisher 2020-04-19 10:01:27 +02:00