summaryrefslogtreecommitdiff
path: root/source/fitz
AgeCommit message (Collapse)Author
2018-09-21Add fz_lookup_cjk_font_by_name to create builtin CJK fonts.Tor Andersson
2018-09-21Regularize language and script names.Tor Andersson
Drop the unused 'serif' argument to the CJK lookup functions. Use the BCP 47 names for CJK scripts and languages: zh-Hant for traditional Chinese, zh-Hans for simplified Chinese, ja for Japanese, ko for Korean. The lookup function also allows commonly used language+country codes: zh-TW and zh-HK for traditional Chinese, zh-CN for simplified Chinese.
2018-09-20Be consistent in use of #if FZ_ENABLE_...Robin Watts
Using #ifdef FZ_ENABLE_ means we build code in, even if we have defined FZ_ENABLE_WHATEVER to be 0 (as we do in config.h).
2018-09-20Bug 699798: Avoid removing page from list if page was not loaded.Sebastian Rasmussen
MuPDF may attempt to load a page but fail to do so, e.g. due to a circular page tree. When this happens the page will never be introduced into the document's list of pages. Its next and prev pointers are both NULL, but the code in fz_drop_page() falsely assumed that the prev pointer was always set. Thanks to oss-fuzz for reporting.
2018-09-19Make fz_page objects singleton.Tor Andersson
Keep a list of currently open pages for each document. Attempting to load a page that is already loaded will return the same instance again.
2018-09-19Update to OpenJPEG 2.3.0.Sebastian Rasmussen
There is a regression for 2325_-_JPX_image_with_padding_rejected.pdf. Object 3 in that document is a JPX-encoded image. Its EOC marker is preceded by two extra bytes of data, 0x80 0x80. This makes the file broken according to the JPEG 2000 specification. Acrobat Reader and the Kakadu JPX decoder accepts this file without issues, so OpenJPEG 2.1.0 added code to fix this (bug 226, commit 005e75bdc). That fix detects exactly two bytes of 0x80 0x80, a rather brittle fix. Adding more padding or changing the padding byte values is not accepted. Adding more padding is acceptable to Acrobat Reader and Kakadu. An unrelated fix for another problem has since broken OpenJPEG's support for this broken image.
2018-09-13jpx: Handle ICC color profiles.Sebastian Rasmussen
2018-09-13Bug 699769: Fix bugs in upsampling code for JPX images.Sebastian Rasmussen
The upsampling code in the JPX decode attempted to guess a suitable upsampling factor. The guessed factor was wrong, causing writes of samples outside of the decoded image buffer. Simply limiting the coordinates to the image buffer would not suffice because the factor was wrong for every upsampled row of pixels. openjpeg does provide an upsampling factor, so use that instead and also take the component offsets into account when decoding components into the pixmap. Combined this resolves the issue that previously triggered ASAN. Thanks to oss-fuzz for reporting.
2018-09-13Make naming of effective overprint argument consistent.Sebastian Rasmussen
2018-09-13Bug 699750: Check for overprinting correctly.Sebastian Rasmussen
2018-09-12Set the profile BGR flag for non-default ICC colorspaces too.Sebastian Rasmussen
2018-09-06Fix typo in size field of ICC profile colorspace.Sebastian Rasmussen
2018-09-05Take colorspace name from ICC profile.Sebastian Rasmussen
2018-09-05Bug 699715: Support embedded ICC color profiles in GIF.Sebastian Rasmussen
2018-09-05When decoding GIF, move pixmap into struct so it can be changed.Sebastian Rasmussen
This makes it possible to change the colorspace when encountering ICC colorspaces.
2018-09-05Bug 699702: Handle ICC profiles split into multiple APP-markers.Sebastian Rasmussen
2018-09-05Add missing fz_var declarations.Tor Andersson
2018-09-05Add fz_new_stext_page_from_annot utility function.Tor Andersson
2018-09-05Use colorspace type enum instead of magic profile names.Tor Andersson
2018-09-04Fix 699177: Don't clamp line width to 1 after scaling by matrix expansion.Tor Andersson
2018-08-30Bug 699694: Fix reference counting for JBIG2 globals.Sebastian Rasmussen
fz_open_jbig2d() is called at two locations in MuPDF. At one location a reference to the JBIG2 globals struct was taken before passing it to fz_open_jbig2d(). At the other location no such reference was taken, but rather ownership of the struct was implicitly transferred to fz_open_jbig2d(). This inconsistency led to a leak of the globals struct at the first location. Now, passing a JBIG2 globals struct to fz_open_jbig2d() never implictly takes ownership. Instead the JBIG2 stream will take a reference if it needs it and drops it in case of error. As usual it is the callers responsibility to drop the reference to the globals struct it owns.
2018-08-28Bug 699683: Skip painting too large images when using interpolation.Tor Andersson
When painting images using interpolation 16.16 fixpoint arithmetics is used. This limits the width/height of any image that can be painted to 32767. There was no size check, so large images caused overflow and subsequent out of bounds accesses which triggered MSAN. This c Thanks to oss-fuzz for reporting.
2018-08-28Bug 699675: Handle lack of default colorspaces when rendering type 3 font glyph.Sebastian Rasmussen
Previously this would result in trying to dereference a NULL pointer. Thanks to oss-fuzz for reporting.
2018-08-22Remove the old 'nested depth' tracking.Tor Andersson
This was used to prevent infinite cycles in the Type3 font CharProcs, but the previous commits forbids all cycles in order to prevent memory leaks due to cyclic reference counts.
2018-08-14Bug 699631: Handle unsupported triangle mesh edge flags.Sebastian Rasmussen
There were two issues with the code parsing the triangle mesh's edge flags: * meshes were not require to start with an independent triangle * out of range edge flags caused vertices to be ignored A mesh where the edge flag of the first vertice is out of range, and the edge flag of the second vertex indicates continuation of a prior triangle would result in trying to create a triangle where the third coordinate would be uninitialized. This commit requires the edge flag of the first vertex to indicate a new independent triangle and if out of range edge flags are encountered they are treated as if they indicate a new triangle. Thanks to oss-fuzz for reporting.
2018-08-14Bug 698898: Always pop draw stack in case of exception.Sebastian Rasmussen
When fz_draw_clip_image_mask() calls fz_get_pixmap_from_image() may throw an exception, in this case beacuse a predicted image has an unsupported number of components (1, 2, 4, 8 and 16 are supported, but 6 is not). When this happens the recently pushed stack element is never popped, which later trips an assert() in fz_draw_end_group() at a later stage. By moving the call to fz_get_pixmap_from_image() inside fz_try the stack will be popped, thus avoiding triggering the assert(). This also requires the pixmap variable to be fz_var()ed because it changes inside the fz_try-block.
2018-08-14Bug 698887: Fix leak of device/pixmap when rendering fails.Sebastian Rasmussen
2018-08-10Tweak hexdumped data to increase build portability.Tor Andersson
Follow bin2coff layout for hexdumped data instead of trying to emulate the objcopy layout (which seems to break for the android tools). Only use the basename of the resource in hexdump / bin2coff. Ifdef on HAVE_OBJCOPY instead of _WIN32.
2018-08-10Clean up null/range/endstream filter.Tor Andersson
Use separate functions to keep the code simpler. Use memmem to simplify and optimize search for 'endstream' token. Do not look for 'endobj' since that could cause a false positives in compressed object streams that have duff lengths.
2018-08-10Add fz_memmem function taken from musl libc.Tor Andersson
2018-08-10Preprocessor gluing tokens together causes clang error.Sebastian Rasmussen
2018-08-01Update jbig2dec.Sebastian Rasmussen
2018-07-17Fix memory leaks in document signing functionsPaul Gardiner
2018-07-06Bug 699308: Fix stream reading logic to better cope with duff Lengths.Robin Watts
Always look for the "endstream" marker after a PDF stream to see if we've hit the end. Allow for "endobj" to cope with producers that omit endstream entirely. Avoid slowing down legal files by only checking for the end marker after the specified length has been read.
2018-07-06Fix stray consts.Robin Watts
2018-07-05Add fz_transform_page helper function.Tor Andersson
Create a matrix that transforms a page with resolution and rotation, and grid fits the resulting bounding box.
2018-07-05Silence warning.Tor Andersson
2018-07-05Pass rects by value: device and document interface.Tor Andersson
2018-07-05Pass matrices by value: device and document interface.Tor Andersson
2018-07-05Pass rect and matrix by value in geometry functions.Tor Andersson
Several things irk me about passing values as const pointers: * They can be NULL, which is not a valid value. * They require explicit temporary variables for storage. * They don't compose easily in a legible manner, requiring weird pointer passing semantics where the variable being assigned is hidden as an argument in the innermost function call. * We can't change the value through the pointer, requiring yet more local variables to hold copies of the input value. In the device interface where we pass a matrix to a function, we often find ourselves making a local copy of the matrix so we can concatenate other transforms to it. This copying is a lot of unnecessary busywork that I hope to eventually avoid by laying the groundwork with this commit. This is a rather large API change, so I apologize for the inconvenience, but I hope the end result and gain in legibility will be worth the pain.
2018-07-04Clean up some incomprehensible code.Tor Andersson
2018-07-04Add fz_snap_selection function to snap selection to chars/words/lines.Tor Andersson
Updates the input point coordinates, and also returns a quad with appropriate UI handles.
2018-07-04Add fz_is_point_inside_rect utility function.Tor Andersson
2018-06-22Update base 14 fonts to URW++ release from 2017-07-27.Tor Andersson
The Dingbats and Symbol fonts have not been changed.
2018-06-22Don't pollute namespace with our 'restrict' macro. Use FZ_RESTRICT instead.Tor Andersson
2018-06-22Use fz_quad type in structured text and selection/highlighting.Tor Andersson
2018-06-22Add fz_quad type.Tor Andersson
2018-06-22Remember the md5 digest in the fz_font struct.Tor Andersson
2018-06-22Cache base14 and CJK fonts.Tor Andersson
Do not cache PDF fonts, since they have custom metrics and encodings that cannot be shared. This is primarily to speed up font loading for EPUB, PDF appearance synthesis, and any other uses of default metrics and unicode encoded fonts.
2018-06-22Check pointer for NULL in fz_free before locking.Tor Andersson