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

weazyprint 0.37 fails with google font stylesheets #477

Closed
johndagostino opened this Issue Jun 16, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@johndagostino

johndagostino commented Jun 16, 2017

Example below works as expected on 0.36 but fails with the recently released 0.37

Backtrace from WeazyPrint

Traceback (most recent call last):
  File "/usr/local/bin/weasyprint", line 11, in <module>
    load_entry_point('WeasyPrint==0.37', 'console_scripts', 'weasyprint')()
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/__main__.py", line 172, in main
    getattr(html, 'write_' + format_)(output, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/__init__.py", line 181, in write_pdf
    presentational_hints=presentational_hints).write_pdf(
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/__init__.py", line 146, in render
    self, stylesheets, enable_hinting, presentational_hints)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/document.py", line 317, in _render
    font_config=font_config)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/css/__init__.py", line 770, in get_all_computed_styles
    element_tree, device_media_type, url_fetcher, font_config))
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/css/__init__.py", line 160, in find_stylesheets
    font_config=font_config)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/__init__.py", line 268, in __init__
    self.fonts, font_config)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/css/__init__.py", line 722, in preprocess_stylesheet
    base_url, content))
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/css/descriptors.py", line 165, in preprocess_descriptors
    result = list(validate(base_url, descriptor.name, tokens))
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/css/descriptors.py", line 143, in validate
    value = function(tokens, base_url)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/css/validation.py", line 172, in wrapper
    result = function(remove_whitespace(part), *args)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/css/descriptors.py", line 76, in src
    return 'local', font_family(token.content, allow_spaces=True)
AttributeError: 'FunctionBlock' object has no attribute 'content'

Example test html file

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Test</title>
  <link href="https://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet">
</head>
<body>
  <div class="book">
  </div>
</body>
</html>

@liZe liZe closed this in ccf58d7 Jun 16, 2017

@liZe

This comment has been minimized.

Show comment
Hide comment
@liZe

liZe Jun 16, 2017

Member

Thanks for reporting this issue, sorry for this problem…

Member

liZe commented Jun 16, 2017

Thanks for reporting this issue, sorry for this problem…

@liZe liZe added bug crash labels Jun 16, 2017

@liZe liZe added this to the v0.38 milestone Jun 16, 2017

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Aug 1, 2017

kleink
Update py-weasyprint to 0.39.
Version 0.39
------------

Released on 2017-06-24.

Bug fixes:

* Fix the use of WeasyPrint's URL fetcher with CairoSVG.


Version 0.38
------------

Released on 2017-06-16.

Bug fixes:

* `#477 <https://github.com/Kozea/WeasyPrint/issues/477>`_:
  Don't crash on font-face's src attributes with local functions.


Version 0.37
------------

Released on 2017-06-15.

WeasyPrint now depends on tinycss2 instead of tinycss.

New features:

* `#437 <https://github.com/Kozea/WeasyPrint/issues/437>`_:
  Support local links in generated PDFs.

Bug fixes:

* `#412 <https://github.com/Kozea/WeasyPrint/issues/412>`_:
  Use a NullHandler log handler when WeasyPrint is used as a library.
* `#417 <https://github.com/Kozea/WeasyPrint/issues/417>`_,
  `#472 <https://github.com/Kozea/WeasyPrint/issues/472>`_:
  Don't crash on some line breaks.
* `#327 <https://github.com/Kozea/WeasyPrint/issues/327>`_:
  Don't crash with replaced elements with height set in percentages.
* `#467 <https://github.com/Kozea/WeasyPrint/issues/467>`_:
  Remove incorrect line breaks.
* `#446 <https://github.com/Kozea/WeasyPrint/pull/446>`_:
  Let the logging module do the string interpolation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment