summaryrefslogtreecommitdiff
path: root/source/xps
AgeCommit message (Collapse)Author
2016-06-17Use 'size_t' instead of int as appropriate.Robin Watts
This silences the many warnings we get when building for x64 in windows. This does not address any of the warnings we get in thirdparty libraries - in particular harfbuzz. These look (at a quick glance) harmless though.
2016-06-14Fix typos in various parts of the code.Sebastian Rasmussen
2016-04-27Fix 696649: remove fz_rethrow_message calls.Tor Andersson
2016-04-05Clean up bidi enum names.Tor Andersson
And use the same enum for both the internal bidi code and the layout code.
2016-03-11Implement fz_text_language support functions.Robin Watts
Add code to convert to and from fz_text_language codes from ISO 639 language strings. No validation is carried out.
2016-03-11Rejig Bidirectional and Text code.Robin Watts
We move to using bidirectional "levels" throughout. This should give us better behaviour vis-a-vis nested l2r/l2r text. This also allows us to carry xps levels throughout with no loss of information. This also avoids the need to special case numbers. We accordingly carry more information into fz_text. As well as wmode, also hold additional details about the text spans. We now include the directionality of the bidi level text (either as derived from bidi code, or from the original document (e.g. xps)), the directionality of text (as specified in the original document (e.g. html)), and the language of the text (if specified in the original document).
2016-02-24Add fz_show_string function and move wmode argument to end.Tor Andersson
2016-02-24Add optional scissor hint argument to text clipping functions.Tor Andersson
2016-02-24Clarify scissor argument to clip device functions.Tor Andersson
The scissor argument is an optional (potentially NULL) rectangle that can give hints to devices about the area that can be scissored. This is used by the draw device and display list device to minimize the size of temporary clip mask buffers. The scissor rectangle, if used, must have been transformed by the current transform matrix.
2016-02-22Rename fz_add_text to fz_show_glyph.Tor Andersson
Match naming of fz_moveto/lineto etc for paths.
2016-02-10Add bold/italic/monospaced/serif flags to fz_font.Tor Andersson
Use the flags when selecting a fallback font.
2015-12-15Rename fz_buffer_cat to fz_append_buffer.Tor Andersson
2015-12-11Remove text clip accumulation.Tor Andersson
We can now group all clipped text into one fz_text object and simplify the device interface.
2015-12-11Keep spans of multiple fonts and sizes in one fz_text object.Tor Andersson
2015-12-11xps: Simplify infinite loop check.Tor Andersson
2015-10-06xps: Add separate link parsing step.Tor Andersson
Don't rely on having to run the page once with an identity transform before being able to load the links.
2015-10-06xps: Make guts of path and text parsing publically visible.Tor Andersson
For use in a later link parsing refactoring commit.
2015-10-06xps: Simplify transform attribute/tag parsing.Tor Andersson
2015-10-02Reference count fz_outline struct.Robin Watts
2015-10-02fz_link fixes.Robin Watts
Make fz_link reference counting threadsafe. Remember to free dests of GOTO links. Accordingly, ensure that XPS does not create links with uninitialised dests.
2015-09-14Remove unused functions.Tor Andersson
2015-09-01Default to invert_cmyk_jpeg for all formats other than PDF.Tor Andersson
2015-07-20Bug 696061: Fix leak of xml block.Robin Watts
Bug 696061 showed GhostXPS crashing with a SEGV. Checking MuPDF showed that a fix had already been applied here, but Memento shows that the fix was causing a leak. We therefore patch the leak here.
2015-04-14Split fz_meta into separate querying functions.Tor Andersson
Add fz_has_permission function to fz_document. Add fz_lookup_metadata function to fz_document. Remove fz_meta function from fz_document.
2015-03-24Path rework for improved memory usage.Robin Watts
Firstly, we make the definition of the path structures local to path.c. This is achieved by using an fz_path_processor function to step through paths enumerating each section using callback functions. Next, we extend the internal path representation to include other section types, including quads, beziers with common control points rectangles, horizontal, vertical and degenerate lines. We also roll close path sections up into the previous sections commands. The hairiest part of this is that fz_transform_path has to cope with changing the path commands depending on the matrix. This is a relatively rare operation though.
2015-02-26Clean up some type casts.Tor Andersson
2015-02-17Remove pointless return value checks when calling fz_open_file.Tor Andersson
fz_open_file does not return NULL on failure -- it throws an exception!
2015-02-17Add ctx parameter and remove embedded contexts for API regularity.Tor Andersson
Purge several embedded contexts: Remove embedded context in fz_output. Remove embedded context in fz_stream. Remove embedded context in fz_device. Remove fz_rebind_stream (since it is no longer necessary). Remove embedded context in svg_device. Remove embedded context in XML parser. Add ctx argument to fz_document functions. Remove embedded context in fz_document. Remove embedded context in pdf_document. Remove embedded context in pdf_obj. Make fz_page independent of fz_document in the interface. We shouldn't need to pass the document to all functions handling a page. If a page is tied to the source document, it's redundant; otherwise it's just pointless. Fix reference counting oddity in fz_new_image_from_pixmap.
2015-02-17Rename fz_close_* and fz_free_* to fz_drop_*.Tor Andersson
Rename fz_close to fz_drop_stream. Rename fz_close_archive to fz_drop_archive. Rename fz_close_output to fz_drop_output. Rename fz_free_* to fz_drop_*. Rename pdf_free_* to pdf_drop_*. Rename xps_free_* to xps_drop_*.
2015-02-17Reference count fz_document.Tor Andersson
2015-02-17Reference count fz_path and fz_text.Tor Andersson
Disallow modification of shared fz_path and fz_text objects. They should follow a create once, consume often pattern, and as such should be immutable once created.
2014-12-12make xps_read_part report correct part sizesSimon Bünzli
Starting with commit 2f4cdd4fd0580e3121773e89a7c6e7a9e1ffa54b, xps_read_part zero-terminates the read data. It does however also count that zero-terminator to the part's size which confuses callers handling non-text data.
2014-12-12fix memory leaksSimon Bünzli
Commit 5add23c7233c3f34fdfa6387873b1d3bdb93e1d6 and commit 2f4cdd4fd0580e3121773e89a7c6e7a9e1ffa54b introduced three memory leaks which only appear in error cases: * unzip.c leaks if a ZIP archive uses a compression method other than store or Deflate * xps-zip.c leaks if fz_open_archive_with_stream throws for broken ZIP archives * xps-zip.c leaks also if a piece of a split file is missing
2014-12-03xps: Use ZIP archive module.Tor Andersson
2014-09-17xps: Add fz_xml_is_tag to simplify tag matching.Tor Andersson
2014-09-17Improve XML parser.Tor Andersson
Add a whitespace preserving mode, for future use with XHTML. Also parse XHTML entities. This is not strictly according to spec, but for properly formed XML documents it should not matter.
2014-09-02Add locale-independent number formatting and parsing functions.Tor Andersson
2014-08-19don't render non-empty dashing with zero-length phaseSimon Bünzli
Adobe Reader and Microsoft XPS viewer differ in their handling of non-empty dashed strokes where the phase is 0: Adobe Reader considers these to be faulty and omits them while Microsoft XPS Viewer renders them the same as an empty dash (i.e. solid). This patch makes Fitz no longer render such strokes and ensures that MuXPS never emits them so that the desired behavior results (this is the easier implementation since XPS rendering code renders stroked paths in a single location whereas PDF rendering does it all over the place). See https://code.google.com/p/sumatrapdf/issues/detail?id=2339 for a testcase.
2014-08-19prevent buffer overflow and memory leak in xps-glyphs.cSimon Bünzli
xps_deobfuscate_font_resource assumes that a font has at least 32 bytes of data required for deobfuscation. If a broken font has less data, the buffer overflows. Also, the data buffer is leaked when fz_new_font_from_buffer throws.
2014-07-18fix ZIP64 support in xps-zip.cSimon Bünzli
Per the ZIP specification, ZIP64 values are only used if the original value was -1 (i.e. 0xFFFF for 16-bit and 0xFFFFFFFF for 32-bit values). Microsoft's XPS viewer behaves according to specification and so should MuXPS.
2014-07-02Handle the application/xps mimetype.Matt Holgate
I think this is non-standard, but some applications seem to use it. The email app on Android uses it, despite the fact the original email actually embedded it as application/octet-stream. I guess the email app is looking at the filename.
2014-05-12prevent indeterminacy by uninitialized variablesSimon Bünzli
There are two issues where variables may be used unitialized: * extract_exif_resolution fails to set xres and yres for JPEG images if there's no valid resolution unit (mainly affects XPS documents) * xps_measure_font_glyph uses hadv and vadv unitialized if the glyph id isn't valid (i.e. if FT_Get_Advance fails)
2014-04-23Fix bug 693580 by skipping xml tag namespace prefixes.Tor Andersson
fts_5904.xps and fts_5905.xps use namespace prefixes. Work around that by ignoring the namespace prefix for tag names. A more robust solution would be to expand or record the tag and attribute namespaces in the fz_xml node structure, but that's a overkill for our current needs.
2014-04-22Error out on unsupported encrypted zip filesSebastian Rasmussen
2014-02-17Add fz_transform_point_xy to simplify transforming a point.Tor Andersson
Many times, the idiom p.x = x; p.y = y; fz_transform_point() is used. This function should simplify that use case by both initializing and transforming the point in one call.
2014-01-16Bug 694957: fix stack buffer overflow in xps_parse_colorSimon Bünzli
xps_parse_color happily reads more than FZ_MAX_COLORS values out of a ContextColor array which overflows the passed in samples array. Limiting the number of allowed samples to FZ_MAX_COLORS and make sure to use that constant for all callers fixes the problem. Thanks to Jean-Jamil Khalifé for reporting and investigating the issue and providing a sample exploit file.
2014-01-07Introduce 'document handlers'.Robin Watts
We define a document handler for each file type (2 in the case of PDF, one to handle files with the ability to 'run' them, and one without). We then register these handlers with the context at startup, and then call fz_open_document... as usual. This enables people to select the document types they want at will (and even to extend the library with more document types should they wish).
2014-01-06Bug 694869: Fix indetermisms with broken PNG files.Robin Watts
This bug shows 2 problems with our data handling. Firstly, if a zip file entry has less data in the stream than it is declared to have, we would leave the end of the data uninitialised. We now put out a warning, and blank it with zeros. Secondly, if the PNG decompression fails to decode enough data, we don't notice. Now we give a warning and blank the remaining pixels.
2014-01-06fix MSVC warnings C4054 and C4152Simon Bünzli
These warnings are caused by casting function pointers to void* instead of proper function types.
2014-01-06fix various MSVC warningsSimon Bünzli
Some warnings we'd like to enable for MuPDF and still be able to compile it with warnings as errors using MSVC (2008 to 2013): * C4115: 'timeval' : named type definition in parentheses * C4204: nonstandard extension used : non-constant aggregate initializer * C4295: 'hex' : array is too small to include a terminating null character * C4389: '==' : signed/unsigned mismatch * C4702: unreachable code * C4706: assignment within conditional expression Also, globally disable C4701 which is frequently caused by MSVC not being able to correctly figure out fz_try/fz_catch code flow. And don't define isnan for VS2013 and later where that's no longer needed.