Till Kamppeter [Sat, 15 Oct 2022 14:13:50 +0000 (16:13 +0200)]
libcupsfilters: Added info about source of human-readable option strings
The files cupsfilters/catalog.c and cupsfilters/catalog.h contain an
API to obtain human-readable and translated strings for printer
options and choices. Document where the actual strings are taken from.
Till Kamppeter [Sat, 15 Oct 2022 13:23:10 +0000 (15:23 +0200)]
libppd: Code clean-up for code of libppd
Cleaned up the code following the coding style rules in the
DEVELOPING.md file of the CUPS source code.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
In addition, all the file's header comments reflect the new license,
Apache 2.0, the same license as used for CUPS.
Till Kamppeter [Tue, 11 Oct 2022 23:02:42 +0000 (01:02 +0200)]
libcupsfilters: Code clean-up for code of testpdf1 and testpdf2
Cleaned up the code following the coding style rules in the
DEVELOPING.md file of the CUPS source code.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
In addition, one can now supply a fon file as argument to testpdf2, so
that this program embeds the supplied font instead of a standard one.
Till Kamppeter [Tue, 11 Oct 2022 22:40:52 +0000 (00:40 +0200)]
libcupsfilters: Move test suite programs to cupsfilters/
Two test suite programs for libcupsfilters, test_pdf1.c and
test_pdf2.c were still in the filter/ directory. This commit moves
them into cupsfilters and correct their naming style.
Till Kamppeter [Tue, 11 Oct 2022 06:49:40 +0000 (08:49 +0200)]
libcupsfilters: Renamed functions and types in fontembed code
Renamed all functions and types in the source files in the fontembed/
subdirectory tofollow the rules of DEVELOPING.md of CUPS.
To distinguish functions and types internal to only fontembed/ and
internal to the whole libcupsfilters, the ones internal to fontembed/
have two underscores in the beginning of their names now
("__cfFontEmbed...", "__cf_fontembed_...") while the ones which form
the internal API to libcupsfilters have only one ("_cfFontEmbed...",
"_cf_fontembed_...").
Also considered the API of fontembed as internal to
libcupsfilters. Therefore renamed cupsfilters/fontembed.h to
cupsfilters/fontembed-private.h and not installing it into
/usr/include.
Till Kamppeter [Mon, 10 Oct 2022 18:34:12 +0000 (20:34 +0200)]
libfontembed, libcupsfilters: Merge libfontembed into libcupsfilters
libfontembed is only used by cups-filters, and here only by the
cfFilterTextToPDF() filter function ("texttopdf" CUPS filter, also
part of "universal" CUPS filter). It is also not used by any other
package (at least of Ubuntu Main and Universe).
To ease the separation of cups-filters into their components (similar
to CUPDS 3.x we will separate, into libcupsfilters, libppd,
cups-filters, and cups-browsed, to cleanly separate off the PPD file
support) we merge the functionality of libfontembed into
Libcupsfilters, to keep the cfFilterTextToPDF() filter function for
plain text file printing support.
Till Kamppeter [Mon, 10 Oct 2022 12:16:03 +0000 (14:16 +0200)]
libfontembed: Code clean-up for code of libfontembed
Cleaned up the code following the coding style rules in the
DEVELOPING.md file of the CUPS source code.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
Till Kamppeter [Fri, 7 Oct 2022 12:03:22 +0000 (14:03 +0200)]
libcupsfilters: Added RGBW support to cfFilterPCLmToRaster()
Requesting RGBW as destination color space (to test, use pclmtoraster
CUPS filter wrapper and PPD for HP inkjet with hpcups driver of HPLIP)
leads to wrong color output on some input files and even to a crash on
others.
This is cause by missing support for RGBW and this, instead RGB being
output into the destination file with RGBW declared as the color space
in its header.
This commit adds explicit support for RGBW output and this way solves
the problem.
Till Kamppeter [Thu, 6 Oct 2022 15:59:38 +0000 (17:59 +0200)]
libcupsfilters: Code clean-up for code of libcupsfilters
Completed the code clean-up of the source files of libcupsfilters in
the cupsfilters/ directory itself (no sub-directory) following the
coding style rules in the DEVELOPING.md file of the CUPS source code.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
Till Kamppeter [Thu, 29 Sep 2022 22:41:46 +0000 (00:41 +0200)]
libcupsfilters: Code clean-up for code of libcupsfilters
Cleaned up the second bunch of source code files of libcupsfilters in
the cupsfilters/ directory itself (no sub-directory) following the
coding style rules in the DEVELOPING.md file of the CUPS source code.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions rteceived during more than a
decade, even before the start of the cups-filters project.
Till Kamppeter [Sun, 25 Sep 2022 21:03:08 +0000 (23:03 +0200)]
libcupsfilters: Removed portability implementationsn of functions
For portability implementations of the GNU C functions getline() and
strcasestr() were included in the source code but there is nothing in
the build system making them actually used if the system does not
provide them.
Therefor we do not take them to 2.x and remove them here.
Till Kamppeter [Sat, 10 Sep 2022 06:48:48 +0000 (08:48 +0200)]
libcupsfilters: Code clean-up for code of cfFilterPDFToPDF()
Cleaned up the first bunch of source code files of libcupsfilters in
the cupsfilters/ directory itself (no sub-directory) following the
coding stype rules in the DEVELOPING.md file of the CUPS source code.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions rteceived during more than a
decade, even before the start of the cups-filters project.
Till Kamppeter [Mon, 5 Sep 2022 22:06:10 +0000 (00:06 +0200)]
libcupsfilters: Code clean-up for code of cfFilterPDFToPDF()
Cleaned up all the source code files of the cfFilterPDFToPDF() filter
function (all files in cupsfilters/pdftopdf/) following the coding
stype rules in the DEVELOPING.md file of the CUPS source code.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Till Kamppeter [Sun, 4 Sep 2022 13:22:57 +0000 (15:22 +0200)]
Removed PHP and Perl APIs
The included PHP and Perl APIs did not get actually maintained and
especially never used by anyone. They still were on the API level of
CUPS 1.2. And the Perl part was not even supported by the build system
(only the scripting/perl/ directory in EXTRA_DIST to get it into the
source tarball).
Therefore we do not take it over into cups-filters 2.x and drop it
here.
Till Kamppeter [Sun, 4 Sep 2022 12:59:33 +0000 (14:59 +0200)]
libcupsfilters: Removed support for legacy image formats
Removed support for the legacy image formats GIF, Photo CD, X Pixmap,
X Bitmap, PNM (Portable Anymap/Bitmap/Graymap/Pixmap), BMP, SGI RGB,
Sun Raster. This is to avoid the requirement to maintain gthe code
supporting these mostly obsolete image formats.
Till Kamppeter [Sat, 3 Sep 2022 18:08:14 +0000 (20:08 +0200)]
libcupsfilters: Update comments about filter functions in filter.h
The filter functions cfFilterGhostscript() and cfFilterPWGtoPDF()
allow the output format also to be supplied as parameter and not
only via filter data structure.
Till Kamppeter [Sat, 3 Sep 2022 18:00:30 +0000 (20:00 +0200)]
libcupsfilters: Let cfFilterUniversal() not se unnecessary parameters
With the new fields content_type and final_content_type in the filter
data structure the output format does not need to get supplied as
parameter any more for most filter functions. So let
cfFilterUniversal() not supply any parameters any more to filter
functions which do not use them any more.
Till Kamppeter [Sat, 3 Sep 2022 16:31:42 +0000 (18:31 +0200)]
libcupsfilters: Do not feed CUPS Raster into cfFilterPWGToPDF()
- In cfFilterUniversal() correct filter chains to always feed PWG
Raster (or Apple Raster) into cfFilterPWGToPDF():
o After cfFilterImageToRaster() call cfFilterRasterToPWG() before
cfFilterPWGToPDF()
o Do not accept CUPS Raster as input format for cfFilterUniversal(),
so we only need to convert PWG Raster and Apple Raster to PDF,
which works with cfFilterPWGToPDF(). CUPS Raster as input is
actually not needed, as it is not used as network format for print
jobs but only internally by CUPS, usually for Raster drivers. Also
updated the MIME rules to not accept CUPS Raster.
o Convert application/vnd.adobe-reader-postscript (PostScript from
Adobe Reader) always to PDF via cfFilterGhostscript() (to PWG
Raster) and cfFilterPWGToPDF() (to PDF). Removed the other paths
for simplification. Also made sure that the filters to convert PDF
to the final format get added to the chain.
- Let cfFilterRasterToPWG() also accept the final output format PCLm
and then create PWG Raster, in preparation for cfFilterPWGToPDF().
- Let cfFilterPWGToRaster() not accept PCLm as final output format as
its input format (PWG or Apple Raster) is directly accepted by
cfFilterPWGToPDF() and so this filter is not needed for PCLm as
final output format.
- These changes also fix printing
application/vnd.adobe-reader-postscript (PostScript from Adobe
Reader) with the cfFilterUniversal() filter function.
Till Kamppeter [Fri, 2 Sep 2022 23:31:37 +0000 (01:31 +0200)]
libcupsfilters: Renamed cfFilterRasterToPDF() to cfFilterPWGToPDF()
Renamed the filter function cfFilterRasterToPDF() to
cfFilterPWGToPDF() as it actually does not work with CUPS Raster input
but only with PWG Raster input (or URF/Apple Raster).
Also renamed the corresponding CUPS filters to pwgtopdf and pwgtopclm.
Till Kamppeter [Fri, 2 Sep 2022 22:58:48 +0000 (00:58 +0200)]
libcupsfilters: In cfFilterPDFToRaster() Fixed margins of output pages
The PDF rasterizing filter function cfFilterPDFToRaster() which is
based on Poppler and usually only used when Ghostscript is not
available did not get enough testing and produced raster files with
wrong margins.
This commit fixes the problems:
- Apply "MediaClass"/"media-class" option only if final output format
is CUPS Raster or PWG Raster. Let the option do not change any thing
if not present. When switching the format due to this option, also
change the outformat variable.
- Supply a pointer to the outformat to parse_opts(), so that if
parse_opts() changes the outformat the caller gets this change.
- The cfFilterRasterToPCLm() filter function only accepts PWG Raster
as input, not CUPS Raster.
Till Kamppeter [Fri, 2 Sep 2022 11:24:51 +0000 (13:24 +0200)]
libcupsfilters: cfFilterUniversal() supports also Poppler's pdftops now
Added support for Poppler's pdftops instead of Ghostscript for PDF
rendering by the universal filter function cfFilterUniversal().
By conditional compiling either the filter functions to use
Ghostscript or the ones to use pdftops are used. This can be
controlled via ./configure script, by using the "--disable-..."
argument for the unwished PDF renderer. If both PDF renderers are
enabled, Ghostscript is preferred.
If pdftops is used, the cfFilterUniversal() filter function does not
support PostScript input. For this Ghostscript is required.
If both Ghostscript and pdftops are disabled by ./configure arguments,
the "universal" CUPS filter wrapper is not installed, to not use the
then rather crippled cfFilterUniversal() filter function as CUPS
filter.
Till Kamppeter [Thu, 1 Sep 2022 21:58:21 +0000 (23:58 +0200)]
Build system: Improvements for ./configure script
- Make sure that always a valid PDF-to-PostScript renderer is
selected, especially if one or another renderer is disabled, like
"hybrid" ("--with-pdftops=hybrid") does not make sense if Ghostscipt
is disabled ("--disable ghostscript"). In this case the first valid
renderer found will beused.
- In the summary at the end report which PDF-to-PostScript renderer
gets actually used.
- Changed oder of treating the PDF-to-PostScript renderer, so that as
first choice Ghostscript would be taken and as second choice
Poppler's pdftops.
- Generate for each supported PDF renderer a "HAVE_..." macro in
config.h, for easily excluding unnecessary code.
Till Kamppeter [Tue, 30 Aug 2022 18:02:49 +0000 (20:02 +0200)]
libppd: In ppdFilterUniversal() set output data type also if no PPD supplied
Now both cfFilterUniversal() and its PPD file support wrapper
ppdFilterUniversal() are absolutely compatible if no PPD file got
supplied via named extension to the filter data.
Before, if no PPD was supplied and no actual_output_type in the
parameters, the output data type stayed undetermined and the function
errored out not being able to find a filter combination for the
requested conversion.
Now always final_content_type of thef ilter data is used if there is
no actual_output_type specified in the parameters, regardless of
whether we have a PPD file or not.
Till Kamppeter [Mon, 29 Aug 2022 16:13:06 +0000 (18:13 +0200)]
libppd: Improvements on ppdLoadAttributes() PPD-to-printer-IPP-attributes
As this function is for telling filters and drivers how to print a job
on the printer for which the supplied PPD is and NOT for a PPD
retro-fitting Printer Application (or any other PPD-supporting IPP
print server) to answer a get-printer-attributes IPP request several
changes were needed.
- More sophisticated way to find the default resolution. Do not only
look for "*DefaultResolution:" but also the result of a
ppdRasterInterpretPPD() call, what is marked in the "Resolution"
option, "*cupsUrfSupported:", "*cupsPwgRaster...", "*cupsPclm..."
(from PPD generator of libppd).
- To determine the supported output formats take care that in
"*cupsFilter2: ..." lines in the PPD the final output format is the
second word and no the first, as in "*cupsFilter: ..." lines.
- For media-col-ready use the same entry as for media-col-default and
for media-ready use the same entry as for media-default.
- For print-content-optimize-supported, use the 5 standard values, no
just "auto".
- Removed the irrelevant parts about supplies. They produced constant,
device-independent output anyway.
- Removed the document-password-supported attribute.
- When synthesizing a device ID, also create a CMD: field from the
MIME rules in the "*cupsFilter(2): ..." lines.
Till Kamppeter [Sun, 28 Aug 2022 21:49:32 +0000 (23:49 +0200)]
libppd: Corrections for determining resolution in ppdFilterPDFToPS()
If we have a PPD file we use ppdRasterInterpretPPD() to determine the
actual resolution of the current job. Only consider the resolution
invalid if both horizontal and vertical resolution are 100 dpi.
When getting resolution from PPD's "Resolution" option setting or
default resolution, set y resolution to x resolution if we have only
one number ("600dpi").
Till Kamppeter [Sun, 28 Aug 2022 15:55:56 +0000 (17:55 +0200)]
libppd: In ppdLoadAttributes() complete custom page size support
If the user has sent a job on a custom page size, these custom size is
correctly set as default size in the printer IPP attributes derived
from the PPD file, as media-col, with dimensions, margins, and PWG
specifying the size in the units originally used for it.
Also added the custom page size range keywords to the
"media-supported" printer IPP attribute.
Till Kamppeter [Sat, 27 Aug 2022 23:16:02 +0000 (01:16 +0200)]
libcupsfilters: Compare case-insesitively in cfFilterUniversal()
Case-sensitive comparing of MIME types does not make sense, there are
no two MIME types where the names only differ by lower/uppar
case. This way wrongly written MIME types (like application/pclm
instead of application/PCLm) are no problem any more.
Till Kamppeter [Sat, 27 Aug 2022 23:04:32 +0000 (01:04 +0200)]
libppd: In ppdFilterLoadPPD() let PDF filter log pages when output is PS
PostScript output is going through the ppdFilterPSToPS() filter to
insert the PostScript code of the option settings into the PostScript
output data stream. The ppdFilterPSToPS() filter only logs pages if
the PPD is a pure PostScript PPD (without "*cupsFilter(2): ..."
lines). If it is not, the PDF filter has to log. This change lets the
PDF filter log the pages in such a case.
Till Kamppeter [Sat, 27 Aug 2022 20:53:45 +0000 (22:53 +0200)]
libppd: In ppdFilterLoadPPD() correct check for final output type
To determine whether the PDF filter (usually cfFilterPDFToPDF()) has
to do the page logging for CUPS ("PAGE: XX YY" log messages) or the
driver filter, we check the final output type (FINAL_CONTENT_TYPE
environment cariable from CUPS) to see whether a driver filter is
involved which should log the pages by itself.
The code to compare the final output type with the "*cupsFilter(2):
..." lines in the PPD file was broken, which is fixed with this
commit.
Till Kamppeter [Thu, 25 Aug 2022 21:32:36 +0000 (23:32 +0200)]
libfontembed, libcupsfilters, libppd: assert() only if DEBUG is set
A failing assert() makes the whole program crash, a daemon (Printer
Application) crashes when a filter fails on a damaged input file, a
distro-packaged program sends automatic bug reports to the distro,
... Sometimes assert() is really overkill.
But assert() can be useful for debugging, as one gets easily aware
when some values are wrong somewhere (this probably made the
contributors yo cups-filters insert that many assert() calls).
At least, assert() should only be used for debugging, not in
production code.
Therefore we have replaced all assert() calls by the DEBUG_assert()
macro and the macro is set to assert() when the code is compiled with
the DEBUG macro set and to nothing otherwise. For setting this macro
and other debugging macros there are */debug-internal.h files for all
the 3 libraries now.
Also defined functions for DEBUG_printf and DEBUG_puts in
libcupsfilters (cupsfilters/debug.c).
On a compilation with DEBUG set ("CXXFLAGS=-DDEBUG CFLAGS=-DDEBUG
./configure ...") found some build failures and fixed them.
Till Kamppeter [Sat, 20 Aug 2022 20:38:08 +0000 (22:38 +0200)]
libppd: Added NULL checks when "libppd" extension not present
The functions ppdFilterExternalCUPS(), ppdFilterEmitJCL(), and
ppdFilterUniversal() get the PPD file via the "libppd" extension for
the filter data. There was no NULL check when the extension was not
present, without extension there was simply a crash, a hang, or other
unexpected behavior.
This commit adds NULL checks so that if the extension is missing, the
functions simply do what they can do without PPD file, but do not
cause a crash.
Till Kamppeter [Sat, 20 Aug 2022 15:29:37 +0000 (17:29 +0200)]
libppd: Make driverless printing PPDs from CUPS work correctly
If one sets up a driverless printer with CUPS, either manually by the
"-m everywhere" option for "lpadmin" (or equivalent functionality in
the web interface) or automatically when CUPS creates a temporary
queue, the generated PPD file did not work correctly with current
cups-filters.
CUPS' auto-generated PPD files to not contain "*cupsUrfSupported: ..."
or "*cupsPwgRaster..." lines, but instead, add pseudo-PostScript code
(as in PPDs for CUPS Raster drivers) to the "ColorModel" and
"cupsPrintQuality" options.
Therefore the ppdLoadAttributes() function should not create artifical
"urf-supported" or "pwg-raster-..." printer IPP attributes and the
ppdFilterLoadPPD() should instead create a sample Raster header as it
already does for PPDs for CUPS Raster drivers. This way color space,
depth, and resolution get supplied to the filters via the header.
Carlos Nihelton [Tue, 16 Aug 2022 14:47:52 +0000 (11:47 -0300)]
Makefile.am: Move the libppd declarations after cups-filters (#477)
When doing "sudo make install", the re-linking breaks because libppd depends on libcupsfilters (and not vice-versa, as before), not yet installed. Reordering the declarations in the Makefile.am seems to fix the bahavior.
To reproduce the issue try on a minimal Ubuntu environment, such as WSL or cloud images running on LXD or docker:
```
sudo apt install autotools-dev autoconf automake autopoint libavahi-client-dev libavahi-glib-dev libcurl4-gnutls-dev libglib2.0-dev libgnutls28-dev libjpeg-dev libpam0g-dev libpng-dev libusb-1.0-0-dev zlib1g-dev libcups2-dev libcupsimage2-dev libssl-dev libtool libqpdf-dev poppler-utils libfontconfig1-dev libpoppler-cpp-dev libtiff5-dev libdbus-1-dev libexif-dev librsvg2-bin sharutils liblcms2-dev ghostscript pkg-config g++ --no-install-recommends
git clone https://github.com/OpenPrinting/cups-filters
cd cups-filters
./autogen.sh
./configure --prefix=/usr --disable-ldap --disable-foomatic --disable-braille --disable-mutool
make
sudo make install
```
Only the install target should fail to relink the libppd against libcupsfilters due the latter not yet being installed. With this patch the order is corrected which should solve the problem.
Till Kamppeter [Thu, 11 Aug 2022 12:51:35 +0000 (14:51 +0200)]
libcupsfilters, libppd: Separated PPD file support from libcupsfilters
This commit reverses the dependencies of the libcupsfilters and libppd
libraries. Instead of libcupsfilters depending on libppd no libppd
depends on libcupsfilters.
This is important for removing PPD file support from OS distributions
and so allow discontinuing the maintenance of PPD-file-supporting code
in the future. In a later step libppd and the filter executables for
CUPS will get separated from the cups-filters project/repository into
their own projects/repositories.
CUPS will not use PPD files any more from version 3.0.0 on, but go
all-IPP instead. CUPS iteself will only support driverless IPP
printers (IPP Everywhere, AirPrint, Mopria) and no classic printer
drivers which consist of PPD files and filter/backend executables any
more. For printers which still need drivers Printer Applications ar
the new driver format. A Printer Application is a software emulation
of a driverless IPP printer which on the other end talks with the
physical printer.
These modifications introduce several changes on the APIs of
libcupsfilters and libppd. Software depending on these libraries (like
pappl-retrofit) needs to get adapted. All filter executables,
backends, and utilities included in cups-filters got already adapted
with this commit.
The following changes have been done:
- cf_filter_data_t gets support for an array of named extension data
structures and does not support field for the PPD name and data any
more. libppd defines an extension named "libppd" to hold PPD name
and data. Filter functions (of libppd) which explicitly use/support
PPD files access the PPD file through this extension, others simply
ignore the extension if present.
- All filter functions in libcupsfilters drop PPD support completely.
They get printer-specific data only by the printer IPP attributes
and by option settings in the option list of the cf_filter_data_t
structure. The full functionality of each filter function is
conserved.
- Filter functions which process or generate raster data can also get
the parameters for the raster data as a CUPS Raster sample header.
- To continue offering PPD-supporting CUPS filters libppd provides the
ppdLoadAttributes() to convert a PPD file into printer IPP
attributes, the ppdFilterLoadPPD() to convert further PPD attributes
which have no IPP equivalent into option settings and a CUPS Raster
sample header, and the wrapper function ppdFilterCUPSWrapper()
called by the CUPS filter executable, making the mentioned two
functions be called before the filter function itself (in most cases
from libcupsfilters) gets called.
- Filter functions which need PPD file support, especially those which
output PostScript, and also the former cfFilterExternalCUPS() (now
ppdFilterExternalCUPS()) filter function have moved to libppd.
- The support for PostScript output has also been removed. Nowadays it
only serves for printing on PostScript printers (where one usually
also has a PPD file), as document exchange format PostScript got
fully replaced by PDF.
- If PPD file support cannot be added to a filter function by only
extracting the printer's properties from the PPD via printer IPP
attributes and option settings, a wrapper filter function is created
in libppd. This we do for cfFilterUniversal() (to correct the output
format according to "*cupsFilters2: ..." lines in the PPD) and for
cfFilterPDFToPDF()/cfFilterImageToPDF() (to add JCL/PJL commands
from the PPD file for "classic" PDF printers).
- In raster driver support code moved the functions to read parameters
from the PPD file to libppd.
- Moved the PPD file generator used by cups-browsed and by the
driverless utility to libppd.
- Moved the handling of common parameters, like page size, duplex,
backside orientation, color spaces and depths, Raster headers, ...,
by the filter functions into separate functions to not duplicate the
code in each filter function.
- Improved the page size handling, especially accepting all types of
parameter supply (options, job attributes, printer attributes,
Raster headers, handling borderless printing and overspray,
specification of size by dimensions or by name, custom size,
margins, recognition whether user explicitly requested a page size
(if not, use input page size if possible) ...
- Made functions for handling human-readable/translation strings (of
the PPD generator) API functions of libcupsfilters.
Till Kamppeter [Fri, 20 May 2022 14:05:23 +0000 (16:05 +0200)]
libcupsfilters: In the env variables for cfFilterExternalCUPS() use CUPS 2.5.99
Use CUPS version 2.5.99 for the "SOFTWARE" environment variable when
calling CUPS filters or backends via the cfFilterExternalCUPS() filter
function. This is the last CUPS version which supports PPD files and
classic printer drivers.
Till Kamppeter [Fri, 20 May 2022 09:38:40 +0000 (11:38 +0200)]
libcupsfilters: Correct lengths of log message prefixes
In the cfFilterExternalCUPS() filter function we catch the stderr
(log) output of the called CUPS filter and convert it into log
function calls with correct log levels. here we need to compare
exactly the prefix, not more and not less, to safely identify the log
level of each line.
Sachin Thakan [Sat, 14 May 2022 07:12:36 +0000 (12:42 +0530)]
libcupsfilters: Read image resolution from EXIF data of JPEG, PNG, TIFF
If images are printed with "print-scaling=none" one wants to have their original size. To get an original size in absolute dimensions (inches, cm) one needs the pixel count and resolution (dpi, ppi). The resolution is supposed to be in the image's own header but in practice it is often not there.
Images from cameras, and also from some scanners, have additional metadata, the so-called EXIF data which usually contains a resolution. So we read out this with the help of libexif.
In Linux distributions there we usually have libexif and so it is no big effort to let libcupsfilters use it. But it is not required, so for low-resource systems libcupsfilters can be built without (and then not having this feature).
Till Kamppeter [Tue, 12 Apr 2022 08:37:40 +0000 (10:37 +0200)]
libcupsfilters: For ghostscript() require GS 9.56.0
Removed the conditionals for the presence or absemse of the
"appleraster" output device in Ghostscript (version 9.56.0 and
newer). We already require that the "pclm" device is there (GS version
9.55.0 and newer). So we remove the conditionals now and simply
require Ghostscript 9.56.0.
Till Kamppeter [Tue, 12 Apr 2022 08:00:28 +0000 (10:00 +0200)]
libcupsfilters: Added gray PCLm support to ghostscript()
PCLm does not only support 24-bit sRGB bur also 8-bit sGray. All PCLm
printers, regardless of whether they are color or monochrome accept
these two color spaces. Monochrome printers have to convert color into
gray if needed.
Ghhostscript has a grayscale PCLm output device, "pclm8" since version
9.56.0. We now make use of it if the job is monochrome. This also
allows us to supply the cortrecr sGray ICC profile instead of the sRGB
one.
Till Kamppeter [Tue, 12 Apr 2022 07:44:31 +0000 (09:44 +0200)]
libcupsfilters: Let ghostscript() do raster PDF in gray on bw jobs
The ghostscript() filter function did PDF Image (raster PDF) output in
color if the printer is a color printer, in gray only if the printer
is monochrome. Monochrome jobs were therefore printed in color on
color printers. This commit makes grayscale output also used if the
job is monochrome.
Till Kamppeter [Mon, 11 Apr 2022 18:18:15 +0000 (20:18 +0200)]
libcupsfilters: Let ghostscript() output Apple Raster directly
From version 9.56.0 on Ghostscript support direct Apple Raster (URF)
output.
Therefore now we check via ./configure whether the installed
Ghostscript has an "appleraster" output device and if so, we let the
ghostscript() filter function call Ghostscript using this output
device to directly output Apple Raster, so that we do not need to call
the rastertopwg() filter function any more.
In this case an extra MIME conversion rule taking into account the
Apple Raster output from the gstoraster CUPS filter gets installed and
also the universal() filter function gets built to not call the
rastertopwg() filter function after ghostscript() when Apple Raster
output is requested.
Till Kamppeter [Mon, 11 Apr 2022 14:38:55 +0000 (16:38 +0200)]
libfontembed: Renamed files to use "-", not "_", ¨-private.h" for non-API
Renamed all source files so that they do not use "_" but use "-"
instead.
Renamed header files which are not containing public API to
"*-private.h".
Let "make install" also install fontembed/embed-pdf.h as it is
included by the already installed fontembed/embed.h. This is also a
sign that no one has used libfontembed separate from cups-filters.
Till Kamppeter [Mon, 11 Apr 2022 12:12:55 +0000 (14:12 +0200)]
libcupsfilters: Renamed all C++ source files to *.cxx
This commit makes all our C++ source files having the same extension:
".cxx", once to reduce confusion and also as ".cxx" is commonly used
under Linux, macOS, Unix, and Windows, according to DEVELOPING.md
in the CUPS source code.
Till Kamppeter [Mon, 11 Apr 2022 11:25:38 +0000 (13:25 +0200)]
libcupsfilters: Do actual commit for the previous commit message
Normally, GIT does not accept the command "git commit" without
specifying files or "-a" for all modified files. Strangely enough, it
accepts it when files got deleted and then it only commits the
deletions. So the previous commit (f89c3136cb8) only contains the
deletions of the cupsfilters/image-sgi.h and
cupsfilters/image-sgilib.c and not the actual changes.
Till Kamppeter [Mon, 11 Apr 2022 11:12:34 +0000 (13:12 +0200)]
libcupsfilters: Renamed internal functions and data types
Renamed the internal functions and data types according to the rules
of the DEVELOPING.md file of the CUPS source code, to extend this
coding style to cups-filters.
1. Renamed source-file-local functions to all-lowercase with "_"
separators, also declared all these functions static (= valid only
for the same source file) if not yet done so. These functions do
not appear in *.h files.
2. Renamed library-local (non-API, but used in several files of the
library) to camel-case starting with "_cf...".
3. Renamed data types to all-lowercase with "_" separators, ending
with "..._e" for enumerations, "..._s" for structs, and "..._t" for
type definitions.
Also moved the content of the files cupsfilters/image-sgi.h and
cupsfilters/image-sgilib.c into cupsfilters/image-sgi.c and removed
unused code for outputting SGI images, and re-arranged the order of
the functions in the cupsfilters/texttopdf.c source file (to not have
the main function in the middle of the file).
Till Kamppeter [Sun, 10 Apr 2022 08:52:58 +0000 (10:52 +0200)]
libcupsfilters: Silenced warnings about deprecated uint16/uint32
The function to read TIFF image files via libtiff in
cupsfilters/image-tiff.c uses the deprecated types uint16 and
uint32. The replacements for these types are uint16_t and uint32_t.
This commit replaces the types and so silences the compiler warnings.
Till Kamppeter [Fri, 8 Apr 2022 23:32:23 +0000 (01:32 +0200)]
libcupsfilters: Joined cfFilterImageToPS() and cfFilterPSToPS() in one file
cfFilterImageToPS() and cfFilterPSToPS() have some common functions
which were implemented in both the imagetops.c and pstops.c
files. Joined the files into one imagetops-pstops.c file letting the
two filter functions share these functions. Also did some code
clean-up for more consistency.
Till Kamppeter [Fri, 8 Apr 2022 19:34:19 +0000 (21:34 +0200)]
Updated NEWS for new API functions cfFilterLoadPPD()/cfFilterFreePPD()
Added new API function cfFilterLoadPPD() and cfFilterFreePPD() for
easy setup of filter function (chain) calls. Call cfFilterLoadPPD()
when setting up the filter data structure before calling the filter
functions and call cfFilterFreePPD() when done.
Till Kamppeter [Fri, 8 Apr 2022 19:23:26 +0000 (21:23 +0200)]
libcupsfilters: Let filter functions not load or modify PPD file data
Let the filter functions not load the PPD file data and not mark
options in the PPD file data to make them better usable with Printer
Applications and to avoid race conditions in filter chains.
To keep the behavior of CUPS filters, changed the
cfFilterCUPSWrapper() function and the implicitclass CUPS backend
appropriately.
Also added support for direct Apple Raster output to the
cfFilterPDFToRaster() (Poppler) filter function and fixed a bug in the
output format selection in the cfFilterRasterToPWG() filter function.
The files cupsfilters/kmdevices.h and cupsfilters/kmdevices.cpp form
an interface for Kolor Manager, a KDE system settings component for
color management with Oyranos.
Kolor Manager is unmaintained for several years, same for Oyranos. The
kmdevices.* are not included in the build of libcupsfilters, only
shipped for optional use (requires uncommenting a line in
colormanager.c) and no one complained about their non-inclusion in the
build. They even contain a typo which would prevent them from
building. So one can assume that no one cares about them.
Therefore they get removed now, before the cups-filters 2.x release.
Till Kamppeter [Tue, 5 Apr 2022 15:38:43 +0000 (17:38 +0200)]
libcupsfilters: In pdftops() identify old LaserJets more precisely
Old HP LaserJet printers have a firmware bug which makes them not
working with Ghostscript's PostScript output, so in pdftops() we
switch to Poppler for them.
We consider an old LaserJet every "HP LaserJet XXXXY" printer with
XXXX being a number (not preceded by a letter), typically 1-4 digits
and Y being 0-2 letters, no separated from the numbers by a space.
Unfortunately, we checked only whether after "LaserJet" comes a number
and not the rest. This made also modern printers with names like "HP
LaserJet 500 color M551" considered old and these modern printers have
another PostScript interpreter bug which makes them not print some
files with Poppler, so they need Ghostscript's PostScript output.
Therefore we refine the check for the old-LaserJet quirk to see
whether after the number are extra words and if so, this is again a
modern printer and we do not switch to Poppler.
Till Kamppeter [Tue, 5 Apr 2022 15:01:02 +0000 (17:01 +0200)]
libcupsfilters: Updated comment about human-readable strings in PPD Generator
There is a longer comment about how to obtain and handle
human-readable strings and translations in the PPD file generator for
driverless printing, right before the source code of the PPD file
generator.
This comment tells that there are no human-readable strings for the
manual color space and depth choices in the ColorModel option wheras
IPP has only simple bi-level/grayscale/color choices and the exact
color space and depth the filters are supposed to select automatically
according to job and printer.
This part of the comment got already obsolete a few days later when I
made the filters auto-selecting color space and depth via the newly
introduced cupsRasterPrepareHeader() and cupsRasterSetColorSpace()
functions.
Now I discovered this forgotten comment and removed the obsolete part.
Till Kamppeter [Mon, 4 Apr 2022 17:43:18 +0000 (19:43 +0200)]
Build system: Bumped cups-filters version to 2.0b1
Bumped the version number to teh one of our first planned release of
2.x, 2.0b1.
Also changed the version number handling in configure.ac, to allow
both X.Y.Z version numbers and also X.Yb1 or X.Yrc1 version numbers.
Taken this part from PAPPL's configure.ac.
Till Kamppeter [Mon, 4 Apr 2022 17:40:04 +0000 (19:40 +0200)]
libcupsfilters: Bumped soname to 2
The libcupsfilters libraries of cups-filters 2.x and 1.x do not have
compatible APIs any more, not only additions of filter functions but
also changes of function's interfaces for new features like log
functions.
Till Kamppeter [Mon, 4 Apr 2022 13:39:43 +0000 (15:39 +0200)]
libcupsfilters, mupdftoraster, mupdftopwg: Renamed filter function
Renamed the filter function mupdftoraster() and the corresponding CUPS
filter to mupdftopwg(). This is because the "mutool" utility of MuPDF
only supports PWG Raster output, no CUPS Raster and no Apple Raster.
It also does not make the impression that this will change anytime
soon, as this is already this way for many years and there is also no
feature request posted asking for adding the other formats.
This way it is easily communicated that the filter function has to be
followed by the pwgtoraster() filter function to get CUPS Raster.
Note that the "outformat" parameter (the CUPS filter feeds in the
value of the FINAL_CONTENT_TYPE environment variable here) does not
change the actual output format (PWG Raster) of mupdftopwg(), it is
only to tell the final output format of the print job, so that
mupdftopwg() can grab color space, color depth, and resolution info
for this final format from the PPD file (or from the printer IPP
attributes) and call "mutool" according to this format.
Till Kamppeter [Sun, 3 Apr 2022 22:13:00 +0000 (00:13 +0200)]
libcupsfilters: Make pdftopdf() also work correctly with auro-rotating off
If one turns off auto-rotating in the pdftopdf() filter function
(option "nopdfAutoRotate") the orientation of the input page on the
output sheet is manually controlled by the options
"orientation-requested" and "landscape".
The cropping of the pages (with "print-scaling=none") did not work
correctly with auto-rotating turned off. This commit fixes this.
Till Kamppeter [Sun, 3 Apr 2022 17:28:17 +0000 (19:28 +0200)]
libcupsfilters: Make pdftopdf() correctly working with "landscape" option
The "landscape" option rotates the input pages by 90 degrees, in the
direction given by the "*LandscapeOrientation" in the PPD file.
The "orientation-requested" option/IPP attribute rotates the page
according to its value: 3: No rotation; 4: 90 degrees anticlockwise;
5: 90 dgrees clockwise; 6: 180 degrees (upside-down).
After that, at least when not suppressed via "nopdfAutoRotate"
("pdfAutoRotate=false") option, auto-rotation kicks in, rotating the
page by 90 degrees (direction according to "*LandscapeOrientation" in
the PPD file) if the orientations of the input page and the output
page mis-match.
If the output format is not supplied as parameter, ghostscript()
defaults to CUPS Raster now, as the ghostscript CUPS filter already
does.
rastertopwg does not support CUPS Raster output, so we changed the
CUPS filter rastertopwg to default to PWG Raster instead.
The rastertopwg() filter function errors out when NULL is supplied as
parameter. We let it also error out now if an unsupported output
format is supplied.
Till Kamppeter [Mon, 28 Mar 2022 18:00:59 +0000 (20:00 +0200)]
libcupsfilters: rastertopclm() fails if no default resolution given
Some PCLm printers, especially the ones which support only one
resolution in PCLm ("pclm-source-resolution-supported" IPP attribute)
do not have the "pclm-source-resolution-default" IPP attribute. This
broke rastertopclm().
This is fixed now for both direct use of the printer IPP attributes or
use via an auto-generated PPD file. The missing default resolution is
simply filles with the first item of
"pclm-source-resolution-supported" then. If this item is also missing,
we error out on this printer/PPD file.
Till Kamppeter [Mon, 28 Mar 2022 11:04:07 +0000 (13:04 +0200)]
libcupsfilters: Allow mupdftoraster() be used for all raster formats
The mupdftoraster() filter function only produces PWG Raster, due to
the fact that mutool of MuPDF produces PWG Raster but not Apple
Raster, CUPS Raster, or PCLm.
To obtain the other formats one needs post-filtering with pwgtoraster
and rastertopclm. To make this working in the best possible way and to
make it working at all with any PPD file (also those which do not have
information for generating the inbetween PWG Raster format) we have
prepared mupdftoraster appropriately.
Changes done:
- Get final output format via parameters
- Call cupsRasterPrepareHeader() with PWG Raster as header format and
the final output format as final format
- If the final format is not PWG Raster we need post-filtering. In
this case let mutool only generate output with a maximum of 3 color
channels (no CMYK) as the post filters pwgtoraster and rastertopclm
only support 1- or 3-color-channel input.
- Add explicit support for the RGBW color space (#17, used by HPLIP's
hpcups driver).
- On an unknown final output color space default to color instead of
mono output. A post filter can turn color into monochrome but not
vice-versa.
- Let the CUPS filter wrapper read the final output format from the
FINAL_CONTENT_TYPE environment variable. Default to CUPS Raster on
an unknown format, as those formats typically come from CUPS Raster
("rasterto...") drivers.
- Do not pass in the full list of environment variables any more. We
do not manipulate these. Instead we call mutool with execvp() to
simply use the caller's environment instead of execvpe() with a
supplied environment.
- Update the MIME rules: Remove rule telling that mupdftoraster
outputs CUPS Raster, add rules for pwgtoraster, and also rules to
reflect that rastertopclm also accepts Apple Raster or PWG Raster as
input.
Till Kamppeter [Sun, 27 Mar 2022 15:04:29 +0000 (17:04 +0200)]
libcupsfilters: In pdftopdf() fix N-up printing with long-edge-first
If the printer takes the paper long-edge-first and the number-up
option for printing multiple pages per sheet is used, the grid for the
shrinked pages onm the output sheet is set wrongly (number of lines
and number of columns swapped). This commit fixes the this bug.
Till Kamppeter [Sun, 27 Mar 2022 14:51:19 +0000 (16:51 +0200)]
libcupsfilters: In pdftopdf() fix cropping with long-edge-first
If the printer takes the paper long-edge-first (lasers and inkjets
usually take it short-edge first, but roll-fed large-formats or label
printers also take long-edge-first) the cropping of the page image for
crop-to-fit (print-scaling=none) and fill (print-scaling=fill) by the
pdftopdf() filter function did not work correctly. This is fixed now.
Till Kamppeter [Sat, 26 Mar 2022 00:49:20 +0000 (01:49 +0100)]
libcupsfilters: Added PWG/Apple Raster support to pwgtoraster()
The pwgtoraster() filter function is now able to also output PWG
Raster and Apple Raster, for direct conversion between PWG and Apple
Raster without inbetween CUPS Raster step. Also CUPS Raster based on
PCLm info in the PPD or in the printer IPP attributes for feeding into
rastertopclm is supported.
With this we can for example use MuPDF via the mupdftoraster() filter
function which has only PWG Raster output for all driverless printing
formats (Apple Raster, PWG Raster, PCLm) and also for classic CUPS
Raster drivers (CUPS Raster format).
Selection of the ourput format is done via the parameters, like with
the other filter functions.
We also allow the overspray/rounding correction kick in on jobs where
the output page size is not explicitly requested, as rounding errors
can always happen. Page size dimensions in the PPD can easily deviate
from the exact dimensions of the input pages.
Till Kamppeter [Fri, 25 Mar 2022 10:38:11 +0000 (11:38 +0100)]
libcupsfilters: In pwgtoraster() determine input format by ImagingBoundingBox
pwgtoraster() converts PWG or Apple Raster input to CUPS Raster output.
Before, it identified whether the input format is a supported one by
the "PwgRaster" in the MediaClass field of the CUPS Raster header data
structure, which is the case if the input file header contains this
"magic string" or if libcups creates a CUPS Raster Header for an Apple
Raster file it reads. Unfortunately, there are sources of PWG Raster
files omitting to put "PwgRaster" into the MediaClass field (like
MuPDF used in the mupdftoraster() filter function) and so
pwgtoraster() rejects the otherwise correct input as unsupported CUPS
Raster. So we need a new form of identifying PWG Raster.
In contrary to the CUPS Raster format the two supported formats have
no margin definition and contain a bitmap for the whole page including
the unprintable margins. Therefore the supported formats have se the
ImagingBoundingBox field to all-zero, which is illegal in CUPS Raster
as it spans a zero-size printing area. We now make use of this to
identify the input format and simply accept files with all-zero
ImagingBoundingBox and reject others, safely telling apart CUPS Raster
from PWG/Apple Raster.
Now mupdftoraster() and so MuPDF can be used with CUPS Raster drivers.
Till Kamppeter [Thu, 24 Mar 2022 22:47:27 +0000 (23:47 +0100)]
libcupsfilters: In the PPD generator removed check for presence of gstopxl
Generally gstopxl is part of cups-filters as cups-browsed is and so
they usually get installed together. So we remove the check for the
presence of the filter. The check will also not work in many cases,
especially when the program using the PPD generator is not called by
CUPS, for example if the PPD generator is called by cups-browsed (and
not by the driverless utility used by CUPS).
For cups-filters installations without Ghostscript, gstopxl is not
built/installed, for this case we will later add conditionals in the
PPD generator to not build the support for PCL-XL via gstopxl.
Till Kamppeter [Thu, 24 Mar 2022 16:16:15 +0000 (17:16 +0100)]
libcupsfilters: In universal() supply texttopdf parameters in parameters
When the universal() filter function calls the texttopdf() filter
function it grabs the parameters for texttopdf() from the environment
variables which CUPS usually sets. There is no way to supply these
parameters without environment variables (for non-CUPS applications).
With this commit the parameters data structure of universal() is
extended to also contain the parameter data structure of texttopdf()
so that one can supply these parameters on the universal() filter
function call. The environment variables are no checked by the CUPS
wrapper which is used to call universal() as a CUPS filter.
Till Kamppeter [Wed, 23 Mar 2022 19:53:41 +0000 (20:53 +0100)]
libcupsfilters: Added Apple Raster output to pclmtoraster()
The pclmtoraster() filter function outputs CUPS Raster and PWG Raster
using the Raster output functions of libcups. So it is trivial to add
Apple Raster using the appropriate mode in cupsRasterOpen(). We are
doing this now and by a parameter we can select the output format, as
with most other filter functions.
Before, the switching between CUPS Raster and PWG Raster was only
possible via the FINAL_CONTENT_TYPE environment variable which works
for a CUPS filter but not generally for a filter function.
Also switched to use cupsRasterPrepareHeader() instead of
ppdRasterInterpretPPD()/cupsRasterParseIPPOptions().