Comparar commits

..

1 Commits

Autor SHA1 Mensagem Data
msweet ab00dadce7 Import cups.org releases
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/tags/release-1.2rc3@4306 a1ca3aef-8c08-0410-bb20-df032aa958be
2013-05-10 18:56:23 +00:00
139 arquivos alterados com 12166 adições e 18709 exclusões
+1 -46
Ver Arquivo
@@ -1,51 +1,6 @@
CHANGES.txt - 2006-05-08
CHANGES.txt - 2006-04-24
------------------------
CHANGES IN CUPS V1.2.0
- Documentation updates (STR #1618, STR #1620, STR #1622,
STR #1637)
- Static file copy buffers reduced from 64k to 32k to
work around bogus MallocDebug library assumptions (STR
#1660)
- The scheduler did not decode the backend exit code
properly (STR #1648)
- The MacOS X USB backend did not report the 1284 device ID,
nor did it fix device IDs returned by HP printers.
- The scheduler started more slowly than 1.1.x with large
numbers of printers (STR #1653)
- cupsRasterInterpretPPD() didn't support the
cupsPreferredBitsPerColor attribute, and imagetoraster
didn't use the new API.
- The "make test" script did not create all of the necessary
subdirectories for testing (STR #1638)
- The scheduler did not prevent rotation of logs
redirected to /dev/null (STR #1651)
- "make test" did not include the SNMP backend in the
test environment (STR #1625)
- The EPM packaging files did not work (STR #1621)
- "Use Default Configuration" inserted a broken
configuration file (STR #1624)
- Redirects in the web interface did not always preserve
the encrypted status of a connection (STR #1603)
- Added the Apple "pap" backend.
- Added CUPS library to CUPS Image shared library
linkage to support Linux --as-needed linker option
(STR #1606)
- Fixed support for --enable-pie (STR #1609)
- The pdftops filter did not validate the length of the
encryption key (STR #1608)
- Updated the Polish localization.
- "Encryption Required" in the cupsd.conf file now only
requires encryption when the connection is not over the
loopback interface or domain socket.
- Printer names containing "+" were not quoted properly in
the web interface (STR #1600)
- The SNMP backend now reports the make and model in the
information string so that the auto-generated printer
name is more useful than just an IP address.
CHANGES IN CUPS V1.2rc3
- The cups-lpd program always did reverse lookups on the
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
INSTALL - CUPS v1.2.0 - 2006-05-08
----------------------------------
INSTALL - CUPS v1.2rc1 - 2006-03-24
-----------------------------------
This file describes how to compile and install CUPS from source
code. For more information on CUPS see the file called
+1 -2
Ver Arquivo
@@ -130,14 +130,13 @@ DSOLIBS = @DSOLIBS@ $(COMMONLIBS)
IMGLIBS = @IMGLIBS@ -lm
IMGFILTERS = @IMGFILTERS@
LDFLAGS = -L../cups -L../filter $(RC_CFLAGS) $(ARCHFLAGS) \
@LDFLAGS@ @PIEFLAGS@ $(OPTIM)
@LDFLAGS@ $(OPTIM)
LINKCUPS = @LINKCUPS@ $(SSLLIBS)
LINKCUPSIMAGE = @LINKCUPSIMAGE@
LIBS = $(LINKCUPS) $(COMMONLIBS)
OPTIM = @OPTIM@
OPTIONS =
PAMLIBS = @PAMLIBS@
PAP = @PAP@
PDFTOPS = @PDFTOPS@
PHPDIR = @PHPDIR@
SSLFLAGS = @SSLFLAGS@
-19
Ver Arquivo
@@ -57,25 +57,6 @@ clean:
done
#
# Remove all non-distribution files...
#
distclean: clean
$(RM) Makedefs config.h config.log config.status
$(RM) cups-config conf/cupsd.conf conf/pam.std
$(RM) doc/help/standard.html doc/index.html
$(RM) init/cups.sh init/cups-lpd
$(RM) man/cups-deviced.man man/cups-driverd.man
$(RM) man/cups-lpd.man man/cupsaddsmb.man man/cupsd.man
$(RM) man/cupsd.conf.man man/lpoptions.man
$(RM) packaging/cups templates/edit-config.tmpl templates/header.tmpl
-$(RM) doc/*/index.html
-$(RM) templates/*/edit-config.tmpl
-$(RM) templates/*/header.tmpl
-$(RM) -r autom4te*.cache
#
# Make dependencies
#
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
README - CUPS v1.2.0 - 2006-05-08
---------------------------------
README - CUPS v1.2rc1 - 2006-03-24
----------------------------------
Looking for compile instructions? Read the file "INSTALL.txt"
instead...
+2 -11
Ver Arquivo
@@ -27,9 +27,9 @@
include ../Makedefs
RBACKENDS = ipp lpd
UBACKENDS = $(PAP) parallel scsi serial snmp socket usb
UBACKENDS = parallel scsi serial snmp socket usb
TARGETS = betest test1284 $(RBACKENDS) $(UBACKENDS)
OBJS = betest.o ipp.o lpd.o pap.o parallel.o scsi.o \
OBJS = betest.o ipp.o lpd.o parallel.o scsi.o \
serial.o snmp.o socket.o test1284.o usb.o
@@ -136,15 +136,6 @@ lpd: lpd.o ../cups/$(LIBCUPS)
$(CC) $(LDFLAGS) -o lpd lpd.o $(LIBS)
#
# pap
#
pap: pap.o ../cups/$(LIBCUPS)
echo Linking $@...
$(CC) $(LDFLAGS) -o pap pap.o $(BACKLIBS) $(LIBS) -framework AppleTalk
#
# parallel
#
+1 -1
Ver Arquivo
@@ -1215,7 +1215,7 @@ compress_files(int num_files, /* I - Number of files */
*out; /* Output file */
struct stat outinfo; /* Output file information */
char filename[1024], /* Temporary filename */
buffer[32768]; /* Copy buffer */
buffer[65536]; /* Copy buffer */
fprintf(stderr, "DEBUG: Compressing %d job files...\n", num_files);
+1 -1
Ver Arquivo
@@ -590,7 +590,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
#endif /* __APPLE__ */
size_t nbytes; /* Number of bytes written */
off_t tbytes; /* Total bytes written */
char buffer[32768]; /* Output buffer */
char buffer[65536]; /* Output buffer */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
-1568
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+4 -14
Ver Arquivo
@@ -1244,7 +1244,7 @@ fix_make_model(
const char *old_make_model, /* I - Old make-and-model string */
int make_model_size) /* I - Size of new string buffer */
{
char *mmptr; /* Pointer into make-and-model string */
const char *mmptr; /* Pointer into make-and-model string */
/*
@@ -1259,7 +1259,7 @@ fix_make_model(
* with a single HP manufacturer prefix...
*/
mmptr = (char *)old_make_model + 15;
mmptr = old_make_model + 15;
while (isspace(*mmptr & 255))
mmptr ++;
@@ -1292,16 +1292,7 @@ fix_make_model(
* becomes "Tektronix Phaser 560"...
*/
_cups_strcpy(mmptr, mmptr + 7);
}
if ((mmptr = strchr(make_model, ',')) != NULL)
{
/*
* Drop anything after a trailing comma...
*/
*mmptr = '\0';
_cups_strcpy((char *)mmptr, mmptr + 7);
}
}
@@ -1442,10 +1433,9 @@ list_devices(void)
cache;
cache = (snmp_cache_t *)cupsArrayNext(Devices))
if (cache->uri)
printf("network %s \"%s\" \"%s %s\" \"%s\"\n",
printf("network %s \"%s\" \"%s\" \"%s\"\n",
cache->uri,
cache->make_and_model ? cache->make_and_model : "Unknown",
cache->make_and_model ? cache->make_and_model : "Unknown",
cache->addrname, cache->id ? cache->id : "");
}
+2 -14
Ver Arquivo
@@ -228,6 +228,7 @@ static void parse_pserror (char *sockBuffer, int len);
void list_devices()
{
puts("direct usb \"Unknown\" \"USB Printer (usb)\"");
iterate_printers(list_device_callback, NULL);
}
@@ -441,26 +442,14 @@ static Boolean list_device_callback(void *refcon, io_service_t obj)
if (deviceIDString != NULL) {
CFStringRef make = NULL, model = NULL, serial = NULL;
char uristr[1024], makestr[1024], modelstr[1024], serialstr[1024], optionsstr[1024];
char idstr[1024];
copy_deviceinfo(deviceIDString, &make, &model, &serial);
modelstr[0] = '/';
CFStringGetCString(deviceIDString, idstr, sizeof(idstr), kCFStringEncodingUTF8);
CFStringGetCString(make, makestr, sizeof(makestr), kCFStringEncodingUTF8);
CFStringGetCString(model, &modelstr[1], sizeof(modelstr)-1, kCFStringEncodingUTF8);
/*
* Fix common HP 1284 bug...
*/
if (!strcasecmp(makestr, "Hewlett-Packard"))
strcpy(makestr, "HP");
if (!strncasecmp(modelstr + 1, "hp ", 3))
_cups_strcpy(modelstr + 1, modelstr + 4);
optionsstr[0] = '\0';
if (serial != NULL)
{
@@ -475,8 +464,7 @@ static Boolean list_device_callback(void *refcon, io_service_t obj)
httpAssembleURI(HTTP_URI_CODING_ALL, uristr, sizeof(uristr), "usb", NULL, makestr, 0, modelstr);
strncat(uristr, optionsstr, sizeof(uristr));
printf("direct %s \"%s %s\" \"%s %s USB\" \"%s\"\n", uristr, makestr,
&modelstr[1], makestr, &modelstr[1], idstr);
printf("direct %s \"%s %s\" \"%s\"\n", uristr, makestr, &modelstr[1], &modelstr[1]);
release_deviceinfo(&make, &model, &serial);
CFRelease(deviceIDString);
+1 -32
Ver Arquivo
@@ -44,7 +44,6 @@
static void cgi_copy(FILE *out, FILE *in, int element, char term,
int indent);
static void cgi_puts(const char *s, FILE *out);
static void cgi_puturi(const char *s, FILE *out);
/*
@@ -236,7 +235,6 @@ cgi_copy(FILE *out, /* I - Output file */
char outval[1024], /* Formatted output string */
compare[1024]; /* Comparison string */
int result; /* Result of comparison */
int uriencode; /* Encode as URI */
fprintf(stderr, "DEBUG: %*sStarting at file position %ld...\n", indent, "",
@@ -255,13 +253,9 @@ cgi_copy(FILE *out, /* I - Output file */
* Get a variable name...
*/
uriencode = 0;
for (s = name; (ch = getc(in)) != EOF;)
if (strchr("}]<>=! \t\n", ch))
break;
else if (s == name && ch == '%')
uriencode = 1;
else if (s > name && ch == '?')
break;
else if (s < (name + sizeof(name) - 1))
@@ -405,12 +399,7 @@ cgi_copy(FILE *out, /* I - Output file */
*/
if (out)
{
if (uriencode)
cgi_puturi(outptr, out);
else
cgi_puts(outptr, out);
}
cgi_puts(outptr, out);
continue;
}
@@ -648,26 +637,6 @@ cgi_puts(const char *s, /* I - String to output */
}
/*
* 'cgi_puturi()' - Put a URI string to the output file, quoting as needed...
*/
static void
cgi_puturi(const char *s, /* I - String to output */
FILE *out) /* I - Output file */
{
while (*s)
{
if (strchr("%&+ <>#=", *s) || *s & 128)
fprintf(out, "%%%02X", *s & 255);
else
putc(*s, out);
s ++;
}
}
/*
* End of "$Id$".
*/
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-common.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id: cups-common.m4 5354 2006-03-29 20:55:15Z mike $"
dnl
dnl Common configuration stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -265,5 +265,5 @@ AC_SUBST(DEFAULT_IPP_PORT)
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_IPP_PORT,$DEFAULT_IPP_PORT)
dnl
dnl End of "$Id: cups-common.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id: cups-common.m4 5354 2006-03-29 20:55:15Z mike $".
dnl
+5 -13
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-compiler.m4 5473 2006-05-01 15:51:09Z mike $"
dnl "$Id: cups-compiler.m4 5288 2006-03-14 02:38:07Z mike $"
dnl
dnl Compiler stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -73,15 +73,12 @@ AC_SUBST(LIB64DIR)
AC_SUBST(UNINSTALL64)
dnl Position-Independent Executable support on Linux and *BSD...
AC_ARG_ENABLE(pie, [ --enable-pie use GCC -fPIE option, default=no])
AC_ARG_ENABLE(pie, [ --enable-pie use GCC -fpie option, default=no])
dnl Update compiler options...
CXXLIBS=""
AC_SUBST(CXXLIBS)
PIEFLAGS=""
AC_SUBST(PIEFLAGS)
if test -n "$GCC"; then
if test -z "$OPTIM"; then
if test "x$with_optim" = x; then
@@ -99,13 +96,8 @@ if test -n "$GCC"; then
case $uname in
Linux*)
if test x$enable_pie = xyes; then
PIEFLAGS="-pie -fPIE"
fi
;;
*)
if test x$enable_pie = xyes; then
echo "Sorry, --enable-pie is not supported on this OS!"
OPTIM="$OPTIM -fpie"
LDFLAGS="$LDFLAGS -pie"
fi
;;
esac
@@ -475,5 +467,5 @@ if test $uname = HP-UX; then
fi
dnl
dnl End of "$Id: cups-compiler.m4 5473 2006-05-01 15:51:09Z mike $".
dnl End of "$Id: cups-compiler.m4 5288 2006-03-14 02:38:07Z mike $".
dnl
+3 -3
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-defaults.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id$"
dnl
dnl Default cupsd configuration settings for the Common UNIX Printing System
dnl (CUPS).
@@ -219,7 +219,7 @@ AC_DEFINE_UNQUOTED(CUPS_DEFAULT_GROUP, "$CUPS_GROUP")
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_SYSTEM_GROUPS, "$CUPS_SYSTEM_GROUPS")
dnl Default printcap file...
AC_ARG_WITH(printcap, [ --with-printcap set default printcap file],
AC_ARG_WITH(printcap, [ --with-printcap set default printcap file],
default_printcap="$withval",
default_printcap="/etc/printcap")
@@ -236,5 +236,5 @@ fi
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTCAP, "$CUPS_DEFAULT_PRINTCAP")
dnl
dnl End of "$Id: cups-defaults.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id$".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-directories.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id: cups-directories.m4 5314 2006-03-20 19:06:50Z mike $"
dnl
dnl Directory stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -300,5 +300,5 @@ AC_DEFINE_UNQUOTED(CUPS_STATEDIR, "$localstatedir/run/cups")
AC_SUBST(CUPS_STATEDIR)
dnl
dnl End of "$Id: cups-directories.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id: cups-directories.m4 5314 2006-03-20 19:06:50Z mike $".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-image.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id: cups-image.m4 5451 2006-04-22 21:54:49Z mike $"
dnl
dnl Image library/filter stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -110,5 +110,5 @@ AC_SUBST(EXPORT_LIBZ)
AC_CHECK_HEADER(stdlib.h,AC_DEFINE(HAVE_STDLIB_H))
dnl
dnl End of "$Id: cups-image.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id: cups-image.m4 5451 2006-04-22 21:54:49Z mike $".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-launchd.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id$"
dnl
dnl launchd stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -49,5 +49,5 @@ AC_SUBST(DEFAULT_LAUNCHD_CONF)
AC_SUBST(LAUNCHDLIBS)
dnl
dnl End of "$Id: cups-launchd.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id$".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-ldap.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id$"
dnl
dnl LDAP configuration stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -46,5 +46,5 @@ AC_SUBST(LIBLDAP)
dnl
dnl End of "$Id: cups-ldap.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id$".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-libtool.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id: cups-libtool.m4 4494 2005-02-18 02:18:11Z mike $"
dnl
dnl Libtool stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -45,5 +45,5 @@ if test x$LIBTOOL != x; then
fi
dnl
dnl End of "$Id: cups-libtool.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id: cups-libtool.m4 4494 2005-02-18 02:18:11Z mike $".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-manpages.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id: cups-manpages.m4 5099 2006-02-13 02:46:10Z mike $"
dnl
dnl Manpage stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -103,5 +103,5 @@ AC_SUBST(MAN8EXT)
AC_SUBST(MAN8DIR)
dnl
dnl End of "$Id: cups-manpages.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id: cups-manpages.m4 5099 2006-02-13 02:46:10Z mike $".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-network.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id: cups-network.m4 4873 2005-12-07 01:46:54Z mike $"
dnl
dnl Networking stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -85,5 +85,5 @@ AC_SUBST(CUPS_DEFAULT_DOMAINSOCKET)
AC_SUBST(CUPS_LISTEN_DOMAINSOCKET)
dnl
dnl End of "$Id: cups-network.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id: cups-network.m4 4873 2005-12-07 01:46:54Z mike $".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-opsys.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id: cups-opsys.m4 5075 2006-02-05 01:00:29Z mike $"
dnl
dnl Operating system stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -39,5 +39,5 @@ case "$uname" in
esac
dnl
dnl "$Id: cups-opsys.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id: cups-opsys.m4 5075 2006-02-05 01:00:29Z mike $"
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-pam.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id: cups-pam.m4 4913 2006-01-11 01:42:04Z mike $"
dnl
dnl PAM stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -94,5 +94,5 @@ AC_SUBST(PAMLIBS)
AC_SUBST(PAMMOD)
dnl
dnl End of "$Id: cups-pam.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id: cups-pam.m4 4913 2006-01-11 01:42:04Z mike $".
dnl
-37
Ver Arquivo
@@ -1,37 +0,0 @@
dnl
dnl "$Id: cups-pam.m4 5466 2006-04-26 19:52:27Z mike $"
dnl
dnl PAP (AppleTalk) stuff for the Common UNIX Printing System (CUPS).
dnl
dnl Copyright 2006 by Easy Software Products, all rights reserved.
dnl
dnl These coded instructions, statements, and computer programs are the
dnl property of Easy Software Products and are protected by Federal
dnl copyright law. Distribution and use rights are outlined in the file
dnl "LICENSE.txt" which should have been included with this file. If this
dnl file is missing or damaged please contact Easy Software Products
dnl at:
dnl
dnl Attn: CUPS Licensing Information
dnl Easy Software Products
dnl 44141 Airport View Drive, Suite 204
dnl Hollywood, Maryland 20636 USA
dnl
dnl Voice: (301) 373-9600
dnl EMail: cups-info@cups.org
dnl WWW: http://www.cups.org
dnl
# Currently the PAP backend is only supported on MacOS X with the AppleTalk
# SDK installed...
PAP=""
if test $uname = Darwin; then
PAP="pap"
AC_CHECK_HEADER(AppleTalk/at_proto.h)
fi
AC_SUBST(PAP)
dnl
dnl End of "$Id: cups-pam.m4 5466 2006-04-26 19:52:27Z mike $".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-pdf.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id$"
dnl
dnl PDF filter configuration stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -39,5 +39,5 @@ fi
AC_SUBST(PDFTOPS)
dnl
dnl End of "$Id: cups-pdf.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id$".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-scripting.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id: cups-scripting.m4 5176 2006-02-25 18:14:10Z mike $"
dnl
dnl Scripting configuration stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -100,5 +100,5 @@ if test "x$CUPS_PYTHON" != x; then
fi
dnl
dnl End of "$Id: cups-scripting.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id: cups-scripting.m4 5176 2006-02-25 18:14:10Z mike $".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-sharedlibs.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id: cups-sharedlibs.m4 5112 2006-02-16 04:41:59Z mike $"
dnl
dnl Shared library support for the Common UNIX Printing System (CUPS).
dnl
@@ -152,5 +152,5 @@ AC_SUBST(IMGLIBS)
AC_SUBST(EXPORT_LDFLAGS)
dnl
dnl End of "$Id: cups-sharedlibs.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id: cups-sharedlibs.m4 5112 2006-02-16 04:41:59Z mike $".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-slp.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id: cups-openslp.m4 4494 2005-02-18 02:18:11Z mike $"
dnl
dnl OpenSLP configuration stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -44,5 +44,5 @@ AC_SUBST(LIBSLP)
dnl
dnl End of "$Id: cups-slp.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id: cups-openslp.m4 4494 2005-02-18 02:18:11Z mike $".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-ssl.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id: cups-ssl.m4 5457 2006-04-24 15:36:12Z mike $"
dnl
dnl OpenSSL/GNUTLS stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -113,5 +113,5 @@ AC_SUBST(EXPORT_SSLLIBS)
dnl
dnl End of "$Id: cups-ssl.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id: cups-ssl.m4 5457 2006-04-24 15:36:12Z mike $".
dnl
+2 -2
Ver Arquivo
@@ -1,5 +1,5 @@
dnl
dnl "$Id: cups-threads.m4 5466 2006-04-26 19:52:27Z mike $"
dnl "$Id$"
dnl
dnl Threading stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -53,5 +53,5 @@ fi
AC_SUBST(PTHREAD_FLAGS)
dnl
dnl End of "$Id: cups-threads.m4 5466 2006-04-26 19:52:27Z mike $".
dnl End of "$Id$".
dnl
-7
Ver Arquivo
@@ -429,13 +429,6 @@
#undef HAVE_DBUS
/*
* Do we have the AppleTalk/at_proto.h header?
*/
#undef HAVE_APPLETALK_AT_PROTO_H
#endif /* !_CUPS_CONFIG_H_ */
/*
-1
Ver Arquivo
@@ -43,7 +43,6 @@ sinclude(config-scripts/cups-threads.m4)
sinclude(config-scripts/cups-largefile.m4)
sinclude(config-scripts/cups-launchd.m4)
sinclude(config-scripts/cups-defaults.m4)
sinclude(config-scripts/cups-pap.m4)
sinclude(config-scripts/cups-pdf.m4)
sinclude(config-scripts/cups-scripting.m4)
+1 -1
Ver Arquivo
@@ -271,7 +271,7 @@ libcups.2.dylib: $(LIBOBJS)
# libcups_s.a
#
libcups_s.a: $(LIBOBJS) libcups_s.exp
libcups_s.a: $(LIBOBJS)
echo Creating $@...
$(DSO) $(DSOFLAGS) -Wl,-bexport:libcups_s.exp -o libcups_s.o $(LIBOBJS) $(SSLLIBS) $(COMMONLIBS) $(LIBZ) -lm
$(RM) $@
+1 -4
Ver Arquivo
@@ -939,14 +939,11 @@ cups_array_find(cups_array_t *a, /* I - Array */
DEBUG_puts("cups_array_find: linear search");
diff = 1;
diff = 0;
for (current = 0; current < a->num_elements; current ++)
if (a->elements[current] == e)
{
diff = 0;
break;
}
}
/*
+2 -2
Ver Arquivo
@@ -40,7 +40,7 @@
* '_cups_getifaddrs()' - Get a list of network interfaces on the system.
*/
int /* O - 0 on success, -1 on error */
static int /* O - 0 on success, -1 on error */
_cups_getifaddrs(struct ifaddrs **addrs)/* O - List of interfaces */
{
int sock; /* Socket */
@@ -216,7 +216,7 @@ _cups_getifaddrs(struct ifaddrs **addrs)/* O - List of interfaces */
* '_cups_freeifaddrs()' - Free an interface list...
*/
void
static void
_cups_freeifaddrs(struct ifaddrs *addrs)/* I - Interface list to free */
{
struct ifaddrs *next; /* Next interface in list */
+3 -4
Ver Arquivo
@@ -31,8 +31,7 @@
* Include necessary headers...
*/
# include <stdlib.h>
# include <config.h>
# include "config.h"
# ifdef __sun
/*
@@ -166,9 +165,9 @@ struct ifaddrs /**** Interface Structure ****/
void *ifa_data; /* Interface statistics */
};
extern int _cups_getifaddrs(struct ifaddrs **addrs);
static int _cups_getifaddrs(struct ifaddrs **addrs);
# define getifaddrs _cups_getifaddrs
extern void _cups_freeifaddrs(struct ifaddrs *addrs);
static void _cups_freeifaddrs(struct ifaddrs *addrs);
# define freeifaddrs _cups_freeifaddrs
# endif /* HAVE_GETIFADDRS */
+1 -2
Ver Arquivo
@@ -6,6 +6,7 @@ _cupsCharmapGet
_cupsEncodingName
_cupsGetPassword
_cupsGlobals
_cupsLangFlush
_cupsLangPrintf
_cupsLangPuts
_cupsLangString
@@ -22,8 +23,6 @@ _cupsStrFormatd
_cupsStrFree
_cupsStrScand
_cupsStrStatistics
_cups_getifaddrs
_cups_freeifaddrs
_cups_strcpy
_cups_strlcat
_cups_strlcpy
+1 -1
Ver Arquivo
@@ -69,7 +69,7 @@ cupsDoFileRequest(http_t *http, /* I - HTTP connection to server */
FILE *file; /* File to send */
struct stat fileinfo; /* File information */
int bytes; /* Number of bytes read/written */
char buffer[32768]; /* Output buffer */
char buffer[65536]; /* Output buffer */
DEBUG_printf(("cupsDoFileRequest(%p, %p, \'%s\', \'%s\')\n",
+2 -3
Ver Arquivo
@@ -31,14 +31,13 @@
* Include necessary headers...
*/
# include <config.h>
# include <stdio.h>
# include <stdlib.h>
# include <stdarg.h>
# include <ctype.h>
# include <locale.h>
# include <config.h>
# ifdef HAVE_STRING_H
# include <string.h>
# endif /* HAVE_STRING_H */
+37 -81
Ver Arquivo
@@ -78,95 +78,51 @@ main(int argc, /* I - Number of command-line arguments */
status = 0;
if (argc == 1)
{
fputs("ppdOpenFile: ", stdout);
fputs("ppdOpenFile: ", stdout);
if ((ppd = ppdOpenFile("test.ppd")) != NULL)
puts("PASS");
else
{
ppd_status_t err; /* Last error in file */
int line; /* Line number in file */
status ++;
err = ppdLastError(&line);
printf("FAIL (%s on line %d)\n", ppdErrorString(err), line);
}
fputs("ppdMarkDefaults: ", stdout);
ppdMarkDefaults(ppd);
if ((conflicts = ppdConflicts(ppd)) == 0)
puts("PASS");
else
{
status ++;
printf("FAIL (%d conflicts)\n", conflicts);
}
fputs("ppdEmitString: ", stdout);
if ((s = ppdEmitString(ppd, PPD_ORDER_ANY, 0.0)) != NULL &&
!strcmp(s, default_code))
puts("PASS");
else
{
printf("FAIL (%d bytes instead of %d)\n", s ? (int)strlen(s) : 0,
(int)strlen(default_code));
if (s)
puts(s);
}
if (s)
free(s);
ppdClose(ppd);
}
if ((ppd = ppdOpenFile("test.ppd")) != NULL)
puts("PASS");
else
{
if ((ppd = ppdOpenFile(argv[1])) == NULL)
{
ppd_status_t err; /* Last error in file */
int line; /* Line number in file */
ppd_status_t err; /* Last error in file */
int line; /* Line number in file */
status ++;
err = ppdLastError(&line);
status ++;
err = ppdLastError(&line);
printf("%s: %s on line %d\n", argv[1], ppdErrorString(err), line);
}
else
{
int i, j, k; /* Looping vars */
ppd_group_t *group; /* Option group */
ppd_option_t *option; /* Option */
ppdLocalize(ppd);
for (i = ppd->num_groups, group = ppd->groups;
i > 0;
i --, group ++)
{
printf("%s (%s):\n", group->name, group->text);
for (j = group->num_options, option = group->options;
j > 0;
j --, option ++)
{
printf(" %s (%s):\n", option->keyword, option->text);
for (k = 0; k < option->num_choices; k ++)
printf(" - %s (%s)\n", option->choices[k].choice,
option->choices[k].text);
}
}
}
printf("FAIL (%s on line %d)\n", ppdErrorString(err), line);
}
fputs("ppdMarkDefaults: ", stdout);
ppdMarkDefaults(ppd);
if ((conflicts = ppdConflicts(ppd)) == 0)
puts("PASS");
else
{
status ++;
printf("FAIL (%d conflicts)\n", conflicts);
}
fputs("ppdEmitString: ", stdout);
if ((s = ppdEmitString(ppd, PPD_ORDER_ANY, 0.0)) != NULL &&
!strcmp(s, default_code))
puts("PASS");
else
{
printf("FAIL (%d bytes instead of %d)\n", s ? (int)strlen(s) : 0,
(int)strlen(default_code));
if (s)
puts(s);
}
if (s)
free(s);
ppdClose(ppd);
return (status);
}
+1
Ver Arquivo
@@ -167,6 +167,7 @@ HELPFILES = \
help/spec-command.html \
help/spec-design.html \
help/spec-ipp.html \
help/spec-postscript.html \
help/spec-ppd.html \
help/spec-raster.html \
help/spec-stp.html \
-38
Ver Arquivo
@@ -929,22 +929,6 @@ policy to use for IPP operation. The default is
<CODE>default</CODE>.</P>
<H2 CLASS="title"><SPAN CLASS="info">CUPS 1.2</SPAN><A NAME="DefaultShared">DefaultShared</A></H2>
<H3>Examples</H3>
<PRE CLASS="command">
DefaultShared yes
DefaultShared no
</PRE>
<H3>Description</H3>
<P>The <CODE>DefaultShared</CODE> directive specifies whether
printers are shared (published) by default. The default is
<CODE>yes</CODE>.</P>
<H2 CLASS="title"><A NAME="Deny">Deny</A></H2>
<H3>Examples</H3>
@@ -2683,28 +2667,6 @@ to wait before an active HTTP or IPP request times out. The
default timeout is 300 seconds.</P>
<H2 CLASS="title"><SPAN CLASS="info">CUPS 1.2</SPAN><A NAME="UseNetworkDefault">UseNetworkDefault</A></H2>
<H3>Examples</H3>
<PRE CLASS="command">
UseNetworkDefault yes
UseNetworkDefault no
</PRE>
<H3>Description</H3>
<P>The <CODE>UseNetworkDefault</CODE> directive controls whether
the client will use a network/remote printer as a default
printer. If enabled, the default printer of a server is used as
the default printer on a client. When multiple servers are
advertising a default printer, the client's default printer is
set to the first discovered printer, or to the implicit class for
the same printer available from multiple servers.</P>
<P>The default is <CODE>yes</CODE>.</P>
<H2 CLASS="title"><A NAME="User">User</A></H2>
<H3>Examples</H3>
+120
Ver Arquivo
@@ -0,0 +1,120 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<!-- SECTION: Specifications -->
<head>
<title>Generating PostScript for CUPS</title>
<meta name='keywords' content='Programming, PostScript, Document Structuring Conventions'>
<link rel='stylesheet' type='text/css' href='../cups.css'>
</head>
<body>
<!--
"$Id$"
CUPS PostScript file specification for the Common UNIX Printing System (CUPS).
Copyright 2006 by Easy Software Products.
These coded instructions, statements, and computer programs are the
property of Easy Software Products and are protected by Federal
copyright law. Distribution and use rights are outlined in the file
"LICENSE.txt" which should have been included with this file. If this
file is missing or damaged please contact Easy Software Products
at:
Attn: CUPS Licensing Information
Easy Software Products
44141 Airport View Drive, Suite 204
Hollywood, Maryland 20636 USA
Voice: (301) 373-9600
EMail: cups-info@cups.org
WWW: http://www.cups.org
-->
<h2 class='title'><a name='INTRODUCTION'>Introduction</a></h2>
<p>This document describes how to generate PostScript output for
CUPS and is largely based on the <a
href="http://partners.adobe.com/public/developer/en/ps/5001.DSC_Spec.pdf">
Adobe TechNote #5001: PostScript Language Document Structuring
Conventions Specification Version 3.0</a>. While CUPS can
generally print any PostScript file, following the rules in the
Adobe TechNote and this document will ensure that your PostScript
output will work reliably.</p>
<blockquote><b>Note:</b> While PostScript is currently the
defacto-standard print job file format/language for UNIX-based
applications, it is slowly being phased out in favor of Adobe's
Portable Document Format ("PDF") which offers many advantages
over PostScript. MacOS X uses PDF as the primary print job file
format, and we expect Linux to soon follow. Both PostScript and
PDF are complex formats, and we highly recommend using high-level
toolkits whenever possible.</blockquote>
<h3>Anatomy of a PostScript File</h3>
<p>PostScript files are ASCII text files starting with a header
line (<tt>%!PS-Adobe-3.0</tt>) followed by a combination of
comment lines starting with two percent signs (<tt>%%</tt>) and
PostScript code lines. The lines themselves should not exceed 255
characters to conform to the DSC. The following short PostScript
file produces a box with a smiley face in it:</p>
<pre class="command">
%!PS-Adobe-3.0
%%BoundingBox: 36 36 576 756
%%Pages: 1
%%LanguageLevel: 2
%%EndComments
%%Page: (1) 1
% Draw a black box around the page
0 setgray
1 setlinewidth
36 36 540 720 rectstroke
% Draw a two inch blue circle in the middle of the page
0 0 1 setrgbcolor
306 396 144 0 360 arc closepath fill
% Draw two half inch yellow circles for eyes
1 1 0 setrgbcolor
252 432 36 0 360 arc closepath fill
360 432 36 0 360 arc closepath fill
% Draw the smile
1 setlinecap
18 setlinewidth
306 396 99 200 340 arc stroke
% Print it!
showpage
%%EOF
</pre>
<div class="figure"><table summary="Sample PostScript File Output">
<caption>Figure 1: <a name="FIGURE_1">Sample PostScript File Output</a></caption>
<tr><td align="center"><img src="../images/smiley.jpg"
width="445" height="570" alt="Sample PostScript File Output"></td></tr>
</table></div>
<h2>Embedding Printer Options</h2>
<h2>Embedding Fonts and Text</h2>
<h2>Embedding Images</h2>
<blockquote><b>Note:</b> While some printers support arbitrary
binary data in PostScript files, we do not recommend this
practice because it does not work with all printers or
interfaces. In most cases, the Base-85 encoding and compression
filters can be used to embed images with very little, if any,
increase in data size.</blockquote>
</body>
</html>
+10 -7
Ver Arquivo
@@ -8,7 +8,7 @@
</head>
<body>
<!--
"$Id: spec-ppd.html 5496 2006-05-05 19:26:23Z mike $"
"$Id: spec-ppd.html 5217 2006-03-02 21:24:01Z mike $"
CUPS PPD extensions specification for the Common UNIX Printing System (CUPS).
@@ -473,20 +473,23 @@ is not absolute, it is loaded relative to the
<h4>Customizing the Profile Selection Keywords</h4>
<p>The <tt>MediaType</tt> and <tt>Resolution</tt> keywords can be
reassigned to different main keywords, allowing drivers to do
color profile selection based on different parameters. The
<tt>cupsICCQualifier2</tt> and <tt>cupsICCQualifier3</tt>
<p>The <tt>ColorModel</tt>, <tt>MediaType</tt>, and
<tt>Resolution</tt> keywords can be reassigned to different main
keywords, allowing drivers to do color profile selection based
on different parameters. The <tt>cupsICCQualifier1</tt>,
<tt>cupsICCQualifier2</tt>, and <tt>cupsICCQualifier3</tt>
attributes define the mapping from selector to main keyword:</p>
<pre class='command'>
*cupsICCQualifier2: MainKeyword2
*cupsICCQualifier3: MainKeyword3
*cupsICCQualifier1: MainKeyword
*cupsICCQualifier2: MainKeyword
*cupsICCQualifier3: MainKeyword
</pre>
<p>The default mapping is as follows:</p>
<pre class='command'>
*cupsICCQualifier1: ColorModel
*cupsICCQualifier2: MediaType
*cupsICCQualifier3: Resolution
</pre>
+10 -13
Ver Arquivo
@@ -31,14 +31,11 @@ HREF="overview.html">"Overview of CUPS"</A> document instead.</P>
SSL-encrypted, and TLS-encrypted connections over
a single port</LI>
<LI><EM>Network Printer Discovery;</EM> CUPS can
now find printers on the LAN using SNMP</LI>
</OL></DD>
<DT>Browsing</DT>
<DD><OL START="5">
<DD><OL START="4">
<LI><EM>LDAP Support;</EM> CUPS now supports
printer sharing via the Lightweight Directory
@@ -79,7 +76,7 @@ HREF="overview.html">"Overview of CUPS"</A> document instead.</P>
<DT>Web Interface</DT>
<DD><OL START="12">
<DD><OL START="11">
<LI><EM>Improved Look and Feel;</EM> The web
interface has improved readability and a more
@@ -172,7 +169,7 @@ HREF="overview.html">"Overview of CUPS"</A> document instead.</P>
<DT>IPP Support</DT>
<DD><OL START="31"></EM></LI>
<DD><OL START="30"></EM></LI>
<LI><EM>IPP Notifications;</EM> CUPS now supports
the complete IPP notification specification to
@@ -272,7 +269,7 @@ HREF="overview.html">"Overview of CUPS"</A> document instead.</P>
<DT>Scheduler</DT>
<DD><OL START="49">
<DD><OL START="48">
<LI><EM>Remote Printer Caching;</EM> The scheduler
now maintains a remote printer cache so that
@@ -379,7 +376,7 @@ HREF="overview.html">"Overview of CUPS"</A> document instead.</P>
<DT>LPD Client Support</DT>
<DD><OL START="69">
<DD><OL START="68">
<LI><EM>Performance Improvements;</EM> CUPS no
longer loads every available printer before
@@ -396,7 +393,7 @@ HREF="overview.html">"Overview of CUPS"</A> document instead.</P>
<DT>Localization and Internationalization</DT>
<DD><OL START="72">
<DD><OL START="71">
<LI><EM>Command-Line Programs;</EM> All
command-line programs are now fully
@@ -414,7 +411,7 @@ HREF="overview.html">"Overview of CUPS"</A> document instead.</P>
<DT>Printer Drivers</DT>
<DD><OL START="75">
<DD><OL START="74">
<LI><EM>New Drivers;</EM> CUPS 1.2 adds Zebra
CPCL and EPL label printer drivers</LI>
@@ -449,7 +446,7 @@ HREF="overview.html">"Overview of CUPS"</A> document instead.</P>
<DT>CUPS API</DT>
<DD><OL START="82">
<DD><OL START="81">
<LI><EM>Thread Safety;</EM> All of the CUPS API
is now thread-safe on systems that support POSIX
@@ -506,7 +503,7 @@ HREF="overview.html">"Overview of CUPS"</A> document instead.</P>
<DT>CUPS Imaging API</DT>
<DD><OL START="92">
<DD><OL START="91">
<LI><EM>Image API;</EM> The new image API
provides access to image files of arbitrary size
@@ -522,7 +519,7 @@ HREF="overview.html">"Overview of CUPS"</A> document instead.</P>
</OL></DD>
<DT>Scripting Support</DT>
<DD><OL START="94">
<DD><OL START="93">
<LI><EM>PHP Bindings;</EM> The PHP language
bindings have been revamped to be more consistent
Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 579 B

Depois

Largura:  |  Altura:  |  Tamanho: 638 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 544 B

Depois

Largura:  |  Altura:  |  Tamanho: 475 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 606 B

Depois

Largura:  |  Altura:  |  Tamanho: 490 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 613 B

Depois

Largura:  |  Altura:  |  Tamanho: 702 B

+4 -8
Ver Arquivo
@@ -205,8 +205,7 @@ hpgltops: $(HPGLOBJS) common.o ../cups/$(LIBCUPS)
libcupsimage.so.2 libcupsimage.sl.2: $(IMAGEOBJS)
echo Linking $@...
$(DSO) $(ARCHFLAGS) $(DSOFLAGS) -o $@ $(IMAGEOBJS) $(DSOLIBS) \
-L../cups $(LINKCUPS) -lm
$(DSO) $(ARCHFLAGS) $(DSOFLAGS) -o $@ $(IMAGEOBJS) $(DSOLIBS) -lm
$(RM) `basename $@ .2`
$(LN) $@ `basename $@ .2`
@@ -217,8 +216,7 @@ libcupsimage.so.2 libcupsimage.sl.2: $(IMAGEOBJS)
libcupsimage.32.so.2: $(IMAGE32OBJS)
echo Linking 32-bit $@...
$(DSO) $(ARCH32FLAGS) $(DSOFLAGS) -o $@ $(IMAGE32OBJS) $(DSOLIBS) \
-L../cups $(LINKCUPS) -lm
$(DSO) $(ARCH32FLAGS) $(DSOFLAGS) -o $@ $(IMAGE32OBJS) $(DSOLIBS) -lm
#
@@ -227,8 +225,7 @@ libcupsimage.32.so.2: $(IMAGE32OBJS)
libcupsimage.64.so.2: $(IMAGE64OBJS)
echo Linking 64-bit $@...
$(DSO) $(ARCH64FLAGS) $(DSOFLAGS) -o $@ $(IMAGE64OBJS) $(DSOLIBS) \
-L../cups $(LINKCUPS) -lm
$(DSO) $(ARCH64FLAGS) $(DSOFLAGS) -o $@ $(IMAGE64OBJS) $(DSOLIBS) -lm
#
@@ -250,7 +247,7 @@ libcupsimage.2.dylib: $(IMAGEOBJS)
# libcupsimage_s.a
#
libcupsimage_s.a: $(IMAGEOBJS) libcupsimage_s.exp
libcupsimage_s.a: $(IMAGEOBJS)
echo Linking $@...
$(DSO) $(DSOFLAGS) -Wl,-berok,-bexport:libcupsimage_s.exp \
-o libcupsimage_s.o $(IMAGEOBJS) $(DSOLIBS) -lm
@@ -265,7 +262,6 @@ libcupsimage_s.a: $(IMAGEOBJS) libcupsimage_s.exp
libcupsimage.la: $(IMAGEOBJS)
echo Linking $@...
$(DSO) $(ARCHFLAGS) $(DSOFLAGS) -o $@ $(IMAGEOBJS:.o=.lo) $(DSOLIBS) \
-L../cups $(LINKCUPS) \
-rpath $(LIBDIR) -version-info 2:2
+366 -144
Ver Arquivo
@@ -26,6 +26,8 @@
* Contents:
*
* main() - Main entry...
* exec_code() - Execute PostScript setpagedevice commands as
* appropriate.
* format_CMY() - Convert image data to CMY.
* format_CMYK() - Convert image data to CMYK.
* format_K() - Convert image data to black.
@@ -36,7 +38,6 @@
* format_YMC() - Convert image data to YMC.
* format_YMCK() - Convert image data to YMCK.
* make_lut() - Make a lookup table given gamma and brightness values.
* raster_cb() - Validate the page header.
*/
/*
@@ -171,6 +172,7 @@ int Planes[] = /* Number of planes for each colorspace */
* Local functions...
*/
static void exec_code(cups_page_header2_t *header, const char *code);
static void format_CMY(cups_page_header2_t *header, unsigned char *row, int y, int z, int xsize, int ysize, int yerr0, int yerr1, cups_ib_t *r0, cups_ib_t *r1);
static void format_CMYK(cups_page_header2_t *header, unsigned char *row, int y, int z, int xsize, int ysize, int yerr0, int yerr1, cups_ib_t *r0, cups_ib_t *r1);
static void format_K(cups_page_header2_t *header, unsigned char *row, int y, int z, int xsize, int ysize, int yerr0, int yerr1, cups_ib_t *r0, cups_ib_t *r1);
@@ -182,7 +184,6 @@ static void format_W(cups_page_header2_t *header, unsigned char *row, int y, int
static void format_YMC(cups_page_header2_t *header, unsigned char *row, int y, int z, int xsize, int ysize, int yerr0, int yerr1, cups_ib_t *r0, cups_ib_t *r1);
static void format_YMCK(cups_page_header2_t *header, unsigned char *row, int y, int z, int xsize, int ysize, int yerr0, int yerr1, cups_ib_t *r0, cups_ib_t *r1);
static void make_lut(cups_ib_t *, int, float, float);
static int raster_cb(cups_page_header2_t *header, int preferred_bits);
/*
@@ -211,10 +212,12 @@ main(int argc, /* I - Number of command-line arguments */
xtemp, /* Bitmap width in pixels */
ytemp, /* Bitmap height in pixels */
page; /* Current page number */
int xc0, yc0, /* Corners of the page in image coords */
int xc0, yc0, /* Corners of the page in image coords */
xc1, yc1;
ppd_file_t *ppd; /* PPD file */
ppd_choice_t *choice; /* PPD option choice */
ppd_choice_t *choice, /* PPD option choice */
**choices; /* List of marked choices */
int count; /* Number of marked choices */
char *resolution, /* Output resolution */
*media_type; /* Media type */
ppd_profile_t *profile; /* Color profile */
@@ -503,11 +506,31 @@ main(int argc, /* I - Number of command-line arguments */
* Set the needed options in the page header...
*/
if (cupsRasterInterpretPPD(&header, ppd, num_options, options, raster_cb))
{
fputs("ERROR: Bad page setup!\n", stderr);
return (1);
}
memset(&header, 0, sizeof(header));
header.HWResolution[0] = 100;
header.HWResolution[1] = 100;
header.cupsBitsPerColor = 1;
header.cupsColorOrder = CUPS_ORDER_CHUNKED;
header.cupsColorSpace = CUPS_CSPACE_K;
if (ppd && ppd->patches)
exec_code(&header, ppd->patches);
if ((count = ppdCollect(ppd, PPD_ORDER_DOCUMENT, &choices)) > 0)
for (i = 0; i < count; i ++)
exec_code(&header, choices[i]->code);
if ((count = ppdCollect(ppd, PPD_ORDER_ANY, &choices)) > 0)
for (i = 0; i < count; i ++)
exec_code(&header, choices[i]->code);
if ((count = ppdCollect(ppd, PPD_ORDER_PROLOG, &choices)) > 0)
for (i = 0; i < count; i ++)
exec_code(&header, choices[i]->code);
if ((count = ppdCollect(ppd, PPD_ORDER_PAGE, &choices)) > 0)
for (i = 0; i < count; i ++)
exec_code(&header, choices[i]->code);
/*
* Get the media type and resolution that have been chosen...
@@ -532,6 +555,7 @@ main(int argc, /* I - Number of command-line arguments */
case CUPS_CSPACE_W :
primary = CUPS_IMAGE_WHITE;
secondary = CUPS_IMAGE_WHITE;
header.cupsBitsPerPixel = header.cupsBitsPerColor;
break;
default :
@@ -540,6 +564,25 @@ main(int argc, /* I - Number of command-line arguments */
case CUPS_CSPACE_RGBW :
primary = CUPS_IMAGE_RGB;
secondary = CUPS_IMAGE_RGB;
/*
* Ensure that colorimetric colorspaces use at least 8 bits per
* component...
*/
if (header.cupsColorSpace >= CUPS_CSPACE_CIEXYZ &&
header.cupsBitsPerColor < 8)
header.cupsBitsPerColor = 8;
if (header.cupsColorOrder == CUPS_ORDER_CHUNKED)
{
if (header.cupsBitsPerColor >= 8)
header.cupsBitsPerPixel = header.cupsBitsPerColor * 3;
else
header.cupsBitsPerPixel = header.cupsBitsPerColor * 4;
}
else
header.cupsBitsPerPixel = header.cupsBitsPerColor;
break;
case CUPS_CSPACE_K :
@@ -548,6 +591,7 @@ main(int argc, /* I - Number of command-line arguments */
case CUPS_CSPACE_SILVER :
primary = CUPS_IMAGE_BLACK;
secondary = CUPS_IMAGE_BLACK;
header.cupsBitsPerPixel = header.cupsBitsPerColor;
break;
case CUPS_CSPACE_CMYK :
@@ -557,12 +601,27 @@ main(int argc, /* I - Number of command-line arguments */
case CUPS_CSPACE_GMCS :
primary = CUPS_IMAGE_CMYK;
secondary = CUPS_IMAGE_CMYK;
if (header.cupsColorOrder == CUPS_ORDER_CHUNKED)
header.cupsBitsPerPixel = header.cupsBitsPerColor * 4;
else
header.cupsBitsPerPixel = header.cupsBitsPerColor;
break;
case CUPS_CSPACE_CMY :
case CUPS_CSPACE_YMC :
primary = CUPS_IMAGE_CMY;
secondary = CUPS_IMAGE_CMY;
if (header.cupsColorOrder == CUPS_ORDER_CHUNKED)
{
if (header.cupsBitsPerColor >= 8)
header.cupsBitsPerPixel = 24;
else
header.cupsBitsPerPixel = header.cupsBitsPerColor * 4;
}
else
header.cupsBitsPerPixel = header.cupsBitsPerColor;
break;
case CUPS_CSPACE_KCMYcm :
@@ -570,11 +629,21 @@ main(int argc, /* I - Number of command-line arguments */
{
primary = CUPS_IMAGE_CMY;
secondary = CUPS_IMAGE_CMY;
if (header.cupsColorOrder == CUPS_ORDER_CHUNKED)
header.cupsBitsPerPixel = 8;
else
header.cupsBitsPerPixel = 1;
}
else
{
primary = CUPS_IMAGE_CMYK;
secondary = CUPS_IMAGE_CMYK;
if (header.cupsColorOrder == CUPS_ORDER_CHUNKED)
header.cupsBitsPerPixel = header.cupsBitsPerColor * 4;
else
header.cupsBitsPerPixel = header.cupsBitsPerColor;
}
break;
}
@@ -1397,6 +1466,184 @@ main(int argc, /* I - Number of command-line arguments */
}
/*
* 'exec_code()' - Execute PostScript setpagedevice commands as appropriate.
*/
static void
exec_code(cups_page_header2_t *header, /* I - Page header */
const char *code) /* I - Option choice to execute */
{
char *ptr, /* Pointer into name/value string */
name[255], /* Name of pagedevice entry */
value[1024]; /* Value of pagedevice entry */
for (; *code != '\0';)
{
/*
* Search for the start of a dictionary name...
*/
while (*code != '/' && *code != '\0')
code ++;
if (*code == '\0')
break;
/*
* Get the name...
*/
code ++;
for (ptr = name; isalnum(*code & 255) && (ptr - name) < (sizeof(name) - 1);)
*ptr++ = *code++;
*ptr = '\0';
/*
* The parse the value as needed...
*/
while (isspace(*code & 255))
code ++;
if (*code == '\0')
break;
if (*code == '[')
{
/*
* Read array of values...
*/
code ++;
for (ptr = value;
*code != ']' && *code != '\0' &&
(ptr - value) < (sizeof(value) - 1);)
*ptr++ = *code++;
*ptr = '\0';
}
else if (*code == '(')
{
/*
* Read string value...
*/
code ++;
for (ptr = value;
*code != ')' && *code != '\0' &&
(ptr - value) < (sizeof(value) - 1);)
if (*code == '\\')
{
code ++;
if (isdigit(*code & 255))
*ptr++ = (char)strtol(code, (char **)&code, 8);
else
*ptr++ = *code++;
}
else
*ptr++ = *code++;
*ptr = '\0';
}
else if (isdigit(*code & 255) || *code == '-')
{
/*
* Read single number...
*/
for (ptr = value;
(isdigit(*code & 255) || *code == '-') &&
(ptr - value) < (sizeof(value) - 1);)
*ptr++ = *code++;
*ptr = '\0';
}
else
{
/*
* Read a single name...
*/
for (ptr = value;
(isalnum(*code & 255) || *code == '_') &&
(ptr - value) < (sizeof(value) - 1);)
*ptr++ = *code++;
*ptr = '\0';
}
/*
* Assign the value as needed...
*/
if (!strcmp(name, "MediaClass"))
strlcpy(header->MediaClass, value, sizeof(header->MediaClass));
else if (!strcmp(name, "MediaColor"))
strlcpy(header->MediaColor, value, sizeof(header->MediaColor));
else if (!strcmp(name, "MediaType"))
strlcpy(header->MediaType, value, sizeof(header->MediaType));
else if (!strcmp(name, "OutputType"))
strlcpy(header->OutputType, value, sizeof(header->OutputType));
else if (!strcmp(name, "AdvanceDistance"))
header->AdvanceDistance = atoi(value);
else if (!strcmp(name, "AdvanceMedia"))
header->AdvanceMedia = atoi(value);
else if (!strcmp(name, "Collate"))
header->Collate = !strcmp(value, "true");
else if (!strcmp(name, "CutMedia"))
header->CutMedia = (cups_cut_t)atoi(value);
else if (!strcmp(name, "Duplex"))
header->Duplex = !strcmp(value, "true");
else if (!strcmp(name, "HWResolution"))
sscanf(value, "%d%d", header->HWResolution + 0, header->HWResolution + 1);
else if (!strcmp(name, "InsertSheet"))
header->InsertSheet = !strcmp(value, "true");
else if (!strcmp(name, "Jog"))
header->Jog = atoi(value);
else if (!strcmp(name, "LeadingEdge"))
header->LeadingEdge = atoi(value);
else if (!strcmp(name, "Margins"))
sscanf(value, "%d%d", header->Margins + 0, header->Margins + 1);
else if (!strcmp(name, "ManualFeed"))
header->ManualFeed = !strcmp(value, "true");
else if (!strcmp(name, "cupsMediaPosition") || /* Compatibility */
!strcmp(name, "MediaPosition"))
header->MediaPosition = atoi(value);
else if (!strcmp(name, "MediaWeight"))
header->MediaWeight = atoi(value);
else if (!strcmp(name, "MirrorPrint"))
header->MirrorPrint = !strcmp(value, "true");
else if (!strcmp(name, "NegativePrint"))
header->NegativePrint = !strcmp(value, "true");
else if (!strcmp(name, "Orientation"))
header->Orientation = atoi(value);
else if (!strcmp(name, "OutputFaceUp"))
header->OutputFaceUp = !strcmp(value, "true");
else if (!strcmp(name, "Separations"))
header->Separations = !strcmp(value, "true");
else if (!strcmp(name, "TraySwitch"))
header->TraySwitch = !strcmp(value, "true");
else if (!strcmp(name, "Tumble"))
header->Tumble = !strcmp(value, "true");
else if (!strcmp(name, "cupsMediaType"))
header->cupsMediaType = atoi(value);
else if (!strcmp(name, "cupsBitsPerColor"))
header->cupsBitsPerColor = atoi(value);
else if (!strcmp(name, "cupsColorOrder"))
header->cupsColorOrder = (cups_order_t)atoi(value);
else if (!strcmp(name, "cupsColorSpace"))
header->cupsColorSpace = (cups_cspace_t)atoi(value);
else if (!strcmp(name, "cupsCompression"))
header->cupsCompression = atoi(value);
else if (!strcmp(name, "cupsRowCount"))
header->cupsRowCount = atoi(value);
else if (!strcmp(name, "cupsRowFeed"))
header->cupsRowFeed = atoi(value);
else if (!strcmp(name, "cupsRowStep"))
header->cupsRowStep = atoi(value);
}
}
/*
* 'format_CMY()' - Convert image data to CMY.
*/
@@ -1410,18 +1657,18 @@ format_CMY(cups_page_header2_t *header, /* I - Page header */
int ysize, /* I - Height of image data */
int yerr0, /* I - Top Y error */
int yerr1, /* I - Bottom Y error */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
{
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
switch (XPosition)
@@ -1776,7 +2023,7 @@ format_CMY(cups_page_header2_t *header, /* I - Page header */
*/
static void
format_CMYK(cups_page_header2_t *header,/* I - Page header */
format_CMYK(cups_page_header2_t *header, /* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
int y, /* I - Current row */
int z, /* I - Current plane */
@@ -1784,19 +2031,19 @@ format_CMYK(cups_page_header2_t *header,/* I - Page header */
int ysize, /* I - Height of image data */
int yerr0, /* I - Top Y error */
int yerr1, /* I - Bottom Y error */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
{
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
*kptr, /* Pointer into black */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
*kptr, /* Pointer into black */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
switch (XPosition)
@@ -2158,14 +2405,14 @@ format_K(cups_page_header2_t *header, /* I - Page header */
int ysize, /* I - Height of image data */
int yerr0, /* I - Top Y error */
int yerr1, /* I - Bottom Y error */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
{
cups_ib_t *ptr, /* Pointer into row */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
cups_ib_t *ptr, /* Pointer into row */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
(void)z;
@@ -2268,7 +2515,7 @@ format_K(cups_page_header2_t *header, /* I - Page header */
*/
static void
format_KCMY(cups_page_header2_t *header,/* I - Page header */
format_KCMY(cups_page_header2_t *header, /* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
int y, /* I - Current row */
int z, /* I - Current plane */
@@ -2276,19 +2523,19 @@ format_KCMY(cups_page_header2_t *header,/* I - Page header */
int ysize, /* I - Height of image data */
int yerr0, /* I - Top Y error */
int yerr1, /* I - Bottom Y error */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
{
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
*kptr, /* Pointer into black */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
*kptr, /* Pointer into black */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
switch (XPosition)
@@ -2676,31 +2923,30 @@ format_KCMY(cups_page_header2_t *header,/* I - Page header */
*/
static void
format_KCMYcm(
cups_page_header2_t *header, /* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
int y, /* I - Current row */
int z, /* I - Current plane */
int xsize, /* I - Width of image data */
int ysize, /* I - Height of image data */
int yerr0, /* I - Top Y error */
int yerr1, /* I - Bottom Y error */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
format_KCMYcm(cups_page_header2_t *header,/* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
int y, /* I - Current row */
int z, /* I - Current plane */
int xsize,/* I - Width of image data */
int ysize,/* I - Height of image data */
int yerr0,/* I - Top Y error */
int yerr1,/* I - Bottom Y error */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
{
int pc, pm, py, pk; /* Cyan, magenta, yellow, and black values */
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
*kptr, /* Pointer into black */
*lcptr, /* Pointer into light cyan */
*lmptr, /* Pointer into light magenta */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
int pc, pm, py, pk; /* Cyan, magenta, yellow, and black values */
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
*kptr, /* Pointer into black */
*lcptr, /* Pointer into light cyan */
*lmptr, /* Pointer into light magenta */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
switch (XPosition)
@@ -3014,7 +3260,7 @@ format_KCMYcm(
*/
static void
format_RGBA(cups_page_header2_t *header,/* I - Page header */
format_RGBA(cups_page_header2_t *header, /* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
int y, /* I - Current row */
int z, /* I - Current plane */
@@ -3022,18 +3268,18 @@ format_RGBA(cups_page_header2_t *header,/* I - Page header */
int ysize, /* I - Height of image data */
int yerr0, /* I - Top Y error */
int yerr1, /* I - Bottom Y error */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
{
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
switch (XPosition)
@@ -3425,14 +3671,14 @@ format_W(cups_page_header2_t *header, /* I - Page header */
int ysize, /* I - Height of image data */
int yerr0, /* I - Top Y error */
int yerr1, /* I - Bottom Y error */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
{
cups_ib_t *ptr, /* Pointer into row */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
cups_ib_t *ptr, /* Pointer into row */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
(void)z;
@@ -3543,18 +3789,18 @@ format_YMC(cups_page_header2_t *header, /* I - Page header */
int ysize, /* I - Height of image data */
int yerr0, /* I - Top Y error */
int yerr1, /* I - Bottom Y error */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
{
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
switch (XPosition)
@@ -3924,7 +4170,7 @@ format_YMC(cups_page_header2_t *header, /* I - Page header */
*/
static void
format_YMCK(cups_page_header2_t *header,/* I - Page header */
format_YMCK(cups_page_header2_t *header, /* I - Page header */
unsigned char *row, /* IO - Bitmap data for device */
int y, /* I - Current row */
int z, /* I - Current plane */
@@ -3932,19 +4178,19 @@ format_YMCK(cups_page_header2_t *header,/* I - Page header */
int ysize, /* I - Height of image data */
int yerr0, /* I - Top Y error */
int yerr1, /* I - Bottom Y error */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
cups_ib_t *r0, /* I - Primary image data */
cups_ib_t *r1) /* I - Image data for interpolation */
{
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
*kptr, /* Pointer into black */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
cups_ib_t *ptr, /* Pointer into row */
*cptr, /* Pointer into cyan */
*mptr, /* Pointer into magenta */
*yptr, /* Pointer into yellow */
*kptr, /* Pointer into black */
bitmask; /* Current mask for pixel */
int bitoffset; /* Current offset in line */
int bandwidth; /* Width of a color band */
int x, /* Current X coordinate on page */
*dither; /* Pointer into dither array */
switch (XPosition)
@@ -4364,30 +4610,6 @@ make_lut(cups_ib_t *lut, /* I - Lookup table */
}
/*
* 'raster_cb()' - Validate the page header.
*/
static int /* O - 0 if OK, -1 if not */
raster_cb(
cups_page_header2_t *header, /* IO - Raster header */
int preferred_bits) /* I - Preferred bits per color */
{
/*
* Ensure that colorimetric colorspaces use at least 8 bits per
* component...
*/
if ((header->cupsColorSpace == CUPS_CSPACE_CIEXYZ ||
header->cupsColorSpace == CUPS_CSPACE_CIELab ||
header->cupsColorSpace >= CUPS_CSPACE_ICC1) &&
header->cupsBitsPerColor < 8)
header->cupsBitsPerColor = 8;
return (0);
}
/*
* End of "$Id$".
*/
+24 -45
Ver Arquivo
@@ -53,8 +53,7 @@
* Local functions...
*/
static int exec_code(cups_page_header2_t *header, int *preferred_bits,
const char *code);
static int exec_code(cups_page_header2_t *header, const char *code);
/*
@@ -65,12 +64,6 @@ static int exec_code(cups_page_header2_t *header, int *preferred_bits,
* cupsRasterInterpretPPD() - this allows you to do per-page options
* without manipulating the options array.
*
* The "func" argument specifies an optional callback function that is
* called prior to the computation of the final raster data. The function
* can make changes to the cups_page_header2_t data as needed to use a
* supported raster format and then returns 0 on success and -1 if the
* requested attributes cannot be supported.
*
* @since CUPS 1.2@
*/
@@ -79,8 +72,7 @@ cupsRasterInterpretPPD(
cups_page_header2_t *h, /* O - Page header */
ppd_file_t *ppd, /* I - PPD file */
int num_options, /* I - Number of options */
cups_option_t *options, /* I - Options */
cups_interpret_cb_t func) /* I - Optional page header callback */
cups_option_t *options) /* I - Options */
{
int i; /* Looping var */
int status; /* Cummulative status */
@@ -92,7 +84,6 @@ cupsRasterInterpretPPD(
bottom, /* Bottom position */
right, /* Right position */
top; /* Top position */
int preferred_bits; /* Preferred bits per color */
/*
@@ -130,8 +121,7 @@ cupsRasterInterpretPPD(
* Apply patches and options to the page header...
*/
status = 0;
preferred_bits = 0;
status = 0;
if (ppd)
{
@@ -140,7 +130,7 @@ cupsRasterInterpretPPD(
*/
if (ppd->patches)
status |= exec_code(h, &preferred_bits, ppd->patches);
status |= exec_code(h, ppd->patches);
/*
* Then apply printer options in the proper order...
@@ -149,28 +139,40 @@ cupsRasterInterpretPPD(
if ((count = ppdCollect(ppd, PPD_ORDER_DOCUMENT, &choices)) > 0)
{
for (i = 0; i < count; i ++)
status |= exec_code(h, &preferred_bits, choices[i]->code);
status |= exec_code(h, choices[i]->code);
}
if ((count = ppdCollect(ppd, PPD_ORDER_ANY, &choices)) > 0)
{
for (i = 0; i < count; i ++)
status |= exec_code(h, &preferred_bits, choices[i]->code);
status |= exec_code(h, choices[i]->code);
}
if ((count = ppdCollect(ppd, PPD_ORDER_PROLOG, &choices)) > 0)
{
for (i = 0; i < count; i ++)
status |= exec_code(h, &preferred_bits, choices[i]->code);
status |= exec_code(h, choices[i]->code);
}
if ((count = ppdCollect(ppd, PPD_ORDER_PAGE, &choices)) > 0)
{
for (i = 0; i < count; i ++)
status |= exec_code(h, &preferred_bits, choices[i]->code);
status |= exec_code(h, choices[i]->code);
}
}
/*
* Check parameters...
*/
if (!h->HWResolution[0] || !h->HWResolution[1] ||
!h->PageSize[0] || !h->PageSize[1] ||
(h->cupsBitsPerColor != 1 && h->cupsBitsPerColor != 2 &&
h->cupsBitsPerColor != 4 && h->cupsBitsPerColor != 8) ||
h->cupsBorderlessScalingFactor < 0.9 ||
h->cupsBorderlessScalingFactor > 1.1)
return (-1);
/*
* Allow option override for page scaling...
*/
@@ -228,26 +230,6 @@ cupsRasterInterpretPPD(
h->cupsImagingBBox[2] = right;
h->cupsImagingBBox[3] = top;
/*
* Use the callback to validate the page header...
*/
if (func && (*func)(h, preferred_bits))
return (-1);
/*
* Check parameters...
*/
if (!h->HWResolution[0] || !h->HWResolution[1] ||
!h->PageSize[0] || !h->PageSize[1] ||
(h->cupsBitsPerColor != 1 && h->cupsBitsPerColor != 2 &&
h->cupsBitsPerColor != 4 && h->cupsBitsPerColor != 8 &&
h->cupsBitsPerColor != 16) ||
h->cupsBorderlessScalingFactor < 0.9 ||
h->cupsBorderlessScalingFactor > 1.1)
return (-1);
/*
* Compute the bitmap parameters...
*/
@@ -312,7 +294,6 @@ cupsRasterInterpretPPD(
*/
case CUPS_CSPACE_RGBA :
case CUPS_CSPACE_RGBW :
case CUPS_CSPACE_CMYK :
case CUPS_CSPACE_YMCK :
case CUPS_CSPACE_KCMY :
@@ -341,10 +322,8 @@ cupsRasterInterpretPPD(
*/
static int /* O - 0 on success, -1 on error */
exec_code(
cups_page_header2_t *h, /* O - Page header */
int *preferred_bits,/* O - Preferred bits per color */
const char *code) /* I - Option choice to execute */
exec_code(cups_page_header2_t *h, /* O - Page header */
const char *code) /* I - Option choice to execute */
{
int i; /* Index into array */
int type; /* Type of value */
@@ -548,8 +527,6 @@ exec_code(
h->cupsMediaType = atoi(value);
else if (!strcmp(name, "cupsBitsPerColor") && type == CUPS_TYPE_NUMBER)
h->cupsBitsPerColor = atoi(value);
else if (!strcmp(name, "cupsPreferredBitsPerColor") && type == CUPS_TYPE_NUMBER)
*preferred_bits = atoi(value);
else if (!strcmp(name, "cupsColorOrder") && type == CUPS_TYPE_NUMBER)
h->cupsColorOrder = (cups_order_t)atoi(value);
else if (!strcmp(name, "cupsColorSpace") && type == CUPS_TYPE_NUMBER)
@@ -597,6 +574,8 @@ exec_code(
if (sscanf(value, "(%63[^)])", h->cupsRenderingIntent) != 1)
return (-1);
}
else
return (-1);
}
/*
+1 -4
Ver Arquivo
@@ -317,8 +317,6 @@ typedef struct _cups_raster_s /**** Raster stream data ****/
*pcurrent; /* Current byte in pixel buffer */
} cups_raster_t;
typedef int (*cups_interpret_cb_t)(cups_page_header2_t *header, int preferred_bits);
/*
* Prototypes...
@@ -339,8 +337,7 @@ extern unsigned cupsRasterWritePixels(cups_raster_t *r,
extern int cupsRasterInterpretPPD(cups_page_header2_t *h,
ppd_file_t *ppd,
int num_options,
cups_option_t *options,
cups_interpret_cb_t func);
cups_option_t *options);
extern unsigned cupsRasterReadHeader2(cups_raster_t *r,
cups_page_header2_t *h);
extern unsigned cupsRasterWriteHeader2(cups_raster_t *r,
+1 -2
Ver Arquivo
@@ -46,8 +46,7 @@ MAN5 = classes.conf.$(MAN5EXT) \
cupsd.conf.$(MAN5EXT) \
mime.convs.$(MAN5EXT) \
mime.types.$(MAN5EXT) \
printers.conf.$(MAN5EXT) \
subscriptions.conf.$(MAN5EXT)
printers.conf.$(MAN5EXT)
MAN7 = backend.$(MAN7EXT) \
filter.$(MAN7EXT)
MAN8 = accept.$(MAN8EXT) \
-98
Ver Arquivo
@@ -1,98 +0,0 @@
.\"
.\" "$Id: subscriptions.conf.man 5099 2006-02-13 02:46:10Z mike $"
.\"
.\" subscriptions.conf man page for the Common UNIX Printing System (CUPS).
.\"
.\" Copyright 2006 by Easy Software Products.
.\"
.\" These coded instructions, statements, and computer programs are the
.\" property of Easy Software Products and are protected by Federal
.\" copyright law. Distribution and use rights are outlined in the file
.\" "LICENSE.txt" which should have been included with this file. If this
.\" file is missing or damaged please contact Easy Software Products
.\" at:
.\"
.\" Attn: CUPS Licensing Information
.\" Easy Software Products
.\" 44141 Airport View Drive, Suite 204
.\" Hollywood, Maryland 20636 USA
.\"
.\" Voice: (301) 373-9600
.\" EMail: cups-info@cups.org
.\" WWW: http://www.cups.org
.\"
.TH subscriptions.conf 5 "Common UNIX Printing System" "30 April 2006" "Easy Software Products"
.SH NAME
subscriptions.conf \- subscriptions file for cups
.SH DESCRIPTION
The \fIsubscriptions.conf\fR file defines the local subscriptions
that are active. It is normally located in the \fI/etc/cups\fR
directory and is generated automatically by the \fIcupsd(8)\fR
program when subscriptions are created, renewed, or cancelled.
.LP
Each line in the file can be a configuration directive, a blank line,
or a comment. Comment lines start with the # character.
.SH DIRECTIVES
.TP 5
<Subscription NNN> ... </Subscription>
.br
Defines a subscription.
.TP 5
Events name [ ... name ]
.br
Specifies the events that are subscribed.
.TP 5
ExpirationTime unix-time
.br
Specifies the expiration time of a subscription as a UNIX time
value in seconds since January 1st, 1970.
.TP 5
Interval seconds
.br
Specifies the preferred time interval for event notifications in
seconds.
.TP 5
JobId job-id
.br
Specifies the job ID associated with the subscription.
.TP 5
LeaseDuration seconds
.br
Specifies the number of seconds that the subscription is valid
for. If 0, the subscription does not expire.
.TP 5
NextEventId number
.br
Specifies the next notify-sequence-number to use for the
subscription.
.TP 5
NextSubscriptionId number
.br
Specifies the next subscription-id to use.
.TP 5
Owner username
.br
Specifies the user that owns the subscription.
.TP 5
PrinterName printername
.br
Specifies the printer or class associated with the subscription.
.TP 5
Recipient uri
.br
Specifies the notify-recipient-uri value for push-type notifications.
.TP 5
UserData hex-escaped-data
.br
Specifies user data to be included in event notifications. This
is typically the "from" address in mailto: notifications.
.SH SEE ALSO
\fIclasses.conf(5)\fR, \fIcupsd(8)\fR, \fIcupsd.conf(5)\fR,
\fImime.convs(5)\fR, \fImime.types(5)\fR, \fRprinters.conf(5)\fR
.br
http://localhost:631/help
.SH COPYRIGHT
Copyright 1997-2006 by Easy Software Products, All Rights Reserved.
.\"
.\" End of "$Id: subscriptions.conf.man 5099 2006-02-13 02:46:10Z mike $".
.\"
+1 -1
Ver Arquivo
@@ -10,7 +10,7 @@
\f1\b WARNING\
\f0\b0 \
Because MacOS X packages cannot be uninstalled, you will need to reinstall MacOS X to revert to the original CUPS 1.1.x software.\
This is pre-release software and should not be used in production environments. Because MacOS X packages cannot be uninstalled, you will need to reinstall MacOS X to revert to the original CUPS 1.1.x software.\
\
Please report all problems using the Bugs & Features page on the CUPS home page:\
\
+2 -2
Ver Arquivo
@@ -28,7 +28,7 @@
%copyright 1993-2006 by Easy Software Products, All Rights Reserved.
%vendor Easy Software Products
%license LICENSE.txt
%readme packaging/cups.readme
%readme packaging/cups.license
%version @CUPS_VERSION@
%description The Common UNIX Printing System provides a portable printing
%description layer for UNIX(r) operating systems. It has been developed by
@@ -172,7 +172,7 @@ $INSTALLSTATIC=@INSTALLSTATIC@
$MAN1EXT=@MAN1EXT@
$MAN5EXT=@MAN5EXT@
$MAN7EXT=@MAN7EXT@
$MAN8EXT=@MAN8EXT@
$MAN8DIR=@MAN8DIR@
$DSOLIBS=@DSOLIBS@
+161 -9
Ver Arquivo
@@ -1,21 +1,86 @@
README - CUPS v1.2.0b1 - 01/10/2006
-----------------------------------
*****************************************************************
*****************************************************************
**** ****
**** WARNING: THIS IS BETA RELEASE SOFTWARE AND MAY BE ****
**** TOTALLY UNSTABLE. DO NOT USE IN ENVIRONMENTS ****
**** WHERE RELIABLE SOFTWARE IS REQUIRED! ****
**** ****
*****************************************************************
*****************************************************************
Looking for compile instructions? Read the file "INSTALL.txt"
instead...
*****************************************************************
*****************************************************************
**** ****
**** IF YOU HAVE A NON-POSTSCRIPT PRINTER, YOU WILL ALSO ****
**** NEED TO INSTALL ESP GHOSTSCRIPT OR A PATCHED VERSION ****
**** OF A STANDARD GHOSTSCRIPT RELEASE. ****
**** ****
*****************************************************************
*****************************************************************
INTRODUCTION
CUPS provides a portable printing layer for UNIX(r)-based
operating systems. It has been developed by Easy Software
Products to promote a standard printing solution for all UNIX
vendors and users. CUPS provides the System V and Berkeley
command-line interfaces.
CUPS uses the Internet Printing Protocol ("IPP") as the basis
for managing print jobs and queues. The Line Printer Daemon
("LPD") Server Message Block ("SMB"), and AppSocket (a.k.a.
JetDirect) protocols are also supported with reduced
functionality. CUPS adds network printer browsing and
PostScript Printer Description ("PPD") based printing options to
support real-world printing under UNIX.
CUPS includes an image file RIP that supports printing of image
files to non-PostScript printers. A customized version of GNU
Ghostscript for CUPS called ESP Ghostscript is available
separately to support printing of PostScript files within the
CUPS driver framework. Sample drivers for Dymo, EPSON, HP, and
OKIDATA printers are included that use these filters.
Drivers for thousands of printers are provided with our ESP
Print Pro software, available at:
http://www.easysw.com/printpro/
CUPS is licensed under the GNU General Public License and GNU
Library General Public License. Please contact Easy Software
Products for commercial support and "binary distribution"
rights.
SYSTEM REQUIREMENTS
Binary distributions require a minimum of 10MB of free disk
space. We do not recommend using CUPS on a workstation with less
than 32MB of RAM or a PC with less than 16MB of RAM.
If you are installing from source you'll need ANSI-compliant C
and C++ compilers and optionally one or more image file support
libraries. Complete source installation instructions can be
found in the file "INSTALL.txt".
SOFTWARE REQUIREMENTS
The following operating system software is required to install
one of the binary distributions from Easy Software Products:
- AIX 5.2 or higher
- AIX 4.3 or higher
- HP-UX 11.00 or higher
- IRIX 6.5 or higher
- Linux 2.4 with glibc 2.3 or higher (LSB 3.1)
- MacOS X 10.4 or higher (PowerPC or Intel)
- Solaris 8 or higher (SPARC or Intel)
- Linux 2.4 with glibc 2.2 or higher
- Solaris 7 or higher (SPARC or Intel)
INSTALLING "PORTABLE" CUPS DISTRIBUTIONS
@@ -25,7 +90,7 @@ distributions in TAR format with installation and removal
scripts generated by our ESP Package Manager (EPM) software,
which is available from:
http://www.easysw.com/epm/
http://www.easysw.com/epm
WARNING: Installing CUPS will overwrite your existing printing
system. Backup files are made by the installation script and
@@ -47,9 +112,10 @@ be installed and the scheduler will be started automatically.
INSTALLING HOST-SPECIFIC (RPM, DEBIAN, ETC.) DISTRIBUTIONS
The host-specific distributions use the operating system software
installation tools. To install a host-specific distribution
please consult your operating system documentation.
The host-specific distributions use the operating system
software installation tools. To install a host-specific
distribution please consult the CUPS Software Administrators
Manual or your operating system documentation.
READING THE DOCUMENTATION
@@ -98,7 +164,93 @@ shown a menu of available functions.
DO NOT use the hostname for your machine - it will not work with
the default CUPS configuration. To enable administration access
on other addresses, consult the on-line help.
on other addresses, consult the CUPS Software Administrators
Manual.
SETTING UP PRINTER QUEUES FROM THE COMMAND-LINE
CUPS works best with PPD (PostScript Printer Description)
files. In a pinch you can also use System V style printer
interface scripts.
Six sample PPD files are provided with this distribution that
utilize the PostScript and image file RIPs and the sample EPSON
and HP printer drivers. To add the sample DeskJet driver to the
system for a printer connected to the parallel port, use one of
the following commands:
HP-UX:
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/c2t0d0_lp -E
IRIX:
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/plp -E
Linux:
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/lp0 -E
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/lp1 -E
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/lp2 -E
Solaris:
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/bpp0 -E
/usr/lib/lpadmin -p DeskJet -m deskjet.ppd -v parallel:/dev/ecpp0 -E
Similarly, for the other sample drivers you can use:
Driver PPD File
----------------------------- ------------
Dymo Label Printers dymo.ppd
EPSON Stylus Color Series stcolor.ppd
EPSON Stylus Photo Series stphoto.ppd
EPSON Stylus New Color Series stcolor2.ppd
EPSON Stylus New Photo Series stphoto2.ppd
EPSON 9-pin Series epson9.ppd
EPSON 24-pin Series epson24.ppd
HP DeskJet Series deskjet.ppd
HP New DeskJet Series deskjet2.ppd
HP LaserJet Series laserjet.ppd
OKIDATA 9-Pin Series okidata9.ppd
OKIDATA 24-Pin Series okidat24.ppd
These sample drivers provide basic printing capabilities, but
generally do not exercise the full potential of the printers or
CUPS. For commercial printer drivers check out our ESP Print
Pro software at:
http://www.easysw.com/printpro/
PRINTING FILES
CUPS provides both the System V "lp" and Berkeley "lpr" commands
for printing:
lp filename
lpr filename
Both the "lp" and "lpr" commands support printing options for
the driver:
lp -omedia=A4 -oresolution=600dpi filename
lpr -omedia=A4 -oresolution=600dpi filename
CUPS recognizes many types of images files as well as PDF,
PostScript, HP-GL/2, and text files, so you can print those
files directly rather than through an application.
If you have an application that generates output specifically
for your printer then you need to use the "-oraw" or "-l"
options:
lp -oraw filename
lpr -l filename
This will prevent the filters from misinterpreting your print
file.
LEGAL STUFF
-6
Ver Arquivo
@@ -140,12 +140,6 @@ GBool Decrypt::makeFileKey2(int encVersion, int encRevision, int keyLength,
int len, i, j;
GBool ok;
// check whether we have non-zero keyLength
if ( keyLength < 5 || keyLength > 16 ) {
return gFalse;
}
// generate file key
buf = (Guchar *)gmalloc(72 + fileID->getLength());
if (userPassword) {
+21
Ver Arquivo
@@ -59,12 +59,33 @@ LIBOBJS = \
PSOutputDev.o \
PSTokenizer.o \
SecurityHandler.o \
SplashBitmap.o \
SplashClip.o \
Splash.o \
SplashFont.o \
SplashFontEngine.o \
SplashFontFile.o \
SplashFontFileID.o \
SplashFTFont.o \
SplashFTFontEngine.o \
SplashFTFontFile.o \
SplashOutputDev.o \
SplashPath.o \
SplashPattern.o \
SplashScreen.o \
SplashState.o \
SplashT1Font.o \
SplashT1FontEngine.o \
SplashT1FontFile.o \
SplashXPath.o \
SplashXPathScanner.o \
Stream.o \
UnicodeMap.o \
UnicodeTypeTable.o \
XpdfPluginAPI.o \
XRef.o
OBJS = pdftops.o $(LIBOBJS)
TARGETS = libxpdf.a pdftops
+3191
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+204
Ver Arquivo
@@ -0,0 +1,204 @@
//========================================================================
//
// Splash.h
//
//========================================================================
#ifndef SPLASH_H
#define SPLASH_H
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "SplashTypes.h"
#include "SplashClip.h"
class SplashBitmap;
struct SplashGlyphBitmap;
class SplashState;
class SplashPattern;
class SplashScreen;
class SplashPath;
class SplashXPath;
class SplashFont;
//------------------------------------------------------------------------
// Retrieves the next line of pixels in an image mask. Normally,
// fills in *<line> and returns true. If the image stream is
// exhausted, returns false.
typedef GBool (*SplashImageMaskSource)(void *data, SplashColorPtr pixel);
// Retrieves the next line of pixels in an image. Normally, fills in
// *<line> and returns true. If the image stream is exhausted,
// returns false.
typedef GBool (*SplashImageSource)(void *data, SplashColorPtr line);
//------------------------------------------------------------------------
// Splash
//------------------------------------------------------------------------
class Splash {
public:
// Create a new rasterizer object.
Splash(SplashBitmap *bitmapA);
~Splash();
//----- state read
SplashPattern *getStrokePattern();
SplashPattern *getFillPattern();
SplashScreen *getScreen();
SplashBlendFunc getBlendFunc();
SplashCoord getStrokeAlpha();
SplashCoord getFillAlpha();
SplashCoord getLineWidth();
int getLineCap();
int getLineJoin();
SplashCoord getMiterLimit();
SplashCoord getFlatness();
SplashCoord *getLineDash();
int getLineDashLength();
SplashCoord getLineDashPhase();
SplashClip *getClip();
//----- state write
void setStrokePattern(SplashPattern *strokeColor);
void setFillPattern(SplashPattern *fillColor);
void setScreen(SplashScreen *screen);
void setBlendFunc(SplashBlendFunc func);
void setStrokeAlpha(SplashCoord alpha);
void setFillAlpha(SplashCoord alpha);
void setLineWidth(SplashCoord lineWidth);
void setLineCap(int lineCap);
void setLineJoin(int lineJoin);
void setMiterLimit(SplashCoord miterLimit);
void setFlatness(SplashCoord flatness);
// the <lineDash> array will be copied
void setLineDash(SplashCoord *lineDash, int lineDashLength,
SplashCoord lineDashPhase);
void clipResetToRect(SplashCoord x0, SplashCoord y0,
SplashCoord x1, SplashCoord y1);
SplashError clipToRect(SplashCoord x0, SplashCoord y0,
SplashCoord x1, SplashCoord y1);
SplashError clipToPath(SplashPath *path, GBool eo);
//----- state save/restore
void saveState();
SplashError restoreState();
//----- soft mask
void setSoftMask(SplashBitmap *softMaskA);
//----- drawing operations
// Fill the bitmap with <color>. This is not subject to clipping.
void clear(SplashColorPtr color);
// Stroke a path using the current stroke pattern.
SplashError stroke(SplashPath *path);
// Fill a path using the current fill pattern.
SplashError fill(SplashPath *path, GBool eo);
// Fill a path, XORing with the current fill pattern.
SplashError xorFill(SplashPath *path, GBool eo);
// Draw a character, using the current fill pattern.
SplashError fillChar(SplashCoord x, SplashCoord y, int c, SplashFont *font);
// Draw a glyph, using the current fill pattern. This function does
// not free any data, i.e., it ignores glyph->freeData.
SplashError fillGlyph(SplashCoord x, SplashCoord y,
SplashGlyphBitmap *glyph);
// Draws an image mask using the fill color. This will read <h>
// lines of <w> pixels from <src>, starting with the top line. "1"
// pixels will be drawn with the current fill color; "0" pixels are
// transparent. The matrix:
// [ mat[0] mat[1] 0 ]
// [ mat[2] mat[3] 0 ]
// [ mat[4] mat[5] 1 ]
// maps a unit square to the desired destination for the image, in
// PostScript style:
// [x' y' 1] = [x y 1] * mat
// Note that the Splash y axis points downward, and the image source
// is assumed to produce pixels in raster order, starting from the
// top line.
SplashError fillImageMask(SplashImageMaskSource src, void *srcData,
int w, int h, SplashCoord *mat);
// Draw an image. This will read <h> lines of <w> pixels from
// <src>, starting with the top line. These pixels are assumed to
// be in the source mode, <srcMode>. The following combinations of
// source and target modes are supported:
// source target
// ------ ------
// Mono1 Mono1
// Mono8 Mono1 -- with dithering
// Mono8 Mono8
// RGB8 RGB8
// BGR8 BGR8
// ARGB8 RGB8 -- with source alpha (masking)
// BGRA8 BGR8 -- with source alpha (masking)
// The matrix behaves as for fillImageMask.
SplashError drawImage(SplashImageSource src, void *srcData,
SplashColorMode srcMode,
int w, int h, SplashCoord *mat);
//----- misc
// Return the associated bitmap.
SplashBitmap *getBitmap() { return bitmap; }
// Get a bounding box which includes all modifications since the
// last call to clearModRegion.
void getModRegion(int *xMin, int *yMin, int *xMax, int *yMax)
{ *xMin = modXMin; *yMin = modYMin; *xMax = modXMax; *yMax = modYMax; }
// Clear the modified region bounding box.
void clearModRegion();
// Get clipping status for the last drawing operation subject to
// clipping.
SplashClipResult getClipRes() { return opClipRes; }
// Toggle debug mode on or off.
void setDebugMode(GBool debugModeA) { debugMode = debugModeA; }
private:
void updateModX(int x);
void updateModY(int y);
void strokeNarrow(SplashXPath *xPath);
void strokeWide(SplashXPath *xPath);
SplashXPath *makeDashedPath(SplashXPath *xPath);
SplashError fillWithPattern(SplashPath *path, GBool eo,
SplashPattern *pattern, SplashCoord alpha);
void drawPixel(int x, int y, SplashColorPtr color,
SplashCoord alpha, GBool noClip);
void drawPixel(int x, int y, SplashPattern *pattern,
SplashCoord alpha, GBool noClip);
void drawSpan(int x0, int x1, int y, SplashPattern *pattern,
SplashCoord alpha, GBool noClip);
void xorSpan(int x0, int x1, int y, SplashPattern *pattern, GBool noClip);
void dumpPath(SplashPath *path);
void dumpXPath(SplashXPath *path);
SplashBitmap *bitmap;
SplashState *state;
SplashBitmap *softMask;
int modXMin, modYMin, modXMax, modYMax;
SplashClipResult opClipRes;
GBool debugMode;
};
#endif
+243
Ver Arquivo
@@ -0,0 +1,243 @@
//========================================================================
//
// SplashBitmap.cc
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdio.h>
#include "gmem.h"
#include "SplashErrorCodes.h"
#include "SplashBitmap.h"
//------------------------------------------------------------------------
// SplashBitmap
//------------------------------------------------------------------------
SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad,
SplashColorMode modeA, GBool topDown) {
width = widthA;
height = heightA;
mode = modeA;
switch (mode) {
case splashModeMono1:
rowSize = (width + 7) >> 3;
break;
case splashModeMono8:
rowSize = width;
break;
case splashModeAMono8:
rowSize = width * 2;
break;
case splashModeRGB8:
case splashModeBGR8:
rowSize = width * 3;
break;
case splashModeARGB8:
case splashModeBGRA8:
#if SPLASH_CMYK
case splashModeCMYK8:
#endif
rowSize = width * 4;
break;
#if SPLASH_CMYK
case splashModeACMYK8:
rowSize = width * 5;
break;
#endif
}
rowSize += rowPad - 1;
rowSize -= rowSize % rowPad;
data = (SplashColorPtr)gmalloc(rowSize * height);
if (!topDown) {
data += (height - 1) * rowSize;
rowSize = -rowSize;
}
}
SplashBitmap::~SplashBitmap() {
if (rowSize < 0) {
gfree(data + (height - 1) * rowSize);
} else {
gfree(data);
}
}
SplashError SplashBitmap::writePNMFile(char *fileName) {
FILE *f;
SplashColorPtr row, p;
int x, y;
if (!(f = fopen(fileName, "wb"))) {
return splashErrOpenFile;
}
switch (mode) {
case splashModeMono1:
fprintf(f, "P4\n%d %d\n", width, height);
row = data;
for (y = 0; y < height; ++y) {
p = row;
for (x = 0; x < width; x += 8) {
fputc(*p ^ 0xff, f);
++p;
}
row += rowSize;
}
break;
case splashModeMono8:
fprintf(f, "P5\n%d %d\n255\n", width, height);
row = data;
for (y = 0; y < height; ++y) {
p = row;
for (x = 0; x < width; ++x) {
fputc(*p, f);
++p;
}
row += rowSize;
}
break;
case splashModeAMono8:
fprintf(f, "P5\n%d %d\n255\n", width, height);
row = data;
for (y = 0; y < height; ++y) {
p = row;
for (x = 0; x < width; ++x) {
fputc(splashAMono8M(p), f);
p += 2;
}
row += rowSize;
}
break;
case splashModeRGB8:
fprintf(f, "P6\n%d %d\n255\n", width, height);
row = data;
for (y = 0; y < height; ++y) {
p = row;
for (x = 0; x < width; ++x) {
fputc(splashRGB8R(p), f);
fputc(splashRGB8G(p), f);
fputc(splashRGB8B(p), f);
p += 3;
}
row += rowSize;
}
break;
case splashModeBGR8:
fprintf(f, "P6\n%d %d\n255\n", width, height);
row = data;
for (y = 0; y < height; ++y) {
p = row;
for (x = 0; x < width; ++x) {
fputc(splashBGR8R(p), f);
fputc(splashBGR8G(p), f);
fputc(splashBGR8B(p), f);
p += 3;
}
row += rowSize;
}
break;
case splashModeARGB8:
fprintf(f, "P6\n%d %d\n255\n", width, height);
row = data;
for (y = 0; y < height; ++y) {
p = row;
for (x = 0; x < width; ++x) {
fputc(splashARGB8R(p), f);
fputc(splashARGB8G(p), f);
fputc(splashARGB8B(p), f);
p += 4;
}
row += rowSize;
}
break;
case splashModeBGRA8:
fprintf(f, "P6\n%d %d\n255\n", width, height);
row = data;
for (y = 0; y < height; ++y) {
p = row;
for (x = 0; x < width; ++x) {
fputc(splashBGRA8R(p), f);
fputc(splashBGRA8G(p), f);
fputc(splashBGRA8B(p), f);
p += 4;
}
row += rowSize;
}
break;
#if SPLASH_CMYK
case splashModeCMYK8:
case splashModeACMYK8:
// PNM doesn't support CMYK
break;
#endif
}
fclose(f);
return splashOk;
}
void SplashBitmap::getPixel(int x, int y, SplashColorPtr pixel) {
SplashColorPtr p;
if (y < 0 || y >= height || x < 0 || x >= width) {
return;
}
switch (mode) {
case splashModeMono1:
p = &data[y * rowSize + (x >> 3)];
pixel[0] = (p[0] >> (7 - (x & 7))) & 1;
break;
case splashModeMono8:
p = &data[y * rowSize + x];
pixel[0] = p[0];
break;
case splashModeAMono8:
p = &data[y * rowSize + 2 * x];
pixel[0] = p[0];
pixel[1] = p[1];
break;
case splashModeRGB8:
case splashModeBGR8:
p = &data[y * rowSize + 3 * x];
pixel[0] = p[0];
pixel[1] = p[1];
pixel[2] = p[2];
break;
case splashModeARGB8:
case splashModeBGRA8:
#if SPLASH_CMYK
case splashModeCMYK8:
#endif
p = &data[y * rowSize + 4 * x];
pixel[0] = p[0];
pixel[1] = p[1];
pixel[2] = p[2];
pixel[3] = p[3];
break;
#if SPLASH_CMYK
case splashModeACMYK8:
p = &data[y * rowSize + 5 * x];
pixel[0] = p[0];
pixel[1] = p[1];
pixel[2] = p[2];
pixel[3] = p[3];
pixel[4] = p[4];
break;
#endif
}
}
+55
Ver Arquivo
@@ -0,0 +1,55 @@
//========================================================================
//
// SplashBitmap.h
//
//========================================================================
#ifndef SPLASHBITMAP_H
#define SPLASHBITMAP_H
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "SplashTypes.h"
//------------------------------------------------------------------------
// SplashBitmap
//------------------------------------------------------------------------
class SplashBitmap {
public:
// Create a new bitmap. It will have <widthA> x <heightA> pixels in
// color mode <modeA>. Rows will be padded out to a multiple of
// <rowPad> bytes. If <topDown> is false, the bitmap will be stored
// upside-down, i.e., with the last row first in memory.
SplashBitmap(int widthA, int heightA, int rowPad,
SplashColorMode modeA, GBool topDown = gTrue);
~SplashBitmap();
int getWidth() { return width; }
int getHeight() { return height; }
int getRowSize() { return rowSize; }
SplashColorMode getMode() { return mode; }
SplashColorPtr getDataPtr() { return data; }
SplashError writePNMFile(char *fileName);
void getPixel(int x, int y, SplashColorPtr pixel);
private:
int width, height; // size of bitmap
int rowSize; // size of one row of data, in bytes
// - negative for bottom-up bitmaps
SplashColorMode mode; // color mode
SplashColorPtr data; // pointer to row zero of the bitmap data
friend class Splash;
};
#endif
+270
Ver Arquivo
@@ -0,0 +1,270 @@
//========================================================================
//
// SplashClip.cc
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdlib.h>
#include <string.h>
#include "gmem.h"
#include "SplashErrorCodes.h"
#include "SplashMath.h"
#include "SplashPath.h"
#include "SplashXPath.h"
#include "SplashXPathScanner.h"
#include "SplashClip.h"
//------------------------------------------------------------------------
// SplashClip.flags
//------------------------------------------------------------------------
#define splashClipEO 0x01 // use even-odd rule
//------------------------------------------------------------------------
// SplashClip
//------------------------------------------------------------------------
SplashClip::SplashClip(SplashCoord x0, SplashCoord y0,
SplashCoord x1, SplashCoord y1) {
if (x0 < x1) {
xMin = splashFloor(x0);
xMax = splashFloor(x1);
} else {
xMin = splashFloor(x1);
xMax = splashFloor(x0);
}
if (y0 < y1) {
yMin = splashFloor(y0);
yMax = splashFloor(y1);
} else {
yMin = splashFloor(y1);
yMax = splashFloor(y0);
}
paths = NULL;
flags = NULL;
scanners = NULL;
length = size = 0;
}
SplashClip::SplashClip(SplashClip *clip) {
int i;
xMin = clip->xMin;
yMin = clip->yMin;
xMax = clip->xMax;
yMax = clip->yMax;
length = clip->length;
size = clip->size;
paths = (SplashXPath **)gmallocn(size, sizeof(SplashXPath *));
flags = (Guchar *)gmallocn(size, sizeof(Guchar));
scanners = (SplashXPathScanner **)
gmallocn(size, sizeof(SplashXPathScanner *));
for (i = 0; i < length; ++i) {
paths[i] = clip->paths[i]->copy();
flags[i] = clip->flags[i];
scanners[i] = new SplashXPathScanner(paths[i], flags[i] & splashClipEO);
}
}
SplashClip::~SplashClip() {
int i;
for (i = 0; i < length; ++i) {
delete paths[i];
delete scanners[i];
}
gfree(paths);
gfree(flags);
gfree(scanners);
}
void SplashClip::grow(int nPaths) {
if (length + nPaths > size) {
if (size == 0) {
size = 32;
}
while (size < length + nPaths) {
size *= 2;
}
paths = (SplashXPath **)greallocn(paths, size, sizeof(SplashXPath *));
flags = (Guchar *)greallocn(flags, size, sizeof(Guchar));
scanners = (SplashXPathScanner **)
greallocn(scanners, size, sizeof(SplashXPathScanner *));
}
}
void SplashClip::resetToRect(SplashCoord x0, SplashCoord y0,
SplashCoord x1, SplashCoord y1) {
int i;
for (i = 0; i < length; ++i) {
delete paths[i];
delete scanners[i];
}
gfree(paths);
gfree(flags);
gfree(scanners);
paths = NULL;
flags = NULL;
scanners = NULL;
length = size = 0;
if (x0 < x1) {
xMin = splashFloor(x0);
xMax = splashFloor(x1);
} else {
xMin = splashFloor(x1);
xMax = splashFloor(x0);
}
if (y0 < y1) {
yMin = splashFloor(y0);
yMax = splashFloor(y1);
} else {
yMin = splashFloor(y1);
yMax = splashFloor(y0);
}
}
SplashError SplashClip::clipToRect(SplashCoord x0, SplashCoord y0,
SplashCoord x1, SplashCoord y1) {
int x0I, y0I, x1I, y1I;
if (x0 < x1) {
x0I = splashFloor(x0);
x1I = splashFloor(x1);
} else {
x0I = splashFloor(x1);
x1I = splashFloor(x0);
}
if (x0I > xMin) {
xMin = x0I;
}
if (x1I < xMax) {
xMax = x1I;
}
if (y0 < y1) {
y0I = splashFloor(y0);
y1I = splashFloor(y1);
} else {
y0I = splashFloor(y1);
y1I = splashFloor(y0);
}
if (y0I > yMin) {
yMin = y0I;
}
if (y1I < yMax) {
yMax = y1I;
}
return splashOk;
}
SplashError SplashClip::clipToPath(SplashPath *path, SplashCoord flatness,
GBool eo) {
SplashXPath *xPath;
xPath = new SplashXPath(path, flatness, gTrue);
// check for an empty path
if (xPath->length == 0) {
xMax = xMin - 1;
yMax = yMin - 1;
delete xPath;
// check for a rectangle
} else if (xPath->length == 4 &&
((xPath->segs[0].x0 == xPath->segs[0].x1 &&
xPath->segs[0].x0 == xPath->segs[1].x0 &&
xPath->segs[0].x0 == xPath->segs[3].x1 &&
xPath->segs[2].x0 == xPath->segs[2].x1 &&
xPath->segs[2].x0 == xPath->segs[1].x1 &&
xPath->segs[2].x0 == xPath->segs[3].x0 &&
xPath->segs[1].y0 == xPath->segs[1].y1 &&
xPath->segs[1].y0 == xPath->segs[0].y1 &&
xPath->segs[1].y0 == xPath->segs[2].y0 &&
xPath->segs[3].y0 == xPath->segs[3].y1 &&
xPath->segs[3].y0 == xPath->segs[0].y0 &&
xPath->segs[3].y0 == xPath->segs[2].y1) ||
(xPath->segs[0].y0 == xPath->segs[0].y1 &&
xPath->segs[0].y0 == xPath->segs[1].y0 &&
xPath->segs[0].y0 == xPath->segs[3].y1 &&
xPath->segs[2].y0 == xPath->segs[2].y1 &&
xPath->segs[2].y0 == xPath->segs[1].y1 &&
xPath->segs[2].y0 == xPath->segs[3].y0 &&
xPath->segs[1].x0 == xPath->segs[1].x1 &&
xPath->segs[1].x0 == xPath->segs[0].x1 &&
xPath->segs[1].x0 == xPath->segs[2].x0 &&
xPath->segs[3].x0 == xPath->segs[3].x1 &&
xPath->segs[3].x0 == xPath->segs[0].x0 &&
xPath->segs[3].x0 == xPath->segs[2].x1))) {
clipToRect(xPath->segs[0].x0, xPath->segs[0].y0,
xPath->segs[2].x0, xPath->segs[2].y0);
delete xPath;
} else {
grow(1);
xPath->sort();
paths[length] = xPath;
flags[length] = eo ? splashClipEO : 0;
scanners[length] = new SplashXPathScanner(xPath, eo);
++length;
}
return splashOk;
}
GBool SplashClip::test(int x, int y) {
int i;
// check the rectangle
if (x < xMin || x > xMax || y < yMin || y > yMax) {
return gFalse;
}
// check the paths
for (i = 0; i < length; ++i) {
if (!scanners[i]->test(x, y)) {
return gFalse;
}
}
return gTrue;
}
SplashClipResult SplashClip::testRect(int rectXMin, int rectYMin,
int rectXMax, int rectYMax) {
if (rectXMax < xMin || rectXMin > xMax ||
rectYMax < yMin || rectYMin > yMax) {
return splashClipAllOutside;
}
if (rectXMin >= xMin && rectXMax <= xMax &&
rectYMin >= yMin && rectYMax <= yMax &&
length == 0) {
return splashClipAllInside;
}
return splashClipPartial;
}
SplashClipResult SplashClip::testSpan(int spanXMin, int spanXMax, int spanY) {
int i;
if (spanXMax < xMin || spanXMin > xMax ||
spanY < yMin || spanY > yMax) {
return splashClipAllOutside;
}
if (!(spanXMin >= xMin && spanXMax <= xMax &&
spanY >= yMin && spanY <= yMax)) {
return splashClipPartial;
}
for (i = 0; i < length; ++i) {
if (!scanners[i]->testSpan(xMin, xMax, spanY)) {
return splashClipPartial;
}
}
return splashClipAllInside;
}
+97
Ver Arquivo
@@ -0,0 +1,97 @@
//========================================================================
//
// SplashClip.h
//
//========================================================================
#ifndef SPLASHCLIP_H
#define SPLASHCLIP_H
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "SplashTypes.h"
class SplashPath;
class SplashXPath;
class SplashXPathScanner;
//------------------------------------------------------------------------
enum SplashClipResult {
splashClipAllInside,
splashClipAllOutside,
splashClipPartial
};
//------------------------------------------------------------------------
// SplashClip
//------------------------------------------------------------------------
class SplashClip {
public:
// Create a clip, for the given rectangle.
SplashClip(SplashCoord x0, SplashCoord y0,
SplashCoord x1, SplashCoord y1);
// Copy a clip.
SplashClip *copy() { return new SplashClip(this); }
~SplashClip();
// Reset the clip to a rectangle.
void resetToRect(SplashCoord x0, SplashCoord y0,
SplashCoord x1, SplashCoord y1);
// Intersect the clip with a rectangle.
SplashError clipToRect(SplashCoord x0, SplashCoord y0,
SplashCoord x1, SplashCoord y1);
// Interesect the clip with <path>.
SplashError clipToPath(SplashPath *path, SplashCoord flatness,
GBool eo);
// Returns true if (<x>,<y>) is inside the clip.
GBool test(int x, int y);
// Tests a rectangle against the clipping region. Returns one of:
// - splashClipAllInside if the entire rectangle is inside the
// clipping region, i.e., all pixels in the rectangle are
// visible
// - splashClipAllOutside if the entire rectangle is outside the
// clipping region, i.e., all the pixels in the rectangle are
// clipped
// - splashClipPartial if the rectangle is part inside and part
// outside the clipping region
SplashClipResult testRect(int rectXMin, int rectYMin,
int rectXMax, int rectYMax);
// Similar to testRect, but tests a horizontal span.
SplashClipResult testSpan(int spanXMin, int spanXMax, int spanY);
// Get the rectangle part of the clip region.
int getXMin() { return xMin; }
int getXMax() { return xMax; }
int getYMin() { return yMin; }
int getYMax() { return yMax; }
// Get the number of arbitrary paths used by the clip region.
int getNumPaths() { return length; }
private:
SplashClip(SplashClip *clip);
void grow(int nPaths);
int xMin, yMin, xMax, yMax;
SplashXPath **paths;
Guchar *flags;
SplashXPathScanner **scanners;
int length, size;
};
#endif
+32
Ver Arquivo
@@ -0,0 +1,32 @@
//========================================================================
//
// SplashErrorCodes.h
//
//========================================================================
#ifndef SPLASHERRORCODES_H
#define SPLASHERRORCODES_H
#include <config.h>
//------------------------------------------------------------------------
#define splashOk 0 // no error
#define splashErrNoCurPt 1 // no current point
#define splashErrEmptyPath 2 // zero points in path
#define splashErrBogusPath 3 // only one point in subpath
#define splashErrNoSave 4 // state stack is empty
#define splashErrOpenFile 5 // couldn't open file
#define splashErrNoGlyph 6 // couldn't get the requested glyph
#define splashErrModeMismatch 7 // invalid combination of color modes
#define splashErrSingularMatrix 8 // matrix is singular
#endif
+320
Ver Arquivo
@@ -0,0 +1,320 @@
//========================================================================
//
// SplashFTFont.cc
//
//========================================================================
#include <config.h>
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <ft2build.h>
#include FT_OUTLINE_H
#include FT_INTERNAL_OBJECTS_H // needed for FT_New_Size decl
#include "gmem.h"
#include "SplashMath.h"
#include "SplashGlyphBitmap.h"
#include "SplashPath.h"
#include "SplashFTFontEngine.h"
#include "SplashFTFontFile.h"
#include "SplashFTFont.h"
//------------------------------------------------------------------------
static int glyphPathMoveTo(FT_Vector *pt, void *path);
static int glyphPathLineTo(FT_Vector *pt, void *path);
static int glyphPathConicTo(FT_Vector *ctrl, FT_Vector *pt, void *path);
static int glyphPathCubicTo(FT_Vector *ctrl1, FT_Vector *ctrl2,
FT_Vector *pt, void *path);
//------------------------------------------------------------------------
// SplashFTFont
//------------------------------------------------------------------------
SplashFTFont::SplashFTFont(SplashFTFontFile *fontFileA, SplashCoord *matA):
SplashFont(fontFileA, matA, fontFileA->engine->aa)
{
FT_Face face;
SplashCoord size, div;
int x, y;
face = fontFileA->face;
if (FT_New_Size(face, &sizeObj)) {
return;
}
face->size = sizeObj;
size = splashSqrt(mat[2]*mat[2] + mat[3]*mat[3]);
if (FT_Set_Pixel_Sizes(face, 0, (int)size)) {
return;
}
div = face->bbox.xMax > 20000 ? 65536 : 1;
// transform the four corners of the font bounding box -- the min
// and max values form the bounding box of the transformed font
x = (int)((mat[0] * face->bbox.xMin + mat[2] * face->bbox.yMin) /
(div * face->units_per_EM));
xMin = xMax = x;
y = (int)((mat[1] * face->bbox.xMin + mat[3] * face->bbox.yMin) /
(div * face->units_per_EM));
yMin = yMax = y;
x = (int)((mat[0] * face->bbox.xMin + mat[2] * face->bbox.yMax) /
(div * face->units_per_EM));
if (x < xMin) {
xMin = x;
} else if (x > xMax) {
xMax = x;
}
y = (int)((mat[1] * face->bbox.xMin + mat[3] * face->bbox.yMax) /
(div * face->units_per_EM));
if (y < yMin) {
yMin = y;
} else if (y > yMax) {
yMax = y;
}
x = (int)((mat[0] * face->bbox.xMax + mat[2] * face->bbox.yMin) /
(div * face->units_per_EM));
if (x < xMin) {
xMin = x;
} else if (x > xMax) {
xMax = x;
}
y = (int)((mat[1] * face->bbox.xMax + mat[3] * face->bbox.yMin) /
(div * face->units_per_EM));
if (y < yMin) {
yMin = y;
} else if (y > yMax) {
yMax = y;
}
x = (int)((mat[0] * face->bbox.xMax + mat[2] * face->bbox.yMax) /
(div * face->units_per_EM));
if (x < xMin) {
xMin = x;
} else if (x > xMax) {
xMax = x;
}
y = (int)((mat[1] * face->bbox.xMax + mat[3] * face->bbox.yMax) /
(div * face->units_per_EM));
if (y < yMin) {
yMin = y;
} else if (y > yMax) {
yMax = y;
}
// This is a kludge: some buggy PDF generators embed fonts with
// zero bounding boxes.
if (xMax == xMin) {
xMin = 0;
xMax = (int)size;
}
if (yMax == yMin) {
yMin = 0;
yMax = (int)((SplashCoord)1.2 * size);
}
// compute the transform matrix
#if USE_FIXEDPOINT
matrix.xx = (FT_Fixed)((mat[0] / size).getRaw());
matrix.yx = (FT_Fixed)((mat[1] / size).getRaw());
matrix.xy = (FT_Fixed)((mat[2] / size).getRaw());
matrix.yy = (FT_Fixed)((mat[3] / size).getRaw());
#else
matrix.xx = (FT_Fixed)((mat[0] / size) * 65536);
matrix.yx = (FT_Fixed)((mat[1] / size) * 65536);
matrix.xy = (FT_Fixed)((mat[2] / size) * 65536);
matrix.yy = (FT_Fixed)((mat[3] / size) * 65536);
#endif
}
SplashFTFont::~SplashFTFont() {
}
GBool SplashFTFont::getGlyph(int c, int xFrac, int yFrac,
SplashGlyphBitmap *bitmap) {
return SplashFont::getGlyph(c, xFrac, 0, bitmap);
}
GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac,
SplashGlyphBitmap *bitmap) {
SplashFTFontFile *ff;
FT_Vector offset;
FT_GlyphSlot slot;
FT_UInt gid;
int rowSize;
Guchar *p, *q;
int i;
ff = (SplashFTFontFile *)fontFile;
ff->face->size = sizeObj;
offset.x = (FT_Pos)(int)((SplashCoord)xFrac * splashFontFractionMul * 64);
offset.y = 0;
FT_Set_Transform(ff->face, &matrix, &offset);
slot = ff->face->glyph;
if (ff->codeToGID && c < ff->codeToGIDLen) {
gid = (FT_UInt)ff->codeToGID[c];
} else {
gid = (FT_UInt)c;
}
// if we have the FT2 bytecode interpreter, autohinting won't be used
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
if (FT_Load_Glyph(ff->face, gid,
aa ? FT_LOAD_NO_BITMAP : FT_LOAD_DEFAULT)) {
return gFalse;
}
#else
// FT2's autohinting doesn't always work very well (especially with
// font subsets), so turn it off if anti-aliasing is enabled; if
// anti-aliasing is disabled, this seems to be a tossup - some fonts
// look better with hinting, some without, so leave hinting on
if (FT_Load_Glyph(ff->face, gid,
aa ? FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP
: FT_LOAD_DEFAULT)) {
return gFalse;
}
#endif
if (FT_Render_Glyph(slot, aa ? ft_render_mode_normal
: ft_render_mode_mono)) {
return gFalse;
}
bitmap->x = -slot->bitmap_left;
bitmap->y = slot->bitmap_top;
bitmap->w = slot->bitmap.width;
bitmap->h = slot->bitmap.rows;
bitmap->aa = aa;
if (aa) {
rowSize = bitmap->w;
} else {
rowSize = (bitmap->w + 7) >> 3;
}
bitmap->data = (Guchar *)gmalloc(rowSize * bitmap->h);
bitmap->freeData = gTrue;
for (i = 0, p = bitmap->data, q = slot->bitmap.buffer;
i < bitmap->h;
++i, p += rowSize, q += slot->bitmap.pitch) {
memcpy(p, q, rowSize);
}
return gTrue;
}
struct SplashFTFontPath {
SplashPath *path;
GBool needClose;
};
SplashPath *SplashFTFont::getGlyphPath(int c) {
static FT_Outline_Funcs outlineFuncs = {
&glyphPathMoveTo,
&glyphPathLineTo,
&glyphPathConicTo,
&glyphPathCubicTo,
0, 0
};
SplashFTFontFile *ff;
SplashFTFontPath path;
FT_GlyphSlot slot;
FT_UInt gid;
FT_Glyph glyph;
ff = (SplashFTFontFile *)fontFile;
ff->face->size = sizeObj;
FT_Set_Transform(ff->face, &matrix, NULL);
slot = ff->face->glyph;
if (ff->codeToGID && c < ff->codeToGIDLen) {
gid = ff->codeToGID[c];
} else {
gid = (FT_UInt)c;
}
if (FT_Load_Glyph(ff->face, gid, FT_LOAD_NO_BITMAP)) {
return NULL;
}
if (FT_Get_Glyph(slot, &glyph)) {
return NULL;
}
path.path = new SplashPath();
path.needClose = gFalse;
FT_Outline_Decompose(&((FT_OutlineGlyph)glyph)->outline,
&outlineFuncs, &path);
if (path.needClose) {
path.path->close();
}
FT_Done_Glyph(glyph);
return path.path;
}
static int glyphPathMoveTo(FT_Vector *pt, void *path) {
SplashFTFontPath *p = (SplashFTFontPath *)path;
if (p->needClose) {
p->path->close();
p->needClose = gFalse;
}
p->path->moveTo(pt->x / 64.0, -pt->y / 64.0);
return 0;
}
static int glyphPathLineTo(FT_Vector *pt, void *path) {
SplashFTFontPath *p = (SplashFTFontPath *)path;
p->path->lineTo(pt->x / 64.0, -pt->y / 64.0);
p->needClose = gTrue;
return 0;
}
static int glyphPathConicTo(FT_Vector *ctrl, FT_Vector *pt, void *path) {
SplashFTFontPath *p = (SplashFTFontPath *)path;
SplashCoord x0, y0, x1, y1, x2, y2, x3, y3, xc, yc;
if (!p->path->getCurPt(&x0, &y0)) {
return 0;
}
xc = ctrl->x / 64.0;
yc = -ctrl->y / 64.0;
x3 = pt->x / 64.0;
y3 = -pt->y / 64.0;
// A second-order Bezier curve is defined by two endpoints, p0 and
// p3, and one control point, pc:
//
// p(t) = (1-t)^2*p0 + t*(1-t)*pc + t^2*p3
//
// A third-order Bezier curve is defined by the same two endpoints,
// p0 and p3, and two control points, p1 and p2:
//
// p(t) = (1-t)^3*p0 + 3t*(1-t)^2*p1 + 3t^2*(1-t)*p2 + t^3*p3
//
// Applying some algebra, we can convert a second-order curve to a
// third-order curve:
//
// p1 = (1/3) * (p0 + 2pc)
// p2 = (1/3) * (2pc + p3)
x1 = (SplashCoord)(1.0 / 3.0) * (x0 + (SplashCoord)2 * xc);
y1 = (SplashCoord)(1.0 / 3.0) * (y0 + (SplashCoord)2 * yc);
x2 = (SplashCoord)(1.0 / 3.0) * ((SplashCoord)2 * xc + x3);
y2 = (SplashCoord)(1.0 / 3.0) * ((SplashCoord)2 * yc + y3);
p->path->curveTo(x1, y1, x2, y2, x3, y3);
p->needClose = gTrue;
return 0;
}
static int glyphPathCubicTo(FT_Vector *ctrl1, FT_Vector *ctrl2,
FT_Vector *pt, void *path) {
SplashFTFontPath *p = (SplashFTFontPath *)path;
p->path->curveTo(ctrl1->x / 64.0, -ctrl1->y / 64.0,
ctrl2->x / 64.0, -ctrl2->y / 64.0,
pt->x / 64.0, -pt->y / 64.0);
p->needClose = gTrue;
return 0;
}
#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+55
Ver Arquivo
@@ -0,0 +1,55 @@
//========================================================================
//
// SplashFTFont.h
//
//========================================================================
#ifndef SPLASHFTFONT_H
#define SPLASHFTFONT_H
#include <config.h>
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include <ft2build.h>
#include FT_FREETYPE_H
#include "SplashFont.h"
class SplashFTFontFile;
//------------------------------------------------------------------------
// SplashFTFont
//------------------------------------------------------------------------
class SplashFTFont: public SplashFont {
public:
SplashFTFont(SplashFTFontFile *fontFileA, SplashCoord *matA);
virtual ~SplashFTFont();
// Munge xFrac and yFrac before calling SplashFont::getGlyph.
virtual GBool getGlyph(int c, int xFrac, int yFrac,
SplashGlyphBitmap *bitmap);
// Rasterize a glyph. The <xFrac> and <yFrac> values are the same
// as described for getGlyph.
virtual GBool makeGlyph(int c, int xFrac, int yFrac,
SplashGlyphBitmap *bitmap);
// Return the path for a glyph.
virtual SplashPath *getGlyphPath(int c);
private:
FT_Size sizeObj;
FT_Matrix matrix;
};
#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
#endif
+144
Ver Arquivo
@@ -0,0 +1,144 @@
//========================================================================
//
// SplashFTFontEngine.cc
//
//========================================================================
#include <config.h>
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdio.h>
#ifndef WIN32
# include <unistd.h>
#endif
#include "gmem.h"
#include "GString.h"
#include "gfile.h"
#include "FoFiTrueType.h"
#include "FoFiType1C.h"
#include "SplashFTFontFile.h"
#include "SplashFTFontEngine.h"
#ifdef VMS
#if (__VMS_VER < 70000000)
extern "C" int unlink(char *filename);
#endif
#endif
//------------------------------------------------------------------------
static void fileWrite(void *stream, char *data, int len) {
fwrite(data, 1, len, (FILE *)stream);
}
//------------------------------------------------------------------------
// SplashFTFontEngine
//------------------------------------------------------------------------
SplashFTFontEngine::SplashFTFontEngine(GBool aaA, FT_Library libA) {
FT_Int major, minor, patch;
aa = aaA;
lib = libA;
// as of FT 2.1.8, CID fonts are indexed by CID instead of GID
FT_Library_Version(lib, &major, &minor, &patch);
useCIDs = major > 2 ||
(major == 2 && (minor > 1 || (minor == 1 && patch > 7)));
}
SplashFTFontEngine *SplashFTFontEngine::init(GBool aaA) {
FT_Library libA;
if (FT_Init_FreeType(&libA)) {
return NULL;
}
return new SplashFTFontEngine(aaA, libA);
}
SplashFTFontEngine::~SplashFTFontEngine() {
FT_Done_FreeType(lib);
}
SplashFontFile *SplashFTFontEngine::loadType1Font(SplashFontFileID *idA,
char *fileName,
GBool deleteFile,
char **enc) {
return SplashFTFontFile::loadType1Font(this, idA, fileName, deleteFile, enc);
}
SplashFontFile *SplashFTFontEngine::loadType1CFont(SplashFontFileID *idA,
char *fileName,
GBool deleteFile,
char **enc) {
return SplashFTFontFile::loadType1Font(this, idA, fileName, deleteFile, enc);
}
SplashFontFile *SplashFTFontEngine::loadCIDFont(SplashFontFileID *idA,
char *fileName,
GBool deleteFile) {
FoFiType1C *ff;
Gushort *cidToGIDMap;
int nCIDs;
SplashFontFile *ret;
// check for a CFF font
if (useCIDs) {
cidToGIDMap = NULL;
nCIDs = 0;
} else if ((ff = FoFiType1C::load(fileName))) {
cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
delete ff;
} else {
cidToGIDMap = NULL;
nCIDs = 0;
}
ret = SplashFTFontFile::loadCIDFont(this, idA, fileName, deleteFile,
cidToGIDMap, nCIDs);
if (!ret) {
gfree(cidToGIDMap);
}
return ret;
}
SplashFontFile *SplashFTFontEngine::loadTrueTypeFont(SplashFontFileID *idA,
char *fileName,
GBool deleteFile,
Gushort *codeToGID,
int codeToGIDLen) {
FoFiTrueType *ff;
GString *tmpFileName;
FILE *tmpFile;
SplashFontFile *ret;
if (!(ff = FoFiTrueType::load(fileName))) {
return NULL;
}
tmpFileName = NULL;
if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) {
delete ff;
return NULL;
}
ff->writeTTF(&fileWrite, tmpFile);
delete ff;
fclose(tmpFile);
ret = SplashFTFontFile::loadTrueTypeFont(this, idA,
tmpFileName->getCString(),
gTrue, codeToGID, codeToGIDLen);
if (ret) {
if (deleteFile) {
unlink(fileName);
}
} else {
unlink(tmpFileName->getCString());
}
delete tmpFileName;
return ret;
}
#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+61
Ver Arquivo
@@ -0,0 +1,61 @@
//========================================================================
//
// SplashFTFontEngine.h
//
//========================================================================
#ifndef SPLASHFTFONTENGINE_H
#define SPLASHFTFONTENGINE_H
#include <config.h>
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include <ft2build.h>
#include FT_FREETYPE_H
#include "gtypes.h"
class SplashFontFile;
class SplashFontFileID;
//------------------------------------------------------------------------
// SplashFTFontEngine
//------------------------------------------------------------------------
class SplashFTFontEngine {
public:
static SplashFTFontEngine *init(GBool aaA);
~SplashFTFontEngine();
// Load fonts.
SplashFontFile *loadType1Font(SplashFontFileID *idA, char *fileName,
GBool deleteFile, char **enc);
SplashFontFile *loadType1CFont(SplashFontFileID *idA, char *fileName,
GBool deleteFile, char **enc);
SplashFontFile *loadCIDFont(SplashFontFileID *idA, char *fileName,
GBool deleteFile);
SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, char *fileName,
GBool deleteFile,
Gushort *codeToGID, int codeToGIDLen);
private:
SplashFTFontEngine(GBool aaA, FT_Library libA);
GBool aa;
FT_Library lib;
GBool useCIDs;
friend class SplashFTFontFile;
friend class SplashFTFont;
};
#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
#endif
+111
Ver Arquivo
@@ -0,0 +1,111 @@
//========================================================================
//
// SplashFTFontFile.cc
//
//========================================================================
#include <config.h>
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include "gmem.h"
#include "SplashFTFontEngine.h"
#include "SplashFTFont.h"
#include "SplashFTFontFile.h"
//------------------------------------------------------------------------
// SplashFTFontFile
//------------------------------------------------------------------------
SplashFontFile *SplashFTFontFile::loadType1Font(SplashFTFontEngine *engineA,
SplashFontFileID *idA,
char *fileNameA,
GBool deleteFileA,
char **encA) {
FT_Face faceA;
Gushort *codeToGIDA;
char *name;
int i;
if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) {
return NULL;
}
codeToGIDA = (Gushort *)gmallocn(256, sizeof(int));
for (i = 0; i < 256; ++i) {
codeToGIDA[i] = 0;
if ((name = encA[i])) {
codeToGIDA[i] = (Gushort)FT_Get_Name_Index(faceA, name);
}
}
return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA,
faceA, codeToGIDA, 256);
}
SplashFontFile *SplashFTFontFile::loadCIDFont(SplashFTFontEngine *engineA,
SplashFontFileID *idA,
char *fileNameA,
GBool deleteFileA,
Gushort *codeToGIDA,
int codeToGIDLenA) {
FT_Face faceA;
if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) {
return NULL;
}
return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA,
faceA, codeToGIDA, codeToGIDLenA);
}
SplashFontFile *SplashFTFontFile::loadTrueTypeFont(SplashFTFontEngine *engineA,
SplashFontFileID *idA,
char *fileNameA,
GBool deleteFileA,
Gushort *codeToGIDA,
int codeToGIDLenA) {
FT_Face faceA;
if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) {
return NULL;
}
return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA,
faceA, codeToGIDA, codeToGIDLenA);
}
SplashFTFontFile::SplashFTFontFile(SplashFTFontEngine *engineA,
SplashFontFileID *idA,
char *fileNameA, GBool deleteFileA,
FT_Face faceA,
Gushort *codeToGIDA, int codeToGIDLenA):
SplashFontFile(idA, fileNameA, deleteFileA)
{
engine = engineA;
face = faceA;
codeToGID = codeToGIDA;
codeToGIDLen = codeToGIDLenA;
}
SplashFTFontFile::~SplashFTFontFile() {
if (face) {
FT_Done_Face(face);
}
if (codeToGID) {
gfree(codeToGID);
}
}
SplashFont *SplashFTFontFile::makeFont(SplashCoord *mat) {
SplashFont *font;
font = new SplashFTFont(this, mat);
font->initCache();
return font;
}
#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+70
Ver Arquivo
@@ -0,0 +1,70 @@
//========================================================================
//
// SplashFTFontFile.h
//
//========================================================================
#ifndef SPLASHFTFONTFILE_H
#define SPLASHFTFONTFILE_H
#include <config.h>
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include <ft2build.h>
#include FT_FREETYPE_H
#include "SplashFontFile.h"
class SplashFontFileID;
class SplashFTFontEngine;
//------------------------------------------------------------------------
// SplashFTFontFile
//------------------------------------------------------------------------
class SplashFTFontFile: public SplashFontFile {
public:
static SplashFontFile *loadType1Font(SplashFTFontEngine *engineA,
SplashFontFileID *idA, char *fileNameA,
GBool deleteFileA, char **encA);
static SplashFontFile *loadCIDFont(SplashFTFontEngine *engineA,
SplashFontFileID *idA, char *fileNameA,
GBool deleteFileA,
Gushort *codeToCIDA, int codeToGIDLenA);
static SplashFontFile *loadTrueTypeFont(SplashFTFontEngine *engineA,
SplashFontFileID *idA,
char *fileNameA,
GBool deleteFileA,
Gushort *codeToGIDA,
int codeToGIDLenA);
virtual ~SplashFTFontFile();
// Create a new SplashFTFont, i.e., a scaled instance of this font
// file.
virtual SplashFont *makeFont(SplashCoord *mat);
private:
SplashFTFontFile(SplashFTFontEngine *engineA,
SplashFontFileID *idA,
char *fileNameA, GBool deleteFileA,
FT_Face faceA,
Gushort *codeToGIDA, int codeToGIDLenA);
SplashFTFontEngine *engine;
FT_Face face;
Gushort *codeToGID;
int codeToGIDLen;
friend class SplashFTFont;
};
#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
#endif
+172
Ver Arquivo
@@ -0,0 +1,172 @@
//========================================================================
//
// SplashFont.cc
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <string.h>
#include "gmem.h"
#include "SplashMath.h"
#include "SplashGlyphBitmap.h"
#include "SplashFontFile.h"
#include "SplashFont.h"
//------------------------------------------------------------------------
struct SplashFontCacheTag {
int c;
short xFrac, yFrac; // x and y fractions
int mru; // valid bit (0x80000000) and MRU index
int x, y, w, h; // offset and size of glyph
};
//------------------------------------------------------------------------
// SplashFont
//------------------------------------------------------------------------
SplashFont::SplashFont(SplashFontFile *fontFileA, SplashCoord *matA,
GBool aaA) {
fontFile = fontFileA;
fontFile->incRefCnt();
mat[0] = matA[0];
mat[1] = matA[1];
mat[2] = matA[2];
mat[3] = matA[3];
aa = aaA;
cache = NULL;
cacheTags = NULL;
xMin = yMin = xMax = yMax = 0;
}
void SplashFont::initCache() {
int i;
// this should be (max - min + 1), but we add some padding to
// deal with rounding errors
glyphW = xMax - xMin + 3;
glyphH = yMax - yMin + 3;
if (aa) {
glyphSize = glyphW * glyphH;
} else {
glyphSize = ((glyphW + 7) >> 3) * glyphH;
}
// set up the glyph pixmap cache
cacheAssoc = 8;
if (glyphSize <= 256) {
cacheSets = 8;
} else if (glyphSize <= 512) {
cacheSets = 4;
} else if (glyphSize <= 1024) {
cacheSets = 2;
} else {
cacheSets = 1;
}
cache = (Guchar *)gmallocn(cacheSets* cacheAssoc, glyphSize);
cacheTags = (SplashFontCacheTag *)gmallocn(cacheSets * cacheAssoc,
sizeof(SplashFontCacheTag));
for (i = 0; i < cacheSets * cacheAssoc; ++i) {
cacheTags[i].mru = i & (cacheAssoc - 1);
}
}
SplashFont::~SplashFont() {
fontFile->decRefCnt();
if (cache) {
gfree(cache);
}
if (cacheTags) {
gfree(cacheTags);
}
}
GBool SplashFont::getGlyph(int c, int xFrac, int yFrac,
SplashGlyphBitmap *bitmap) {
SplashGlyphBitmap bitmap2;
int size;
Guchar *p;
int i, j, k;
// no fractional coordinates for large glyphs or non-anti-aliased
// glyphs
if (!aa || glyphH > 50) {
xFrac = yFrac = 0;
}
// check the cache
i = (c & (cacheSets - 1)) * cacheAssoc;
for (j = 0; j < cacheAssoc; ++j) {
if ((cacheTags[i+j].mru & 0x80000000) &&
cacheTags[i+j].c == c &&
(int)cacheTags[i+j].xFrac == xFrac &&
(int)cacheTags[i+j].yFrac == yFrac) {
bitmap->x = cacheTags[i+j].x;
bitmap->y = cacheTags[i+j].y;
bitmap->w = cacheTags[i+j].w;
bitmap->h = cacheTags[i+j].h;
for (k = 0; k < cacheAssoc; ++k) {
if (k != j &&
(cacheTags[i+k].mru & 0x7fffffff) <
(cacheTags[i+j].mru & 0x7fffffff)) {
++cacheTags[i+k].mru;
}
}
cacheTags[i+j].mru = 0x80000000;
bitmap->aa = aa;
bitmap->data = cache + (i+j) * glyphSize;
bitmap->freeData = gFalse;
return gTrue;
}
}
// generate the glyph bitmap
if (!makeGlyph(c, xFrac, yFrac, &bitmap2)) {
return gFalse;
}
// if the glyph doesn't fit in the bounding box, return a temporary
// uncached bitmap
if (bitmap2.w > glyphW || bitmap2.h > glyphH) {
*bitmap = bitmap2;
return gTrue;
}
// insert glyph pixmap in cache
if (aa) {
size = bitmap2.w * bitmap2.h;
} else {
size = ((bitmap2.w + 7) >> 3) * bitmap2.h;
}
p = NULL; // make gcc happy
for (j = 0; j < cacheAssoc; ++j) {
if ((cacheTags[i+j].mru & 0x7fffffff) == cacheAssoc - 1) {
cacheTags[i+j].mru = 0x80000000;
cacheTags[i+j].c = c;
cacheTags[i+j].xFrac = (short)xFrac;
cacheTags[i+j].yFrac = (short)yFrac;
cacheTags[i+j].x = bitmap2.x;
cacheTags[i+j].y = bitmap2.y;
cacheTags[i+j].w = bitmap2.w;
cacheTags[i+j].h = bitmap2.h;
p = cache + (i+j) * glyphSize;
memcpy(p, bitmap2.data, size);
} else {
++cacheTags[i+j].mru;
}
}
*bitmap = bitmap2;
bitmap->data = p;
bitmap->freeData = gFalse;
if (bitmap2.freeData) {
gfree(bitmap2.data);
}
return gTrue;
}
+97
Ver Arquivo
@@ -0,0 +1,97 @@
//========================================================================
//
// SplashFont.h
//
//========================================================================
#ifndef SPLASHFONT_H
#define SPLASHFONT_H
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "gtypes.h"
#include "SplashTypes.h"
struct SplashGlyphBitmap;
struct SplashFontCacheTag;
class SplashFontFile;
class SplashPath;
//------------------------------------------------------------------------
// Fractional positioning uses this many bits to the right of the
// decimal points.
#define splashFontFractionBits 2
#define splashFontFraction (1 << splashFontFractionBits)
#define splashFontFractionMul \
((SplashCoord)1 / (SplashCoord)splashFontFraction)
//------------------------------------------------------------------------
// SplashFont
//------------------------------------------------------------------------
class SplashFont {
public:
SplashFont(SplashFontFile *fontFileA, SplashCoord *matA, GBool aaA);
// This must be called after the constructor, so that the subclass
// constructor has a chance to compute the bbox.
void initCache();
virtual ~SplashFont();
SplashFontFile *getFontFile() { return fontFile; }
// Return true if <this> matches the specified font file and matrix.
GBool matches(SplashFontFile *fontFileA, SplashCoord *matA) {
return fontFileA == fontFile &&
matA[0] == mat[0] && matA[1] == mat[1] &&
matA[2] == mat[2] && matA[3] == mat[3];
}
// Get a glyph - this does a cache lookup first, and if not found,
// creates a new bitmap and adds it to the cache. The <xFrac> and
// <yFrac> values are splashFontFractionBits bits each, representing
// the numerators of fractions in [0, 1), where the denominator is
// splashFontFraction = 1 << splashFontFractionBits. Subclasses
// should override this to zero out xFrac and/or yFrac if they don't
// support fractional coordinates.
virtual GBool getGlyph(int c, int xFrac, int yFrac,
SplashGlyphBitmap *bitmap);
// Rasterize a glyph. The <xFrac> and <yFrac> values are the same
// as described for getGlyph.
virtual GBool makeGlyph(int c, int xFrac, int yFrac,
SplashGlyphBitmap *bitmap) = 0;
// Return the path for a glyph.
virtual SplashPath *getGlyphPath(int c) = 0;
// Return the font transform matrix.
SplashCoord *getMatrix() { return mat; }
// Return the glyph bounding box.
void getBBox(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA)
{ *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; }
protected:
SplashFontFile *fontFile;
SplashCoord mat[4]; // font transform matrix
GBool aa; // anti-aliasing
int xMin, yMin, xMax, yMax; // glyph bounding box
Guchar *cache; // glyph bitmap cache
SplashFontCacheTag * // cache tags
cacheTags;
int glyphW, glyphH; // size of glyph bitmaps
int glyphSize; // size of glyph bitmaps, in bytes
int cacheSets; // number of sets in cache
int cacheAssoc; // cache associativity (glyphs per set)
};
#endif
+253
Ver Arquivo
@@ -0,0 +1,253 @@
//========================================================================
//
// SplashFontEngine.cc
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#if HAVE_T1LIB_H
#include <t1lib.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#ifndef WIN32
# include <unistd.h>
#endif
#include "gmem.h"
#include "GString.h"
#include "SplashT1FontEngine.h"
#include "SplashFTFontEngine.h"
#include "SplashFontFile.h"
#include "SplashFontFileID.h"
#include "SplashFont.h"
#include "SplashFontEngine.h"
#ifdef VMS
#if (__VMS_VER < 70000000)
extern "C" int unlink(char *filename);
#endif
#endif
//------------------------------------------------------------------------
// SplashFontEngine
//------------------------------------------------------------------------
SplashFontEngine::SplashFontEngine(
#if HAVE_T1LIB_H
GBool enableT1lib,
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
GBool enableFreeType,
#endif
GBool aa) {
int i;
for (i = 0; i < splashFontCacheSize; ++i) {
fontCache[i] = NULL;
}
#if HAVE_T1LIB_H
if (enableT1lib) {
t1Engine = SplashT1FontEngine::init(aa);
} else {
t1Engine = NULL;
}
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
if (enableFreeType) {
ftEngine = SplashFTFontEngine::init(aa);
} else {
ftEngine = NULL;
}
#endif
}
SplashFontEngine::~SplashFontEngine() {
int i;
for (i = 0; i < splashFontCacheSize; ++i) {
if (fontCache[i]) {
delete fontCache[i];
}
}
#if HAVE_T1LIB_H
if (t1Engine) {
delete t1Engine;
}
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
if (ftEngine) {
delete ftEngine;
}
#endif
}
SplashFontFile *SplashFontEngine::getFontFile(SplashFontFileID *id) {
SplashFontFile *fontFile;
int i;
for (i = 0; i < splashFontCacheSize; ++i) {
if (fontCache[i]) {
fontFile = fontCache[i]->getFontFile();
if (fontFile && fontFile->getID()->matches(id)) {
return fontFile;
}
}
}
return NULL;
}
SplashFontFile *SplashFontEngine::loadType1Font(SplashFontFileID *idA,
char *fileName,
GBool deleteFile, char **enc) {
SplashFontFile *fontFile;
fontFile = NULL;
#if HAVE_T1LIB_H
if (!fontFile && t1Engine) {
fontFile = t1Engine->loadType1Font(idA, fileName, deleteFile, enc);
}
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
if (!fontFile && ftEngine) {
fontFile = ftEngine->loadType1Font(idA, fileName, deleteFile, enc);
}
#endif
#ifndef WIN32
// delete the (temporary) font file -- with Unix hard link
// semantics, this will remove the last link; otherwise it will
// return an error, leaving the file to be deleted later (if
// loadXYZFont failed, the file will always be deleted)
if (deleteFile) {
unlink(fontFile ? fontFile->fileName->getCString() : fileName);
}
#endif
return fontFile;
}
SplashFontFile *SplashFontEngine::loadType1CFont(SplashFontFileID *idA,
char *fileName,
GBool deleteFile,
char **enc) {
SplashFontFile *fontFile;
fontFile = NULL;
#if HAVE_T1LIB_H
if (!fontFile && t1Engine) {
fontFile = t1Engine->loadType1CFont(idA, fileName, deleteFile, enc);
}
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
if (!fontFile && ftEngine) {
fontFile = ftEngine->loadType1CFont(idA, fileName, deleteFile, enc);
}
#endif
#ifndef WIN32
// delete the (temporary) font file -- with Unix hard link
// semantics, this will remove the last link; otherwise it will
// return an error, leaving the file to be deleted later (if
// loadXYZFont failed, the file will always be deleted)
if (deleteFile) {
unlink(fontFile ? fontFile->fileName->getCString() : fileName);
}
#endif
return fontFile;
}
SplashFontFile *SplashFontEngine::loadCIDFont(SplashFontFileID *idA,
char *fileName,
GBool deleteFile) {
SplashFontFile *fontFile;
fontFile = NULL;
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
if (!fontFile && ftEngine) {
fontFile = ftEngine->loadCIDFont(idA, fileName, deleteFile);
}
#endif
#ifndef WIN32
// delete the (temporary) font file -- with Unix hard link
// semantics, this will remove the last link; otherwise it will
// return an error, leaving the file to be deleted later (if
// loadXYZFont failed, the file will always be deleted)
if (deleteFile) {
unlink(fontFile ? fontFile->fileName->getCString() : fileName);
}
#endif
return fontFile;
}
SplashFontFile *SplashFontEngine::loadTrueTypeFont(SplashFontFileID *idA,
char *fileName,
GBool deleteFile,
Gushort *codeToGID,
int codeToGIDLen) {
SplashFontFile *fontFile;
fontFile = NULL;
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
if (!fontFile && ftEngine) {
fontFile = ftEngine->loadTrueTypeFont(idA, fileName, deleteFile,
codeToGID, codeToGIDLen);
}
#endif
if (!fontFile) {
gfree(codeToGID);
}
#ifndef WIN32
// delete the (temporary) font file -- with Unix hard link
// semantics, this will remove the last link; otherwise it will
// return an error, leaving the file to be deleted later (if
// loadXYZFont failed, the file will always be deleted)
if (deleteFile) {
unlink(fontFile ? fontFile->fileName->getCString() : fileName);
}
#endif
return fontFile;
}
SplashFont *SplashFontEngine::getFont(SplashFontFile *fontFile,
SplashCoord *mat) {
SplashFont *font;
int i, j;
font = fontCache[0];
if (font && font->matches(fontFile, mat)) {
return font;
}
for (i = 1; i < splashFontCacheSize; ++i) {
font = fontCache[i];
if (font && font->matches(fontFile, mat)) {
for (j = i; j > 0; --j) {
fontCache[j] = fontCache[j-1];
}
fontCache[0] = font;
return font;
}
}
font = fontFile->makeFont(mat);
if (fontCache[splashFontCacheSize - 1]) {
delete fontCache[splashFontCacheSize - 1];
}
for (j = splashFontCacheSize - 1; j > 0; --j) {
fontCache[j] = fontCache[j-1];
}
fontCache[0] = font;
return font;
}
+86
Ver Arquivo
@@ -0,0 +1,86 @@
//========================================================================
//
// SplashFontEngine.h
//
//========================================================================
#ifndef SPLASHFONTENGINE_H
#define SPLASHFONTENGINE_H
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "gtypes.h"
class SplashT1FontEngine;
class SplashFTFontEngine;
class SplashDTFontEngine;
class SplashDT4FontEngine;
class SplashFontFile;
class SplashFontFileID;
class SplashFont;
//------------------------------------------------------------------------
#define splashFontCacheSize 16
//------------------------------------------------------------------------
// SplashFontEngine
//------------------------------------------------------------------------
class SplashFontEngine {
public:
// Create a font engine.
SplashFontEngine(
#if HAVE_T1LIB_H
GBool enableT1lib,
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
GBool enableFreeType,
#endif
GBool aa);
~SplashFontEngine();
// Get a font file from the cache. Returns NULL if there is no
// matching entry in the cache.
SplashFontFile *getFontFile(SplashFontFileID *id);
// Load fonts - these create new SplashFontFile objects.
SplashFontFile *loadType1Font(SplashFontFileID *idA, char *fileName,
GBool deleteFile, char **enc);
SplashFontFile *loadType1CFont(SplashFontFileID *idA, char *fileName,
GBool deleteFile, char **enc);
SplashFontFile *loadCIDFont(SplashFontFileID *idA, char *fileName,
GBool deleteFile);
SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, char *fileName,
GBool deleteFile,
Gushort *codeToGID, int codeToGIDLen);
// Get a font - this does a cache lookup first, and if not found,
// creates a new SplashFont object and adds it to the cache. The
// matrix:
// [ mat[0] mat[1] ]
// [ mat[2] mat[3] ]
// specifies the font transform in PostScript style:
// [x' y'] = [x y] * mat
// Note that the Splash y axis points downward.
SplashFont *getFont(SplashFontFile *fontFile, SplashCoord *mat);
private:
SplashFont *fontCache[splashFontCacheSize];
#if HAVE_T1LIB_H
SplashT1FontEngine *t1Engine;
#endif
#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
SplashFTFontEngine *ftEngine;
#endif
};
#endif
+55
Ver Arquivo
@@ -0,0 +1,55 @@
//========================================================================
//
// SplashFontFile.cc
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdio.h>
#ifndef WIN32
# include <unistd.h>
#endif
#include "GString.h"
#include "SplashFontFile.h"
#include "SplashFontFileID.h"
#ifdef VMS
#if (__VMS_VER < 70000000)
extern "C" int unlink(char *filename);
#endif
#endif
//------------------------------------------------------------------------
// SplashFontFile
//------------------------------------------------------------------------
SplashFontFile::SplashFontFile(SplashFontFileID *idA, char *fileNameA,
GBool deleteFileA) {
id = idA;
fileName = new GString(fileNameA);
deleteFile = deleteFileA;
refCnt = 0;
}
SplashFontFile::~SplashFontFile() {
if (deleteFile) {
unlink(fileName->getCString());
}
delete fileName;
delete id;
}
void SplashFontFile::incRefCnt() {
++refCnt;
}
void SplashFontFile::decRefCnt() {
if (!--refCnt) {
delete this;
}
}
+60
Ver Arquivo
@@ -0,0 +1,60 @@
//========================================================================
//
// SplashFontFile.h
//
//========================================================================
#ifndef SPLASHFONTFILE_H
#define SPLASHFONTFILE_H
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "gtypes.h"
#include "SplashTypes.h"
class GString;
class SplashFontEngine;
class SplashFont;
class SplashFontFileID;
//------------------------------------------------------------------------
// SplashFontFile
//------------------------------------------------------------------------
class SplashFontFile {
public:
virtual ~SplashFontFile();
// Create a new SplashFont, i.e., a scaled instance of this font
// file.
virtual SplashFont *makeFont(SplashCoord *mat) = 0;
// Get the font file ID.
SplashFontFileID *getID() { return id; }
// Increment the reference count.
void incRefCnt();
// Decrement the reference count. If the new value is zero, delete
// the SplashFontFile object.
void decRefCnt();
protected:
SplashFontFile(SplashFontFileID *idA, char *fileNameA,
GBool deleteFileA);
SplashFontFileID *id;
GString *fileName;
GBool deleteFile;
int refCnt;
friend class SplashFontEngine;
};
#endif
+23
Ver Arquivo
@@ -0,0 +1,23 @@
//========================================================================
//
// SplashFontFileID.cc
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include "SplashFontFileID.h"
//------------------------------------------------------------------------
// SplashFontFileID
//------------------------------------------------------------------------
SplashFontFileID::SplashFontFileID() {
}
SplashFontFileID::~SplashFontFileID() {
}
+30
Ver Arquivo
@@ -0,0 +1,30 @@
//========================================================================
//
// SplashFontFileID.h
//
//========================================================================
#ifndef SPLASHFONTFILEID_H
#define SPLASHFONTFILEID_H
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "gtypes.h"
//------------------------------------------------------------------------
// SplashFontFileID
//------------------------------------------------------------------------
class SplashFontFileID {
public:
SplashFontFileID();
virtual ~SplashFontFileID();
virtual GBool matches(SplashFontFileID *id) = 0;
};
#endif
+26
Ver Arquivo
@@ -0,0 +1,26 @@
//========================================================================
//
// SplashGlyphBitmap.h
//
//========================================================================
#ifndef SPLASHGLYPHBITMAP_H
#define SPLASHGLYPHBITMAP_H
#include <config.h>
#include "gtypes.h"
//------------------------------------------------------------------------
// SplashGlyphBitmap
//------------------------------------------------------------------------
struct SplashGlyphBitmap {
int x, y, w, h; // offset and size of glyph
GBool aa; // anti-aliased: true means 8-bit alpha
// bitmap; false means 1-bit
Guchar *data; // bitmap data
GBool freeData; // true if data memory should be freed
};
#endif
+78
Ver Arquivo
@@ -0,0 +1,78 @@
//========================================================================
//
// SplashMath.h
//
//========================================================================
#ifndef SPLASHMATH_H
#define SPLASHMATH_H
#include <config.h>
#if USE_FIXEDPONT
#include "FixedPoint.h"
#else
#include <math.h>
#endif
#include "SplashTypes.h"
static inline SplashCoord splashAbs(SplashCoord x) {
#if USE_FIXEDPOINT
return FixedPoint::abs(x);
#else
return fabs(x);
#endif
}
static inline int splashFloor(SplashCoord x) {
#if USE_FIXEDPOINT
return FixedPoint::floor(x);
#else
return (int)floor(x);
#endif
}
static inline int splashCeil(SplashCoord x) {
#if USE_FIXEDPOINT
return FixedPoint::ceil(x);
#else
return (int)ceil(x);
#endif
}
static inline int splashRound(SplashCoord x) {
#if USE_FIXEDPOINT
return FixedPoint::round(x);
#else
return (int)floor(x + 0.5);
#endif
}
static inline SplashCoord splashSqrt(SplashCoord x) {
#if USE_FIXEDPOINT
return FixedPoint::sqrt(x);
#else
return sqrt(x);
#endif
}
static inline SplashCoord splashPow(SplashCoord x, SplashCoord y) {
#if USE_FIXEDPOINT
return FixedPoint::pow(x, y);
#else
return pow(x, y);
#endif
}
static inline SplashCoord splashDist(SplashCoord x0, SplashCoord y0,
SplashCoord x1, SplashCoord y1) {
SplashCoord dx, dy;
dx = x1 - x0;
dy = y1 - y0;
#if USE_FIXEDPOINT
return FixedPoint::sqrt(dx * dx + dy * dy);
#else
return sqrt(dx * dx + dy * dy);
#endif
}
#endif
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+222
Ver Arquivo
@@ -0,0 +1,222 @@
//========================================================================
//
// SplashOutputDev.h
//
// Copyright 2003 Glyph & Cog, LLC
//
//========================================================================
#ifndef SPLASHOUTPUTDEV_H
#define SPLASHOUTPUTDEV_H
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "gtypes.h"
#include "SplashTypes.h"
#include "config.h"
#include "OutputDev.h"
#include "GfxState.h"
class Gfx8BitFont;
class SplashBitmap;
class Splash;
class SplashPath;
class SplashPattern;
class SplashFontEngine;
class SplashFont;
class T3FontCache;
struct T3FontCacheTag;
struct T3GlyphStack;
//------------------------------------------------------------------------
// number of Type 3 fonts to cache
#define splashOutT3FontCacheSize 8
//------------------------------------------------------------------------
// SplashOutputDev
//------------------------------------------------------------------------
class SplashOutputDev: public OutputDev {
public:
// Constructor.
SplashOutputDev(SplashColorMode colorModeA, int bitmapRowPadA,
GBool reverseVideoA, SplashColorPtr paperColorA,
GBool bitmapTopDownA = gTrue,
GBool allowAntialiasA = gTrue);
// Destructor.
virtual ~SplashOutputDev();
//----- get info about output device
// Does this device use upside-down coordinates?
// (Upside-down means (0,0) is the top left corner of the page.)
virtual GBool upsideDown() { return gTrue; }
// Does this device use drawChar() or drawString()?
virtual GBool useDrawChar() { return gTrue; }
// Does this device use beginType3Char/endType3Char? Otherwise,
// text in Type 3 fonts will be drawn with drawChar/drawString.
virtual GBool interpretType3Chars() { return gTrue; }
//----- initialization and control
// Start a page.
virtual GBool startPage(int pageNum, GfxState *state);
// End a page.
virtual void endPage();
//----- link borders
virtual void drawLink(Link *link, Catalog *catalog);
//----- save/restore graphics state
virtual void saveState(GfxState *state);
virtual void restoreState(GfxState *state);
//----- update graphics state
virtual void updateAll(GfxState *state);
virtual void updateCTM(GfxState *state, double m11, double m12,
double m21, double m22, double m31, double m32);
virtual void updateLineDash(GfxState *state);
virtual void updateFlatness(GfxState *state);
virtual void updateLineJoin(GfxState *state);
virtual void updateLineCap(GfxState *state);
virtual void updateMiterLimit(GfxState *state);
virtual void updateLineWidth(GfxState *state);
virtual void updateFillColor(GfxState *state);
virtual void updateStrokeColor(GfxState *state);
virtual void updateBlendMode(GfxState *state);
virtual void updateFillOpacity(GfxState *state);
virtual void updateStrokeOpacity(GfxState *state);
//----- update text state
virtual void updateFont(GfxState *state);
//----- path painting
virtual void stroke(GfxState *state);
virtual void fill(GfxState *state);
virtual void eoFill(GfxState *state);
//----- path clipping
virtual void clip(GfxState *state);
virtual void eoClip(GfxState *state);
//----- text drawing
virtual void drawChar(GfxState *state, double x, double y,
double dx, double dy,
double originX, double originY,
CharCode code, int nBytes, Unicode *u, int uLen);
virtual GBool beginType3Char(GfxState *state, double x, double y,
double dx, double dy,
CharCode code, Unicode *u, int uLen);
virtual void endType3Char(GfxState *state);
virtual void endTextObject(GfxState *state);
//----- image drawing
virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
int width, int height, GBool invert,
GBool inlineImg);
virtual void drawImage(GfxState *state, Object *ref, Stream *str,
int width, int height, GfxImageColorMap *colorMap,
int *maskColors, GBool inlineImg);
virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
int width, int height,
GfxImageColorMap *colorMap,
Stream *maskStr, int maskWidth, int maskHeight,
GBool maskInvert);
virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
int width, int height,
GfxImageColorMap *colorMap,
Stream *maskStr,
int maskWidth, int maskHeight,
GfxImageColorMap *maskColorMap);
//----- Type 3 font operators
virtual void type3D0(GfxState *state, double wx, double wy);
virtual void type3D1(GfxState *state, double wx, double wy,
double llx, double lly, double urx, double ury);
//----- special access
// Called to indicate that a new PDF document has been loaded.
void startDoc(XRef *xrefA);
void setPaperColor(SplashColorPtr paperColorA);
GBool isReverseVideo() { return reverseVideo; }
void setReverseVideo(GBool reverseVideoA) { reverseVideo = reverseVideoA; }
// Get the bitmap and its size.
SplashBitmap *getBitmap() { return bitmap; }
int getBitmapWidth();
int getBitmapHeight();
// Returns the last rasterized bitmap, transferring ownership to the
// caller.
SplashBitmap *takeBitmap();
// Get the Splash object.
Splash *getSplash() { return splash; }
// Get the modified region.
void getModRegion(int *xMin, int *yMin, int *xMax, int *yMax);
// Clear the modified region.
void clearModRegion();
// Set the Splash fill color.
void setFillColor(int r, int g, int b);
// Get a font object for a Base-14 font, using the Latin-1 encoding.
SplashFont *getFont(GString *name, double *mat);
SplashFont *getCurrentFont() { return font; }
private:
#if SPLASH_CMYK
SplashPattern *getColor(GfxGray gray, GfxRGB *rgb, GfxCMYK *cmyk);
#else
SplashPattern *getColor(GfxGray gray, GfxRGB *rgb);
#endif
SplashPath *convertPath(GfxState *state, GfxPath *path);
void drawType3Glyph(T3FontCache *t3Font,
T3FontCacheTag *tag, Guchar *data,
double x, double y);
static GBool imageMaskSrc(void *data, SplashColorPtr line);
static GBool imageSrc(void *data, SplashColorPtr line);
static GBool alphaImageSrc(void *data, SplashColorPtr line);
static GBool maskedImageSrc(void *data, SplashColorPtr line);
SplashColorMode colorMode;
int bitmapRowPad;
GBool bitmapTopDown;
GBool allowAntialias;
GBool reverseVideo; // reverse video mode
SplashColor paperColor; // paper color
XRef *xref; // xref table for current document
SplashBitmap *bitmap;
Splash *splash;
SplashFontEngine *fontEngine;
T3FontCache * // Type 3 font cache
t3FontCache[splashOutT3FontCacheSize];
int nT3Fonts; // number of valid entries in t3FontCache
T3GlyphStack *t3GlyphStack; // Type 3 glyph context stack
SplashFont *font; // current font
GBool needFontUpdate; // set when the font needs to be updated
SplashPath *textClipPath; // clipping path built with text object
};
#endif
+178
Ver Arquivo
@@ -0,0 +1,178 @@
//========================================================================
//
// SplashPath.cc
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <string.h>
#include "gmem.h"
#include "SplashErrorCodes.h"
#include "SplashPath.h"
//------------------------------------------------------------------------
// SplashPath
//------------------------------------------------------------------------
// A path can be in three possible states:
//
// 1. no current point -- zero or more finished subpaths
// [curSubpath == length]
//
// 2. one point in subpath
// [curSubpath == length - 1]
//
// 3. open subpath with two or more points
// [curSubpath < length - 1]
SplashPath::SplashPath() {
pts = NULL;
flags = NULL;
length = size = 0;
curSubpath = 0;
}
SplashPath::SplashPath(SplashPath *path) {
length = path->length;
size = path->size;
pts = (SplashPathPoint *)gmallocn(size, sizeof(SplashPathPoint));
flags = (Guchar *)gmallocn(size, sizeof(Guchar));
memcpy(pts, path->pts, length * sizeof(SplashPathPoint));
memcpy(flags, path->flags, length * sizeof(Guchar));
curSubpath = path->curSubpath;
}
SplashPath::~SplashPath() {
gfree(pts);
gfree(flags);
}
// Add space for <nPts> more points.
void SplashPath::grow(int nPts) {
if (length + nPts > size) {
if (size == 0) {
size = 32;
}
while (size < length + nPts) {
size *= 2;
}
pts = (SplashPathPoint *)greallocn(pts, size, sizeof(SplashPathPoint));
flags = (Guchar *)greallocn(flags, size, sizeof(Guchar));
}
}
void SplashPath::append(SplashPath *path) {
int i;
curSubpath = length + path->curSubpath;
grow(path->length);
for (i = 0; i < path->length; ++i) {
pts[length] = path->pts[i];
flags[length] = path->flags[i];
++length;
}
}
SplashError SplashPath::moveTo(SplashCoord x, SplashCoord y) {
if (onePointSubpath()) {
return splashErrBogusPath;
}
grow(1);
pts[length].x = x;
pts[length].y = y;
flags[length] = splashPathFirst | splashPathLast;
curSubpath = length++;
return splashOk;
}
SplashError SplashPath::lineTo(SplashCoord x, SplashCoord y) {
if (noCurrentPoint()) {
return splashErrNoCurPt;
}
flags[length-1] &= ~splashPathLast;
grow(1);
pts[length].x = x;
pts[length].y = y;
flags[length] = splashPathLast;
++length;
return splashOk;
}
SplashError SplashPath::curveTo(SplashCoord x1, SplashCoord y1,
SplashCoord x2, SplashCoord y2,
SplashCoord x3, SplashCoord y3) {
if (noCurrentPoint()) {
return splashErrNoCurPt;
}
flags[length-1] &= ~splashPathLast;
grow(3);
pts[length].x = x1;
pts[length].y = y1;
flags[length] = splashPathCurve;
++length;
pts[length].x = x2;
pts[length].y = y2;
flags[length] = splashPathCurve;
++length;
pts[length].x = x3;
pts[length].y = y3;
flags[length] = splashPathLast;
++length;
return splashOk;
}
SplashError SplashPath::arcCWTo(SplashCoord x1, SplashCoord y1,
SplashCoord xc, SplashCoord yc) {
if (noCurrentPoint()) {
return splashErrNoCurPt;
}
flags[length-1] &= ~splashPathLast;
grow(2);
pts[length].x = xc;
pts[length].y = yc;
flags[length] = splashPathArcCW;
++length;
pts[length].x = x1;
pts[length].y = y1;
flags[length] = splashPathLast;
++length;
return splashOk;
}
SplashError SplashPath::close() {
if (noCurrentPoint()) {
return splashErrNoCurPt;
}
if (curSubpath == length - 1 ||
pts[length - 1].x != pts[curSubpath].x ||
pts[length - 1].y != pts[curSubpath].y) {
lineTo(pts[curSubpath].x, pts[curSubpath].y);
}
flags[curSubpath] |= splashPathClosed;
flags[length - 1] |= splashPathClosed;
curSubpath = length;
return splashOk;
}
void SplashPath::offset(SplashCoord dx, SplashCoord dy) {
int i;
for (i = 0; i < length; ++i) {
pts[i].x += dx;
pts[i].y += dy;
}
}
GBool SplashPath::getCurPt(SplashCoord *x, SplashCoord *y) {
if (noCurrentPoint()) {
return gFalse;
}
*x = pts[length - 1].x;
*y = pts[length - 1].y;
return gTrue;
}
+112
Ver Arquivo
@@ -0,0 +1,112 @@
//========================================================================
//
// SplashPath.h
//
//========================================================================
#ifndef SPLASHPATH_H
#define SPLASHPATH_H
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "SplashTypes.h"
//------------------------------------------------------------------------
// SplashPathPoint
//------------------------------------------------------------------------
struct SplashPathPoint {
SplashCoord x, y;
};
//------------------------------------------------------------------------
// SplashPath.flags
//------------------------------------------------------------------------
// first point on each subpath sets this flag
#define splashPathFirst 0x01
// last point on each subpath sets this flag
#define splashPathLast 0x02
// if the subpath is closed, its first and last points must be
// identical, and must set this flag
#define splashPathClosed 0x04
// curve control points set this flag
#define splashPathCurve 0x08
// clockwise arc center points set this flag
#define splashPathArcCW 0x10
//------------------------------------------------------------------------
// SplashPath
//------------------------------------------------------------------------
class SplashPath {
public:
// Create an empty path.
SplashPath();
// Copy a path.
SplashPath *copy() { return new SplashPath(this); }
~SplashPath();
// Append <path> to <this>.
void append(SplashPath *path);
// Start a new subpath.
SplashError moveTo(SplashCoord x, SplashCoord y);
// Add a line segment to the last subpath.
SplashError lineTo(SplashCoord x, SplashCoord y);
// Add a third-order (cubic) Bezier curve segment to the last
// subpath.
SplashError curveTo(SplashCoord x1, SplashCoord y1,
SplashCoord x2, SplashCoord y2,
SplashCoord x3, SplashCoord y3);
// Add a clockwise circular arc with center (xc, yc) and endpoint
// (x1, y1).
SplashError arcCWTo(SplashCoord x1, SplashCoord y1,
SplashCoord xc, SplashCoord yc);
// Close the last subpath, adding a line segment if necessary.
SplashError close();
// Add (<dx>, <dy>) to every point on this path.
void offset(SplashCoord dx, SplashCoord dy);
// Get the points on the path.
int getLength() { return length; }
void getPoint(int i, double *x, double *y, Guchar *f)
{ *x = pts[i].x; *y = pts[i].y; *f = flags[i]; }
// Get the current point.
GBool getCurPt(SplashCoord *x, SplashCoord *y);
private:
SplashPath(SplashPath *path);
void grow(int nPts);
GBool noCurrentPoint() { return curSubpath == length; }
GBool onePointSubpath() { return curSubpath == length - 1; }
GBool openSubpath() { return curSubpath < length - 1; }
SplashPathPoint *pts; // array of points
Guchar *flags; // array of flags
int length, size; // length/size of the pts and flags arrays
int curSubpath; // index of first point in last subpath
friend class SplashXPath;
friend class Splash;
};
#endif
+68
Ver Arquivo
@@ -0,0 +1,68 @@
//========================================================================
//
// SplashPattern.cc
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include "SplashMath.h"
#include "SplashScreen.h"
#include "SplashPattern.h"
//------------------------------------------------------------------------
// SplashPattern
//------------------------------------------------------------------------
SplashPattern::SplashPattern() {
}
SplashPattern::~SplashPattern() {
}
//------------------------------------------------------------------------
// SplashSolidColor
//------------------------------------------------------------------------
SplashSolidColor::SplashSolidColor(SplashColorPtr colorA) {
splashColorCopy(color, colorA);
}
SplashSolidColor::~SplashSolidColor() {
}
void SplashSolidColor::getColor(int x, int y, SplashColorPtr c) {
splashColorCopy(c, color);
}
//------------------------------------------------------------------------
// SplashHalftone
//------------------------------------------------------------------------
SplashHalftone::SplashHalftone(SplashColorPtr color0A, SplashColorPtr color1A,
SplashScreen *screenA, SplashCoord valueA) {
splashColorCopy(color0, color0A);
splashColorCopy(color1, color1A);
screen = screenA;
value = valueA;
}
SplashPattern *SplashHalftone::copy() {
return new SplashHalftone(color0, color1, screen->copy(), value);
}
SplashHalftone::~SplashHalftone() {
delete screen;
}
void SplashHalftone::getColor(int x, int y, SplashColorPtr c) {
splashColorCopy(c, screen->test(x, y, value) ? color1 : color0);
}
GBool SplashHalftone::isStatic() {
return screen->isStatic(value);
}
+90
Ver Arquivo
@@ -0,0 +1,90 @@
//========================================================================
//
// SplashPattern.h
//
//========================================================================
#ifndef SPLASHPATTERN_H
#define SPLASHPATTERN_H
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "SplashTypes.h"
class SplashScreen;
//------------------------------------------------------------------------
// SplashPattern
//------------------------------------------------------------------------
class SplashPattern {
public:
SplashPattern();
virtual SplashPattern *copy() = 0;
virtual ~SplashPattern();
// Return the color value for a specific pixel.
virtual void getColor(int x, int y, SplashColorPtr c) = 0;
// Returns true if this pattern object will return the same color
// value for all pixels.
virtual GBool isStatic() = 0;
private:
};
//------------------------------------------------------------------------
// SplashSolidColor
//------------------------------------------------------------------------
class SplashSolidColor: public SplashPattern {
public:
SplashSolidColor(SplashColorPtr colorA);
virtual SplashPattern *copy() { return new SplashSolidColor(color); }
virtual ~SplashSolidColor();
virtual void getColor(int x, int y, SplashColorPtr c);
virtual GBool isStatic() { return gTrue; }
private:
SplashColor color;
};
//------------------------------------------------------------------------
// SplashHalftone
//------------------------------------------------------------------------
class SplashHalftone: public SplashPattern {
public:
SplashHalftone(SplashColorPtr color0A, SplashColorPtr color1A,
SplashScreen *screenA, SplashCoord valueA);
virtual SplashPattern *copy();
virtual ~SplashHalftone();
virtual void getColor(int x, int y, SplashColorPtr c);
virtual GBool isStatic();
private:
SplashColor color0, color1;
SplashScreen *screen;
SplashCoord value;
};
#endif
+141
Ver Arquivo
@@ -0,0 +1,141 @@
//========================================================================
//
// SplashScreen.cc
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <string.h>
#include "gmem.h"
#include "SplashMath.h"
#include "SplashScreen.h"
//------------------------------------------------------------------------
// SplashScreen
//------------------------------------------------------------------------
// This generates a 45 degree screen using a circular dot spot
// function. DPI = resolution / ((size / 2) * sqrt(2)).
// Gamma correction (gamma = 1 / 1.33) is also computed here.
SplashScreen::SplashScreen(int sizeA) {
SplashCoord *dist;
SplashCoord u, v, d, val;
int size2, x, y, x1, y1, i;
size2 = sizeA >> 1;
if (size2 < 1) {
size2 = 1;
}
size = size2 << 1;
// initialize the threshold matrix
mat = (SplashCoord *)gmallocn(size * size, sizeof(SplashCoord));
for (y = 0; y < size; ++y) {
for (x = 0; x < size; ++x) {
mat[y * size + x] = -1;
}
}
// build the distance matrix
dist = (SplashCoord *)gmallocn(size * size2, sizeof(SplashCoord));
for (y = 0; y < size2; ++y) {
for (x = 0; x < size2; ++x) {
if (x + y < size2 - 1) {
u = (SplashCoord)x + 0.5 - 0;
v = (SplashCoord)y + 0.5 - 0;
} else {
u = (SplashCoord)x + 0.5 - (SplashCoord)size2;
v = (SplashCoord)y + 0.5 - (SplashCoord)size2;
}
dist[y * size2 + x] = u*u + v*v;
}
}
for (y = 0; y < size2; ++y) {
for (x = 0; x < size2; ++x) {
if (x < y) {
u = (SplashCoord)x + 0.5 - 0;
v = (SplashCoord)y + 0.5 - (SplashCoord)size2;
} else {
u = (SplashCoord)x + 0.5 - (SplashCoord)size2;
v = (SplashCoord)y + 0.5 - 0;
}
dist[(size2 + y) * size2 + x] = u*u + v*v;
}
}
// build the threshold matrix
minVal = 1;
maxVal = 0;
x1 = y1 = 0; // make gcc happy
for (i = 1; i <= size * size2; ++i) {
d = size * size2;
for (y = 0; y < size; ++y) {
for (x = 0; x < size2; ++x) {
if (mat[y * size + x] < 0 &&
dist[y * size2 + x] < d) {
x1 = x;
y1 = y;
d = dist[y1 * size2 + x1];
}
}
}
u = (SplashCoord)1 - (SplashCoord)i / (SplashCoord)(size * size2 + 1);
val = splashPow(u, 1.33);
if (val < minVal) {
minVal = val;
}
if (val > maxVal) {
maxVal = val;
}
mat[y1 * size + x1] = val;
if (y1 < size2) {
mat[(y1 + size2) * size + x1 + size2] = val;
} else {
mat[(y1 - size2) * size + x1 + size2] = val;
}
}
gfree(dist);
}
SplashScreen::SplashScreen(SplashScreen *screen) {
int n;
size = screen->size;
n = size * size * sizeof(SplashCoord);
mat = (SplashCoord *)gmalloc(n);
memcpy(mat, screen->mat, n);
minVal = screen->minVal;
maxVal = screen->maxVal;
}
SplashScreen::~SplashScreen() {
gfree(mat);
}
int SplashScreen::test(int x, int y, SplashCoord value) {
int xx, yy;
if (value < minVal) {
return 0;
}
if (value >= maxVal) {
return 1;
}
if ((xx = x % size) < 0) {
xx = -xx;
}
if ((yy = y % size) < 0) {
yy = -yy;
}
return value < mat[yy * size + xx] ? 0 : 1;
}
GBool SplashScreen::isStatic(SplashCoord value) {
return value < minVal || value >= maxVal;
}
+50
Ver Arquivo
@@ -0,0 +1,50 @@
//========================================================================
//
// SplashScreen.h
//
//========================================================================
#ifndef SPLASHSCREEN_H
#define SPLASHSCREEN_H
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "SplashTypes.h"
//------------------------------------------------------------------------
// SplashScreen
//------------------------------------------------------------------------
class SplashScreen {
public:
SplashScreen(int sizeA);
SplashScreen(SplashScreen *screen);
~SplashScreen();
SplashScreen *copy() { return new SplashScreen(this); }
// Return the computed pixel value (0=black, 1=white) for the gray
// level <value> at (<x>, <y>).
int test(int x, int y, SplashCoord value);
// Returns true if value is above the white threshold or below the
// black threshold, i.e., if the corresponding halftone will be
// solid white or black.
GBool isStatic(SplashCoord value);
private:
SplashCoord *mat; // threshold matrix
int size; // size of the threshold matrix
SplashCoord minVal; // any pixel value below minVal generates
// solid black
SplashCoord maxVal; // any pixel value above maxVal generates
// solid white
};
#endif
+110
Ver Arquivo
@@ -0,0 +1,110 @@
//========================================================================
//
// SplashState.cc
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <string.h>
#include "gmem.h"
#include "SplashPattern.h"
#include "SplashScreen.h"
#include "SplashClip.h"
#include "SplashState.h"
//------------------------------------------------------------------------
// SplashState
//------------------------------------------------------------------------
// number of components in each color mode
int splashColorModeNComps[] = {
1, 1, 2, 3, 3, 4, 4
};
SplashState::SplashState(int width, int height) {
SplashColor color;
memset(&color, 0, sizeof(SplashColor));
strokePattern = new SplashSolidColor(color);
fillPattern = new SplashSolidColor(color);
screen = new SplashScreen(10);
blendFunc = NULL;
strokeAlpha = 1;
fillAlpha = 1;
lineWidth = 0;
lineCap = splashLineCapButt;
lineJoin = splashLineJoinMiter;
miterLimit = 10;
flatness = 1;
lineDash = NULL;
lineDashLength = 0;
lineDashPhase = 0;
clip = new SplashClip(0, 0, width - 1, height - 1);
next = NULL;
}
SplashState::SplashState(SplashState *state) {
strokePattern = state->strokePattern->copy();
fillPattern = state->fillPattern->copy();
screen = state->screen->copy();
blendFunc = state->blendFunc;
strokeAlpha = state->strokeAlpha;
fillAlpha = state->fillAlpha;
lineWidth = state->lineWidth;
lineCap = state->lineCap;
lineJoin = state->lineJoin;
miterLimit = state->miterLimit;
flatness = state->flatness;
if (state->lineDash) {
lineDashLength = state->lineDashLength;
lineDash = (SplashCoord *)gmallocn(lineDashLength, sizeof(SplashCoord));
memcpy(lineDash, state->lineDash, lineDashLength * sizeof(SplashCoord));
} else {
lineDash = NULL;
lineDashLength = 0;
}
lineDashPhase = state->lineDashPhase;
clip = state->clip->copy();
next = NULL;
}
SplashState::~SplashState() {
delete strokePattern;
delete fillPattern;
delete screen;
gfree(lineDash);
delete clip;
}
void SplashState::setStrokePattern(SplashPattern *strokePatternA) {
delete strokePattern;
strokePattern = strokePatternA;
}
void SplashState::setFillPattern(SplashPattern *fillPatternA) {
delete fillPattern;
fillPattern = fillPatternA;
}
void SplashState::setScreen(SplashScreen *screenA) {
delete screen;
screen = screenA;
}
void SplashState::setLineDash(SplashCoord *lineDashA, int lineDashLengthA,
SplashCoord lineDashPhaseA) {
gfree(lineDash);
lineDashLength = lineDashLengthA;
if (lineDashLength > 0) {
lineDash = (SplashCoord *)gmallocn(lineDashLength, sizeof(SplashCoord));
memcpy(lineDash, lineDashA, lineDashLength * sizeof(SplashCoord));
} else {
lineDash = NULL;
}
lineDashPhase = lineDashPhaseA;
}
+91
Ver Arquivo
@@ -0,0 +1,91 @@
//========================================================================
//
// SplashState.h
//
//========================================================================
#ifndef SPLASHSTATE_H
#define SPLASHSTATE_H
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "SplashTypes.h"
class SplashPattern;
class SplashScreen;
class SplashClip;
//------------------------------------------------------------------------
// line cap values
//------------------------------------------------------------------------
#define splashLineCapButt 0
#define splashLineCapRound 1
#define splashLineCapProjecting 2
//------------------------------------------------------------------------
// line join values
//------------------------------------------------------------------------
#define splashLineJoinMiter 0
#define splashLineJoinRound 1
#define splashLineJoinBevel 2
//------------------------------------------------------------------------
// SplashState
//------------------------------------------------------------------------
class SplashState {
public:
// Create a new state object, initialized with default settings.
SplashState(int width, int height);
// Copy a state object.
SplashState *copy() { return new SplashState(this); }
~SplashState();
// Set the stroke pattern. This does not copy <strokePatternA>.
void setStrokePattern(SplashPattern *strokePatternA);
// Set the fill pattern. This does not copy <fillPatternA>.
void setFillPattern(SplashPattern *fillPatternA);
// Set the screen. This does not copy <screenA>.
void setScreen(SplashScreen *screenA);
// Set the line dash pattern. This copies the <lineDashA> array.
void setLineDash(SplashCoord *lineDashA, int lineDashLengthA,
SplashCoord lineDashPhaseA);
private:
SplashState(SplashState *state);
SplashPattern *strokePattern;
SplashPattern *fillPattern;
SplashScreen *screen;
SplashBlendFunc blendFunc;
SplashCoord strokeAlpha;
SplashCoord fillAlpha;
SplashCoord lineWidth;
int lineCap;
int lineJoin;
SplashCoord miterLimit;
SplashCoord flatness;
SplashCoord *lineDash;
int lineDashLength;
SplashCoord lineDashPhase;
SplashClip *clip;
SplashState *next; // used by Splash class
friend class Splash;
};
#endif
+264
Ver Arquivo
@@ -0,0 +1,264 @@
//========================================================================
//
// SplashT1Font.cc
//
//========================================================================
#include <config.h>
#if HAVE_T1LIB_H
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdlib.h>
#include <t1lib.h>
#include "gmem.h"
#include "SplashMath.h"
#include "SplashGlyphBitmap.h"
#include "SplashPath.h"
#include "SplashT1FontEngine.h"
#include "SplashT1FontFile.h"
#include "SplashT1Font.h"
//------------------------------------------------------------------------
static Guchar bitReverse[256] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};
//------------------------------------------------------------------------
// SplashT1Font
//------------------------------------------------------------------------
SplashT1Font::SplashT1Font(SplashT1FontFile *fontFileA, SplashCoord *matA):
SplashFont(fontFileA, matA, ((SplashT1FontFile *)fontFileA)->engine->aa)
{
T1_TMATRIX matrix;
BBox bbox;
SplashCoord bbx0, bby0, bbx1, bby1;
int x, y;
t1libID = T1_CopyFont(fontFileA->t1libID);
// compute font size
size = (float)splashSqrt(mat[2]*mat[2] + mat[3]*mat[3]);
// transform the four corners of the font bounding box -- the min
// and max values form the bounding box of the transformed font
bbox = T1_GetFontBBox(t1libID);
bbx0 = 0.001 * bbox.llx;
bby0 = 0.001 * bbox.lly;
bbx1 = 0.001 * bbox.urx;
bby1 = 0.001 * bbox.ury;
// some fonts are completely broken, so we fake it (with values
// large enough that most glyphs should fit)
if (bbx0 == 0 && bby0 == 0 && bbx1 == 0 && bby1 == 0) {
bbx0 = bby0 = -0.5;
bbx1 = bby1 = 1.5;
}
x = (int)(mat[0] * bbx0 + mat[2] * bby0);
xMin = xMax = x;
y = (int)(mat[1] * bbx0 + mat[3] * bby0);
yMin = yMax = y;
x = (int)(mat[0] * bbx0 + mat[2] * bby1);
if (x < xMin) {
xMin = x;
} else if (x > xMax) {
xMax = x;
}
y = (int)(mat[1] * bbx0 + mat[3] * bby1);
if (y < yMin) {
yMin = y;
} else if (y > yMax) {
yMax = y;
}
x = (int)(mat[0] * bbx1 + mat[2] * bby0);
if (x < xMin) {
xMin = x;
} else if (x > xMax) {
xMax = x;
}
y = (int)(mat[1] * bbx1 + mat[3] * bby0);
if (y < yMin) {
yMin = y;
} else if (y > yMax) {
yMax = y;
}
x = (int)(mat[0] * bbx1 + mat[2] * bby1);
if (x < xMin) {
xMin = x;
} else if (x > xMax) {
xMax = x;
}
y = (int)(mat[1] * bbx1 + mat[3] * bby1);
if (y < yMin) {
yMin = y;
} else if (y > yMax) {
yMax = y;
}
// This is a kludge: some buggy PDF generators embed fonts with
// zero bounding boxes.
if (xMax == xMin) {
xMin = 0;
xMax = (int)size;
}
if (yMax == yMin) {
yMin = 0;
yMax = (int)(1.2 * size);
}
// Another kludge: an unusually large xMin or yMin coordinate is
// probably wrong.
if (xMin > 0) {
xMin = 0;
}
if (yMin > 0) {
yMin = 0;
}
// Another kludge: t1lib doesn't correctly handle fonts with
// real (non-integer) bounding box coordinates.
if (xMax - xMin > 5000) {
xMin = 0;
xMax = (int)size;
}
if (yMax - yMin > 5000) {
yMin = 0;
yMax = (int)(1.2 * size);
}
// transform the font
matrix.cxx = (double)mat[0] / size;
matrix.cxy = (double)mat[1] / size;
matrix.cyx = (double)mat[2] / size;
matrix.cyy = (double)mat[3] / size;
T1_TransformFont(t1libID, &matrix);
}
SplashT1Font::~SplashT1Font() {
T1_DeleteFont(t1libID);
}
GBool SplashT1Font::getGlyph(int c, int xFrac, int yFrac,
SplashGlyphBitmap *bitmap) {
return SplashFont::getGlyph(c, 0, 0, bitmap);
}
GBool SplashT1Font::makeGlyph(int c, int xFrac, int yFrac,
SplashGlyphBitmap *bitmap) {
GLYPH *glyph;
int n, i;
if (aa) {
glyph = T1_AASetChar(t1libID, c, size, NULL);
} else {
glyph = T1_SetChar(t1libID, c, size, NULL);
}
if (!glyph) {
return gFalse;
}
bitmap->x = -glyph->metrics.leftSideBearing;
bitmap->y = glyph->metrics.ascent;
bitmap->w = glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing;
bitmap->h = glyph->metrics.ascent - glyph->metrics.descent;
bitmap->aa = aa;
if (aa) {
bitmap->data = (Guchar *)glyph->bits;
bitmap->freeData = gFalse;
} else {
n = bitmap->h * ((bitmap->w + 7) >> 3);
bitmap->data = (Guchar *)gmalloc(n);
for (i = 0; i < n; ++i) {
bitmap->data[i] = bitReverse[glyph->bits[i] & 0xff];
}
bitmap->freeData = gTrue;
}
return gTrue;
}
SplashPath *SplashT1Font::getGlyphPath(int c) {
SplashPath *path;
T1_OUTLINE *outline;
T1_PATHSEGMENT *seg;
T1_BEZIERSEGMENT *bez;
SplashCoord x, y, x1, y1;
GBool needClose;
path = new SplashPath();
if (!(outline = T1_GetCharOutline(t1libID, c, size, NULL))) {
return path;
}
x = 0;
y = 0;
needClose = gFalse;
for (seg = outline; seg; seg = seg->link) {
switch (seg->type) {
case T1_PATHTYPE_MOVE:
if (needClose) {
path->close();
needClose = gFalse;
}
x += seg->dest.x / 65536.0;
y += seg->dest.y / 65536.0;
path->moveTo(x, y);
break;
case T1_PATHTYPE_LINE:
x += seg->dest.x / 65536.0;
y += seg->dest.y / 65536.0;
path->lineTo(x, y);
needClose = gTrue;
break;
case T1_PATHTYPE_BEZIER:
bez = (T1_BEZIERSEGMENT *)seg;
x1 = x + bez->dest.x / 65536.0;
y1 = y + bez->dest.y / 65536.0;
path->curveTo(x + bez->B.x / 65536.0, y + bez->B.y / 65536.0,
x + bez->C.x / 65536.0, y + bez->C.y / 65536.0,
x1, y1);
x = x1;
y = y1;
needClose = gTrue;
break;
}
}
if (needClose) {
path->close();
}
T1_FreeOutline(outline);
return path;
}
#endif // HAVE_T1LIB_H
+53
Ver Arquivo
@@ -0,0 +1,53 @@
//========================================================================
//
// SplashT1Font.h
//
//========================================================================
#ifndef SPLASHT1FONT_H
#define SPLASHT1FONT_H
#include <config.h>
#if HAVE_T1LIB_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "SplashFont.h"
class SplashT1FontFile;
//------------------------------------------------------------------------
// SplashT1Font
//------------------------------------------------------------------------
class SplashT1Font: public SplashFont {
public:
SplashT1Font(SplashT1FontFile *fontFileA, SplashCoord *matA);
virtual ~SplashT1Font();
// Munge xFrac and yFrac before calling SplashFont::getGlyph.
virtual GBool getGlyph(int c, int xFrac, int yFrac,
SplashGlyphBitmap *bitmap);
// Rasterize a glyph. The <xFrac> and <yFrac> values are the same
// as described for getGlyph.
virtual GBool makeGlyph(int c, int xFrac, int yFrac,
SplashGlyphBitmap *bitmap);
// Return the path for a glyph.
virtual SplashPath *getGlyphPath(int c);
private:
int t1libID; // t1lib font ID
float size;
};
#endif // HAVE_T1LIB_H
#endif
+124
Ver Arquivo
@@ -0,0 +1,124 @@
//========================================================================
//
// SplashT1FontEngine.cc
//
//========================================================================
#include <config.h>
#if HAVE_T1LIB_H
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdlib.h>
#include <stdio.h>
#ifndef WIN32
# include <unistd.h>
#endif
#include <t1lib.h>
#include "GString.h"
#include "gfile.h"
#include "FoFiType1C.h"
#include "SplashT1FontFile.h"
#include "SplashT1FontEngine.h"
#ifdef VMS
#if (__VMS_VER < 70000000)
extern "C" int unlink(char *filename);
#endif
#endif
//------------------------------------------------------------------------
int SplashT1FontEngine::t1libInitCount = 0;
//------------------------------------------------------------------------
static void fileWrite(void *stream, char *data, int len) {
fwrite(data, 1, len, (FILE *)stream);
}
//------------------------------------------------------------------------
// SplashT1FontEngine
//------------------------------------------------------------------------
SplashT1FontEngine::SplashT1FontEngine(GBool aaA) {
aa = aaA;
}
SplashT1FontEngine *SplashT1FontEngine::init(GBool aaA) {
// grayVals[i] = round(i * 255 / 16)
static unsigned long grayVals[17] = {
0, 16, 32, 48, 64, 80, 96, 112, 128, 143, 159, 175, 191, 207, 223, 239, 255
};
//~ for multithreading: need a mutex here
if (t1libInitCount == 0) {
T1_SetBitmapPad(8);
if (!T1_InitLib(NO_LOGFILE | IGNORE_CONFIGFILE | IGNORE_FONTDATABASE |
T1_NO_AFM)) {
return NULL;
}
if (aaA) {
T1_AASetBitsPerPixel(8);
T1_AASetLevel(T1_AA_HIGH);
T1_AAHSetGrayValues(grayVals);
} else {
T1_AANSetGrayValues(0, 1);
}
}
++t1libInitCount;
return new SplashT1FontEngine(aaA);
}
SplashT1FontEngine::~SplashT1FontEngine() {
//~ for multithreading: need a mutex here
if (--t1libInitCount == 0) {
T1_CloseLib();
}
}
SplashFontFile *SplashT1FontEngine::loadType1Font(SplashFontFileID *idA,
char *fileName,
GBool deleteFile,
char **enc) {
return SplashT1FontFile::loadType1Font(this, idA, fileName, deleteFile, enc);
}
SplashFontFile *SplashT1FontEngine::loadType1CFont(SplashFontFileID *idA,
char *fileName,
GBool deleteFile,
char **enc) {
FoFiType1C *ff;
GString *tmpFileName;
FILE *tmpFile;
SplashFontFile *ret;
if (!(ff = FoFiType1C::load(fileName))) {
return NULL;
}
tmpFileName = NULL;
if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) {
delete ff;
return NULL;
}
ff->convertToType1(NULL, gTrue, &fileWrite, tmpFile);
delete ff;
fclose(tmpFile);
ret = SplashT1FontFile::loadType1Font(this, idA, tmpFileName->getCString(),
gTrue, enc);
if (ret) {
if (deleteFile) {
unlink(fileName);
}
} else {
unlink(tmpFileName->getCString());
}
delete tmpFileName;
return ret;
}
#endif // HAVE_T1LIB_H
+53
Ver Arquivo
@@ -0,0 +1,53 @@
//========================================================================
//
// SplashT1FontEngine.h
//
//========================================================================
#ifndef SPLASHT1FONTENGINE_H
#define SPLASHT1FONTENGINE_H
#include <config.h>
#if HAVE_T1LIB_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "gtypes.h"
class SplashFontFile;
class SplashFontFileID;
//------------------------------------------------------------------------
// SplashT1FontEngine
//------------------------------------------------------------------------
class SplashT1FontEngine {
public:
static SplashT1FontEngine *init(GBool aaA);
~SplashT1FontEngine();
// Load fonts.
SplashFontFile *loadType1Font(SplashFontFileID *idA, char *fileName,
GBool deleteFile, char **enc);
SplashFontFile *loadType1CFont(SplashFontFileID *idA, char *fileName,
GBool deleteFile, char **enc);
private:
SplashT1FontEngine(GBool aaA);
static int t1libInitCount;
GBool aa;
friend class SplashT1FontFile;
friend class SplashT1Font;
};
#endif // HAVE_T1LIB_H
#endif
+96
Ver Arquivo
@@ -0,0 +1,96 @@
//========================================================================
//
// SplashT1FontFile.cc
//
//========================================================================
#include <config.h>
#if HAVE_T1LIB_H
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <string.h>
#include <t1lib.h>
#include "gmem.h"
#include "SplashT1FontEngine.h"
#include "SplashT1Font.h"
#include "SplashT1FontFile.h"
//------------------------------------------------------------------------
// SplashT1FontFile
//------------------------------------------------------------------------
SplashFontFile *SplashT1FontFile::loadType1Font(SplashT1FontEngine *engineA,
SplashFontFileID *idA,
char *fileNameA,
GBool deleteFileA,
char **encA) {
int t1libIDA;
char **encTmp;
char *encStrTmp;
int encStrSize;
char *encPtr;
int i;
// load the font file
if ((t1libIDA = T1_AddFont(fileNameA)) < 0) {
return NULL;
}
T1_LoadFont(t1libIDA);
// reencode it
encStrSize = 0;
for (i = 0; i < 256; ++i) {
if (encA[i]) {
encStrSize += strlen(encA[i]) + 1;
}
}
encTmp = (char **)gmallocn(257, sizeof(char *));
encStrTmp = (char *)gmallocn(encStrSize, sizeof(char));
encPtr = encStrTmp;
for (i = 0; i < 256; ++i) {
if (encA[i]) {
strcpy(encPtr, encA[i]);
encTmp[i] = encPtr;
encPtr += strlen(encPtr) + 1;
} else {
encTmp[i] = ".notdef";
}
}
encTmp[256] = "custom";
T1_ReencodeFont(t1libIDA, encTmp);
return new SplashT1FontFile(engineA, idA, fileNameA, deleteFileA,
t1libIDA, encTmp, encStrTmp);
}
SplashT1FontFile::SplashT1FontFile(SplashT1FontEngine *engineA,
SplashFontFileID *idA,
char *fileNameA, GBool deleteFileA,
int t1libIDA, char **encA, char *encStrA):
SplashFontFile(idA, fileNameA, deleteFileA)
{
engine = engineA;
t1libID = t1libIDA;
enc = encA;
encStr = encStrA;
}
SplashT1FontFile::~SplashT1FontFile() {
gfree(encStr);
gfree(enc);
T1_DeleteFont(t1libID);
}
SplashFont *SplashT1FontFile::makeFont(SplashCoord *mat) {
SplashFont *font;
font = new SplashT1Font(this, mat);
font->initCache();
return font;
}
#endif // HAVE_T1LIB_H
+57
Ver Arquivo
@@ -0,0 +1,57 @@
//========================================================================
//
// SplashT1FontFile.h
//
//========================================================================
#ifndef SPLASHT1FONTFILE_H
#define SPLASHT1FONTFILE_H
#include <config.h>
#if HAVE_T1LIB_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "SplashFontFile.h"
class SplashT1FontEngine;
//------------------------------------------------------------------------
// SplashT1FontFile
//------------------------------------------------------------------------
class SplashT1FontFile: public SplashFontFile {
public:
static SplashFontFile *loadType1Font(SplashT1FontEngine *engineA,
SplashFontFileID *idA,
char *fileNameA, GBool deleteFileA,
char **encA);
virtual ~SplashT1FontFile();
// Create a new SplashT1Font, i.e., a scaled instance of this font
// file.
virtual SplashFont *makeFont(SplashCoord *mat);
private:
SplashT1FontFile(SplashT1FontEngine *engineA,
SplashFontFileID *idA,
char *fileNameA, GBool deleteFileA,
int t1libIDA, char **encA, char *encStrA);
SplashT1FontEngine *engine;
int t1libID; // t1lib font ID
char **enc;
char *encStr;
friend class SplashT1Font;
};
#endif // HAVE_T1LIB_H
#endif

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais