summaryrefslogtreecommitdiff
path: root/fitz
AgeCommit message (Collapse)Author
2012-08-06Throw exception on too deeply nested arrays/dictsSebastian Rasmussen
Previously we would run out of error stacks in the context and fail abruptly. Now, throw an exception and hope for the best. At least this plugs any memory leaks.
2012-08-06Free decoded jpx image upon errorSebastian Rasmussen
Thanks to Zeniko for pointing out this fix.
2012-07-20Pass original font name to fz_new_font from PDF interpreter.Tor Andersson
Improves text device output when using substitute fonts. Fixes bug #693019.
2012-07-17Handle glyphs that are too large to render as pixmaps.Tor Andersson
2012-07-09Make synthetic font styles match XPS spec more closely.Tor Andersson
Shear by 20 degrees for italic. Use 2% wider metrics for bold.
2012-07-06Remove debugging functions for release builds.Sebastian Rasmussen
2012-07-06Whitespace fixes in fitz header.Sebastian Rasmussen
2012-07-05Cope with stray returns at the start of a JPEG stream.Robin Watts
Acrobat seems to cope, we should too. See normal_439.pdf for an example.
2012-07-05Move to static inline functions from macros.Robin Watts
Instead of using macros for min/max/abs/clamp, we move to using inline functions. These are more typesafe, and should produce equivalent code on compilers that support inline (i.e. pretty much everything we care about these days). People can always do their own macro versions if they prefer.
2012-07-05Cope with negative lengths being passed to fz_open_nullRobin Watts
normal_994.pdf SEGVs due to a negative length. Simple fix to treat negative length streams as 0 length.
2012-07-04Bug 693160: Fix bug in fz_write_buffer_bits.Robin Watts
When writing few enough bits that they would fit into the 'spare' bits in the last byte, I was failing to update the buffer. Also, I was failing to grow the buffer enough, and calculating the wrong number of bits left over in various places. Both fixed here. Thanks to Robert Jedrzejczyk and Sebras!
2012-07-04Prediction filter assumes it's writing to zeroed memory.Robin Watts
The putcomponent function assumes the function has been cleared. Simple fix to clear bytes at the start of each scanline. Problem seen with normal_217.pdf
2012-06-28Update tiff iamge predictor to cope with 16 bits.Robin Watts
normal_178.pdf contains a monochrome black and white image, encoded as 16bpc rgb.
2012-06-27Fix clipping of stroked text seen in displaylist cases.Robin Watts
When calculating the displaylist node rectangles, we were failing to adjust for linewidth/mitrewidth etc. This could result in glyphs being clipped; see normal_130.pdf for example.
2012-06-27Make ASCII85 decoding more tolerant of end of stream errors.Robin Watts
This solves the normal_87.pdf rendering issues.
2012-06-25Fix incorrect assignment in unused bitmap accessor.Sebastian Rasmussen
2012-06-25Warning fixes and various clean ups:Sebastian Rasmussen
Remove unused variable, silencing compiler warning. No need to initialize variables twice. Remove initialization of unread variable. Remove unnecessary check for NULL. Close output file upon error in cmapdump.
2012-06-22Fix a char vs unsigned char warning.Robin Watts
2012-06-18Fix indentation and white space errors.Tor Andersson
2012-06-12A few general utility functions added for the sake of the forms workPaul Gardiner
2012-06-11Move to using sigsetjmp/siglongjmp on more platforms.Robin Watts
Previously we used to have a special case hack in for MacOS. Now we call sigsetjmp/siglongjmp on all platforms that define __unix. (i.e. pretty much all of them except windows).
2012-06-11Fix Bug 693102: Overflows in large pixmap indexing.Robin Watts
When we allocate a pixmap > 2G, but < 4G, the index into that pixmap, when calculated as an int can be negative. Fix this with various casts to unsigned int. If we ever move to support >4G images we'll need to rejig the casting to cast each part of the element to ptrdiff_t first.
2012-06-11Fix Bug 693099: Render failure due to corrupt jpeg data.Robin Watts
The file supplied with the bug contains corrupt jpeg data on page 61. This causes an error to be thrown which results in mudraw exiting. Previously, when image decode was done at loading time, the error would have been thrown under the pdf interpreter rather than under the display list renderer. This error would have been caught, a warning given, and the program would have continued. This is not ideal behaviour, as there is no way for a caller to know that there was a problem, and that the image is potentially incomplete. The solution adopted here, solves both these problems. The fz_cookie structure is expanded to include a 'errors' count. Whenever we meet an error during rendering, we increment the 'errors' count, and continue. This enables applications to spot the errors count being non-zero on exit and to display a warning. mupdf is updated here to pass a cookie in and to check the error count at the end; if it is found to be non zero, then a warning is given (just once per visit to each page) to say that the page may have errors on it.
2012-06-08Fix Bug 693097; memory overwrite when handling knockout groups.Robin Watts
When handling knockout groups, we have to copy the background from the previous group in so we can 'knockout' properly. If the previous group is a different colorspace, this gives us problems! The fix, implemented here, is to update the copy_pixmap_rect function to know how to copy between pixmaps of different depth. Gray <-> RGB are the ones we really care about; the generic code will probably do a horrible job, but shouldn't ever be called at present. This suffices to stop the crashing - we will probably revisit this when we revise the blending support.
2012-05-31Add linearization to pdf_write function.Robin Watts
Extend mupdfclean to have a new -l file that writes the file linearized. This should still be considered experimental When writing a pdf file, analyse object use, flatten resource use, reorder the objects, generate a hintstream and output with linearisaton parameters. This is enough for Acrobat to accept the file as being optimised for Fast Web View. We ought to add more tables to the hintstream in some cases, but I doubt anyone actually uses it, the spec is so badly written. Certainly acrobat accepts the file as being optimised for 'Fast Web View'. Update fz_dict_put to allow for us adding a reference to the dictionary that is the sole owner of that reference already (i.e. don't drop then keep something that has a reference count of just 1). Update pdf_load_image_stream to use the stm_buf from the xref if there is one. Update pdf_close_document to discard any stm_bufs it may be holding. Update fz_dict_put to be pdf_dict_put - this was missed in a renaming ages ago and has been inconsistent since.
2012-05-23Make CCITTFax tables static.Tor Andersson
2012-05-18Update fitz.h with __cplusplus guard to protect against inline changes.Robin Watts
When including fitz.h from C++ files, we must not alter the definition of inline, as it may upset code that follows it. We only alter the definition to enable it if it's available, and it's always available in C++ - so simply avoiding changing it in the C++ case gives us what we want.
2012-05-08Switch to reading content streams on the fly during interpretation.Robin Watts
Previously, before interpreting a pages content stream we would load it entirely into a buffer. Then we would interpret that buffer. This has a cost in memory use. Here, we update the code to read from a stream on the fly. This has required changes in various different parts of the code. Firstly, we have removed all use of the FILE lock - as stream reads can now safely be interrupted by resource (or object) reads from elsewhere in the file, the file lock becomes a very hard thing to maintain, and doesn't actually benefit us at all. The choices were to either use a recursive lock, or to remove it entirely; I opted for the latter. The file lock enum value remains as a placeholder for future use in extendable data streams. Secondly, we add a new 'concat' filter that concatenates a series of streams together into one, optionally putting whitespace between each stream (as the pdf parser requires this). Finally, we change page/xobject/pattern content streams to work on the fly, but we leave type3 glyphs using buffers (as presumably these will be run repeatedly).
2012-05-08Update seeking behaviour of null streams.Robin Watts
In order to (hopefully) allow page content streams to be interpreted without having to preload them all into memory before we run them, we need to make the stream reading code cope with other users moving the stream pointer. For example: Consider the case where we are midway through interpreting a contents stream, and us hitting an operator that requires something to be read from Resources. This will move the underlying stream file pointer, and cause the contents stream to read incorrectly when control returns to the interpreter. The solution to this seems to be fairly simple; whenever we create a filter out of the file stream, the existing code puts in a 'null' filter first, to enforce a length limit on the stream. This null filter already does most of the work we need it to, in that by it being there, the buffering of data is done in the null filter rather than in the underlying stream layer. All we need to do is to keep track of where in the underlying stream the null filter thinks it is, and ensure that it seeks there before each read (in case anyone else has moved it). We move the setting of the offset to be explicit in the pdf_open_filter (and associated) call(s), rather than requiring fz_seeks elsewhere.
2012-05-07Do not rely on printf NULL-pointer handling for missing font names.Sebastian Rasmussen
2012-04-28Fix typo in pdf writing code.Sebastian Rasmussen
2012-04-28Move guts of pdfclean into new pdf_write function.Robin Watts
Expose pdf_write function through the document interface.
2012-04-23Fix whitespace and indentation.Tor Andersson
2012-04-20Pass UTF8 filename to fz_open_document / fz_open_file to remove kludges.Tor Andersson
Use _wopen on a UTF8 -> wchar_t decoded filename to support UTF8 filenames for win32.
2012-04-19Change fz_document_open to assume PDF format by default.Robin Watts
Previously, we would only open files with the correct extension. Until such time as we get file type detection by contents working assume that any file that doesn't end in .xps or .cbz is a pdf file.
2012-04-19Retry loading a hinted glyph without hinting if freetype returns an error.Tor Andersson
Allows us to render files with broken font hinting programs when hinting is enabled(whether by no-AA or DynaLab detection). Fix bug 692949.
2012-04-18Note that the fz_meta interface is subject to change.Robin Watts
Comment changes only.
2012-04-17Add Meta interface to fz_document.Robin Watts
Use this to reintroduce "Document Properties..." in mupdf viewer.
2012-04-10Add fz_new_draw_device_with_bbox functionRobin Watts
Restricts rendering to a sub rectangle of the supplied bbox.
2012-04-09Fix use of uninitialised variable.Robin Watts
In my previous commit, I forgot to initialise the variable before using it. Thanks to Bas Weelinck for spotting this.
2012-04-09Bug 692979: Fix race condition in thread debugging.Robin Watts
Bas Weelinck points out a potential problem with multiple threads starting up at the same time, running into a race condition in the thread debugging code. He suggests using an extra lock to avoid this, and indeed, it would be a simple way. I am reluctant to introduce an extra lock purely for this case though, so I've instead reused the ALLOC lock. This has the advantage of us not having to take the lock except in the 'first call with a new context' case.
2012-04-09Bug 692976: Fix spurious thread lock debug warnings on context clonesRobin Watts
When cloning, ensure the locks are done on the new context, not the old one; this makes no difference except to suppress some spurious debugging messages. Also ensure that DEBUG is predefined for Makefile based debug and memento builds. Thanks to Bas Weelinck.
2012-04-05Fix potential problems on malloc failure.Robin Watts
Don't reset the size of arrays until we have successfully resized them.
2012-04-05Bug 692946 - fix 'stray white pixels in black areas' when halftoning.Robin Watts
Depending on the operation used (< or <=) the threshold array should never have either 0 and ff in it. As we are using <, it should never have 0 in it. Fixed here.
2012-03-28Add documentation for fz_link_dest and text extraction device.Robin Watts
2012-03-28Warn that the fz_link_dest struct is not finished.Tor Andersson
2012-03-28Whitespace fixes.Tor Andersson
2012-03-21Update iOS app.Tor Andersson
2012-03-19Fix typo in text device where lines would group into blocks too eagerly.Tor Andersson
The default page userspace transform changed to a top-down coordinate space, and I forgot this detail when updating the text device branch. Also remove the final block sorting pass to give preference to the original PDF text order.
2012-03-19Don't create empty spans and lines in the text device.Tor Andersson