summaryrefslogtreecommitdiff
path: root/pdf/pdf_fmap.c
Commit message (Collapse)AuthorAgeFilesLines
* Update postal address in file headersChris Liddell2023-04-041-2/+2
|
* Revise how the pdfi fontmap code checks a font file existsChris Liddell2023-02-271-10/+1
| | | | | | | | | | Originally, the code assumed that any extra font files were on disk files, and did not account for the possibility that they might be in the romfs (or potentially access via the Postscript %os% or similer i/o device). This revises it to cope with such cases. Stems from Bug 706267.
* Bug 706315: Fix condition for explicit freeing of file enumeratorChris Liddell2023-01-101-0/+2
| | | | | We should only explicitly free the file enumerator if the enumeration loop exits early.
* GhostPDF - check for failure to open files when building font mapKen Sharp2023-01-101-1/+3
| | | | | | | | | | | | | | | | | | | Bug #706315 "`ps2pdf -sFONTPATH=. ...` crashes with SIGSEGV" When enumerating files in a directory in order to build a font map, we were not checking the result of sfopen but assuming it would succeed and then trying to read from it. On Windows at least, the file may already be open exclusively which results in sfopen returning a NULL, which causes a seg fault when we try to use it in sgets(). I'm unable to reproduce this problem on Linux so I can't be certain it is the same problem as in the report, but it seems likely. Fixed by simply checking the return value for NULL and ignoring the file if it is. We obviously can't use it as a font anyway so there's no harm in ignoring it.
* GhostPDF - Don't flag a warning on compressed Length 0 streamsKen Sharp2022-12-091-1/+5
| | | | | | | | | | | Example file Bug689644.pdf Streams of 0 length, compressed with Flate (and possibly other schemes) were throwing an error, because we couldn't read even enough bytes to satisfy the signature. If we get a stream o f 0 length, don't bother processing it at all, just return immediately. This prevents us flagging a spurious error.
* pdfi: Remove the CIDSystemInfo Supplement check in the cidfmap codeChris Liddell2022-08-231-16/+1
| | | | | | | | | The pdfi code for reading and using mappings for CIDFonts in cidfmap validated all the CIDSystemInfo (registry, ordering and supplement) and if any didn't match, it would reject the mapping. It turns out that the old code ignored the Supplement value, so the pdfi code will now, too.
* OSS_fuzz #48564Ken Sharp2022-07-011-2/+2
| | | | | | | | | | | Yet more fallout from the change to objects not always being pointers to structures. using object->type doesn't work if object isn't a pointer to a struct, we need to use pdfi_type_of instead. Since this keeps happening, audit all occurrences of ->type and .type in the pdfi code and make sure we use the pdfi_type_of() function where needed. A couple of these are in code not compiled in due to #if 0 pre-processor directives, but fix them anyway.
* pdfi: Don't return error after consulting "native" font mapChris Liddell2022-06-061-13/+17
| | | | | | If we didn't find a map for a font name in the native font map (i.e. that generated by scanning FONTPATH) then were returning the error, instead of carrying on to check the regular font map (from Fontmap.GS).
* Bug 705298: Change priority of font mapsChris Liddell2022-06-011-16/+21
| | | | | | | | | | The pdfi fontmap code prioritized explicit mappings from the Fontmap file, over mappings generated automatically from the FONTPATH option. Turns out, it should be the other way around. Secondly, the pdfi code would "sanitize" the font name to look for before consulting either font map, where we should check the name as read from the PDF before trying the sanitized version.
* GhostPDF - Coverity fixesKen Sharp2022-05-061-1/+1
| | | | | | | | | | | | | | | | | CID 378377 pdf_fontps.c - Assign the return value from pdfI-array_put() to 'code' so that we deal with possible errors. CID 378378 pdf_xref.c - check the return from pdfi_loop_detector_mark() for errors CID 378379 pdf_obj.c - comment out a couple of cases. Coverity is (correctly) complaining these are dead. CID 378384 pdf_fmap.c - cater for the (expected) return value of 0 from dict_get() so that we don't end up using an uninitialised variable.
* PDFI: Use helper functions for converting pdf_obj -> numsRobin Watts2022-05-051-29/+15
| | | | | | | | | This includes functions to pop values off the stack, convert to the appropriate types etc, that encapsulate error handling etc. Use these throughout the code. This drastically simplifies lots of code, and avoids needless error-prone repetition. It also means we can add debug testing/warnings in many fewer places.
* pdfi: Introduce pdfi_type_of.Robin Watts2022-05-051-16/+16
| | | | | All code now reads pdf obj types using pdfi_type_of rather than directly accessing obj->type. This will help us in the next optimisation step.
* lgtm fix: Don't check "code >= 0" twice.Robin Watts2022-01-171-2/+2
|
* Implement the NONATIVEFONTMAP command line parameter.Chris Liddell2021-12-161-0/+8
| | | | Prevents scanning FONTDIR for potential substitute fonts.
* pdfi: Add "first attempt" CIDFont fallback to match gsChris Liddell2021-11-251-0/+1
| | | | | | | | | Ghostscript's first attempt to find a suitable fallback CIDFont is to assemble a "fake" font name from the CIDSystemInfo /Registry and /Ordering strings. Allowing a mapping to catch any, for example, Adobe GB1 CIDFonts by defining a substitute CIDFont called /Adobe-GB1. Extremely rarely used, it seems, but should be supported nonetheless.
* CID 373913: Fix ignored return value.Chris Liddell2021-11-151-0/+5
|
* CID 373905: initialised a variableChris Liddell2021-11-151-1/+1
|
* Fix reference counting for pdfnativefontmap dictChris Liddell2021-11-111-0/+1
| | | | Fixes a memory leak
* CID 373900/373902/373903: placate coverity "unused value" complaintChris Liddell2021-11-111-1/+8
| | | | | | In these cases, we mostly ignore errors, because it probably means the file in question wasn't a valid font file. But hopefully we can placate Coverity by checking for and acting on an out-of-memory condition.
* CID 373901: Add a load of bounds checking in TTF font scanningChris Liddell2021-11-111-6/+50
|
* Fix a comment marker typoChris Liddell2021-11-091-1/+1
|
* Support user specified Fontmap files in pdfiChris Liddell2021-11-091-25/+65
| | | | | | | | | | Handle -sFONTMAP param in gpdl, and copy the relevant strings from the Postscript world when pdfi is called from Ghostscript. To make things a little simpler, there is also a tweak to the Postscript code, so the FONTMAP parameter gets split into an array of strings during initialisation, rather than at use time, which saves doing that process once for Postscript and once for pdfi.
* native font map from font file scanChris Liddell2021-11-091-15/+554
| | | | | | | | | | | | | | | | | | | | First pass at FONTDIR scanning... Handles Type 1 and TTF/TTC/OTTO files. CFF still to do. And probably some tidying up. Slightly rejig font file scanning. Previously, the code used the magic number to decide which file scanning function to call, which would attempt to find the font name in the file, and return it, so the caller could add the name/path to the native font map. But that approach was messy when the ability to deal with TrueType collections was implemented. So, this tweaks it so the scanning function also does the adding of the font mapping to the dictionary.
* pdfi support for cidfmapChris Liddell2021-11-091-35/+228
| | | | | Slightly limited due to not supporting full Postscript (so no use of cvn, .getenv, concatstrings etc).
* gpdf: Build and use resource search path listChris Liddell2021-09-091-8/+8
| | | | | | | | Also use the genericrsourcedir to find fonts. gpdf: allow setting of FONTPATH param gpdf/gs: Populate the pdfi search paths from the PS environment
* Commit pdfi to master.Robin Watts2021-08-121-0/+181
This is a commit of the pdfi branch to master, eliminating the traditional merge step. The full history of the pdfi branch can be seen in the repo, and that branch is effectively frozen from this point onwards. This commit actually differs from pdfi in a small number of whitespace changes (trailing spaces etc).