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

Windows cannot use custom fonts with the windows installation guide #2185

Closed
kimwonj77 opened this issue Jun 17, 2024 · 1 comment
Closed
Labels
crash Problems preventing documents from being rendered
Milestone

Comments

@kimwonj77
Copy link

This issue is split from #2180.

Why?

WeasyPrint currently depends on Harfbuzz version 4.1.0 or higher. However, according to the Windows installation documentation, the GTK Installer, which installs libpango and harfbuzz, contains version 3.1.2.

Stacktrace

Traceback (most recent call last):
  File "[redacted]\test.py", line 37, in <module>
    HTML(string=html_content, base_url=".").write_pdf("output.pdf")
  File "[redacted]\.venv\Lib\site-packages\weasyprint\__init__.py", line 259, in write_pdf
    self.render(font_config, counter_style, **options)
  File "[redacted]\.venv\Lib\site-packages\weasyprint\document.py", line 404, in write_pdf
    pdf = generate_pdf(self, target, zoom, **options)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[redacted]\.venv\Lib\site-packages\weasyprint\pdf\__init__.py", line 270, in generate_pdf
    pdf_fonts = build_fonts_dictionary(
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "[redacted]\.venv\Lib\site-packages\weasyprint\pdf\fonts.py", line 286, in build_fonts_dictionary
    font.clean(cmap, options['hinting'])
  File "[redacted]\.venv\Lib\site-packages\weasyprint\pdf\fonts.py", line 112, in clean
    self.subset(cmap, hinting)
  File "[redacted]\.venv\Lib\site-packages\weasyprint\pdf\fonts.py", line 184, in subset
    self._harfbuzz_subset(cmap, hinting)
  File "[redacted]\.venv\Lib\site-packages\weasyprint\pdf\fonts.py", line 195, in _harfbuzz_subset
    harfbuzz.hb_set_add_sorted_array(gid_set, gid_array, len(cmap))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[redacted]\.venv\Lib\site-packages\cffi\api.py", line 912, in __getattr__
    make_accessor(name)
  File "[redacted]\.venv\Lib\site-packages\cffi\api.py", line 908, in make_accessor
    accessors[name](name)
  File "[redacted]\.venv\Lib\site-packages\cffi\api.py", line 838, in accessor_function
    value = backendlib.load_function(BType, name)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: function/symbol 'hb_set_add_sorted_array' not found in library 'C:\Program Files\GTK3-Runtime Win64\bin\libharfbuzz-0.dll': error 0x7f

Function List

  • hb_set_add_sorted_array: Added in 4.1.0
  • All other required functions are available from version 3.0, so they are unaffected.

Possible options

User side

  1. Use a newer version of Harfbuzz:
    • Msys2-mingw64 provides a newer version of libpango and Harfbuzz (8.5.0).
  2. Install a newer version of GTK:
  3. Use full_fonts=True
    • It slows down performance and has some issues.
  4. Downgrade WeasyPrint: Not an option, as it hasn't been released yet.

Dev side

  • Avoid using hb_set_add_sorted_array.
@liZe
Copy link
Member

liZe commented Jun 17, 2024

Hi!

The documentation for the next version already tells users to use Msys2.

As the subset code is optional (fonttools is used as a fallback), let’s keep it simple and check that we have a version that’s recent enough.

@liZe liZe closed this as completed in 8273f65 Jun 17, 2024
@liZe liZe added the crash Problems preventing documents from being rendered label Jun 17, 2024
@liZe liZe added this to the 63.0 milestone Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Problems preventing documents from being rendered
Projects
None yet
Development

No branches or pull requests

2 participants