Skip to content

1.21.0: test_textbox3 fails when built against system libmupdf (1.21.0) #2040

@dvzrv

Description

@dvzrv

Please provide all mandatory information!

Describe the bug (mandatory)

A clear and concise description of what the bug is.

To Reproduce (mandatory)

Patch setup.py (see #2039).

  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  local _test_dir="test_dir"

  cd $_name-$pkgver
  export PYMUPDF_SETUP_MUPDF_BUILD=""
  python -m build --wheel --no-isolation
  mkdir -vp $_test_dir
  # install to test dir for testing
  python -m installer --destdir="$_test_dir" dist/*.whl

  export PYTHONPATH="$_test_dir/$_site_packages:$PYTHONPATH"
  # pytest -vv -c /dev/null tests/ -k 'not test_textbox3'
  pytest -vv -c /dev/null tests/
=================================== FAILURES ===================================
________________________________ test_textbox3 _________________________________

    def test_textbox3():
        """Use TextWriter for text insertion."""
        doc = fitz.open()
        page = doc.new_page()
        font = fitz.Font("cjk")
        rect = fitz.Rect(50, 50, 400, 400)
        blue = (0, 0, 1)
        tw = fitz.TextWriter(page.rect, color=blue)
>       tw.fill_textbox(
            rect,
            text,
            align=fitz.TEXT_ALIGN_LEFT,
            font=font,
            fontsize=12,
            right_to_left=True,
        )

tests/test_textbox.py:66:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_dir/usr/lib/python3.10/site-packages/fitz/utils.py:4408: in fill_textbox
    append_this(start, line)
test_dir/usr/lib/python3.10/site-packages/fitz/utils.py:4237: in append_this
    return writer.append(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <fitz.fitz.TextWriter; proxy of <Swig Object of type 'TextWriter *' at 0x60af743f6a60> >
pos = Point(52.400001525878906, 778.18798828125)
text = 'auch crassidens), (Pseudorca Schwertwal Kleine Der'
font = Font('Source Han Serif TC Regular'), fontsize = 12, language = None
right_to_left = 0, small_caps = False

    def append(self, pos, text, font=None, fontsize=11, language=None, right_to_left=0, small_caps=0):

        """Store 'text' at point 'pos' using 'font' and 'fontsize'."""

        pos = Point(pos) * self.ictm
        if font is None:
            font = Font("helv")
        if not font.is_writable:
>           raise ValueError("Unsupported font '%s'." % font.name)
E           ValueError: Unsupported font 'Source Han Serif TC Regular'.

test_dir/usr/lib/python3.10/site-packages/fitz/fitz.py:8613: ValueError
=============================== warnings summary ===============================
../../../../usr/lib/python3.10/site-packages/_pytest/cacheprovider.py:433
  /usr/lib/python3.10/site-packages/_pytest/cacheprovider.py:433: PytestCacheWarning: could not create cache path /dev/.pytest_cache/v/cache/nodeids
    config.cache.set("cache/nodeids", sorted(self.cached_nodeids))

../../../../usr/lib/python3.10/site-packages/_pytest/cacheprovider.py:387
  /usr/lib/python3.10/site-packages/_pytest/cacheprovider.py:387: PytestCacheWarning: could not create cache path /dev/.pytest_cache/v/cache/lastfailed
    config.cache.set("cache/lastfailed", self.lastfailed)

../../../../usr/lib/python3.10/site-packages/_pytest/stepwise.py:52
  /usr/lib/python3.10/site-packages/_pytest/stepwise.py:52: PytestCacheWarning: could not create cache path /dev/.pytest_cache/v/cache/stepwise
    session.config.cache.set(STEPWISE_CACHE_DIR, [])

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED ../../../../dev/test_textbox.py::test_textbox3 - ValueError: Unsupport...
============= 1 failed, 92 passed, 1 skipped, 3 warnings in 2.08s ==============

Full build and test logs:
python-pymupdf-1.21.0-1-x86_64-build.log
python-pymupdf-1.21.0-1-x86_64-check.log

Expected behavior (optional)

All tests pass successfully.

Screenshots (optional)

n/a

Your configuration (mandatory)

  • Arch Linux
  • Python 3.10.8, x86_64
  • PyMuPDF 1.21.0 source -> wheel -> package createion

Additional context (optional)

The test does not fail when the bundled sources are being built.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions