Skip to content

Commit

Permalink
Added test for issue #2608.
Browse files Browse the repository at this point in the history
Only run tests on recent mupdf which have fixed the underlying bug.

Test failed in optimised rebased; have fixed.
  • Loading branch information
julian-smith-artifex-com committed Oct 24, 2023
1 parent 265872a commit cb0b741
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/extra.i
Original file line number Diff line number Diff line change
Expand Up @@ -3333,7 +3333,7 @@ void JM_append_rune(fz_buffer *buff, int ch)
else
{
// 8 hex digits
snprintf(text, sizeof(text), "\\u%08x", ch);
snprintf(text, sizeof(text), "\\U%08x", ch);
mupdf::ll_fz_append_string(buff, text);
}
}
Expand Down
Binary file added tests/resources/2201.00069.pdf
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/resources/test_2608_expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
No significant gamma-ray excess above the expected background
is detected from the direction of FRB 20171019A, with 52 gamma
candidate events from the source region and 524 background event.
A second analysis using an independent event calibration and reconstruction (Parsons & Hinton 2014) confirms this result. A search for
variable emission on timescales ranging from milliseconds to several minutes with tools provided in (Brun et al. 2020) does not reveal
any variability above 2.2 𝜎. For the total data set of 1.8 h, 95% confidence level (C. L.) upper limits on the photon flux are derived using
the method described by Rolke et al. (2005). The energy threshold
of the data is highly dependent on the zenith angle of the observations. For these observations, the zenith angles range from 15 to 25
deg, which leads to an energy threshold for the stacked data set of
𝐸th = 120 GeV. The upper limit on the Very High Energy (VHE)
17 changes: 16 additions & 1 deletion tests/test_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Tests for the Font class.
"""
import fitz

import os

def test_font1():
text = "PyMuPDF"
Expand Down Expand Up @@ -37,3 +37,18 @@ def test_fontname():
if str(e).startswith("bad fontname chars"):
detected = True # illegal fontname detected
assert detected

def test_2608():
if fitz.mupdf_version_tuple <= (1, 23, 4):
print( f'Not running test_2608 because mupdf too old: {fitz.mupdf_version_tuple=}')
return
flags = (fitz.TEXT_DEHYPHENATE | fitz.TEXT_MEDIABOX_CLIP)
with fitz.open(os.path.abspath(f'{__file__}/../resources/2201.00069.pdf')) as doc:
page = doc[4]
blocks = page.get_text_blocks(flags=flags)
text = blocks[10][4]
with open(os.path.abspath(f'{__file__}/../test_2608_out'), 'wb') as f:
f.write(text.encode('utf8'))
with open(os.path.abspath(f'{__file__}/../resources/test_2608_expected'), 'rb') as f:
expected = f.read().decode('utf8')
assert text == expected

0 comments on commit cb0b741

Please sign in to comment.