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

Jules - fix pyodide and sysinstall tests. #3970

Merged
merged 3 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ def log( text):
g_pymupdfb_sdist_marker = 'pymupdfb_sdist'

PYMUPDF_SETUP_PY_LIMITED_API = os.environ.get('PYMUPDF_SETUP_PY_LIMITED_API')
assert PYMUPDF_SETUP_PY_LIMITED_API in (None, '0', '1'), \
f'Should be "0", "1" or undefined: {PYMUPDF_SETUP_PY_LIMITED_API=}.'
assert PYMUPDF_SETUP_PY_LIMITED_API in (None, '', '0', '1'), \
f'Should be "", "0", "1" or undefined: {PYMUPDF_SETUP_PY_LIMITED_API=}.'
g_py_limited_api = (PYMUPDF_SETUP_PY_LIMITED_API != '0')

PYMUPDF_SETUP_URL_WHEEL = os.environ.get('PYMUPDF_SETUP_URL_WHEEL')
Expand Down
16 changes: 7 additions & 9 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6489,16 +6489,14 @@ def valid_codepoints(self):
'''
Returns sorted list of valid unicodes of a fz_font.
'''
if 1 or mupdf_version_tuple < (1, 25):
# Not available.
if mupdf_version_tuple < (1, 25):
# mupdf.fz_enumerate_font_cmap2() not available.
return []
# This code should be used when MuPDF has been updated to provide
# fz_ft_font_reverse_cmap().
gid_to_ucs = mupdf.fz_ft_font_reverse_cmap(self.this)
ucs_unique = set(gid_to_ucs)
ucs_unique_sorted = sorted(ucs_unique)
assert ucs_unique_sorted[0] == 0
return ucs_unique_sorted[1:]
ucs_gids = mupdf.fz_enumerate_font_cmap2(self.this)
ucss = [i.ucs for i in ucs_gids]
ucss_unique = set(ucss)
ucss_unique_sorted = sorted(ucss_unique)
return ucss_unique_sorted


class Graftmap:
Expand Down
8 changes: 3 additions & 5 deletions tests/test_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ def test_3933():
print(f'{len(page.get_fonts())=}')

expected = {
'BCDEEE+Calibri': 36,
'BCDEEE+Calibri': 39,
'BCDFEE+SwissReSan-Regu': 53,
'BCDGEE+SwissReSan-Ital': 20,
'BCDHEE+SwissReSan-Bold': 20,
'BCDIEE+SwissReSan-Regu': 53,
'BCDJEE+Calibri': 36,
'BCDJEE+Calibri': 39,
}

for xref, _, _, name, _, _ in page.get_fonts():
Expand All @@ -180,9 +180,7 @@ def test_3933():
font = pymupdf.Font(fontname=name, fontbuffer=content)
supported_symbols = font.valid_codepoints()
print(f'Font {name}: {len(supported_symbols)=}.', flush=1)
if 1 or pymupdf.mupdf_version_tuple < (1, 25):
if pymupdf.mupdf_version_tuple < (1, 25):
assert len(supported_symbols) == 0
else:
# We have a fix but as of 2024-10-17 it is not yet on MuPDF
# master.
assert len(supported_symbols) == expected.get(name)
6 changes: 6 additions & 0 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,12 @@ def test_use_python_logging():
if os.environ.get('PYMUPDF_USE_EXTRA') == '0':
log_prefix = f'.+Using non-default setting from PYMUPDF_USE_EXTRA: \'0\''

if os.path.basename(__file__).startswith(f'test_fitz_'):
# Do nothing, because command `pymupdf` outputs diagnostics containing
# `pymupdf` which are not renamed to `fitz`, which breaks our checking.
print(f'Not testing with fitz alias.')
return

def check(
code,
regexes_stdout,
Expand Down
Loading