summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvipdfm
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-17 21:41:51 +0000
committerKarl Berry <karl@freefriends.org>2006-01-17 21:41:51 +0000
commit487ca4806cc046076293cf6cc5fbba0db282bac7 (patch)
tree847b412ab5158dd7bdd7ed7e5a4cc3fbca94be32 /Build/source/texk/dvipdfm
parenta3d3111bfe26b8e5f5bc6049dfb2a4ca2edc7881 (diff)
texk 1
git-svn-id: svn://tug.org/texlive/trunk@1485 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipdfm')
-rw-r--r--Build/source/texk/dvipdfm/AUTHORS8
-rw-r--r--Build/source/texk/dvipdfm/COPYING340
-rw-r--r--Build/source/texk/dvipdfm/ChangeLog101
-rw-r--r--Build/source/texk/dvipdfm/Credits19
-rw-r--r--Build/source/texk/dvipdfm/INSTALL111
-rw-r--r--Build/source/texk/dvipdfm/INSTALL-BINARY51
-rw-r--r--Build/source/texk/dvipdfm/Makefile.in77
-rw-r--r--Build/source/texk/dvipdfm/Makefile.in.dist223
-rw-r--r--Build/source/texk/dvipdfm/NEWS126
-rw-r--r--Build/source/texk/dvipdfm/OBTAINING10
-rw-r--r--Build/source/texk/dvipdfm/README67
-rw-r--r--Build/source/texk/dvipdfm/README.FIRST14
-rw-r--r--Build/source/texk/dvipdfm/TODO19
-rw-r--r--Build/source/texk/dvipdfm/acconfig.h37
-rw-r--r--Build/source/texk/dvipdfm/acconfig.h.in45
-rw-r--r--Build/source/texk/dvipdfm/aclocal.m499
-rw-r--r--Build/source/texk/dvipdfm/ascii85.c90
-rw-r--r--Build/source/texk/dvipdfm/c-auto.in4
-rw-r--r--Build/source/texk/dvipdfm/cmr.map142
-rw-r--r--Build/source/texk/dvipdfm/colors.h73
-rw-r--r--Build/source/texk/dvipdfm/colorsp.c230
-rw-r--r--Build/source/texk/dvipdfm/colorsp.h39
-rw-r--r--Build/source/texk/dvipdfm/config46
-rw-r--r--Build/source/texk/dvipdfm/config-dist46
-rw-r--r--Build/source/texk/dvipdfm/config.h.in65
-rwxr-xr-xBuild/source/texk/dvipdfm/configure2531
-rw-r--r--Build/source/texk/dvipdfm/configure.in63
-rw-r--r--Build/source/texk/dvipdfm/depend.mak1747
-rw-r--r--Build/source/texk/dvipdfm/depend.mk672
-rw-r--r--Build/source/texk/dvipdfm/doc/dvipdfm.tex1304
-rw-r--r--Build/source/texk/dvipdfm/doc/mwicks.bb5
-rw-r--r--Build/source/texk/dvipdfm/doc/mwicks.jpegbin0 -> 5778 bytes
-rw-r--r--Build/source/texk/dvipdfm/doc/transistor.bb5
-rw-r--r--Build/source/texk/dvipdfm/doc/transistor.eps316
-rw-r--r--Build/source/texk/dvipdfm/doc/transistor.fig94
-rw-r--r--Build/source/texk/dvipdfm/doc/transistor.pdf473
-rw-r--r--Build/source/texk/dvipdfm/dvi.c1238
-rw-r--r--Build/source/texk/dvipdfm/dvi.h67
-rw-r--r--Build/source/texk/dvipdfm/dvicodes.h115
-rw-r--r--Build/source/texk/dvipdfm/dvipdfm.1322
-rw-r--r--Build/source/texk/dvipdfm/dvipdfm.c649
-rw-r--r--Build/source/texk/dvipdfm/dvipdfm.h33
-rw-r--r--Build/source/texk/dvipdfm/dvipdfm.rc34
-rwxr-xr-xBuild/source/texk/dvipdfm/dvipdft130
-rw-r--r--Build/source/texk/dvipdfm/dvipdft.136
-rw-r--r--Build/source/texk/dvipdfm/dvipdft.rc34
-rw-r--r--Build/source/texk/dvipdfm/ebb.134
-rw-r--r--Build/source/texk/dvipdfm/ebb.c327
-rw-r--r--Build/source/texk/dvipdfm/ebb.rc36
-rwxr-xr-xBuild/source/texk/dvipdfm/encodings.c224
-rwxr-xr-xBuild/source/texk/dvipdfm/encodings.h19
-rw-r--r--Build/source/texk/dvipdfm/epdf.c159
-rw-r--r--Build/source/texk/dvipdfm/epdf.h11
-rw-r--r--Build/source/texk/dvipdfm/error.h45
-rw-r--r--Build/source/texk/dvipdfm/htex.c258
-rw-r--r--Build/source/texk/dvipdfm/htex.h37
-rw-r--r--Build/source/texk/dvipdfm/jpeg.c136
-rw-r--r--Build/source/texk/dvipdfm/jpeg.h47
-rwxr-xr-xBuild/source/texk/dvipdfm/macglyphs.h57
-rw-r--r--Build/source/texk/dvipdfm/mem.c95
-rw-r--r--Build/source/texk/dvipdfm/mem.h50
-rw-r--r--Build/source/texk/dvipdfm/mfileio.c128
-rw-r--r--Build/source/texk/dvipdfm/mfileio.h59
-rw-r--r--Build/source/texk/dvipdfm/mpost.c1365
-rw-r--r--Build/source/texk/dvipdfm/mpost.h40
-rw-r--r--Build/source/texk/dvipdfm/numbers.c317
-rw-r--r--Build/source/texk/dvipdfm/numbers.h85
-rw-r--r--Build/source/texk/dvipdfm/pdfdev.c1343
-rw-r--r--Build/source/texk/dvipdfm/pdfdev.h91
-rw-r--r--Build/source/texk/dvipdfm/pdfdoc.c1284
-rw-r--r--Build/source/texk/dvipdfm/pdfdoc.h96
-rw-r--r--Build/source/texk/dvipdfm/pdflimits.h39
-rw-r--r--Build/source/texk/dvipdfm/pdfobj.c1738
-rw-r--r--Build/source/texk/dvipdfm/pdfobj.h187
-rw-r--r--Build/source/texk/dvipdfm/pdfparse.c692
-rw-r--r--Build/source/texk/dvipdfm/pdfparse.h81
-rw-r--r--Build/source/texk/dvipdfm/pdfspecial.c1856
-rw-r--r--Build/source/texk/dvipdfm/pdfspecial.h102
-rw-r--r--Build/source/texk/dvipdfm/pkfont.c620
-rw-r--r--Build/source/texk/dvipdfm/pkfont.h38
-rw-r--r--Build/source/texk/dvipdfm/pngimage.c146
-rw-r--r--Build/source/texk/dvipdfm/pngimage.h40
-rw-r--r--Build/source/texk/dvipdfm/psimage.c152
-rw-r--r--Build/source/texk/dvipdfm/psimage.h39
-rw-r--r--Build/source/texk/dvipdfm/psspecial.c265
-rw-r--r--Build/source/texk/dvipdfm/psspecial.h35
-rw-r--r--Build/source/texk/dvipdfm/stamp-auto.in1
-rw-r--r--Build/source/texk/dvipdfm/standardenc.h112
-rw-r--r--Build/source/texk/dvipdfm/system.h25
-rw-r--r--Build/source/texk/dvipdfm/t1crypt.c26
-rw-r--r--Build/source/texk/dvipdfm/t1crypt.h11
-rw-r--r--Build/source/texk/dvipdfm/t1fonts.map240
-rw-r--r--Build/source/texk/dvipdfm/tfm.c714
-rw-r--r--Build/source/texk/dvipdfm/tfm.h63
-rw-r--r--Build/source/texk/dvipdfm/thumbnail.c108
-rw-r--r--Build/source/texk/dvipdfm/thumbnail.h40
-rw-r--r--Build/source/texk/dvipdfm/tpic.c498
-rw-r--r--Build/source/texk/dvipdfm/tpic.h41
-rwxr-xr-xBuild/source/texk/dvipdfm/ttf.c1031
-rwxr-xr-xBuild/source/texk/dvipdfm/ttf.h39
-rw-r--r--Build/source/texk/dvipdfm/twiddle.h11
-rw-r--r--Build/source/texk/dvipdfm/type1.c1372
-rw-r--r--Build/source/texk/dvipdfm/type1.h39
-rw-r--r--Build/source/texk/dvipdfm/version1
-rw-r--r--Build/source/texk/dvipdfm/vf.c1018
-rw-r--r--Build/source/texk/dvipdfm/vf.h35
-rw-r--r--Build/source/texk/dvipdfm/win32.mak116
-rw-r--r--Build/source/texk/dvipdfm/winansi.h53
108 files changed, 29917 insertions, 0 deletions
diff --git a/Build/source/texk/dvipdfm/AUTHORS b/Build/source/texk/dvipdfm/AUTHORS
new file mode 100644
index 00000000000..91aeb585527
--- /dev/null
+++ b/Build/source/texk/dvipdfm/AUTHORS
@@ -0,0 +1,8 @@
+dvipdfm was written by
+
+Mark Wicks
+Kettering University
+Flint, MI
+
+mwicks@kettering.edu
+
diff --git a/Build/source/texk/dvipdfm/COPYING b/Build/source/texk/dvipdfm/COPYING
new file mode 100644
index 00000000000..60549be514a
--- /dev/null
+++ b/Build/source/texk/dvipdfm/COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/Build/source/texk/dvipdfm/ChangeLog b/Build/source/texk/dvipdfm/ChangeLog
new file mode 100644
index 00000000000..1972c011002
--- /dev/null
+++ b/Build/source/texk/dvipdfm/ChangeLog
@@ -0,0 +1,101 @@
+2000-07-25 Mark A. Wicks <mwicks@betelgeuse.localdomain>
+
+ * Changed version to 0.13
+ * Cleaned up DVI and VF code so it all works on 16 bit chars
+ * Added support for 16 bit virtual fonts (OTF file)
+
+2000-07-23 Mark A. Wicks <mwicks@betelgeuse.localdomain>
+
+ * Cleanly separated encodings from fonts so that multiple
+ encodings can be used for the same font in the same document.
+ That way, all glyphs (>256) are available from a font:-).
+ * Made Type 1 font parsing and font subsetting more robust
+ * Changed version to 0.12.9beta
+ * Changed encoding method to help Acrobat Exchange 3.0
+ merge files created by dvipdfm.
+
+2000-07-06 Mark A. Wicks <mwicks@betelgeuse.localdomain>
+
+ * Changed version to 0.12.8
+ * Fixed a bug in the encoding code that could
+ cause characters to disappear in certain situations
+ * Fixed figure inclusion bugs
+ - Specials generated by older psfig macros now work
+ - Clipping/cropping and bounding box overrides now
+ work on included MetaPost images. Clipping/cropping
+ and bounding box overrides don't (and may never)
+ work on bitmaps.
+
+2000-05-24 Mark A. Wicks <mwicks@betelgeuse.localdomain>
+ * Fixed another unrelated bug that mostly affected color maps on
+ embedded bitmaps
+
+2000-02-06 Mark A. Wicks <mwicks@betelgeuse.localdomain>
+ * Fixed a bug that mostly affected color maps on embedded bitmaps
+
+1999-01 thru
+2000-03 07-06 Mark A. Wicks <mwicks@betelgeuse.localdomain>
+ * Made PS parsing a bit more robust
+
+1999-09-19 Mark A. Wicks <mwicks@betelgeuse.wicks.net>
+ * Changed version to 0.12.4.
+ * Added link breaking code (aka breaklinks) and additional
+ \special operators to support them.
+ * Fixed a bug in slanted font code
+ * Fixed a bug in TFM code that won't actually execute
+ unless you have a defective TFM file.
+
+1999-09-06 Mark A. Wicks <mwicks@betelgeuse.wicks.net>
+
+ * Added native MetaPost and native support
+ for simple PS operators
+ * Added PS/EPS support with helper program
+ * Added a configuration file
+ * Added standard color specials
+ * Added standard landscape and papersize specials
+ * Added support for PSfile and plotfile specials
+
+1999-08-22 Mark A. Wicks <mwicks@betelgeuse.wicks.net>
+
+ * Added slantfont and expand font support
+ * Removed dependency on AFM files
+ * Added support for font remapping to work around
+ some problems with Adobe Reader and certain character positions.
+ * Reworked font code a lot.
+
+1999-02-08 Mark A. Wicks <mwicks@odo.kettering.edu>
+ * Version 0.10.0 includes
+ PK font support
+ Tpic special support
+ kpath searching for included pdf and jpeg files via
+ the path defined by TEXPICTS
+
+1998-11-30 Mark A. Wicks <mwicks@odo.kettering.edu>
+
+ * Cleaned up a lot of little things.
+ * Tried to make code 8-bit clean in most places
+ * Added check for timezone in autoconf script.
+
+1998-11-29 Mark A. Wicks <mwicks@betelgeuse.wicks.net>
+
+ * Added font re-encoding support and created a map file for common
+ PostScript fonts.
+
+ * Cleaned up some little things.
+
+1998-11-27 Mark A. Wicks <mwicks@odo.kettering.edu>
+
+ * Changed source tree to fit with texk distribution.
+
+ * Added cmyk color support.
+
+1998-11-26 Mark A. Wicks <mwicks@odo.kettering.edu>
+
+ * Fixed a bug in the outline/bookmark tree structure.
+
+ * Changed the \special parser so it would recognize numbers
+ that don't start with a digit.
+
+ * Added macro support for Graphics and hyperref.
+
+ * Several minor changes.
diff --git a/Build/source/texk/dvipdfm/Credits b/Build/source/texk/dvipdfm/Credits
new file mode 100644
index 00000000000..a4c0dff85e0
--- /dev/null
+++ b/Build/source/texk/dvipdfm/Credits
@@ -0,0 +1,19 @@
+
+ The kpathsea library is an essential part of dvipdfm (and all Web2c-based
+TeX utilities). Thanks to Karl Berry and Olaf Weber for developing this and
+making it available.
+
+ Thanks to Cesar Crusius for encouraging me to support MetaPost output and
+for providing sample code.
+
+ Thanks to sevearl unnamed people for submitting bug reports. Thanks
+especially to those who tracked down problems and contributed
+patches---Akiro Kakuto and Tommy Ekola.
+
+ Thanks to those who have worked hard to provide support for dvipdfm in
+other Tex/LaTeX packages---Cesar Crucius, D.P. Story, Donald Knuth, Hans
+Hagan, and especially Sebastian Rahtz. I apologize for anyone who I have
+neglected to mention.
+
+
+
diff --git a/Build/source/texk/dvipdfm/INSTALL b/Build/source/texk/dvipdfm/INSTALL
new file mode 100644
index 00000000000..af5cfbb3a96
--- /dev/null
+++ b/Build/source/texk/dvipdfm/INSTALL
@@ -0,0 +1,111 @@
+Prerequisite packages:
+
+ To compile and install this package, you NEED an *installed* version of
+the kpathsea library. Usually a TeTeX installation will have this.
+Specifically, this means the kpathsea headers must be in your preprocessor
+search path (-I) and the kpathsea library must be in your linker search path
+(-L). The kpathsea library is included in source form with the "texk"
+bundle or the "web2c" bundle, available on CTAN.
+
+ Similar remarks hold for "libz" and its headers; however, dvipdfm will
+configure and compile without a recent version of libz--you just won't have
+any compression. It *requires* kpath, however.
+
+ The same comments hold for libpng as for libz. You *should* have a
+recent version of libpng installed before trying to compile dvipdfm. It
+should compile without libpng, but you will lose the ability to include
+thumbnails and png images.
+
+ You will probably want to have GhostScript installed, although it isn't
+absolutely necessary.
+
+Installation:
+
+ Also, you will probabably want
+
+ 1. Unbundle the gzip'ed tar file.
+
+ 2. Before compiling, set the CPPFLAGS, CFLAGS, and LDFLAGS environment
+ variables with any options you want and also any -I or -L options
+ required to locate kpathsea. CPPFLAGS should probably contain -I
+ pointing at the directory containing tex-file.h LDFLAGS should
+ probably contain -L pointing at the directory containing
+ libkpathsea.a
+
+ 3. Type "./configure" in the dvipdfm directory along with any necessary
+ options, e.g., "--prefix=PATH". Make sure you specify the path to
+ the directory containing your TeX tree root using --datadir=PATH,
+ e.g., if your TeX tree in contained in /usr/share/texmf, you should
+ supply the option --datadir=/usr/share to the configure script. Note
+ that the prefix and datadir cannot be set independently. They must
+ belong to the same tree. For example, you could be in trouble if you
+ say something like --datadir=/usr/local/share/tetex and
+ --prefix=/usr/local. The kpathsea library uses the path containing
+ the executable as a hint to locating the temf texmf.cnf file.
+ The executable MUST be placed in the same directory as your other
+ executables that use kpathsea.
+
+ 4. Type "make" in the dvipdfm directory.
+
+ 5. If all goes well, type "make install" in the dvipdfm directory.
+
+ 6. Replace the dvipdfm.def in your LaTex distribution with the one
+ provided by the latest dvipdfm distribution. This is necessary for
+ .eps and .png file support. The install script will not do this
+ for you because I do not believe it is healthy to overwrite a file
+ supplied by a different distribution.
+
+ 7. Run "mktexlsr" or its equivalent depending on your TeX distribution.
+ Even if you installed dvipdfm on a Unix system as an ordinary user,
+ you should run mktexlsr to hash your "local" tex files.
+
+ 8. Edit the config script in the texmf/dvipdfm directory and change to
+ suit your needs. An important configuration option is to set the
+ helper application for converting PS/EPS files to PDF format. By
+ default this is setup for GhostScript. If the idea
+ of executing running a command in a shell scares you,
+ comment out the line with the command string. Alternatively,
+ if you really want to disable it, comment the #define HAVE_SYSTEM
+ in config.h
+
+ I have installed this cleanly myself on Solaris 2.5 and RedHat Linux 5.1
+(upgraded to tetex-0.9). It has been compiled on various platforms by
+various others as part of the TeX-Live project and as part of several
+Windows distributions. I have been using it primarily under Linux.
+
+ Please e-mail bug reports to
+
+ Mark A. Wicks
+ Kettering University
+ mwicks@kettering.edu
+
+Notes/Possible Problems:
+
+ 1. The Makefile installs the "dvipdfm" and the "ebb" binaries.
+ The dvipdfm binary requries kpathsea to do its font searching.
+ You must already have a working TeX installation with its own
+ texmf.cnf, etc.
+
+ 2. In addition to this package, you will need PostScript Type1 fonts for
+ the Computer Modern fonts and any additional fonts you want to use.
+ PostScript Type1 fonts are distributed by the American Math Society.
+ Information about these fonts is available at the URL
+
+ http://www.ams.org/tex/type1-fonts.html
+
+ and the fonts themselves (Computer Modern and AMS fonts) are available at
+
+ ftp://ftp.ams.org/pub/tex/psfonts/
+
+ These fonts need to be installed in a location where the kpathsea
+ library can find them.
+
+ 3. If "dvipdfm" complains that it can't find fonts or its font map file,
+ read the "kpathsea" documentation about debugging path searching. If
+ you can't get kpathsea to find your texmf tree, it can always locate
+ the fonts using environment variables. If "kpathsea" can't find your
+ texmf.cnf, try setting the environment variable TEXMFCNF to point to
+ the directory containing texmf.cnf As a last resort, you can set
+ T1FONTS to point to your ".pfb" files, and set TFMFONTS to point to
+ your ".tfm" files. Use two trailing //s on the path name if you want
+ that path recursively searched).
diff --git a/Build/source/texk/dvipdfm/INSTALL-BINARY b/Build/source/texk/dvipdfm/INSTALL-BINARY
new file mode 100644
index 00000000000..01a7308cee2
--- /dev/null
+++ b/Build/source/texk/dvipdfm/INSTALL-BINARY
@@ -0,0 +1,51 @@
+Installation:
+
+ If you are trying to manually install a pre-compiled binary version of this package,
+you will have to install one to three files.
+
+ 1. Copy the executables dvipdfm and ebb (optional) to a directory in your
+path.
+
+ 2. Copy the t1fonts.map (optional) file to a dvipdfm subdirectory of
+your texmf tree, e.g., /usr/share/texmf/dvipdfm/t1fonts.map
+
+ If dvipdfm doesn't work (probably because kpathsea can't find your
+texmf.cnf file), try one of the following remedies using environment variables:
+
+ i) Set TEXMFCNF to point to the directory containing your texmf.cnf
+ file.
+
+ or
+
+ ii) Set T1FONTS to point to the directory containing your .pfb files,
+ set TFMFONTS to point to the directory containing your .tfm files,
+ and set AFMFONTS to point to the directory containing your .afm files.
+
+Notes:
+ 1. The dvipdfm binary requries kpathsea to do its font searching.
+ You must already have a working TeX installation with its own
+ texmf.cnf, etc.
+
+ 2. In addition to this package, you will need PostScript Type1 fonts for
+ the Computer Modern fonts and any additional fonts you want to use.
+ PostScript Type1 fonts are distributed by the American Math Society.
+ Information about these fonts is available at the URL
+
+ http://www.ams.org/tex/type1-fonts.html
+
+ and the fonts themselves (Computer Modern and AMS fonts) are available at
+
+ ftp://ftp.ams.org/pub/tex/psfonts/
+
+ These fonts need to be installed in a location where the kpathsea
+ library can find them.
+
+ 3. If "dvipdfm" complains that it can't find fonts, read the "kpathsea"
+ documentation about debugging path searching. If you can't get
+ kpathsea to find your texmf tree, it can always locate the
+ fonts using environment variables. If "kpathsea" can't find
+ your texmf.cnf, try setting the environment variable TEXMFCNF
+ to point to the directory containing texmf.cnf. As an
+ alternative, you can set AFMFONTS to point to your ".afm" files
+ (dvipdfm needs these), set T1FONTS to point to your ".pfb" files,
+ and set TFMFONTS to point to your ".tfm" files.
diff --git a/Build/source/texk/dvipdfm/Makefile.in b/Build/source/texk/dvipdfm/Makefile.in
new file mode 100644
index 00000000000..43409e76f9a
--- /dev/null
+++ b/Build/source/texk/dvipdfm/Makefile.in
@@ -0,0 +1,77 @@
+kpse_include ../make/paths.mk
+kpse_include ../make/common.mk
+kpse_include ../make/programs.mk
+
+ZLIBDIR=../../libs/zlib
+ZLIBSRCDIR=$(srcdir)/$(ZLIBDIR)
+ZLIBDEP = @ZLIBDEP@
+LDZLIB = @LDZLIB@
+
+LIBPNGDIR=../../libs/libpng
+LIBPNGSRCDIR=$(srcdir)/$(LIBPNGDIR)
+LIBPNGDEP = @LIBPNGDEP@
+LDLIBPNG = @LDLIBPNG@
+
+LD_ALL_LIBS = $(LDLIBPNG) $(LDZLIB)
+ALL_LIBS_DEP = $(ZLIBDEP) $(LIBPNGDEP)
+
+program = dvipdfm
+programs = $(program) ebb
+default all: $(programs)
+
+prog_cflags = @LIBPNGCPPFLAGS@ @ZLIBCPPFLAGS@
+
+objects=pdfdev.o pdfdoc.o dvi.o mfileio.o mem.o jpeg.o numbers.o pdfobj.o \
+ pdfparse.o pdfspecial.o tfm.o type1.o dvipdfm.o epdf.o vf.o \
+ t1crypt.o pkfont.o tpic.o thumbnail.o pngimage.o htex.o \
+ mpost.o psimage.o psspecial.o colorsp.o encodings.o @TTF_OPT@ ttf.o
+eobjects=ebb.o jpeg.o pdfobj.o mem.o mfileio.o numbers.o pdfparse.o \
+ pngimage.o
+
+$(program): $(objects) $(kpathsea) $(ALL_LIBS_DEP)
+ $(kpathsea_link) $(objects) $(LD_ALL_LIBS) $(LOADLIBES)
+
+ebb: $(eobjects) $(kpathsea) $(ALL_LIBS_DEP)
+ $(kpathsea_link) $(eobjects) $(LD_ALL_LIBS) $(LOADLIBES)
+
+$(LIBPNGDIR)/libpng.a:
+ cd $(LIBPNGDIR); $(MAKE)
+
+$(ZLIBDIR)/libz.a:
+ cd $(ZLIBDIR); $(MAKE)
+
+kpse_include ../make/tkpathsea.mk
+
+install: install-exec install-data
+uninstall: uninstall-exec uninstall-data
+
+distclean::
+ $(RM) config.h
+
+install-exec:
+ $(SHELL) $(top_srcdir)/../mkinstalldirs $(bindir)
+ $(INSTALL_LIBTOOL_PROG) $(program) $(bindir)
+ $(INSTALL_LIBTOOL_PROG) ebb $(bindir)
+ $(INSTALL_SCRIPT) $(srcdir)/dvipdft $(bindir)
+
+uninstall-exec:
+ cd $(bindir); rm -f $(programs)
+
+install-data:
+ $(SHELL) $(top_srcdir)/../mkinstalldirs $(man1dir)
+ $(INSTALL_DATA) $(srcdir)/$(program).1 $(man1dir)/$(program).$(manext)
+ $(INSTALL_DATA) $(srcdir)/dvipdft.1 $(man1dir)/dvipdft.$(manext)
+ $(INSTALL_DATA) $(srcdir)/ebb.1 $(man1dir)/ebb.$(manext)
+
+uninstall-data:
+ rm -f $(man1dir)/dvilj.$(manext)
+ rm -f $(man1dir)/dvipdft.$(manext)
+ rm -f $(man1dir)/ebb.$(manext)
+
+kpse_include ../make/config.mk
+
+info dvi check:
+
+kpse_include ../make/clean.mk
+kpse_include ../make/rdepend.mk
+kpse_include depend.mk
diff --git a/Build/source/texk/dvipdfm/Makefile.in.dist b/Build/source/texk/dvipdfm/Makefile.in.dist
new file mode 100644
index 00000000000..1fe85a6c5af
--- /dev/null
+++ b/Build/source/texk/dvipdfm/Makefile.in.dist
@@ -0,0 +1,223 @@
+CC=@CC@
+CFLAGS=@CFLAGS@
+LDFLAGS=@LDFLAGS@
+CPPFLAGS=@CPPFLAGS@ -I.
+INSTALL=@INSTALL@
+LIBS=@LIBS@ -lm
+srcdir=@srcdir@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+bindir=@bindir@
+datadir=@datadir@
+mandir=@mandir@
+texmf=@TEXMF@
+dvipdfmdir=$(texmf)/dvipdfm
+psheaderdir=$(texmf)/dvips
+programs=dvipdfm ebb
+scripts=dvipdft
+mkinstalldirs=@SHELL@ mkinstalldirs
+.c.o:
+ $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
+src=pdfdev.c pdfdoc.c dvi.c mfileio.c mem.c jpeg.c numbers.c pdfobj.c \
+ pdfparse.c pdfspecial.c tfm.c type1.c dvipdfm.c epdf.c vf.c \
+ t1crypt.c pkfont.c tpic.c thumbnail.c pngimage.c ebb.c htex.c \
+ mpost.c psimage.c psspecial.c colorsp.c encodings.c @TTF_OPT@ ttf.c
+objects=pdfdev.o pdfdoc.o dvi.o mfileio.o mem.o jpeg.o numbers.o pdfobj.o \
+ pdfparse.o pdfspecial.o tfm.o type1.o dvipdfm.o epdf.o vf.o \
+ t1crypt.o pkfont.o tpic.o thumbnail.o pngimage.o htex.o \
+ mpost.o psimage.o psspecial.o colorsp.o encodings.o @TTF_OPT@ ttf.o
+manpages=dvipdfm.1
+
+eobjects=ebb.o jpeg.o pdfobj.o mem.o mfileio.o numbers.o pdfparse.o \
+ pngimage.o
+encodings=ot1.enc ot1alt.enc ot1r.enc
+mapfiles=cmr.map psbase14.map lw35urw.map lw35urwa.map
+check default all: $(programs)
+ebb: $(eobjects) Makefile
+ $(CC) -o ebb $(eobjects) $(LDFLAGS) $(LIBS)
+dvipdfm: $(objects) Makefile
+ $(CC) -o dvipdfm $(objects) $(LDFLAGS) $(LIBS)
+include depend.make
+#
+# Install/uninstall
+#
+install: install-exec install-data install-man
+uninstall: uninstall-exec uninstall-data uninstall-man
+install-exec: all
+ $(mkinstalldirs) $(bindir); \
+ for i in $(programs) $(scripts) ; \
+ do $(INSTALL) $$i $(bindir); \
+ done
+# t1fonts.map.
+install-man:
+ $(mkinstalldirs) $(mandir)/man1; \
+ for i in $(manpages); \
+ do $(INSTALL) -m 644 $$i $(mandir)/man1; \
+ done
+install-data:
+ $(mkinstalldirs) $(dvipdfmdir)/base; \
+ if test -f $(dvipdfmdir)/config; then \
+ /bin/mv $(dvipdfmdir)/config $(dvipdfmdir)/config.sav; \
+ fi
+ $(mkinstalldirs) $(dvipdfmdir)/config; \
+ if test -f $(dvipdfmdir)/t1fonts.map; then \
+ /bin/mv $(dvipdfmdir)/t1fonts.map $(dvipdfmdir)/config; \
+ fi
+ if test -f $(dvipdfmdir)/config.sav; then \
+ /bin/mv $(dvipdfmdir)/config.sav $(dvipdfmdir)/config/config; \
+ fi
+ if test ! -r $(dvipdfmdir)/config/t1fonts.map \
+ || grep 'original t1fonts.map --' $(dvipdfmdir)/config/t1fonts.map \
+ >/dev/null; then \
+ /bin/rm -f $(dvipdfmdir)/config/t1fonts.map; \
+ $(INSTALL) -m 644 ./t1fonts.map $(dvipdfmdir)/config; \
+ else true; fi
+ if test ! -r $(dvipdfmdir)/config/config \
+ || grep 'original config --' $(dvipdfmdir)/config/config \
+ >/dev/null; then \
+ /bin/rm -f $(dvipdfmdir)/config/config; \
+ $(INSTALL) -m 644 ./config $(dvipdfmdir)/config; \
+ else true; fi
+ for i in $(mapfiles); \
+ do $(INSTALL) -m 644 $$i $(dvipdfmdir)/config; \
+ done
+ for i in $(encodings); \
+ do $(INSTALL) -m 644 $$i $(dvipdfmdir)/base; \
+ done
+uninstall-exec:
+ for i in $(programs); \
+ do rm -f $(bindir)/$$i; \
+ done
+ for i in $(scripts); \
+ do rm -f $(bindir)/$$i; \
+ done
+uninstall-man:
+ for i in $(manpages); \
+ do rm -f $(mandir)/man1/$$i; \
+ done
+uninstall-data:
+ if grep 'original pdffonts.map --' $(psheaderdir)/dvipdfm/pdffonts.map \
+ >/dev/null 2>&1; then rm -f $(psheaderdir)/dvipdfm/pdffonts.map; \
+ else true; fi
+ if grep 'original pdffonts.map --' $(dvipdfmdir)/pdffonts.map \
+ >/dev/null 2>&1; then rm -f $(dvipdfmdir)/pdffonts.map; \
+ else true; fi
+ if grep 'original t1fonts.map --' $(dvipdfmdir)/t1fonts.map \
+ >/dev/null 2>&1; then rm -f $(dvipdfmdir)/t1fonts.map; \
+ else true; fi
+ if grep 'original t1fonts.map --' $(dvipdfmdir)/config/t1fonts.map \
+ >/dev/null 2>&1; then rm -f $(dvipdfmdir)/config/t1fonts.map; \
+ else true; fi
+ if grep 'original config --' $(dvipdfmdir)/config \
+ >/dev/null 2>&1; then rm -f $(dvipdfmdir)/config; \
+ else true; fi
+ if grep 'original config --' $(dvipdfmdir)/config/config \
+ >/dev/null 2>&1; then rm -f $(dvipdfmdir)/config/config; \
+ else true; fi
+ for i in $(encodings); \
+ do \
+ if test -r $(dvipdfmdir)/$$i; then /bin/rm -f $(dvipdfmdir)/$$i; fi; \
+ if test -r $(dvipdfmdir)/base/$$i; then /bin/rm -f $(dvipdfmdir)/base/$$i; fi; \
+ done
+ for i in $(mapfiles); \
+ do \
+ if test -r $(dvipdfmdir)/config/$$i; then /bin/rm -f $(dvipdfmdir)/config/$$i; fi; \
+ done
+ for i in base config; \
+ do \
+ if test -d $(dvipdfmdir)/$$i; then /bin/rmdir $(dvipdfmdir)/$$i > /dev/null 2>&1 ; fi; \
+ done
+ if test -d $(dvipdfmdir); then /bin/rmdir $(dvipdfmdir) > /dev/null 2>&1 ; fi
+#
+# Developer stuff
+#
+maintainerclean: clean distclean
+ rm -f config.h.in configure
+distclean: clean
+ rm -f Makefile config.h config.cache confdefs.h
+clean:
+ rm -f $(programs) *.o *.pdf
+ for i in . doc latex-support ; \
+ do rm -f $$i/*.dvi $$i/*.log $$i/*~ $$i/*.out $$i/*.aux $$i/core ; \
+ done
+ rm -f doc/dvipdfm.pdf latex-support/sample.pdf
+TAGS: $(src)
+ etags *.[ch]
+depend:
+ rm -f depend.make
+ make depend.make
+depend.make:
+ $(CC) $(CPPFLAGS) -MM $(src) > depend.make
+@MAINT@#
+@MAINT@# Autoconf stuff
+@MAINT@#
+@MAINT@Makefile: Makefile.in configure
+@MAINT@ echo "***** You need to rerun ./configure. *****"
+@MAINT@ exit 1
+@MAINT@config.h: config.h.in configure.in
+@MAINT@ echo "***** You need to rerun ./configure. *****"
+@MAINT@ rm config.h
+@MAINT@ exit 1
+@MAINT@config.h.in: acconfig.h configure.in
+@MAINT@ autoheader
+@MAINT@ touch config.h.in
+@MAINT@aclocal.m4: SCCS/s.aclocal.m4
+@MAINT@ get aclocal.m4
+@MAINT@configure: configure.in aclocal.m4
+@MAINT@ autoconf
+@MAINT@#
+@MAINT@ # Automated distributions
+@MAINT@#
+@MAINT@TOPDIR=${HOME}/Projects/rpmtree
+@MAINT@doc/dvipdfm.dvi: doc/dvipdfm.tex
+@MAINT@ cd doc; tex dvipdfm
+@MAINT@doc/dvipdfm.pdf: doc/dvipdfm.dvi
+@MAINT@ cd doc; dvipdft dvipdfm
+@MAINT@tarball: depend configure
+ /bin/rm -rf ../dvipdfm
+ mkdir ../dvipdfm
+ tar -zcf ../dvipdfm-@VERSION@.tar.gz -T distribution-file-list
+ cd ..
+ tar -C ../dvipdfm -zxf ../dvipdfm-@VERSION@.tar.gz
+ tar -C .. -zcf ../dvipdfm-@VERSION@.tar.gz dvipdfm
+ /bin/rm -rf ../dvipdfm
+@MAINT@dvipdfm-static: $(objects) Makefile
+ $(CC) -o dvipdfm-static $(objects) --static $(LDFLAGS) $(LIBS)
+@MAINT@ebb-static : $(eobjects) Makefile
+ $(CC) -o ebb-static $(eobjects) --static $(LDFLAGS) $(LIBS)
+@MAINT@bin-dist: dvipdfm-static ebb-static dvipdfm ebb VERSION
+@MAINT@ /bin/rm -rf dvipdfm-bin
+@MAINT@ mkdir -p dvipdfm-bin
+@MAINT@ cp -a dvipdfm ebb INSTALL-BINARY COPYING README t1fonts.map dvipdfm-bin
+@MAINT@ strip dvipdfm ebb dvipdfm-static ebb-static
+@MAINT@ tar -zcf ../dvipdfm-binary-linux-i386-glibc-@VERSION@.tar.gz dvipdfm-bin
+@MAINT@ /bin/rm -rf dvipdfm-bin
+@MAINT@ mkdir -p dvipdfm-bin
+@MAINT@ cp -a INSTALL-BINARY COPYING README t1fonts.map dvipdfm-bin
+@MAINT@ cp -a dvipdfm-static dvipdfm-bin/dvipdfm
+@MAINT@ cp -a ebb-static dvipdfm-bin/ebb
+@MAINT@ tar -zcf ../dvipdfm-binary-linux-i386-static-@VERSION@.tar.gz dvipdfm-bin
+@MAINT@ /bin/rm -rf dvipdfm-bin
+@MAINT@rpm-dist: tarball
+@MAINT@ mkdir -p ${TOPDIR}/SOURCES ${TOPDIR}/BUILD ${TOPDIR}/SPECS ${TOPDIR}/RPMS/i386 ${TOPDIR}/SRPMS
+@MAINT@ sed -e s/VERSION/@VERSION@/ dvipdfm.spec.in > ${TOPDIR}/SPECS/dvipdfm-@VERSION@.spec
+@MAINT@ cp -a ../dvipdfm-@VERSION@.tar.gz ${TOPDIR}/SOURCES/
+@MAINT@ rpm -ba ${TOPDIR}/SPECS/dvipdfm-@VERSION@.spec
+@MAINT@web-dist: rpm-dist tarball doc/dvipdfm.pdf
+@MAINT@ rm /home/httpd/html/dvipdfm/dvipdfm.tar.gz
+
+@MAINT@ cp -a ../dvipdfm-@VERSION@.tar.gz ${TOPDIR}/RPMS/i386/dvipdfm-@VERSION@-1.i386.rpm ${TOPDIR}/SRPMS/dvipdfm-@VERSION@-1.src.rpm /home/httpd/html/dvipdfm/
+@MAINT@ ln -s dvipdfm-@VERSION@.tar.gz /home/httpd/html/dvipdfm/dvipdfm.tar.gz
+@MAINT@ cp -a doc/dvipdfm.pdf /home/httpd/html/dvipdfm/dvipdfm-@VERSION@.pdf
+@MAINT@ rm -f /home/httpd/html/dvipdfm/dvipdfm.pdf
+@MAINT@ ln -s dvipdfm-@VERSION@.pdf /home/httpd/html/dvipdfm/dvipdfm.pdf
+@MAINT@ rm -f /home/httpd/html/dvipdfm/dvipdfm-latest.i386.rpm
+@MAINT@ ln -s dvipdfm-@VERSION@-1.i386.rpm /home/httpd/html/dvipdfm/dvipdfm-latest.i386.rpm
+@MAINT@ rm -f /home/httpd/html/dvipdfm/dvipdfm-latest.src.rpm
+@MAINT@ ln -s dvipdfm-@VERSION@-1.src.rpm /home/httpd/html/dvipdfm/dvipdfm-latest.src.rpm
+@MAINT@ftp-dist: rpm-dist tarball doc/dvipdfm.pdf
+@MAINT@ ssh mwicks@ftp 'rm pub/outgoing/mwicks/dvipdfm/*.tar.gz pub/outgoing/mwicks/dvipdfm/*.pdf ; cd pub/outgoing/mwicks/dvipdfm/; ln -s dvipdfm-@VERSION@.tar.gz dvipdfm.tar.gz'
+@MAINT@ scp ../dvipdfm-@VERSION@.tar.gz mwicks@ftp:pub/outgoing/mwicks/dvipdfm/dvipdfm-@VERSION@.tar.gz
+@MAINT@ scp doc/dvipdfm.pdf mwicks@ftp:pub/outgoing/mwicks/dvipdfm/dvipdfm-@VERSION@.pdf
+@MAINT@ ssh mwicks@ftp 'ln -s dvipdfm-@VERSION@.pdf pub/outgoing/mwicks/dvipdfm/dvipdfm.pdf'
+
diff --git a/Build/source/texk/dvipdfm/NEWS b/Build/source/texk/dvipdfm/NEWS
new file mode 100644
index 00000000000..6e9016e713f
--- /dev/null
+++ b/Build/source/texk/dvipdfm/NEWS
@@ -0,0 +1,126 @@
+October 19, 2000 - Version 0.13.2
+
+ This release adds preliminary support for TrueType fonts.
+
+ Also this release fixes two problems in the makefile that have been
+causing some people difficulties getting dvipdfm to compile. One of these
+problems was the test for compress2() (which was incorrect). The second
+problem occurs because some make implementations don't honor CPPFLAGS. An
+explicit rule has been added to do so.
+
+
+July 25, 2000 - Version 0.13
+
+ This release adds support for 16 bit character sets via Omega's OFM
+files. The DVI and VF code was made 16 bit clean. I am anxious
+to hear from Omega users.
+
+ The release also changes the way encodings are written to the PDF file.
+The prior method was causing compatibility problems with certain software
+that tried to merge PDF files.
+
+ Much of the Type1 font code has been rewritten for this release. The
+rewritten code allows multiple encodings to be used with the same Type 1
+font in the same document so that *all* glyphs (even >256) are available
+from a Type 1 font. Font subsetting has been improved. In particular, the
+internal encoding is completely removed if it's not needed.
+
+July 8, 2000 - Version 0.12.8
+
+ The primary change in this release involves fixing file inclusion
+so that it works with the older TeXfig style specials used by the
+psfig macros. Other changes include fixing several bugs in metapost
+file inclusion, bugs in the parsing of colormaps of PDF files to be
+embedded, and a bug that could cause characters to disappear under
+certain conditions. Work on a problem that affects use of XYPIC
+is in progress.
+
+ WARNING: THE LATEX SUPPORT FILE NAMED DVIPDFM.DEF HAS CHANGED IN VERSION
+ 0.12 TO BE MORE COMPATIBLE WITH DVIPS AND OTHER DVI DRIVERS. IT
+ CANNOT BE USED WITH EARLIER VERSIONS OF DVIDFPM. HOWEVER,
+ EARLIER VERSIONS OF DVIPDFM.DEF CAN BE USED WITH VERSION 0.12.
+
+September 6, 1999 - Version 0.12
+
+ Added native support for including MetaPost output. Along with this
+ comes the ability to interpret simple PostScript operators natively.
+ This allows dvipdfm to process DVI files intended for dvips as long as
+ they don't do anything too fancy. The internal mini-PostScript
+ interpreter is good enough to process the "rotate" commands produced by
+ the standard dvips graphics driver.
+
+ Added support for PostScript files using a helper application such as
+ GhostScript. PostScript files may be included with either the "PSfile"
+ special or the "plotfile" special.
+
+ Added support for the "standard" color specials. Together with the above
+ list, dvipdfm can now process many DVI files targets for dvips (as long
+ as they use very simple PostScript commands). PostScript code such as
+ that produced by PSTricks is not supported.
+
+ Added a configuration file for specifying default command line options.
+
+August 21, 1999.
+
+ WARNING: VERSION 0.11 CHANGES THE FORMAT OF THE t1fonts.map FILE.
+
+ The font code has been reworked in several ways. Version 0.11 does not
+require AFM files. This is a significant improvement since AFM files are
+disappearing from major distributions and repositories. Unfortunately, this
+required a change in the format of the t1fonts.map file.
+
+ A bit of the font code has been rewritten to provide work-alikes for the
+"slantfont" and "extendfont" provided by dvips. There are several
+workarounds for various bugs in Acrobat Reader involving searching for and
+selecting ligatures and there's also an attempt to address the disappearing
+Gamma problem.
+
+ Version 0.11 also adds PNG and thumbnail support.
+
+ Version 0.11 add support for the HyperTeX (HTML) specials for improved
+DVI file portability.
+
+April 8, 1999.
+
+ Version 0.10.5 changes the rule code to use a PDF stroke instead
+of filling a rectangular box. It also omits some unecessary
+font information from the PDF file for the base 14 PS fonts.
+This is to produce for slightly smaller PDF files when using
+these fonts.
+
+March 30, 1999.
+
+ NOTE: VERSION 0.10.4 CHANGES THE NAME/LOCATION OF ITS CONFIGURATION FILES!
+
+ It also fixes a bug that caused nested virtual fonts to fail and fixes a couple of other
+ fairly insignificant bugs.
+
+ Version 0.10.0 introduced PK fonts support and support
+ for TPIC special commands to allow some native graphics
+ support (don't you hate distilling those .eps files).
+
+December 30, 1998.
+ Version 0.9.0 supports partial font embedding and Flate compression. The
+ page tree and destination tree are shipped out as balanced trees.
+
+December 14, 1998.
+ Version 0.8.3 fixes a memory leak in the vf code found by Akiro Kakuto.
+ Another change hopefully makes running ./configure a bit easier.
+
+ Version 0.8.1 and 0.8.2 fix an overflow in the kerning code
+ which occurs for large horizontal motions.
+
+ Version 0.8 supports virtual fonts. Much of the code has been
+ reorganized and rewritten. It is nearly an order of magnitude faster than
+ earlier versions. Version 0.8 no longer requires the kpath source
+ tree. Instead it uses an installed version of libkpathsea and its
+ headers.
+
+Nov. 28, 1998
+ Specifying font encoding now supported. There is a font map file for
+ the more common PostScript fonts.
+
+Nov. 26, 1998
+
+ LaTeX Graphics and hyperref support is now available. See the directory
+ latex-support for information and drivers.
diff --git a/Build/source/texk/dvipdfm/OBTAINING b/Build/source/texk/dvipdfm/OBTAINING
new file mode 100644
index 00000000000..6df772fa6fe
--- /dev/null
+++ b/Build/source/texk/dvipdfm/OBTAINING
@@ -0,0 +1,10 @@
+
+This distribution may be obtained from links at
+
+http://odo.kettering.edu/dvipdfm
+
+or
+
+ftp://ftp.kettering.edu/pub/outgoing/mwicks/dvipdfm
+
+
diff --git a/Build/source/texk/dvipdfm/README b/Build/source/texk/dvipdfm/README
new file mode 100644
index 00000000000..7ee29041a79
--- /dev/null
+++ b/Build/source/texk/dvipdfm/README
@@ -0,0 +1,67 @@
+ This is dvipdfm, a DVI to PDF translator. I wrote this mainly as
+exercise to get at the features of PDF I wanted to experiment with. You're
+probably wondering why I don't use PDFTeX. I am a bit of a purist and I
+would rather use TeX unmodified as Donald Knuth left it.
+You can get it or the manual from
+
+ http://odo.kettering.edu/dvipdfm
+
+or if you prefer FTP:
+
+ ftp://ftp.kettering.edu/pub/outgoing/mwicks/dvipdfm
+
+
+ Features:
+ - TeX \special's that approximate the functionality
+ of the PostScript pdfmarks used by Adobe's
+ Acrobat Distiller. Links, outlines, articles, and named
+ destinations are supported, for example.
+
+ - Ability to include PDF, JPEG, PNG, MetaPost, and self-contained
+ (e.g., eps) PostScript (with help from an external program) files as
+ embedded images. For PDF files, only the first page is included.
+ Resources will be embedded from the original file as necessary.
+ File inclusion does not work for PDF files that store the page
+ contents in several segments in an array.
+
+ - Support for several \special standards for
+ DVI file portability.
+
+ - Support for thumbnails (with a little help from GhostScript).
+
+ - Re-encoding support for PostScript fonts. dvipdfm
+ uses the same .enc files as dvips. The mapfile is different.
+
+ - Virtual font support.
+
+ - Support for arbitrary linear graphics transformations.
+ Any material on the page can be scaled and rotated.
+
+ - An internal color stack accessible via \special's.
+
+ - Beginning of page (BOP) and end of page (EOP)
+ \special's for placing arbitrary PDF stream
+ graphics on every page.
+
+ - Partial font embedding and Flate compression
+ for reduced file size.
+
+ - Balanced page tree and dest tree to improve reader
+ speed on very large documents.
+
+ Limitations (at present):
+
+ - Contents streams consisting of multiple parts cannot be embedded.
+ - All instances of the same Type1 font must have the same encoding.
+
+ Additional Information:
+
+ There is a dvipdfm e-mail list. To join, send
+e-mail to majordomo@gaspra.kettering.edu containing
+the line:
+
+ subscribe dvipdfm
+
+ Mark A. Wicks
+ Kettering University
+ mwicks@kettering.edu
diff --git a/Build/source/texk/dvipdfm/README.FIRST b/Build/source/texk/dvipdfm/README.FIRST
new file mode 100644
index 00000000000..f1f420e29b3
--- /dev/null
+++ b/Build/source/texk/dvipdfm/README.FIRST
@@ -0,0 +1,14 @@
+
+ Read the NEWS file. There are important notes about compatibility with
+earlier versions.
+
+ Also read the INSTALLATION file. Some things have changed since
+earlier releases.
+
+ The install scripts do not overwrite the file named dvipdfm.def in your
+LaTeX tree (I don't think it's polite to clobber files installed by other
+distributions). You will probably want the new functionality provided by
+dvipdfm.def, and you must install this file manually.
+
+ The install scripts also do not run mktexlsr or its equivalent. If you
+are installing dvipdfm for the first time, you should rehash your TeX tree.
diff --git a/Build/source/texk/dvipdfm/TODO b/Build/source/texk/dvipdfm/TODO
new file mode 100644
index 00000000000..e283fb2908e
--- /dev/null
+++ b/Build/source/texk/dvipdfm/TODO
@@ -0,0 +1,19 @@
+ I am pretty bad about this file up to date :-(
+
+Aug 19, 1999.
+
+ - Add MetaPost support
+ - Add TrueType font support
+
+Mar 31, 1999.
+
+My major to-do list items are
+
+ - Add TrueType font support
+ - Move away from requiring the use of .afm files (they are disappearing
+from CTAN :-(.
+
+Nov 26, 1998.
+
+ Need to work on making this fit into the typical
+TeX source tree structure.
diff --git a/Build/source/texk/dvipdfm/acconfig.h b/Build/source/texk/dvipdfm/acconfig.h
new file mode 100644
index 00000000000..ee49123b348
--- /dev/null
+++ b/Build/source/texk/dvipdfm/acconfig.h
@@ -0,0 +1,37 @@
+#define VERSION 0
+
+#define PACKAGE "package"
+
+/* define if you have kpathsea */
+#undef HAVE_KPATHSEA
+
+/* define if your zlib has the compress2 function */
+#undef HAVE_ZLIB_COMPRESS2
+
+/* define if you have zlib and its headers */
+#undef HAVE_ZLIB
+
+/* define if you have xbasename() in your libkpathsea instead of basename() */
+#undef HAVE_XBASENAME
+
+/* define if kpathsea understands TrueType (TTF) formats */
+#undef HAVE_TTF_FORMATS
+
+/* define if struct tm has tm_gmtoff as a member */
+#undef HAVE_TM_GMTOFF
+
+/* define if <time.h> has timezone as an external variable */
+#undef HAVE_TIMEZONE
+
+/* define if kpathsea supports type1 and vf formats */
+#undef HAVE_KPSE_FORMATS
+
+/* define if you have libpng */
+#undef HAVE_LIBPNG
+
+/* Define if kpathsea understands Omega (OFM/OVF) formats */
+#undef HAVE_OMEGA_FORMATS
+
+
+
+
diff --git a/Build/source/texk/dvipdfm/acconfig.h.in b/Build/source/texk/dvipdfm/acconfig.h.in
new file mode 100644
index 00000000000..e81beaf36c9
--- /dev/null
+++ b/Build/source/texk/dvipdfm/acconfig.h.in
@@ -0,0 +1,45 @@
+
+/* Local variables defined by MAW */
+#ifndef _CONFIG_H
+
+#define VERSION 0
+
+#define PACKAGE "package"
+
+/* HAVE_TIMEZONE - Define if <time.h> has timezone as an external variable */
+#undef HAVE_TIMEZONE
+
+/* HAVE_TM_GMTOFF - Define if struct tm has tm_gmtoff as a member */
+#undef HAVE_TM_GMTOFF
+
+/* HAVE_KPATHSEA - Define if you have kpathsea */
+#define HAVE_KPATHSEA
+
+/* HAVE_XBASENAME - Define if you have xbasename() in your libkpathsea instead of basename() */
+#undef HAVE_XBASENAME
+
+/* HAVE_ZLIB - Define if you have zlib and its headers */
+#undef HAVE_ZLIB
+/* HAVE_ZLIB_COMPRESS2 - Define if your zlib has the compress2 function */
+#undef HAVE_ZLIB_COMPRESS2
+
+/* HAVE_KPSE_FORMATS - Define if you have a
+ version of kpathsea with type1 and vf formats */
+#define HAVE_KPSE_FORMATS
+
+/* HAVE_OMEGA_FORMATS - Define if you have a
+ version of kpathsea that understands Omega (OFM/OVF) formats */
+#define HAVE_OMEGA_FORMATS
+
+/* HAVE_TTF_FORMATS - Define if you have a
+ version of kpathsea that understands TrueType (TTF) formats */
+#define HAVE_TTF_FORMATS
+
+/* HAVE_LIBPNG - Define if you have libpng */
+#undef HAVE_LIBPNG
+
+/* HAVE_SYSTEM - Define if you have the system() command */
+#undef HAVE_SYSTEM
+
+
+#endif /* _CONFIG_H */
diff --git a/Build/source/texk/dvipdfm/aclocal.m4 b/Build/source/texk/dvipdfm/aclocal.m4
new file mode 100644
index 00000000000..aa1ec43fb6f
--- /dev/null
+++ b/Build/source/texk/dvipdfm/aclocal.m4
@@ -0,0 +1,99 @@
+#
+# Local tests written by MAW
+#
+AC_DEFUN([AC_EXT_TIMEZONE],
+[AC_MSG_CHECKING([whether time.h defines timezone as an external variable])
+AC_TRY_LINK([#include <time.h>], [ -timezone; ],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIMEZONE)], [AC_MSG_RESULT(no)])])
+AC_DEFUN([AC_HAVE_BASENAME],
+ [AC_MSG_CHECKING([whether basename is in either libgen.h or string.h])
+ AC_TRY_COMPILE([#include <libgen.h>
+#include <string.h>], [extern char basename(void)],
+ [AC_MSG_RESULT(no)], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_BASENAME)])])
+AC_DEFUN([AC_TZ_HAS_TM_GMTOFF],
+[AC_MSG_CHECKING([whether struct tz has tm_gmtoff as a member])
+AC_TRY_COMPILE([#include <time.h>], [struct tm *tp; tp->tm_gmtoff],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TM_GMTOFF)], [AC_MSG_RESULT(no)])])
+#
+AC_DEFUN([AC_HAS_KPSE_FORMATS],
+ [AC_MSG_CHECKING([whether you have kpathsea headers and they whether they know about the required file formats])
+ AC_TRY_COMPILE([#include <stdio.h>
+#include <kpathsea/tex-file.h>],
+ [kpse_tex_ps_header_format;
+ kpse_type1_format;kpse_vf_format],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_KPSE_FORMATS)],
+ [AC_MSG_RESULT(no);
+AC_MSG_ERROR([PS_HEADER and/or VF formats not found in Kpathsea header files.
+
+This version of dvipdfm requires that kpathsea and its headers be installed.
+If you are sure they are installed and in a standard place, maybe you need a
+newer version of kpathsea? You also might try setting the environment
+variable CPPFLAGS (or CFLAGS) with -I pointing to the directory containing
+the file "tex-file.h"
+
+])])])
+#
+AC_DEFUN([AC_HAS_OMEGA_FORMATS],
+ [AC_MSG_CHECKING([whether your kpathsea supports Omega OFM file formats])
+ AC_TRY_COMPILE([#include <stdio.h>
+#include <kpathsea/tex-file.h>],
+ [kpse_ofm_format],
+ [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OMEGA_FORMATS)],
+ [AC_MSG_RESULT(no)])])
+AC_DEFUN([AC_HAS_TTF_FORMATS],
+ [AC_MSG_CHECKING([whether your kpathsea supports Truetype (TTF) file formats])
+ AC_TRY_COMPILE([#include <stdio.h>
+#include <kpathsea/tex-file.h>],
+ [kpse_truetype_format],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_TTF_FORMATS)
+ TTF_OPT=''],
+ [AC_MSG_RESULT(no)])])
+#
+# Check for zlib
+#
+AC_DEFUN([AC_HAS_ZLIB],
+[_cppflags=$CPPFLAGS
+ _ldflags=$LDFLAGS
+AC_ARG_WITH(zlib,
+[ --with-zlib=DIR use zlib include/library files from DIR],[
+ if test -d "$withval"; then
+ CPPFLAGS="$CPPFLAGS -I$withval/include"
+ LDFLAGS="$LDFLAGS -L$withval/lib"
+ fi
+])
+AC_MSG_CHECKING([for zlib header files])
+AC_TRY_COMPILE([#include <zlib.h>], [z_stream p;],
+[AC_MSG_RESULT(yes)
+ AC_CHECK_LIB(z, compress,
+[AC_DEFINE(HAVE_ZLIB)
+ LIBS="$LIBS -lz"
+ AC_CHECK_LIB(z, compress2,
+[AC_DEFINE(HAVE_ZLIB_COMPRESS2)])])],
+[CPPFLAGS=$_cppflags
+ LDDFLAGS=$_ldflags
+ AC_MSG_RESULT(no)])])
+#
+# Check for libpng
+#
+AC_DEFUN([AC_HAS_LIBPNG],
+[_cppflags=$CPPFLAGS
+_ldflags=$LDFLAGS
+AC_ARG_WITH(png,
+[ --with-png=DIR use png include/library files from DIR],[
+ if test -d "$withval"; then
+ CPPFLAGS="$CPPFLAGS -I$withval/include"
+ LDFLAGS="$LDFLAGS -L$withval/lib"
+ fi
+])
+AC_CHECK_FUNC(pow, , AC_CHECK_LIB(m, pow, LIBS="$LIBS -lm"))
+AC_MSG_CHECKING([for png header files])
+AC_TRY_COMPILE([#include <png.h>], [png_infop p;], [
+ AC_MSG_RESULT(yes)
+ AC_CHECK_LIB(png, png_get_image_width, [
+ AC_DEFINE(HAVE_LIBPNG)
+ LIBS="$LIBS -lpng"], , -lz)], [
+ AC_MSG_RESULT(no)])])
+#
+# End of local tests
+#
diff --git a/Build/source/texk/dvipdfm/ascii85.c b/Build/source/texk/dvipdfm/ascii85.c
new file mode 100644
index 00000000000..fd1b8efc0c4
--- /dev/null
+++ b/Build/source/texk/dvipdfm/ascii85.c
@@ -0,0 +1,90 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#include <stdio.h>
+#include <ctype.h>
+
+static int nextch(void)
+{
+ int ch;
+ while ((ch = getchar()) >= 0) {
+ if (ch >= '!' && ch <= 'u' || ch == 'z')
+ return ch;
+ if (ch == '~' && getchar() == '>') {
+ return -1;
+ }
+ }
+ if (ch < 0) {
+ fprintf (stderr, "Premature end of file.\n");
+ exit(1);
+ }
+}
+
+unsigned long int ascii85;
+unsigned binary[4];
+
+static decode_block(void)
+{
+ int i;
+ for (i=3; i>=0; i--){
+ binary[i] = ascii85 % 256u;
+ ascii85 /= 256u;
+ }
+}
+
+static output_block (int n)
+{
+ int i;
+ for (i=0; i<n; i++) {
+ putchar (binary[i]);
+ }
+}
+
+main (int argc, char *argv[])
+{
+ int i, ch, eof = 0, nread;
+ while (!eof) {
+ ascii85 = 0;
+ nread = 0;
+ /* Look ahead for special zero key */
+ if ((ch = nextch()) == 'z') {
+ nread = 4; /* Lie to it */
+ } else{
+ ungetc (ch, stdin);
+ for (i=0; i<5; i++) {
+ if ((ch=nextch()) < 0) {
+ eof = 1;
+ break;
+ }
+ ascii85 = ascii85 * 85 + (ch-'!');
+ nread += 1;
+ }
+ }
+ if (nread > 1) {
+ decode_block();
+ output_block(nread-1);
+ }
+ }
+}
diff --git a/Build/source/texk/dvipdfm/c-auto.in b/Build/source/texk/dvipdfm/c-auto.in
new file mode 100644
index 00000000000..9c30520187e
--- /dev/null
+++ b/Build/source/texk/dvipdfm/c-auto.in
@@ -0,0 +1,4 @@
+/* c-auto.in. Generated automatically from configure.in by autoheader. */
+
+/* The number of bytes in a int. */
+#undef SIZEOF_INT
diff --git a/Build/source/texk/dvipdfm/cmr.map b/Build/source/texk/dvipdfm/cmr.map
new file mode 100644
index 00000000000..12a78acb577
--- /dev/null
+++ b/Build/source/texk/dvipdfm/cmr.map
@@ -0,0 +1,142 @@
+% original cmr.map -- Constructed by M. Wicks, 9/28/99
+%
+% Format is as follows:
+% TeX-name encoding AFM-name PFB-name
+% The default behavior is to use the font's built-in
+% encoding, to use the TeX-name as the AFM-name, and
+% to use the AFM-name as the PFB-name.
+% The word "default" may be used in any field to
+% specify the default behavior. You can
+% also say "none", in the PFB field, for example
+% to say that no PFB should be loaded
+%
+% The following entries are used to force an encoding to work around several
+% bugs in Acrobat reader. The ot1 encoding is used to supply an encoding
+% external to that the the type 1 font definition. The seems to be necessary
+% to be able to search ligatures, for example. The "-r" option
+% is used to remap the character positions that Adobe normally does
+% not use to higher positions. This seems to fix a variety of problems
+%
+cmr10 ot1r -r
+cmr12 ot1r -r
+cmr17 ot1r -r
+cmr6 ot1r -r
+cmr7 ot1r -r
+cmr8 ot1r -r
+cmr9 ot1r -r
+% cmr5 is encoded somewhat differently
+cmr5 -r
+% Bold
+cmbx10 ot1r -r
+cmbx12 ot1r -r
+cmbx6 ot1r -r
+cmbx7 ot1r -r
+cmbx8 ot1r -r
+cmbx9 ot1r -r
+% Symbol fonts are remapped, but not reencoded
+cmex10 -r
+cmbsy10 -r
+cmsy10 -r
+cmsy9 -r
+cmsy8 -r
+cmsy7 -r
+cmsy6 -r
+cmsy5 -r
+lasy10 -r
+lasy9 -r
+lasy8 -r
+lasy7 -r
+lasy6 -r
+lasy5 -r
+cmbsy7 -r
+cmbsy5 -r
+euex10 -r
+eufm10 -r
+eufm7 -r
+eufm5 -r
+eufb10 -r
+eufb7 -r
+eufb5 -r
+eurb10 -r
+eurm10 -r
+eurb7 -r
+eurm7 -r
+eurb5 -r
+eurm5 -r
+msam10 -r
+xycmat10 -r
+xycmbt10 -r
+xydash10 -r
+xycirc10 -r
+xyatip10 -r
+xybtip10 -r
+% Likewise for math italic
+cmmi12 -r
+cmmi10 -r
+cmmib10 -r
+cmmi9 -r
+cmmi8 -r
+cmmi7 -r
+cmmi6 -r
+cmmi5 -r
+% Misc
+cmb10 ot1r -r
+cmbxsl10 ot1r -r
+cmbxti10 ot1alt -r
+cmdunh10 ot1r -r
+cmff10 ot1alt -r
+cmfi10 ot1alt -r
+cmfib8 ot1alt -r
+cmssbx10 ot1r -r
+cmssdc10 ot1r -r
+cmssq8 ot1r -r
+cmssqi8 ot1r -r
+cmu10 ot1alt -r
+cmvtt10 ot1r -r
+lcmss8 ot1r -r
+lcmssb8 ot1r -r
+lcmssi8 ot1r -r
+% tt fonts
+cmtt10 -r
+cmtt12 -r
+cmtt8 -r
+cmtt9 -r
+% Italic
+cmti10 ot1alt -r
+cmti12 ot1alt -r
+cmti7 ot1alt -r
+cmti8 ot1alt -r
+cmti9 ot1alt -r
+% Slanted
+cmsl10 ot1r -r
+cmsl12 ot1r -r
+cmsl8 ot1r -r
+cmsl9 ot1r -r
+% Roman sans serif
+cmss10 ot1r -r
+cmss12 ot1r -r
+cmss17 ot1r -r
+cmss8 ot1r -r
+cmss9 ot1r -r
+% Sans Serif
+cmssi10 ot1r -r
+cmssi12 ot1r -r
+cmssi17 ot1r -r
+cmssi8 ot1r -r
+cmssi9 ot1r -r
+%
+% LaTeX Fonts here too. They don't
+% seem to fit anywhere else.
+%
+lcirclew10 default lcirclew -r
+lcircle10 default lcircle1 -r
+line10 -r
+
+%
+% Required by psnfss2e
+%
+eurmo10 default eurm10 -s 0.167 -r
+eurbo10 default eurb10 -s 0.167 -r
+rsfs5 default rsfs5
+rsfs7 default rsfs7
+rsfs10 default rsfs10%
diff --git a/Build/source/texk/dvipdfm/colors.h b/Build/source/texk/dvipdfm/colors.h
new file mode 100644
index 00000000000..536a7dfe53d
--- /dev/null
+++ b/Build/source/texk/dvipdfm/colors.h
@@ -0,0 +1,73 @@
+struct color_by_name {
+ char *name;
+ struct color color;
+} colors_by_name[] = {
+ {"GreenYellow", {CMYK, 0.15, 0, 0.69, 0}},
+ {"Yellow", {CMYK, 0, 0, 1, 0}},
+ {"Goldenrod", {CMYK, 0, 0.10, 0.84, 0}},
+ {"Dandelion", {CMYK, 0, 0.29, 0.84, 0}},
+ {"Apricot", {CMYK, 0, 0.32, 0.52, 0}},
+ {"Peach", {CMYK, 0, 0.50, 0.70, 0}},
+ {"Melon", {CMYK, 0, 0.46, 0.50, 0}},
+ {"YellowOrange", {CMYK, 0, 0.42, 1, 0}},
+ {"Orange", {CMYK, 0, 0.61, 0.87, 0}},
+ {"BurntOrange", {CMYK, 0, 0.51, 1, 0}},
+ {"Bittersweet", {CMYK, 0, 0.75, 1, 0.24}},
+ {"RedOrange", {CMYK, 0, 0.77, 0.87, 0}},
+ {"Mahogany", {CMYK, 0, 0.85, 0.87, 0.35}},
+ {"Maroon", {CMYK, 0, 0.87, 0.68, 0.32}},
+ {"BrickRed", {CMYK, 0, 0.89, 0.94, 0.28}},
+ {"Red", {CMYK, 0, 1, 1, 0}},
+ {"OrangeRed", {CMYK, 0, 1, 0.50, 0}},
+ {"RubineRed", {CMYK, 0, 1, 0.13, 0}},
+ {"WildStrawberry", {CMYK, 0, 0.96, 0.39, 0}},
+ {"Salmon", {CMYK, 0, 0.53, 0.38, 0}},
+ {"CarnationPink", {CMYK, 0, 0.63, 0, 0}},
+ {"Magenta", {CMYK, 0, 1, 0, 0}},
+ {"VioletRed", {CMYK, 0, 0.81, 0, 0}},
+ {"Rhodamine", {CMYK, 0, 0.82, 0, 0}},
+ {"Mulberry", {CMYK, 0.34, 0.90, 0, 0.02}},
+ {"RedViolet", {CMYK, 0.07, 0.90, 0, 0.34}},
+ {"Fuchsia", {CMYK, 0.47, 0.91, 0, 0.08}},
+ {"Lavender", {CMYK, 0, 0.48, 0, 0}},
+ {"Thistle", {CMYK, 0.12, 0.59, 0, 0}},
+ {"Orchid", {CMYK, 0.32, 0.64, 0, 0}},
+ {"DarkOrchid", {CMYK, 0.40, 0.80, 0.20, 0}},
+ {"Purple", {CMYK, 0.45, 0.86, 0, 0}},
+ {"Plum", {CMYK, 0.50, 1, 0, 0}},
+ {"Violet", {CMYK, 0.79, 0.88, 0, 0}},
+ {"RoyalPurple", {CMYK, 0.75, 0.90, 0, 0}},
+ {"BlueViolet", {CMYK, 0.86, 0.91, 0, 0.04}},
+ {"Periwinkle", {CMYK, 0.57, 0.55, 0, 0}},
+ {"CadetBlue", {CMYK, 0.62, 0.57, 0.23, 0}},
+ {"CornflowerBlue", {CMYK, 0.65, 0.13, 0, 0}},
+ {"MidnightBlue", {CMYK, 0.98, 0.13, 0, 0.43}},
+ {"NavyBlue", {CMYK, 0.94, 0.54, 0, 0}},
+ {"RoyalBlue", {CMYK, 1, 0.50, 0, 0}},
+ {"Blue", {CMYK, 1, 1, 0, 0}},
+ {"Cerulean", {CMYK, 0.94, 0.11, 0, 0}},
+ {"Cyan", {CMYK, 1, 0, 0, 0}},
+ {"ProcessBlue", {CMYK, 0.96, 0, 0, 0}},
+ {"SkyBlue", {CMYK, 0.62, 0, 0.12, 0}},
+ {"Turquoise", {CMYK, 0.85, 0, 0.20, 0}},
+ {"TealBlue", {CMYK, 0.86, 0, 0.34, 0.02}},
+ {"Aquamarine", {CMYK, 0.82, 0, 0.30, 0}},
+ {"BlueGreen", {CMYK, 0.85, 0, 0.33, 0}},
+ {"Emerald", {CMYK, 1, 0, 0.50, 0}},
+ {"JungleGreen", {CMYK, 0.99, 0, 0.52, 0}},
+ {"SeaGreen", {CMYK, 0.69, 0, 0.50, 0}},
+ {"Green", {CMYK, 1, 0, 1, 0}},
+ {"ForestGreen", {CMYK, 0.91, 0, 0.88, 0.12}},
+ {"PineGreen", {CMYK, 0.92, 0, 0.59, 0.25}},
+ {"LimeGreen", {CMYK, 0.50, 0, 1, 0}},
+ {"YellowGreen", {CMYK, 0.44, 0, 0.74, 0}},
+ {"SpringGreen", {CMYK, 0.26, 0, 0.76, 0}},
+ {"OliveGreen", {CMYK, 0.64, 0, 0.95, 0.40}},
+ {"RawSienna", {CMYK, 0, 0.72, 1, 0.45}},
+ {"Sepia", {CMYK, 0, 0.83, 1, 0.70}},
+ {"Brown", {CMYK, 0, 0.81, 1, 0.60}},
+ {"Tan", {CMYK, 0.14, 0.42, 0.56, 0}},
+ {"Gray", {CMYK, 0, 0, 0, 0.50}},
+ {"Black", {CMYK, 0, 0, 0, 1}},
+ {"White", {CMYK, 0, 0, 0, 0}}
+};
diff --git a/Build/source/texk/dvipdfm/colorsp.c b/Build/source/texk/dvipdfm/colorsp.c
new file mode 100644
index 00000000000..0a440645edb
--- /dev/null
+++ b/Build/source/texk/dvipdfm/colorsp.c
@@ -0,0 +1,230 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <stdlib.h>
+#include "system.h"
+#include "mem.h"
+#include "pdfdev.h"
+#include "pdfparse.h"
+#include "pdfspecial.h"
+#include "dvipdfm.h"
+
+static char ignore_colors = 0;
+void color_special_ignore_colors(void)
+{
+ ignore_colors = 1;
+}
+
+static void do_color_special (char **start, char *end)
+{
+ char *command, *token;
+ char *c1=NULL, *c2=NULL, *c3=NULL, *c4=NULL;
+ skip_white (start, end);
+ if ((command = parse_ident (start, end))) {
+ if (!strcmp (command, "push")) { /* Handle a push */
+ skip_white (start, end);
+ if ((token = parse_ident (start, end))) {
+ if (!strcmp (token, "rgb")) { /* Handle rgb color */
+ if ((c1=parse_number(start, end)) &&
+ (c2=parse_number(start, end)) &&
+ (c3=parse_number(start, end))) {
+ dev_begin_rgb_color (atof(c1), atof(c2), atof(c3));
+ }
+ }
+ else if (!strcmp (token, "cmyk")) { /* Handle rgb color */
+ if ((c1=parse_number(start, end)) &&
+ (c2=parse_number(start, end)) &&
+ (c3=parse_number(start, end)) &&
+ (c4=parse_number(start, end))) {
+ dev_begin_cmyk_color (atof(c1), atof(c2), atof(c3), atof(c4));
+ }
+ } else if (!strcmp (token, "gray")) { /* Handle gray */
+ if ((c1=parse_number(start, end))) {
+ dev_begin_gray (atof(c1));
+ }
+ } else if (!strcmp (token, "hsb")) {
+ fprintf (stderr, "\ncolor special: hsb not implemented\n");
+ } else { /* Must be a "named" color */
+ dev_begin_named_color (token);
+ }
+ if (c1) RELEASE(c1);
+ if (c2) RELEASE(c2);
+ if (c3) RELEASE(c3);
+ if (c4) RELEASE(c4);
+ RELEASE (token);
+ }
+ } else if (!strcmp (command, "pop")) { /* Handle a pop */
+ dev_end_color();
+ } else { /* Assume this is a default color change */
+ token = command;
+ if (!strcmp (token, "rgb")) { /* Handle rgb color */
+ if ((c1=parse_number(start, end)) &&
+ (c2=parse_number(start, end)) &&
+ (c3=parse_number(start, end))) {
+ dev_set_def_rgb_color (atof(c1), atof(c2), atof(c3));
+ }
+ }
+ else if (!strcmp (token, "cmyk")) { /* Handle rgb color */
+ if ((c1=parse_number(start, end)) &&
+ (c2=parse_number(start, end)) &&
+ (c3=parse_number(start, end)) &&
+ (c4=parse_number(start, end))) {
+ dev_set_def_cmyk_color (atof(c1), atof(c2), atof(c3), atof(c4));
+ }
+ } else if (!strcmp (token, "gray")) { /* Handle gray */
+ if ((c1=parse_number(start, end))) {
+ dev_set_def_gray (atof(c1));
+ }
+ } else if (!strcmp (token, "hsb")) {
+ fprintf (stderr, "\ncolor special: hsb not implemented\n");
+ } else { /* Must be a "named" color */
+ dev_set_def_named_color (token);
+ }
+ if (c1) RELEASE(c1);
+ if (c2) RELEASE(c2);
+ if (c3) RELEASE(c3);
+ if (c4) RELEASE(c4);
+ }
+ }
+ RELEASE (command);
+}
+
+static void do_background_special (char **start, char *end)
+{
+ char *token;
+ char *c1=NULL, *c2=NULL, *c3=NULL, *c4=NULL;
+ skip_white (start, end);
+ if ((token = parse_ident (start, end))) {
+ if (!strcmp (token, "rgb")) { /* Handle rgb color */
+ if ((c1=parse_number(start, end)) &&
+ (c2=parse_number(start, end)) &&
+ (c3=parse_number(start, end))) {
+ dev_bg_rgb_color (atof(c1), atof(c2), atof(c3));
+ }
+ }
+ else if (!strcmp (token, "cmyk")) { /* Handle rgb color */
+ if ((c1=parse_number(start, end)) &&
+ (c2=parse_number(start, end)) &&
+ (c3=parse_number(start, end)) &&
+ (c4=parse_number(start, end))) {
+ dev_bg_cmyk_color (atof(c1), atof(c2), atof(c3), atof(c4));
+ }
+ } else if (!strcmp (token, "gray")) { /* Handle gray */
+ if ((c1=parse_number(start, end))) {
+ dev_bg_gray (atof(c1));
+ }
+ } else if (!strcmp (token, "hsb")) {
+ fprintf (stderr, "\ncolor special: hsb not implemented\n");
+ } else { /* Must be a "named" color */
+ dev_bg_named_color (token);
+ }
+ if (c1) RELEASE(c1);
+ if (c2) RELEASE(c2);
+ if (c3) RELEASE(c3);
+ if (c4) RELEASE(c4);
+ RELEASE (token);
+ }
+}
+
+static void local_set_paper_size (char **start, char *end)
+{
+ char *key, *val, *val_start, *val_end, *number;
+ char *save = *start;
+ double width = 0.0, height = 0.0, unit;
+ parse_key_val (start, end, &key, &val);
+ if (key && val) {
+ val_start = val;
+ val_end = val+strlen(val);
+ skip_white (&val_start, val_end);
+ if ((number=parse_number(&val_start, val_end))) {
+ width = atof (number);
+ RELEASE (number);
+ if ((unit = parse_one_unit (&val_start, val_end)) > 0.0) {
+ width *= unit;
+ } else {
+ width = 0.0;
+ }
+ } else {
+ fprintf (stderr, "\nExpecting a number here\n");
+ dump (val_start, end);
+ }
+ skip_white (&val_start, val_end);
+ if (val_start < val_end && *(val_start++) == ',') {
+ skip_white (&val_start, val_end);
+ }
+ if ((number=parse_number(&val_start, val_end))) {
+ height = atof (number);
+ RELEASE (number);
+ if ((unit = parse_one_unit (&val_start, val_end)) > 0.0) {
+ height *= unit;
+ } else {
+ height = 0.0;
+ }
+ } else {
+ fprintf (stderr, "\nExpecting a number here\n");
+ dump (val_start, val_end);
+ }
+ if (key) RELEASE (key);
+ if (val) RELEASE (val);
+ }
+ if (width != 0.0 && height != 0.0) {
+ dev_set_page_size (width, height);
+ } else{
+ fprintf (stderr, "\nError parsing papersize special\n");
+ dump (save, end);
+ }
+}
+
+/* Color_special() handles color specials and also
+ handles papersize and landscape specials since
+ there's no good place to put them */
+
+int color_special (char *buffer, UNSIGNED_QUAD size)
+{
+ char *start = buffer, *end;
+ int result = 0;
+ end = buffer + size;
+ skip_white (&start, end);
+ if (!strncmp (start, "color", strlen("color"))) {
+ start += strlen("color");
+ result = 1; /* This is a color special */
+ if (!ignore_colors)
+ do_color_special (&start, end);
+ } else if (!strncmp (start, "background", strlen("background"))) {
+ start += strlen("background");
+ result = 1; /* This is a color special */
+ if (!ignore_colors)
+ do_background_special (&start, end);
+ } else if (!strncmp (start, "landscape", strlen("landscape"))) {
+ set_landscape_mode();
+ result = 1;
+ } else if (!strncmp (start, "papersize", strlen("papersize"))) {
+ local_set_paper_size(&start, end);
+ result = 1;
+ }
+ return result;
+}
+
+
+
diff --git a/Build/source/texk/dvipdfm/colorsp.h b/Build/source/texk/dvipdfm/colorsp.h
new file mode 100644
index 00000000000..17393783de3
--- /dev/null
+++ b/Build/source/texk/dvipdfm/colorsp.h
@@ -0,0 +1,39 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#ifndef COLORSP_H
+
+#include "pdfparse.h"
+
+#define COLORSP_H
+
+int color_special (char *buffer, UNSIGNED_QUAD size);
+void color_special_ignore_colors(void);
+#endif
+
+
+
+
+
+
diff --git a/Build/source/texk/dvipdfm/config b/Build/source/texk/dvipdfm/config
new file mode 100644
index 00000000000..5d471092775
--- /dev/null
+++ b/Build/source/texk/dvipdfm/config
@@ -0,0 +1,46 @@
+% original config -- Made by MAW on 8/31/99
+% Distiller template examples. Uncomment
+% the appropriate one, or (preferably) create your own.
+% Put %i in the command line where the input file name should go.
+% Put %o in the command line where the output file name should go.
+% (dvipdfm must be able to supply the output file name to your
+% command line)
+% Put %b in the line somewhere if you want to specify the
+% "base" name of the input file, e.g., "foo" instead of "foo.eps"
+%
+% Note that it's probably a good idea to fully qualify
+% the paths so you can be sure what you are running
+
+% The following line works with Frank Siegert's pstill
+% D "/usr/local/bin/pstill -c -o %o %i"
+
+% The following line works with GhostScript
+% D "gs -q -sPAPERSIZE=ledger -sDEVICE=pdfwrite -dCompatibilityLevel=1.2 -dUseFlateCompression=true -sOutputFile=%o %i -c quit"
+% The following line works on compressed or uncompressed postscript with GhostScript
+D "zcat -f %i | gs -q -sPAPERSIZE=a0 -sDEVICE=pdfwrite -dCompatibilityLevel=1.2 -dUseFlateCompression=true -sOutputFile=%o - -c quit"
+
+% The following line works with Adobe Acrobat Distiller
+% D "/usr/local/bin/distill -quiet -pairs %i %o"
+
+% Set default paper size here
+p letter
+
+% The "g" option specifies the amount to "grow" annotations by
+% Many TeX macro pages set the annotation bounding box equal
+% to the TeX box that encloses the material. That's not always
+% what you want
+g 1
+
+% PDF version stamp to use in output file and max version of files
+% allowed to be included (2 for 1.2, 3 for 1.3)
+V 2
+%
+% Font map files
+%
+f cmr.map
+f psbase14.map
+% Most distributions now use these names
+f lw35urw.map
+% Some use these names
+% f lw35urwa.map
+
diff --git a/Build/source/texk/dvipdfm/config-dist b/Build/source/texk/dvipdfm/config-dist
new file mode 100644
index 00000000000..5d471092775
--- /dev/null
+++ b/Build/source/texk/dvipdfm/config-dist
@@ -0,0 +1,46 @@
+% original config -- Made by MAW on 8/31/99
+% Distiller template examples. Uncomment
+% the appropriate one, or (preferably) create your own.
+% Put %i in the command line where the input file name should go.
+% Put %o in the command line where the output file name should go.
+% (dvipdfm must be able to supply the output file name to your
+% command line)
+% Put %b in the line somewhere if you want to specify the
+% "base" name of the input file, e.g., "foo" instead of "foo.eps"
+%
+% Note that it's probably a good idea to fully qualify
+% the paths so you can be sure what you are running
+
+% The following line works with Frank Siegert's pstill
+% D "/usr/local/bin/pstill -c -o %o %i"
+
+% The following line works with GhostScript
+% D "gs -q -sPAPERSIZE=ledger -sDEVICE=pdfwrite -dCompatibilityLevel=1.2 -dUseFlateCompression=true -sOutputFile=%o %i -c quit"
+% The following line works on compressed or uncompressed postscript with GhostScript
+D "zcat -f %i | gs -q -sPAPERSIZE=a0 -sDEVICE=pdfwrite -dCompatibilityLevel=1.2 -dUseFlateCompression=true -sOutputFile=%o - -c quit"
+
+% The following line works with Adobe Acrobat Distiller
+% D "/usr/local/bin/distill -quiet -pairs %i %o"
+
+% Set default paper size here
+p letter
+
+% The "g" option specifies the amount to "grow" annotations by
+% Many TeX macro pages set the annotation bounding box equal
+% to the TeX box that encloses the material. That's not always
+% what you want
+g 1
+
+% PDF version stamp to use in output file and max version of files
+% allowed to be included (2 for 1.2, 3 for 1.3)
+V 2
+%
+% Font map files
+%
+f cmr.map
+f psbase14.map
+% Most distributions now use these names
+f lw35urw.map
+% Some use these names
+% f lw35urwa.map
+
diff --git a/Build/source/texk/dvipdfm/config.h.in b/Build/source/texk/dvipdfm/config.h.in
new file mode 100644
index 00000000000..b1e1efad246
--- /dev/null
+++ b/Build/source/texk/dvipdfm/config.h.in
@@ -0,0 +1,65 @@
+/* config.h.in. Generated automatically from configure.in by autoheader. */
+
+/* Define to empty if the keyword does not work. */
+#undef const
+
+/* Define to `unsigned' if <sys/types.h> doesn't define. */
+#undef size_t
+
+/* Define if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define if your <sys/time.h> declares struct tm. */
+#undef TM_IN_SYS_TIME
+
+#define VERSION 0
+
+#define PACKAGE "package"
+
+/* define if you have kpathsea */
+#undef HAVE_KPATHSEA
+
+/* define if your zlib has the compress2 function */
+#undef HAVE_ZLIB_COMPRESS2
+
+/* define if you have zlib and its headers */
+#undef HAVE_ZLIB
+
+/* define if you have xbasename() in your libkpathsea instead of basename() */
+#undef HAVE_XBASENAME
+
+/* define if kpathsea understands TrueType (TTF) formats */
+#undef HAVE_TTF_FORMATS
+
+/* define if struct tm has tm_gmtoff as a member */
+#undef HAVE_TM_GMTOFF
+
+/* define if <time.h> has timezone as an external variable */
+#undef HAVE_TIMEZONE
+
+/* define if kpathsea supports type1 and vf formats */
+#undef HAVE_KPSE_FORMATS
+
+/* define if you have libpng */
+#undef HAVE_LIBPNG
+
+/* Define if kpathsea understands Omega (OFM/OVF) formats */
+#undef HAVE_OMEGA_FORMATS
+
+/* Define if you have the strspn function. */
+#undef HAVE_STRSPN
+
+/* Define if you have the system function. */
+#undef HAVE_SYSTEM
+
+/* Define if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define if you have the <zlib.h> header file. */
+#undef HAVE_ZLIB_H
+
+/* Define if you have the m library (-lm). */
+#undef HAVE_LIBM
+
+/* Define if you have the z library (-lz). */
+#undef HAVE_LIBZ
diff --git a/Build/source/texk/dvipdfm/configure b/Build/source/texk/dvipdfm/configure
new file mode 100755
index 00000000000..fa1038cab5d
--- /dev/null
+++ b/Build/source/texk/dvipdfm/configure
@@ -0,0 +1,2531 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.13
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+ac_help="$ac_help
+ --enable-maint enable autoconf portions of Makefile"
+ac_help="$ac_help
+ --enable-maintainer-mode enable make rules and dependencies not useful
+ (and sometimes confusing) to the casual installer"
+ac_help="$ac_help
+ --without-mktexmf-default do not run mktexmf if MF source missing"
+ac_help="$ac_help
+ --without-mktexpk-default do not run mktexpk if PK font missing"
+ac_help="$ac_help
+ --without-mktextfm-default do not run mktextfm if TFM file missing"
+ac_help="$ac_help
+ --without-mkocp-default do not run mkocp if OCP file missing"
+ac_help="$ac_help
+ --without-mkofm-default do not run mkofm if OFM file missing"
+ac_help="$ac_help
+ --with-mktexfmt-default run mktexfmt if format file missing"
+ac_help="$ac_help
+ --with-mktextex-default run mktextex if TeX source missing"
+ac_help="$ac_help
+ --with-system-zlib use installed zlib library"
+ac_help="$ac_help
+ --with-zlib-libdir=DIR
+ Specify directory where the zlib.a resides."
+ac_help="$ac_help
+ --with-zlib-include=DIR
+ Specify the zlib header files location."
+ac_help="$ac_help
+ --with-system-pnglib use installed pnglib library"
+ac_help="$ac_help
+ --with-pnglib-libdir=DIR
+ Specify directory where the png library (libpng.a) resides."
+ac_help="$ac_help
+ --with-pnglib-include=DIR
+ Specify the pnglib header files location."
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+ac_config_files=
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.13"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_envvar| sed 's/[_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: invalid variable name: $ac_envvar" 1>&2; exit 1; }
+ fi
+ ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+ eval "$ac_envvar='$ac_optarg'"
+ export $ac_envvar ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=dvipdfm.c
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+ac_exeext=
+ac_objext=o
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+
+
+VERSION="0.13.2c"
+
+cat >> confdefs.h <<\EOF
+#define VERSION "0.13.2c"
+EOF
+
+cat >> confdefs.h <<\EOF
+#define PACKAGE "dvipdfm"
+EOF
+
+
+
+
+# Check whether --enable-maint or --disable-maint was given.
+if test "${enable_maint+set}" = set; then
+ enableval="$enable_maint"
+ MAINT=''
+else
+ MAINT='#'
+fi
+
+
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:600: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ if test -z "$COMSPEC"; then ac_x=-f; else ac_x=-x; fi
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test $ac_x $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:631: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_prog_rejected=no
+ if test -z "$COMSPEC"; then ac_x=-f; else ac_x=-x; fi
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test $ac_x $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:683: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ if test -z "$COMSPEC"; then ac_x=-f; else ac_x=-x; fi
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test $ac_x $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:716: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 727 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:732: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:758: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:763: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:772: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:791: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:823: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+#line 838 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:844: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+#line 855 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:861: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 872 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:878: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ case $ac_dir in
+ /*|[A-z]:/*) ac_aux_dir=$ac_dir;;
+ *) ac_aux_dir=`pwd`/$ac_dir;;
+ esac
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ case $ac_dir in
+ /*|[A-z]:/*) ac_aux_dir=$ac_dir;;
+ *) ac_aux_dir=`pwd`/$ac_dir;;
+ esac
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:939: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+ # Hack for MSDOS and descendants.
+ if test -z "$COMSPEC"; then ac_x=-f; else ac_x=-x; fi
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test $ac_x $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+echo "configure:994: checking whether ln -s works" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ rm -f conftestdata
+# MS-DOS is a special case, because it sort of pretends that ln -s
+# works for executables.
+if test -z "$COMSPEC" && ln -s X conftestdata 2>/dev/null
+then
+ rm -f conftestdata
+ ac_cv_prog_LN_S="ln -s"
+else
+ ac_cv_prog_LN_S=ln
+fi
+fi
+LN_S="$ac_cv_prog_LN_S"
+if test "$ac_cv_prog_LN_S" = "ln -s"; then
+ echo "$ac_t""yes" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+echo "configure:1017: checking whether ${MAKE-make} sets \${MAKE}" >&5
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftestmake <<\EOF
+all:
+ @echo 'ac_maketemp="${MAKE}"'
+EOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+else
+ eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftestmake
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ SET_MAKE=
+else
+ echo "$ac_t""no" 1>&6
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+
+
+echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
+echo "configure:1046: checking whether to enable maintainer-specific portions of Makefiles" >&5
+ # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
+if test "${enable_maintainer_mode+set}" = set; then
+ enableval="$enable_maintainer_mode"
+ USE_MAINTAINER_MODE=$enableval
+else
+ USE_MAINTAINER_MODE=no
+fi
+
+ echo "$ac_t""$USE_MAINTAINER_MODE" 1>&6
+ if test "x$USE_MAINTAINER_MODE" = xyes; then
+ MAINT=
+ else
+ MAINT='#M#'
+ fi
+
+
+
+echo $ac_n "checking for loader (symbol LD)""... $ac_c" 1>&6
+echo "configure:1065: checking for loader (symbol LD)" >&5
+if eval "test \"`echo '$''{'cf_cv_subst_LD'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+test -z "$LD" && LD=ld
+cf_cv_subst_LD=$LD
+fi
+
+LD=${cf_cv_subst_LD}
+echo "$ac_t""$LD" 1>&6
+
+
+echo $ac_n "checking for archiver (symbol AR)""... $ac_c" 1>&6
+echo "configure:1079: checking for archiver (symbol AR)" >&5
+if eval "test \"`echo '$''{'cf_cv_subst_AR'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+test -z "$AR" && AR=ar
+cf_cv_subst_AR=$AR
+fi
+
+AR=${cf_cv_subst_AR}
+echo "$ac_t""$AR" 1>&6
+
+
+echo $ac_n "checking for archiver options (symbol ARFLAGS)""... $ac_c" 1>&6
+echo "configure:1093: checking for archiver options (symbol ARFLAGS)" >&5
+if eval "test \"`echo '$''{'cf_cv_subst_ARFLAGS'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+test -z "$ARFLAGS" && ARFLAGS=rc
+cf_cv_subst_ARFLAGS=$ARFLAGS
+fi
+
+ARFLAGS=${cf_cv_subst_ARFLAGS}
+echo "$ac_t""$ARFLAGS" 1>&6
+
+
+
+# Check whether --with-mktexmf-default or --without-mktexmf-default was given.
+if test "${with_mktexmf_default+set}" = set; then
+ withval="$with_mktexmf_default"
+ :
+else
+ with_mktexmf_default=yes
+fi
+
+# Check whether --with-mktexpk-default or --without-mktexpk-default was given.
+if test "${with_mktexpk_default+set}" = set; then
+ withval="$with_mktexpk_default"
+ :
+else
+ with_mktexpk_default=yes
+fi
+
+# Check whether --with-mktextfm-default or --without-mktextfm-default was given.
+if test "${with_mktextfm_default+set}" = set; then
+ withval="$with_mktextfm_default"
+ :
+else
+ with_mktextfm_default=yes
+fi
+
+# Check whether --with-mkocp-default or --without-mkocp-default was given.
+if test "${with_mkocp_default+set}" = set; then
+ withval="$with_mkocp_default"
+ :
+else
+ with_mkocp_default=yes
+fi
+
+# Check whether --with-mkofm-default or --without-mkofm-default was given.
+if test "${with_mkofm_default+set}" = set; then
+ withval="$with_mkofm_default"
+ :
+else
+ with_mkofm_default=yes
+fi
+
+# Check whether --with-mktexfmt-default or --without-mktexfmt-default was given.
+if test "${with_mktexfmt_default+set}" = set; then
+ withval="$with_mktexfmt_default"
+ :
+fi
+
+# Check whether --with-mktextex-default or --without-mktextex-default was given.
+if test "${with_mktextex_default+set}" = set; then
+ withval="$with_mktextex_default"
+ with_mktextex_default=yes
+else
+ with_mktextex_default=no
+fi
+
+
+echo $ac_n "checking where the main texmf tree is located""... $ac_c" 1>&6
+echo "configure:1163: checking where the main texmf tree is located" >&5
+texmfmain=
+if test "x$datadir" != 'x${prefix}/share'; then
+ # First case, datadir is defined...
+ eval p=\"$datadir\"
+ # Unconditionally set the directory, but...
+ texmfmain=`echo "$p/texmf" | sed 's,//*,/,g'`
+ # ... do complain if it wasn't found.
+ if test -d "$texmfmain"; then
+ echo "$ac_t"""$texmfmain"" 1>&6
+ else
+ echo "$ac_t""not found" 1>&6
+ echo "configure: warning: No texmf tree found at $texmfmain.
+ *****************************************************************
+ * Error: The main texmf tree was not found. *
+ * If you do not have the files, you should be able to them from *
+ * the same place you got these sources from, or from one of the *
+ * CTAN hosts. *
+ *****************************************************************
+ Winging it." 1>&2
+ fi
+else
+ # Second case, datadir is default...
+ if test "x$prefix" = "xNONE"; then
+ p="$ac_default_prefix"
+ else
+ eval p=\"$prefix\"
+ fi
+ for e in share/texmf lib/texmf texmf; do
+ if test -d "$p/$e"; then
+ texmfmain='${prefix}'/"$e"
+ break
+ fi
+ done
+ if test -z "$texmfmain" && test "x$prefix" = "xNONE"; then
+ # Still no texmfmain found, no prefix set, perhaps kpsewhich is
+ # installed and can help us out.
+ texmfmain=`kpsewhich --expand-path='$TEXMFMAIN'` 2>/dev/null
+ fi
+ texmfmain=`echo "$texmfmain" | sed 's,//*,/,g'`
+ if test -n "$texmfmain"; then
+ echo "$ac_t"""$texmfmain"" 1>&6
+ else
+ eval texmfmain="$datadir/texmf"
+ echo "$ac_t""not found" 1>&6
+ echo "configure: warning: The main texmf tree was not found at $texmfmain.
+ *****************************************************************
+ * Error: The main texmf tree was not found. *
+ * Use the --datadir option to specify its parent directory. *
+ * If you do not have the files, you should be able to them from *
+ * the same place you got these sources from, or from one of the *
+ * CTAN hosts. *
+ *****************************************************************
+ Winging it by pretending $texmfmain is correct." 1>&2
+ fi
+fi
+
+
+# Check whether --with-system_zlib or --without-system_zlib was given.
+if test "${with_system_zlib+set}" = set; then
+ withval="$with_system_zlib"
+ :
+fi
+
+
+# Check whether --with-zlib_libdir or --without-zlib_libdir was given.
+if test "${with_zlib_libdir+set}" = set; then
+ withval="$with_zlib_libdir"
+ :
+fi
+
+
+# Check whether --with-zlib_include or --without-zlib_include was given.
+if test "${with_zlib_include+set}" = set; then
+ withval="$with_zlib_include"
+ :
+fi
+
+
+# Check whether --with-system-pnglib or --without-system-pnglib was given.
+if test "${with_system_pnglib+set}" = set; then
+ withval="$with_system_pnglib"
+ :
+fi
+
+
+# Check whether --with-pnglib_libdir or --without-pnglib_libdir was given.
+if test "${with_pnglib_libdir+set}" = set; then
+ withval="$with_pnglib_libdir"
+ :
+fi
+
+
+# Check whether --with-pnglib_include or --without-pnglib_include was given.
+if test "${with_pnglib_include+set}" = set; then
+ withval="$with_pnglib_include"
+ :
+fi
+
+
+if test "$needs_zlib" = no; then
+ ZLIBCPPFLAGS=
+ LDZLIB=
+ ZLIBDEP=
+else
+ EXTRA_ZLIB_INCLUDE=
+ EXTRA_ZLIB_LIBDIR=
+
+ if test "$with_system_zlib" = yes; then
+ if test "x$with_zlib_libdir" != x; then
+ EXTRA_ZLIB_LIBDIR="-L$with_zlib_libdir"
+ fi
+ if test "x$with_zlib_include" != x; then
+ EXTRA_ZLIB_INCLUDE="-I$with_zlib_include"
+ fi
+ fi
+
+ OLD_LDFLAGS=$LDFLAGS
+ OLD_CPP=$CPP
+ OLD_LIBS=$LIBS
+
+ LDFLAGS="$LDFLAGS $EXTRA_ZLIB_LIBDIR"
+ CPP="$CPP $EXTRA_ZLIB_INCLUDE"
+
+ if test "$with_system_zlib" = yes; then
+ echo $ac_n "checking for inflate in -lz""... $ac_c" 1>&6
+echo "configure:1289: checking for inflate in -lz" >&5
+ac_lib_var=`echo z'_'inflate | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lz $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1297 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char inflate();
+
+int main() {
+inflate()
+; return 0; }
+EOF
+if { (eval echo configure:1308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo z | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lz $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+echo "configure: warning: Standard ZLIB library not found. Compiling my own." 1>&2
+ with_system_zlib=no
+fi
+
+ fi
+
+ if test "$with_system_zlib" = yes; then
+ for ac_hdr in zlib.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1344: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1349 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1354: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ if test "$ac_cv_header_zlib_h" != yes; then
+ echo "configure: warning: zlib.h not found. Using my own zlib sources." 1>&2
+ with_system_zlib=no
+ fi
+ fi
+
+ LDFLAGS=$OLD_LDFLAGS
+ CPP=$OLD_CPP
+ LIBS=$OLD_LIBS
+
+ if test "$with_system_zlib" != yes; then
+ ZLIBCPPFLAGS='-I$(ZLIBDIR) -I$(ZLIBSRCDIR)'
+ LDZLIB='$(ZLIBDIR)/libz.a'
+ ZLIBDEP='$(ZLIBDIR)/libz.a'
+ using_system_zlib=no
+ else
+ ZLIBCPPFLAGS="$EXTRA_ZLIB_INCLUDE"
+ LDZLIB="$EXTRA_ZLIB_LIBDIR -lz"
+ ZLIBDEP=
+ using_system_zlib=yes
+ fi
+fi
+
+
+
+
+
+if test "$needs_pnglib" = no; then
+ LIBPNGCPPFLAGS=
+ LDLIBPNG=
+ LIBPNGDEP=
+else
+ EXTRA_LIBPNG_INCLUDE=
+ EXTRA_LIBPNG_LIBDIR=
+
+ if test "$with_system_pnglib" = yes; then
+ if test "x$with_pnglib_libdir" != x; then
+ EXTRA_LIBPNG_LIBDIR="-L$with_pnglib_libdir"
+ fi
+ if test "x$with_pnglib_include" != x; then
+ EXTRA_LIBPNG_INCLUDE="-I$with_pnglib_include"
+ fi
+ fi
+
+ OLD_LDFLAGS=$LDFLAGS
+ OLD_CPP=$CPP
+ OLD_LIBS=$LIBS
+
+ LDFLAGS="$LDFLAGS $EXTRA_LIBPNG_LIBDIR"
+ CPP="$CPP $EXTRA_LIBPNG_INCLUDE"
+
+ if test "$with_system_pnglib" = yes; then
+ echo $ac_n "checking for png_set_read_fn in -lpng""... $ac_c" 1>&6
+echo "configure:1433: checking for png_set_read_fn in -lpng" >&5
+ac_lib_var=`echo png'_'png_set_read_fn | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lpng -lz -lm $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1441 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char png_set_read_fn();
+
+int main() {
+png_set_read_fn()
+; return 0; }
+EOF
+if { (eval echo configure:1452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ pnglib=-lpng
+else
+ echo "$ac_t""no" 1>&6
+echo "configure: warning: Standard PNG library not found. Compiling my own." 1>&2
+ with_system_pnglib=no
+fi
+
+ fi
+
+ LDFLAGS=$OLD_LDFLAGS
+ CPP=$OLD_CPP
+ LIBS=$OLD_LIBS
+
+ if test "$with_system_pnglib" != yes; then
+ LIBPNGCPPFLAGS='-I$(LIBPNGDIR) -I$(LIBPNGSRCDIR)'
+ LDLIBPNG='$(LIBPNGDIR)/libpng.a'
+ LIBPNGDEP='$(LIBPNGDIR)/libpng.a'
+ using_system_pnglib=no
+ else
+ LIBPNGCPPFLAGS="$EXTRA_LIBPNG_INCLUDE"
+ LDLIBPNG="$EXTRA_LIBPNG_LIBDIR -lpng"
+ LIBPNGDEP=
+ using_system_pnglib=yes
+ fi
+fi
+
+
+
+
+
+
+cat >> confdefs.h <<\EOF
+#define KPATHSEA 1
+EOF
+
+cat >> confdefs.h <<\EOF
+#define HAVE_KPATHSEA 1
+EOF
+
+cat >> confdefs.h <<\EOF
+#define HAVE_XBASENAME 1
+EOF
+
+cat >> confdefs.h <<\EOF
+#define HAVE_ZLIB 1
+EOF
+
+cat >> confdefs.h <<\EOF
+#define HAVE_ZLIB_COMPRESS2 1
+EOF
+
+cat >> confdefs.h <<\EOF
+#define HAVE_KPSE_FORMATS 1
+EOF
+
+cat >> confdefs.h <<\EOF
+#define HAVE_OMEGA_FORMATS 1
+EOF
+
+cat >> confdefs.h <<\EOF
+#define HAVE_TTF_FORMATS 1
+EOF
+
+cat >> confdefs.h <<\EOF
+#define HAVE_LIBPNG 1
+EOF
+
+TTF_OPT=''
+
+
+# TEXMF='${datadir}/texmf'
+# AC_SUBST(TEXMF)
+
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:1541: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1546 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1554: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ ac_cv_header_stdc=yes
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1571 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "memchr" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1589 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "free" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+ :
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1610 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:1621: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+ cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+for ac_hdr in unistd.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1648: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1653 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1658: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+echo $ac_n "checking whether time.h defines timezone as an external variable""... $ac_c" 1>&6
+echo "configure:1686: checking whether time.h defines timezone as an external variable" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1688 "configure"
+#include "confdefs.h"
+#include <time.h>
+int main() {
+ -timezone;
+; return 0; }
+EOF
+if { (eval echo configure:1695: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_TIMEZONE 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+echo $ac_n "checking whether struct tz has tm_gmtoff as a member""... $ac_c" 1>&6
+echo "configure:1709: checking whether struct tz has tm_gmtoff as a member" >&5
+cat > conftest.$ac_ext <<EOF
+#line 1711 "configure"
+#include "confdefs.h"
+#include <time.h>
+int main() {
+struct tm *tp; tp->tm_gmtoff
+; return 0; }
+EOF
+if { (eval echo configure:1718: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
+#define HAVE_TM_GMTOFF 1
+EOF
+
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+echo $ac_n "checking for working const""... $ac_c" 1>&6
+echo "configure:1733: checking for working const" >&5
+if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1738 "configure"
+#include "confdefs.h"
+
+int main() {
+
+/* Ultrix mips cc rejects this. */
+typedef int charset[2]; const charset x;
+/* SunOS 4.1.1 cc rejects this. */
+char const *const *ccp;
+char **p;
+/* NEC SVR4.0.2 mips cc rejects this. */
+struct point {int x, y;};
+static struct point const zero = {0,0};
+/* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in an arm
+ of an if-expression whose if-part is not a constant expression */
+const char *g = "string";
+ccp = &g + (g ? g-g : 0);
+/* HPUX 7.0 cc rejects these. */
+++ccp;
+p = (char**) ccp;
+ccp = (char const *const *) p;
+{ /* SCO 3.2v4 cc rejects this. */
+ char *t;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+}
+{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+}
+{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+}
+{ /* AIX XL C 1.02.0.0 rejects this saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; };
+ struct s *b; b->j = 5;
+}
+{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+}
+
+; return 0; }
+EOF
+if { (eval echo configure:1787: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_const=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_c_const=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_c_const" 1>&6
+if test $ac_cv_c_const = no; then
+ cat >> confdefs.h <<\EOF
+#define const
+EOF
+
+fi
+
+echo $ac_n "checking for size_t""... $ac_c" 1>&6
+echo "configure:1808: checking for size_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1813 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_size_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_size_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_size_t" 1>&6
+if test $ac_cv_type_size_t = no; then
+ cat >> confdefs.h <<\EOF
+#define size_t unsigned
+EOF
+
+fi
+
+echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
+echo "configure:1844: checking whether struct tm is in sys/time.h or time.h" >&5
+if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1849 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <time.h>
+int main() {
+struct tm *tp; tp->tm_sec;
+; return 0; }
+EOF
+if { (eval echo configure:1857: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_struct_tm=time.h
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_struct_tm=sys/time.h
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_struct_tm" 1>&6
+if test $ac_cv_struct_tm = sys/time.h; then
+ cat >> confdefs.h <<\EOF
+#define TM_IN_SYS_TIME 1
+EOF
+
+fi
+
+
+echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
+echo "configure:1879: checking for 8-bit clean memcmp" >&5
+if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_func_memcmp_clean=no
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1887 "configure"
+#include "confdefs.h"
+
+main()
+{
+ char c0 = 0x40, c1 = 0x80, c2 = 0x81;
+ exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1);
+}
+
+EOF
+if { (eval echo configure:1897: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_func_memcmp_clean=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_func_memcmp_clean=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6
+test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
+
+for ac_func in strspn system
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1917: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1922 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+echo $ac_n "checking for main in -lm""... $ac_c" 1>&6
+echo "configure:1970: checking for main in -lm" >&5
+ac_lib_var=`echo m'_'main | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lm $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1978 "configure"
+#include "confdefs.h"
+
+int main() {
+main()
+; return 0; }
+EOF
+if { (eval echo configure:1985: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo m | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lm $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+ac_config_files="$ac_config_files Makefile"
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+DEFS=-DHAVE_CONFIG_H
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+
+trap 'rm -fr `echo "$ac_config_files config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@VERSION@%$VERSION%g
+s%@MAINT@%$MAINT%g
+s%@CC@%$CC%g
+s%@CPP@%$CPP%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@LN_S@%$LN_S%g
+s%@SET_MAKE@%$SET_MAKE%g
+s%@LD@%$LD%g
+s%@AR@%$AR%g
+s%@ARFLAGS@%$ARFLAGS%g
+s%@texmfmain@%$texmfmain%g
+s%@ZLIBCPPFLAGS@%$ZLIBCPPFLAGS%g
+s%@LDZLIB@%$LDZLIB%g
+s%@ZLIBDEP@%$ZLIBDEP%g
+s%@LIBPNGCPPFLAGS@%$LIBPNGCPPFLAGS%g
+s%@LDLIBPNG@%$LDLIBPNG%g
+s%@LIBPNGDEP@%$LIBPNGDEP%g
+s%@TTF_OPT@%$TTF_OPT%g
+s%@LIBOBJS@%$LIBOBJS%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"$ac_config_files"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*|[A-z]:/*) # Absolute path.
+ srcdir="$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ case "$ac_given_INSTALL" in
+ "") ;;
+ [/$]*|[A-z]:/*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ rm -f conftest.in
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%:% $ac_given_srcdir/%g" -e "s%^%$ac_given_srcdir/%"`
+ cat $ac_file_inputs > conftest.in
+ #
+ # Replace lines of the form ac_include foo with the contents of foo:
+ # first, from the ac_include lines construct a list of file names.
+ # From that list, we construct a second list of those files that exist.
+ # Then we construct lists of sed commands for including those files,
+ # and a sed command that removes the ac_include lines. We don't attempt
+ # to read non-existent files because some (buggy) versions of sed choke
+ # on this. Have to use sed because old (Ultrix, SunOS) awk does not support
+ # getline or system. (Anyway, configure scripts aren't supposed to use awk.)
+ # Can't use only one -e and commands {dr foo} because foo has to be last.
+ # Be careful, because the filename may contain /. Be careful with
+ # whitespace; we need to use echo.
+ #
+ file_substs=`sed -n '/^ac_include/s%ac_include[ ]*\(.*\)%\1%p' conftest.in`
+ # Create the sed command line ...
+ if test -n "$file_substs"; then
+ echo "configure: warning: ac_include is obsolete; instead use kpse_include" 1>&2
+ file_subst_cmd="sed -e 's/^ac_include/kpse_include/'"
+ else
+ file_subst_cmd='sed'
+ fi
+ kpse_substs=`sed -n '/^kpse_include/s%kpse_include[ ]*\(.*\)%\1%p' conftest.in`
+ for ac_inc in $file_substs $kpse_substs; do
+ if test -f "$ac_given_srcdir/$ac_inc"; then
+ ac_mung=`echo $ac_inc | sed 's,/,%,g'`
+ file_subst_cmd="$file_subst_cmd -e '/^kpse_include $ac_mung$/r $ac_given_srcdir/$ac_inc'"
+ fi
+ done
+ file_subst_cmd="$file_subst_cmd -e '/^kpse_include/d'"
+ # ... and fix the whitespace and escaped slashes.
+ file_subst_cmd=`echo "$file_subst_cmd" | sed -e 's,%,\\\/,g' \
+-e 's/kpse_include /kpse_include[ ]*/g'`
+ # I can't find any way to do variable substitution in the sed commands
+ # (so the user could have, e.g., $top_srcdir in their ac_include line).
+ (eval $file_subst_cmd conftest.in) \
+ | sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s* conftest.in
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='\([ ][ ]*\)[^ ].*$%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='\([ ]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+if test "${CONFIG_HEADERS+set}" != set; then
+EOF
+cat >> $CONFIG_STATUS <<EOF
+ CONFIG_HEADERS=" config.h"
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+fi
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ echo creating $ac_file
+
+ rm -f conftest.frag conftest.in conftest.out
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%:% $ac_given_srcdir/%g" -e "s%^%$ac_given_srcdir/%"`
+ cat $ac_file_inputs > conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h. And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+
+rm -f conftest.tail
+while :
+do
+ ac_lines=`grep -c . conftest.vals`
+ # grep -c gives empty output for an empty file on some AIX systems.
+ if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+ # Write a limited-size here document to conftest.frag.
+ echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+ echo 'CEOF
+ sed -f conftest.frag conftest.in > conftest.out
+ rm -f conftest.in
+ mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+ rm -f conftest.vals
+ mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+ rm -f conftest.frag conftest.h
+ echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
+ cat conftest.in >> conftest.h
+ rm -f conftest.in
+ if cmp -s $ac_file conftest.h 2>/dev/null; then
+ echo "$ac_file is unchanged"
+ rm -f conftest.h
+ else
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ fi
+ rm -f $ac_file
+ mv conftest.h $ac_file
+ fi
+fi; done
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+
+
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
+if test "$no_recursion" != yes; then
+
+ # Remove --cache-file and --srcdir arguments so they do not pile up.
+ ac_sub_configure_args=
+ ac_prev=
+ for ac_arg in $ac_configure_args; do
+ if test -n "$ac_prev"; then
+ ac_prev=
+ continue
+ fi
+ case "$ac_arg" in
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ ;;
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ ;;
+ *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;;
+ esac
+ done
+
+ for ac_config_dir in : $subdirs; do
+
+ # Do not complain, so a configure script can configure whichever
+ # parts of a large source tree are present.
+ if test ! -d $srcdir/$ac_config_dir; then
+ continue
+ fi
+
+ echo configuring in $ac_config_dir
+
+ case "$srcdir" in
+ .) ;;
+ *)
+ if test -d ./$ac_config_dir || mkdir ./$ac_config_dir; then :;
+ else
+ { echo "configure: error: can not create `pwd`/$ac_config_dir" 1>&2; exit 1; }
+ fi
+ ;;
+ esac
+
+ ac_popdir=`pwd`
+ cd $ac_config_dir
+
+ # A "../" for each directory in /$ac_config_dir.
+ ac_dots=`echo $ac_config_dir|sed -e 's%^\./%%' -e 's%[^/]$%&/%' -e 's%[^/]*/%../%g'`
+
+ case "$srcdir" in
+ .) # No --srcdir option. We are building in place.
+ ac_sub_srcdir=$srcdir ;;
+ /*|[A-z]:/*) # Absolute path.
+ ac_sub_srcdir=$srcdir/$ac_config_dir ;;
+ *) # Relative path.
+ ac_sub_srcdir=$ac_dots$srcdir/$ac_config_dir ;;
+ esac
+
+ # Check for guested configure; otherwise get Cygnus style configure.
+ if test -f ./configure; then
+ ac_sub_configure=./configure
+ elif test -f $ac_sub_srcdir/configure; then
+ ac_sub_configure=$ac_sub_srcdir/configure
+ elif test -f $ac_sub_srcdir/configure.in; then
+ ac_sub_configure=$ac_configure
+ else
+ echo "configure: warning: no configuration information is in $ac_config_dir" 1>&2
+ ac_sub_configure=
+ fi
+
+ # The recursion is here.
+ if test -n "$ac_sub_configure"; then
+
+ # Make the cache file name correct relative to the subdirectory.
+ case "$cache_file" in
+ /*|[A-z]:/*) ac_sub_cache_file=$cache_file ;;
+ *) # Relative path.
+ ac_sub_cache_file="$ac_dots$cache_file" ;;
+ esac
+ case "$ac_given_INSTALL" in
+ "") ;;
+ [/$]*|[A-z]:/*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo "running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir"
+ # The eval makes quoting arguments work.
+ if eval ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir
+ then :
+ else
+ { echo "configure: error: $ac_sub_configure failed for $ac_config_dir" 1>&2; exit 1; }
+ fi
+ fi
+
+ cd $ac_popdir
+ done
+fi
+
diff --git a/Build/source/texk/dvipdfm/configure.in b/Build/source/texk/dvipdfm/configure.in
new file mode 100644
index 00000000000..641843d6208
--- /dev/null
+++ b/Build/source/texk/dvipdfm/configure.in
@@ -0,0 +1,63 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(dvipdfm.c)
+
+define([_version_],"0.13.2c")
+
+VERSION=_version_
+AC_SUBST(VERSION)
+AC_DEFINE(VERSION,_version_)
+AC_DEFINE(PACKAGE,"dvipdfm")
+
+AC_CONFIG_HEADERS(config.h)
+
+AC_ARG_ENABLE([maint], [ --enable-maint enable autoconf portions of Makefile],
+ [MAINT=''], [MAINT='#'])
+AC_SUBST(MAINT)
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+
+sinclude(../kpathsea/withenable.ac)
+sinclude(../../libs/zlib/withenable.ac)
+sinclude(../../libs/libpng/withenable.ac)
+sinclude(../../libs/zlib/zlib.ac)
+sinclude(../../libs/libpng/libpng.ac)
+
+AC_DEFINE(KPATHSEA)
+AC_DEFINE(HAVE_KPATHSEA)
+AC_DEFINE(HAVE_XBASENAME)
+AC_DEFINE(HAVE_ZLIB)
+AC_DEFINE(HAVE_ZLIB_COMPRESS2)
+AC_DEFINE(HAVE_KPSE_FORMATS)
+AC_DEFINE(HAVE_OMEGA_FORMATS)
+AC_DEFINE(HAVE_TTF_FORMATS)
+AC_DEFINE(HAVE_LIBPNG)
+TTF_OPT=''
+AC_SUBST(TTF_OPT)
+
+# TEXMF='${datadir}/texmf'
+# AC_SUBST(TEXMF)
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(unistd.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_EXT_TIMEZONE
+AC_TZ_HAS_TM_GMTOFF
+
+AC_C_CONST
+AC_TYPE_SIZE_T
+AC_STRUCT_TM
+
+dnl Checks for library functions.
+AC_FUNC_MEMCMP
+AC_CHECK_FUNCS(strspn system)
+AC_CHECK_LIB(m, main)
+
+KPSE_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/Build/source/texk/dvipdfm/depend.mak b/Build/source/texk/dvipdfm/depend.mak
new file mode 100644
index 00000000000..6ee274d2bab
--- /dev/null
+++ b/Build/source/texk/dvipdfm/depend.mak
@@ -0,0 +1,1747 @@
+$(objdir)/colorsp.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ pdfdev.h \
+ numbers.h \
+ pdfobj.h \
+ pdfparse.h \
+ pdfspecial.h \
+ dvipdfm.h
+
+$(objdir)/jpeg.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ mfileio.h \
+ numbers.h \
+ dvi.h \
+ error.h \
+ pdfdev.h \
+ pdfobj.h \
+ jpeg.h \
+ pdfspecial.h
+
+$(objdir)/ttf.obj: \
+ config.h \
+ ttf.h \
+ pdfobj.h \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ error.h \
+ mfileio.h \
+ numbers.h \
+ tfm.h \
+ pdflimits.h \
+ twiddle.h \
+ encodings.h \
+ macglyphs.h
+
+$(objdir)/t1crypt.obj: \
+ t1crypt.h
+
+$(objdir)/pdfdoc.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ config.h \
+ mem.h \
+ error.h \
+ mfileio.h \
+ numbers.h \
+ dvi.h \
+ pdfdev.h \
+ pdfobj.h \
+ pdflimits.h \
+ pdfdoc.h \
+ pdfspecial.h \
+ thumbnail.h
+
+$(objdir)/dvipdfm.obj: \
+ config.h \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ mfileio.h \
+ numbers.h \
+ dvi.h \
+ error.h \
+ pdfdev.h \
+ pdfobj.h \
+ pdfdoc.h \
+ encodings.h \
+ type1.h \
+ ttf.h \
+ colorsp.h \
+ pdfparse.h \
+ pdfspecial.h \
+ vf.h \
+ pkfont.h \
+ thumbnail.h \
+ psimage.h \
+ tfm.h
+
+$(objdir)/thumbnail.obj: \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ system.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ config.h \
+ mfileio.h \
+ numbers.h \
+ mem.h \
+ pdfobj.h \
+ thumbnail.h \
+ $(pngdir)/png.h \
+ $(zlibdir)/zlib.h \
+ $(zlibdir)/zconf.h \
+ $(pngdir)/pngconf.h \
+ pngimage.h
+
+$(objdir)/psimage.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ config.h \
+ mem.h \
+ mfileio.h \
+ numbers.h \
+ pdfobj.h \
+ psimage.h \
+ pdfspecial.h \
+ epdf.h
+
+$(objdir)/numbers.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ error.h \
+ mfileio.h \
+ numbers.h
+
+$(objdir)/pdfobj.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ config.h \
+ mem.h \
+ error.h \
+ mfileio.h \
+ numbers.h \
+ pdflimits.h \
+ pdfobj.h \
+ pdfspecial.h \
+ pdfparse.h \
+ twiddle.h \
+ $(zlibdir)/zlib.h \
+ $(zlibdir)/zconf.h
+
+$(objdir)/pdfdev.obj: \
+ config.h \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ error.h \
+ mfileio.h \
+ numbers.h \
+ dvi.h \
+ pdfdev.h \
+ pdfobj.h \
+ tfm.h \
+ pdfdoc.h \
+ type1.h \
+ ttf.h \
+ pkfont.h \
+ pdfspecial.h \
+ pdfparse.h \
+ tpic.h \
+ htex.h \
+ mpost.h \
+ psspecial.h \
+ colorsp.h \
+ pdflimits.h \
+ twiddle.h \
+ encodings.h \
+ colors.h
+
+$(objdir)/encodings.obj: \
+ pdflimits.h \
+ pdfobj.h \
+ mem.h \
+ error.h \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mfileio.h \
+ numbers.h \
+ pdfparse.h \
+ encodings.h \
+ winansi.h
+
+$(objdir)/mfileio.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mfileio.h \
+ numbers.h \
+ error.h
+
+$(objdir)/epdf.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ mfileio.h \
+ numbers.h \
+ pdfobj.h \
+ pdfdoc.h \
+ pdfspecial.h \
+ epdf.h
+
+$(objdir)/ebb.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ mfileio.h \
+ numbers.h \
+ pdfobj.h \
+ jpeg.h \
+ pdfspecial.h \
+ pdfparse.h \
+ config.h \
+ pngimage.h \
+ $(pngdir)/png.h \
+ $(zlibdir)/zlib.h \
+ $(zlibdir)/zconf.h \
+ $(pngdir)/pngconf.h
+
+$(objdir)/htex.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ mfileio.h \
+ numbers.h \
+ dvi.h \
+ error.h \
+ pdfdev.h \
+ pdfobj.h \
+ htex.h \
+ pdfparse.h \
+ pdfdoc.h
+
+$(objdir)/mpost.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ error.h \
+ mfileio.h \
+ numbers.h \
+ dvi.h \
+ pdfdev.h \
+ pdfobj.h \
+ pdfspecial.h \
+ pdfparse.h \
+ mpost.h \
+ pdflimits.h \
+ pdfdoc.h
+
+$(objdir)/psspecial.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ mfileio.h \
+ numbers.h \
+ psspecial.h \
+ pdfparse.h \
+ pdfobj.h \
+ pdfspecial.h \
+ psimage.h \
+ mpost.h \
+ pdfdoc.h
+
+$(objdir)/dvi.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ error.h \
+ mfileio.h \
+ numbers.h \
+ dvi.h \
+ pdfdev.h \
+ pdfobj.h \
+ dvicodes.h \
+ pdflimits.h \
+ pdfdoc.h \
+ tfm.h \
+ vf.h
+
+$(objdir)/type1.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ error.h \
+ mfileio.h \
+ numbers.h \
+ pdfobj.h \
+ type1.h \
+ tfm.h \
+ pdfparse.h \
+ pdflimits.h \
+ t1crypt.h \
+ twiddle.h \
+ encodings.h \
+ standardenc.h
+
+$(objdir)/mem.obj: \
+ mem.h
+
+$(objdir)/pngimage.obj: \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ system.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ config.h \
+ mem.h \
+ pdfobj.h \
+ $(pngdir)/png.h \
+ $(zlibdir)/zlib.h \
+ $(zlibdir)/zconf.h \
+ $(pngdir)/pngconf.h
+
+$(objdir)/vf.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mfileio.h \
+ numbers.h \
+ pdflimits.h \
+ mem.h \
+ error.h \
+ tfm.h \
+ pdfdev.h \
+ pdfobj.h \
+ dvi.h \
+ vf.h \
+ config.h \
+ dvicodes.h
+
+$(objdir)/tfm.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ error.h \
+ mfileio.h \
+ numbers.h \
+ pdflimits.h \
+ tfm.h \
+ config.h
+
+$(objdir)/pdfparse.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ mfileio.h \
+ numbers.h \
+ dvi.h \
+ error.h \
+ pdfdev.h \
+ pdfobj.h \
+ pdfparse.h \
+ pdfspecial.h \
+ pdfdoc.h
+
+$(objdir)/tpic.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ mfileio.h \
+ numbers.h \
+ tpic.h \
+ pdfparse.h \
+ pdfobj.h \
+ pdfdoc.h \
+ pdfdev.h \
+ dvi.h \
+ error.h
+
+$(objdir)/pdfspecial.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ mfileio.h \
+ numbers.h \
+ dvi.h \
+ error.h \
+ pdfdev.h \
+ pdfobj.h \
+ pdflimits.h \
+ pdfspecial.h \
+ pdfdoc.h \
+ pdfparse.h \
+ jpeg.h \
+ epdf.h \
+ mpost.h \
+ psimage.h \
+ config.h \
+ $(pngdir)/png.h \
+ $(zlibdir)/zlib.h \
+ $(zlibdir)/zconf.h \
+ $(pngdir)/pngconf.h \
+ pngimage.h
+
+$(objdir)/ascii85.obj: \
+
+
+$(objdir)/pkfont.obj: \
+ system.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/kpathsea.h \
+ $(kpathseadir)/config.h \
+ $(kpathseadir)/c-std.h \
+ $(kpathseadir)/c-unistd.h \
+ $(kpathseadir)/systypes.h \
+ $(kpathseadir)/c-memstr.h \
+ $(kpathseadir)/c-errno.h \
+ $(kpathseadir)/c-minmax.h \
+ $(kpathseadir)/c-limits.h \
+ $(kpathseadir)/c-proto.h \
+ $(gnuw32dir)/win32lib.h \
+ $(kpathseadir)/debug.h \
+ $(kpathseadir)/types.h \
+ $(kpathseadir)/lib.h \
+ $(kpathseadir)/progname.h \
+ $(kpathseadir)/absolute.h \
+ $(kpathseadir)/c-ctype.h \
+ $(gnuw32dir)/oldnames.h \
+ $(kpathseadir)/c-dir.h \
+ $(kpathseadir)/c-fopen.h \
+ $(kpathseadir)/c-namemx.h \
+ $(kpathseadir)/c-pathch.h \
+ $(kpathseadir)/c-pathmx.h \
+ $(kpathseadir)/c-stat.h \
+ $(kpathseadir)/c-vararg.h \
+ $(kpathseadir)/cnf.h \
+ $(kpathseadir)/concatn.h \
+ $(kpathseadir)/db.h \
+ $(kpathseadir)/str-list.h \
+ $(kpathseadir)/default.h \
+ $(kpathseadir)/expand.h \
+ $(kpathseadir)/fn.h \
+ $(kpathseadir)/fontmap.h \
+ $(kpathseadir)/hash.h \
+ $(kpathseadir)/getopt.h \
+ $(kpathseadir)/line.h \
+ $(kpathseadir)/magstep.h \
+ $(kpathseadir)/paths.h \
+ $(kpathseadir)/pathsearch.h \
+ $(kpathseadir)/str-llist.h \
+ $(kpathseadir)/proginit.h \
+ $(kpathseadir)/readable.h \
+ $(kpathseadir)/remote.h \
+ $(kpathseadir)/tex-file.h \
+ $(kpathseadir)/tex-glyph.h \
+ $(kpathseadir)/tex-hush.h \
+ $(kpathseadir)/tex-make.h \
+ $(kpathseadir)/tilde.h \
+ $(kpathseadir)/truncate.h \
+ $(kpathseadir)/variable.h \
+ $(kpathseadir)/xopendir.h \
+ $(kpathseadir)/xstat.h \
+ mem.h \
+ error.h \
+ mfileio.h \
+ numbers.h \
+ pkfont.h \
+ pdfobj.h \
+ pdflimits.h \
+ tfm.h
+
diff --git a/Build/source/texk/dvipdfm/depend.mk b/Build/source/texk/dvipdfm/depend.mk
new file mode 100644
index 00000000000..aa723ad798a
--- /dev/null
+++ b/Build/source/texk/dvipdfm/depend.mk
@@ -0,0 +1,672 @@
+ascii85.o: ascii85.c
+colorsp.o: colorsp.c \
+ system.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h \
+ $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h \
+ pdfdev.h numbers.h pdfobj.h pdfparse.h pdfspecial.h dvipdfm.h
+dvi.o: dvi.c \
+ system.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h \
+ $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h \
+ $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h \
+ $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h $(kpathsea_srcdir)/db.h \
+ $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h $(kpathsea_srcdir)/expand.h \
+ $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h $(kpathsea_srcdir)/hash.h \
+ $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h $(kpathsea_srcdir)/magstep.h \
+ $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h $(kpathsea_srcdir)/str-llist.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h $(kpathsea_srcdir)/tex-file.h \
+ $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h $(kpathsea_srcdir)/tex-make.h \
+ $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h $(kpathsea_srcdir)/variable.h \
+ $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h error.h mfileio.h \
+ numbers.h dvi.h pdfdev.h pdfobj.h dvicodes.h pdflimits.h pdfdoc.h tfm.h \
+ vf.h
+dvipdfm.o: dvipdfm.c \
+ config.h system.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h \
+ $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h \
+ $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h $(kpathsea_srcdir)/db.h \
+ $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h $(kpathsea_srcdir)/expand.h \
+ $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h $(kpathsea_srcdir)/hash.h \
+ $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h $(kpathsea_srcdir)/magstep.h \
+ $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h $(kpathsea_srcdir)/str-llist.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h $(kpathsea_srcdir)/tex-file.h \
+ $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h $(kpathsea_srcdir)/tex-make.h \
+ $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h $(kpathsea_srcdir)/variable.h \
+ $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h mfileio.h numbers.h \
+ dvi.h error.h pdfdev.h pdfobj.h pdfdoc.h encodings.h type1.h ttf.h \
+ colorsp.h pdfparse.h pdfspecial.h vf.h pkfont.h thumbnail.h psimage.h \
+ tfm.h
+ebb.o: ebb.c \
+ system.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h \
+ $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h \
+ mfileio.h numbers.h pdfobj.h jpeg.h pdfspecial.h pdfparse.h config.h \
+ pngimage.h
+encodings.o: encodings.c \
+ pdflimits.h pdfobj.h mem.h \
+ error.h system.h $(kpathsea_dir)/c-auto.h \
+ $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h \
+ $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h \
+ mfileio.h numbers.h pdfparse.h encodings.h winansi.h
+epdf.o: epdf.c system.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h \
+ mfileio.h numbers.h pdfobj.h pdfdoc.h pdfspecial.h epdf.h
+htex.o: htex.c \
+ system.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h \
+ $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h $(kpathsea_srcdir)/db.h \
+ $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h $(kpathsea_srcdir)/expand.h \
+ $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h $(kpathsea_srcdir)/hash.h \
+ $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h $(kpathsea_srcdir)/magstep.h \
+ $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h $(kpathsea_srcdir)/str-llist.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h $(kpathsea_srcdir)/tex-file.h \
+ $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h $(kpathsea_srcdir)/tex-make.h \
+ $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h $(kpathsea_srcdir)/variable.h \
+ $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h mfileio.h numbers.h \
+ dvi.h error.h pdfdev.h pdfobj.h htex.h pdfparse.h pdfdoc.h
+jpeg.o: jpeg.c \
+ system.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h \
+ mfileio.h numbers.h dvi.h error.h pdfdev.h pdfobj.h jpeg.h pdfspecial.h
+mem.o: mem.c \
+ mem.h
+mfileio.o: mfileio.c \
+ system.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h \
+ $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h \
+ mfileio.h numbers.h error.h
+mpost.o: mpost.c \
+ system.h $(kpathsea_dir)/c-auto.h \
+ $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h \
+ $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h $(kpathsea_srcdir)/db.h \
+ $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h $(kpathsea_srcdir)/expand.h \
+ $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h $(kpathsea_srcdir)/hash.h \
+ $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h $(kpathsea_srcdir)/magstep.h \
+ $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h $(kpathsea_srcdir)/str-llist.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h $(kpathsea_srcdir)/tex-file.h \
+ $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h $(kpathsea_srcdir)/tex-make.h \
+ $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h $(kpathsea_srcdir)/variable.h \
+ $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h error.h mfileio.h \
+ numbers.h dvi.h pdfdev.h pdfobj.h pdfspecial.h pdfparse.h mpost.h \
+ pdflimits.h pdfdoc.h
+numbers.o: numbers.c system.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h \
+ error.h mfileio.h numbers.h
+pdfdev.o: pdfdev.c config.h \
+ system.h $(kpathsea_dir)/c-auto.h \
+ $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h \
+ $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h $(kpathsea_srcdir)/db.h \
+ $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h $(kpathsea_srcdir)/expand.h \
+ $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h $(kpathsea_srcdir)/hash.h \
+ $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h $(kpathsea_srcdir)/magstep.h \
+ $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h $(kpathsea_srcdir)/str-llist.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h $(kpathsea_srcdir)/tex-file.h \
+ $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h $(kpathsea_srcdir)/tex-make.h \
+ $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h $(kpathsea_srcdir)/variable.h \
+ $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h error.h mfileio.h \
+ numbers.h dvi.h pdfdev.h pdfobj.h tfm.h pdfdoc.h type1.h ttf.h pkfont.h \
+ pdfspecial.h pdfparse.h tpic.h htex.h mpost.h psspecial.h colorsp.h \
+ pdflimits.h twiddle.h encodings.h colors.h
+pdfdoc.o: pdfdoc.c \
+ system.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h \
+ $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h \
+ config.h mem.h error.h mfileio.h numbers.h dvi.h pdfdev.h pdfobj.h \
+ pdflimits.h pdfdoc.h pdfspecial.h thumbnail.h
+pdfobj.o: pdfobj.c \
+ system.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h \
+ $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h \
+ $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h $(kpathsea_srcdir)/db.h \
+ $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h $(kpathsea_srcdir)/expand.h \
+ $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h $(kpathsea_srcdir)/hash.h \
+ $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h $(kpathsea_srcdir)/magstep.h \
+ $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h $(kpathsea_srcdir)/str-llist.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h $(kpathsea_srcdir)/tex-file.h \
+ $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h $(kpathsea_srcdir)/tex-make.h \
+ $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h $(kpathsea_srcdir)/variable.h \
+ $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h config.h mem.h error.h \
+ mfileio.h numbers.h pdflimits.h pdfobj.h pdfspecial.h pdfparse.h \
+ twiddle.h
+pdfparse.o: pdfparse.c \
+ system.h $(kpathsea_dir)/c-auto.h \
+ $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h \
+ $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h $(kpathsea_srcdir)/db.h \
+ $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h $(kpathsea_srcdir)/expand.h \
+ $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h $(kpathsea_srcdir)/hash.h \
+ $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h $(kpathsea_srcdir)/magstep.h \
+ $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h $(kpathsea_srcdir)/str-llist.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h $(kpathsea_srcdir)/tex-file.h \
+ $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h $(kpathsea_srcdir)/tex-make.h \
+ $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h $(kpathsea_srcdir)/variable.h \
+ $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h mfileio.h numbers.h \
+ dvi.h error.h pdfdev.h pdfobj.h pdfparse.h pdfspecial.h pdfdoc.h
+pdfspecial.o: pdfspecial.c \
+ system.h $(kpathsea_dir)/c-auto.h \
+ $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h \
+ $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h $(kpathsea_srcdir)/db.h \
+ $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h $(kpathsea_srcdir)/expand.h \
+ $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h $(kpathsea_srcdir)/hash.h \
+ $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h $(kpathsea_srcdir)/magstep.h \
+ $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h $(kpathsea_srcdir)/str-llist.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h $(kpathsea_srcdir)/tex-file.h \
+ $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h $(kpathsea_srcdir)/tex-make.h \
+ $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h $(kpathsea_srcdir)/variable.h \
+ $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h mfileio.h numbers.h \
+ dvi.h error.h pdfdev.h pdfobj.h pdflimits.h pdfspecial.h pdfdoc.h \
+ pdfparse.h jpeg.h epdf.h mpost.h psimage.h config.h \
+ pngimage.h
+pkfont.o: pkfont.c \
+ system.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h \
+ error.h mfileio.h numbers.h pkfont.h pdfobj.h pdflimits.h tfm.h
+pngimage.o: pngimage.c \
+ $(kpathsea_srcdir)/config.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h \
+ $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h \
+ $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/c-ctype.h system.h \
+ $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h \
+ $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h $(kpathsea_srcdir)/db.h \
+ $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h $(kpathsea_srcdir)/expand.h \
+ $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h $(kpathsea_srcdir)/hash.h \
+ $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h $(kpathsea_srcdir)/magstep.h \
+ $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h $(kpathsea_srcdir)/str-llist.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h $(kpathsea_srcdir)/tex-file.h \
+ $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h $(kpathsea_srcdir)/tex-make.h \
+ $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h $(kpathsea_srcdir)/variable.h \
+ $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h config.h mem.h pdfobj.h
+psimage.o: psimage.c \
+ system.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h \
+ config.h mem.h mfileio.h numbers.h pdfobj.h psimage.h pdfspecial.h \
+ epdf.h
+psspecial.o: psspecial.c \
+ system.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h \
+ $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h \
+ mfileio.h numbers.h psspecial.h pdfparse.h pdfobj.h pdfspecial.h \
+ psimage.h mpost.h pdfdoc.h
+t1crypt.o: t1crypt.c t1crypt.h
+tfm.o: tfm.c \
+ system.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h \
+ error.h mfileio.h numbers.h pdflimits.h tfm.h config.h
+thumbnail.o: thumbnail.c \
+ $(kpathsea_srcdir)/config.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h \
+ $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h \
+ $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/c-ctype.h system.h \
+ $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h \
+ $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h $(kpathsea_srcdir)/db.h \
+ $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h $(kpathsea_srcdir)/expand.h \
+ $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h $(kpathsea_srcdir)/hash.h \
+ $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h $(kpathsea_srcdir)/magstep.h \
+ $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h $(kpathsea_srcdir)/str-llist.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h $(kpathsea_srcdir)/tex-file.h \
+ $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h $(kpathsea_srcdir)/tex-make.h \
+ $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h $(kpathsea_srcdir)/variable.h \
+ $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h config.h mfileio.h numbers.h \
+ mem.h pdfobj.h thumbnail.h \
+ pngimage.h
+tpic.o: tpic.c \
+ system.h $(kpathsea_dir)/c-auto.h \
+ $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h \
+ mfileio.h numbers.h tpic.h pdfparse.h pdfobj.h pdfdoc.h pdfdev.h dvi.h \
+ error.h
+ttf.o: ttf.c config.h ttf.h pdfobj.h \
+ system.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h \
+ $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h \
+ $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h \
+ $(kpathsea_srcdir)/db.h $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h \
+ $(kpathsea_srcdir)/expand.h $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h \
+ $(kpathsea_srcdir)/hash.h $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h \
+ $(kpathsea_srcdir)/magstep.h $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h \
+ $(kpathsea_srcdir)/str-llist.h $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h \
+ $(kpathsea_srcdir)/tex-file.h $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h \
+ $(kpathsea_srcdir)/tex-make.h $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h \
+ $(kpathsea_srcdir)/variable.h $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h \
+ error.h mfileio.h numbers.h tfm.h pdflimits.h twiddle.h encodings.h \
+ macglyphs.h
+type1.o: type1.c \
+ system.h \
+ $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h $(kpathsea_srcdir)/config.h \
+ $(kpathsea_srcdir)/c-std.h $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h \
+ $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h $(kpathsea_srcdir)/db.h \
+ $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h $(kpathsea_srcdir)/expand.h \
+ $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h $(kpathsea_srcdir)/hash.h \
+ $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h $(kpathsea_srcdir)/magstep.h \
+ $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h $(kpathsea_srcdir)/str-llist.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h $(kpathsea_srcdir)/tex-file.h \
+ $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h $(kpathsea_srcdir)/tex-make.h \
+ $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h $(kpathsea_srcdir)/variable.h \
+ $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mem.h error.h mfileio.h \
+ numbers.h pdfobj.h type1.h tfm.h pdfparse.h pdflimits.h t1crypt.h \
+ twiddle.h encodings.h standardenc.h
+vf.o: vf.c \
+ system.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/kpathsea.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h \
+ $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ $(kpathsea_srcdir)/absolute.h $(kpathsea_srcdir)/c-ctype.h $(kpathsea_srcdir)/c-dir.h \
+ $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/c-namemx.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-pathmx.h $(kpathsea_srcdir)/c-stat.h \
+ $(kpathsea_srcdir)/c-vararg.h \
+ $(kpathsea_srcdir)/cnf.h $(kpathsea_srcdir)/concatn.h $(kpathsea_srcdir)/db.h \
+ $(kpathsea_srcdir)/str-list.h $(kpathsea_srcdir)/default.h $(kpathsea_srcdir)/expand.h \
+ $(kpathsea_srcdir)/fn.h $(kpathsea_srcdir)/fontmap.h $(kpathsea_srcdir)/hash.h \
+ $(kpathsea_srcdir)/getopt.h $(kpathsea_srcdir)/line.h $(kpathsea_srcdir)/magstep.h \
+ $(kpathsea_dir)/paths.h $(kpathsea_srcdir)/pathsearch.h $(kpathsea_srcdir)/str-llist.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/readable.h $(kpathsea_srcdir)/tex-file.h \
+ $(kpathsea_srcdir)/tex-glyph.h $(kpathsea_srcdir)/tex-hush.h $(kpathsea_srcdir)/tex-make.h \
+ $(kpathsea_srcdir)/tilde.h $(kpathsea_srcdir)/truncate.h $(kpathsea_srcdir)/variable.h \
+ $(kpathsea_srcdir)/xopendir.h $(kpathsea_srcdir)/xstat.h mfileio.h numbers.h \
+ pdflimits.h mem.h error.h tfm.h pdfdev.h pdfobj.h dvi.h vf.h config.h \
+ dvicodes.h
diff --git a/Build/source/texk/dvipdfm/doc/dvipdfm.tex b/Build/source/texk/dvipdfm/doc/dvipdfm.tex
new file mode 100644
index 00000000000..8ebfc3011a7
--- /dev/null
+++ b/Build/source/texk/dvipdfm/doc/dvipdfm.tex
@@ -0,0 +1,1304 @@
+% $Header$
+% \special{ pdf: pagesize width 8.5truein height 11.0truein}
+\special{ pdf: docview <</PageMode /UseOutlines>>}%
+\catcode`\ =11\def\space{ }\catcode`\ =10
+% Page layout
+\tolerance=2000
+\magnification\magstephalf
+\advance\hoffset by 0.5truein
+\advance\voffset by 0.5truein
+\advance\hsize by -1.0truein
+\advance\vsize by -1.0truein
+\def\makefootline{\baselineskip=40pt\line{\the\footline}}
+%
+% Some helpful symbols
+\def\rtm{{\font\r=cmss10 at 4pt
+\font\c=cmsy5
+\setbox0\hbox{\c\char13}\skip0\wd0\box0\setbox0\hbox{\r R}\advance\skip0 by
+\wd0\kern-0.5\skip0\box0}}
+\def\tm{{\font\r=cmss10 at 4pt \hbox{\r TM}}}%
+%
+% Verbatim mode borrowed from manmac macros
+%
+\outer\def\begindisplay{\obeylines\startdisplay}
+{\obeylines\gdef\startdisplay#1
+ {\catcode`\^^M=5$$#1\halign\bgroup\indent##\hfil&&\qquad##\hfil\cr}}
+\outer\def\enddisplay{\crcr\egroup$$}
+\chardef\other=12
+\def\ttverbatim{\begingroup \catcode`\\=\other \catcode`\{=\other
+ \catcode`\}=\other \catcode`\$=\other \catcode `\&=\other
+ \catcode`\#=\other \catcode`\%=\other \catcode `\~=\other
+ \catcode`\_=\other \catcode`\^=\other
+ \obeyspaces \obeylines \tt}
+{\obeyspaces\gdef {\ }}
+\outer\def\begintt{$$\let\par=\endgraf\ttverbatim \parskip=0pt
+ \catcode`\|=0 \rightskip=-5pc \ttfinish}
+{\catcode`\|=0 |catcode`|\=\other
+ |obeylines % end of line is now active
+ |gdef|ttfinish#1^^M#2\endtt{#1|vbox{#2}|endgroup$$}}
+\catcode`\|=\active
+{\obeylines\gdef|{\ttverbatim\spaceskip=\ttglue\let^^M=\ \let|=\endgroup}}
+\newskip\ttglue
+\ttglue=0.5em plus 0.25em minus 0.15em
+%
+%
+% Some color definitions
+%
+\def\begincolor#1{\special{pdf:bc #1}}%
+\def\endcolor{\special{pdf:ec}}%
+\def\colored#1#2{%
+ \begincolor{#1}#2\endcolor}
+\def\red{[0.8 0.5 0]}%
+\def\green{[0 1 0]}%
+\def\blue{[0 0.4 0.8]}%
+\def\yellow{[0.8 0.9 0.1]}%
+\def\linkcolor{[0.5 0.0 0.7]}%
+%
+% Small help for images
+\def\reserve#1#2#3{\setbox0\hbox{}\wd0=#1
+ \ht0=#2\special{#3}\box0}
+\def\nreserve#1#2#3{\setbox0\hbox{}\wd0=#1
+ \ht0=#2{#3}\box0}
+%
+% Some font definitions
+%
+\font\maintitlefont=cmti12 at 20.74pt
+\font\headingfont=cmss12 at 14.4pt
+\font\subheadingfont=cmss12 at 12pt
+%
+%
+% Miscellaneous token lists
+%
+\newtoks\title\newtoks\author\newtoks\version
+\newtoks\date
+%
+% Bibliography counters
+\newcount\biblioitems\biblioitems=0
+\def\bibitem{\medskip\advance\biblioitems by 1\item{[\the\biblioitems]}}
+%
+% Counters for section levels
+%
+\newcount\sectioncount\newcount\ssectioncount\newcount\sssectioncount
+\sectioncount0\ssectioncount0\sssectioncount0
+%
+\newskip\indentlevel\indentlevel=\parindent
+\newskip\secskip\secskip=24pt plus 1pt minus 2pt
+\newskip\subsecskip\subsecskip=16pt plus 1pt minus 2pt
+\def\beginlist{\par\nobreak\advance\leftskip by \indentlevel\advance\rightskip by
+\indentlevel\medskip\nobreak}
+\def\endlist{\par\advance\leftskip by -\indentlevel\advance\rightskip by
+-\indentlevel\medskip}
+%
+%
+\def\settitle{%
+ {\maintitlefont\colored{\blue}{\the\title}}%
+ \special {pdf: docinfo << /Title (\expandafter\the\title) >>}}
+%
+\def\setauthor{%
+ {\headingfont\colored{\blue}{\the\author}}%
+ \special {pdf: docinfo << /Author (\the\author) >>}}%
+%
+\def\setversion{%
+ {\subheadingfont{\the\version}}%
+}%
+\def\setdate{%
+ {\subheadingfont{\the\date}}%
+}%
+\def\setlink#1{\colored{\linkcolor}{#1}}%
+%
+\def\setheading#1{%
+ {\headingfont\colored{\blue}{#1}}\raise\baselineskip
+ \hbox{\special{pdf: outline 1 << /Title (#1) /Dest [
+@thispage /FitH @ypos ] >> }}}%
+%
+\def\setsubheading#1{%
+ {\subheadingfont\colored{\blue}{#1}}\raise\baselineskip
+ \hbox{\special{pdf: outline 2 << /Title (#1) /Dest [
+@thispage /FitH @ypos ] >> }}}%
+%
+% \def\link#1#2{\setbox0\hbox{\setlink{#1}}%
+% \leavevmode\special{pdf: ann width \the\wd0\space height \the\ht0\space depth \the\dp0
+% << /Type /Annot /Subtype /Link /Border [ 0 0 0 ] /A << /S /GoTo
+% /D (#2) >> >>}\box0\relax}%
+\def\link#1#2{%
+ \leavevmode\special{pdf: bann
+ << /Type /Annot /Subtype /Link /Border [ 0 0 0 ] /A << /S /GoTo /D (#2)
+>>
+>>}\setlink{#1}\special{pdf: eann}\relax}
+%
+\def\dest#1{\hbox{\raise14pt\hbox{\special{pdf:dest (#1) [ @thispage /FitH
+@ypos ]}}}}%
+%
+\def\maketitle{\noindent\settitle\hfill\setauthor\par
+ \hrule height 1.0pt\medskip
+ \noindent\setversion\hfill\setdate\vskip0.3in}%
+%
+\def\section#1{\advance\sectioncount by 1\ssectioncount0
+\vskip-\lastskip\vskip\secskip\goodbreak
+\noindent\setheading{\the\sectioncount. #1}\medskip\nobreak}%
+\def\subsection#1{\vskip-\lastskip\advance\ssectioncount by 1%
+\vskip\subsecskip\noindent
+\setsubheading{\the\sectioncount.\the\ssectioncount\
+ #1}\par\nobreak\smallskip}%
+%
+\def\display#1{\medskip\line{\quad #1\hfil}\medskip}
+\def\example{\medskip\noindent{\it Example:\quad}\nobreak}
+\def\note{\medskip\noindent{\it Note:\quad\nobreak}}
+\def\syntax{\medskip\noindent{\it Syntax:\quad}\nobreak}
+\def\description{\medskip\noindent{\it Description:\quad}\nobreak}
+%
+\def\newpage{\vfill\eject}
+%
+\def\dvipdfm{{\tt dvipdfm}}%
+%
+\title{Dvipdfm User's Manual}
+\author{Mark A. Wicks}
+\version{Version 0.12.4b}
+\date{September 19, 1999}
+\maketitle
+\section{Introduction}
+This package is a DVI (\TeX) to PDF conversion utility,
+having the following features:
+
+\beginlist
+\item{$\bullet$} {\it Support for outline entries (also called bookmarks), named destinations,
+and \link{annotations}{Annotate} (including hyperlinks, forms and widgets).} Nearly
+every Acrobat Distiller pdfmark is approximated.
+
+\item{$\bullet$} {\it Support for ``standard'' DVI specials such
+as Hyper\TeX\ (HTML), TPIC, color specials, |PSfile|, and other PostScript specials.}
+
+\item{$\bullet$} {\it Native support for inclusion of
+\link{MetaPost}{postscript} output and
+inclusion of arbitrary \link{PostScript}{postscript} files with help from an external program.}
+
+\item{$\bullet$} {\it Support for thumbnails with a little help from GhostScript to
+generate the thumbnails.}
+
+\item{$\bullet$} {\it Support for arbitrary, nested linear transformations
+of typeset material.} Any material on the page, including
+\TeX\ text, may be \link{scaled and rotated}{textxform}.
+
+\item{$\bullet$} {\it Ability to include the first page of a \link{PDF file}{pdfimage} as
+an encapsulated object along with its embedded resources such as fonts.}
+Included PDF images may be cropped by supplying a bounding box.
+Note: Currently, this doesn't work if the contents stream
+has multiple segments.
+
+\item{$\bullet$} {\it Ability to include \link{JPEG}{jpegimage} and
+PNG bitmapped images as encapsulated objects.}
+
+\item{$\bullet$} {\it An internal color stack.} A color stack allows you to change the current color, pushing the
+current color onto a stack. At any time, the original color
+can be popped from the stack. This is useful, for example, in
+headlines, that may have a different color from the current text.
+The headline macro can restore the current color without knowing
+what it is.
+
+\item{$\bullet$} {\it Support for partial font embedding and Flate compression
+to reduce file size}
+
+\item{$\bullet$} {\it Support for font reencoding to work around encodings
+that aren't fully supported by the Acrobat suite of products.}
+
+\item{$\bullet$} {\it Balanced page and destination trees.} Balancing
+these trees improves reader access speed
+on very large documents.
+
+\endlist
+
+The electronic version of the document exercises
+some of the hypertext features and serves as
+a sample input file for |dvipdfm|.
+It assumes the reader has some familiarity with the basic features
+of the Portable Document Format. The PDF specification
+is distributed by Adobe Systems\link{[1]}{pdfmanual}.
+An excellent source for information about PDF documents
+in general is \link{[2]}{pdfprimer}. Information about
+using \TeX\ to construct PDF documents (mainly using Distiller) is the
+AcroTeX home page\link{[3]}{acrotex}.
+
+Currently, the widely accepted method to generate PDF file from \TeX\
+is to use Adobe's Acrobat Distiller on a PostScript
+file produced by {\tt dvips}.
+The hyperlink features are accessed by using \TeX\ |special| primitives
+to embed pdfmarks in the PostScript produced by |dvips|.
+H\`an Th\'e Th\`an's PDF\TeX\ project is an alternative method
+of generating PDF from \TeX\ source.
+Although quite good and fairly mature, the PDF\TeX\ project
+modified \TeX\ itself to add primitives that support the PDF features.
+I prefer to work with \TeX\ unmodified, as released by Donald Knuth
+(call me a purist).
+There is an existing DVI to PDF driver called
+|dvipdf| written by Sergey Lesenko. At present, it's not widely
+available, so I haven't used it. I wrote |dvipdfm|
+mainly as an exercise to get at the features
+of PDF I was trying to use. This |dvipdfm| project demonstrates that many features
+of PDF can be accessed by using a DVI driver.
+The PDF features are activated in the driver via
+\TeX\ |special| primitives.
+
+Even though Distiller is the best method of generating PDF (and
+probably will remain so for some time) I have several reasons for
+seeking alternatives to Distiller.
+First, Distiller isn't available for my principle operating
+system---Linux.
+
+My second objection is philosophical.
+\TeX\ is a programming language.
+A DVI file is a page description consisting of very
+simple program instructions that have no branching or
+decision instructions.
+Similarly PostScript is a complete programming language,
+while PDF is a page description language consisting
+of simple program instructions
+without any branching or decision capabilities.
+\TeX\ is like PostScript (without the graphics)
+while DVI is like PDF (without the graphics or the hyperlinks).
+Creating PDF from DVI using Distiller requires converting a page description to a program,
+and converting that program back to a page description.
+To continue this analogy,
+Pdfmarks are PostScript ``escapes'' and are meant for the Distiller.
+\TeX\ |\special| primitives are \TeX\ ``escapes'' and are meant for the DVI driver.
+It seems natural to go directly from DVI to PDF, where \TeX\ replaces
+PostScript, the DVI driver replaces Distiller,
+and \TeX\ |\special| primitives replace the pdfmarks.
+
+Unfortunately, until graphics software
+begins to produce PDF content streams or encapsulated
+PDF objects, PostScript will remain the easiest
+way to include graphics in \TeX\ documents.
+I would hope that in the future, graphics programs
+will begin to produce PDF content streams or PDF objects that
+may be included using a DVI to PDF translator. Either
+of these may be easily embedded using \dvipdfm\ or a similar driver.
+
+\section{Command Line Options}
+\link{Table~1}{commandline} lists the options
+that are available on the command line.
+\par\noindent
+Note: Several flags may be specified at once:
+\example
+\begintt
+dvipdfm -ecz 9 test.dvi
+\endtt
+
+\topinsert
+{\dest{commandline}}
+\centerline{\colored{\blue}{\subheadingfont Table~1---Command line options
+recognized by |dvipdfm|}}
+\bigskip\nobreak
+\centerline{\vbox{\halign{{\tt #}\hskip
+1em\strut&\vtop{\leftskip0pt\rightskip0pt\hsize=3.5in\noindent #}\cr
+\omit\hfil\it Option\hfil&\omit\hfil \it Description \hfil\cr
+\noalign{\smallskip\begincolor\red\hrule\endcolor\smallskip}
+-c&{\it Disable color specials} Specifying this option
+forces all color commands to be ignored. This is useful for printing a color document
+on a black and white printer.\cr
+\noalign{\smallskip}
+-e&{\it Disable partial font embedding.} This may be useful
+for forms which need complete fonts, or if you run accross a PFB
+file that \dvipdfm\ cannot correctly parse.\cr
+\noalign{\smallskip}
+-f&{\it Set font map file name}. See
+the \link{Font Mapping}{fontmap} section for additional information.\cr
+\noalign{\smallskip}
+-m {\it number}&{\it Specify an additional magnification for
+the document}.\cr
+\noalign{\smallskip}
+-o {\it filename}&{\it Set the output PDF file name}.\cr
+\noalign{\smallskip}
+-p {\it papersize}&{\it Specify the output papersize.}
+Valid paper sizes are |letter|, |legal|, |ledger|, |tabloid|,
+|a4|, or |a3|. The default is |letter|. Arbitrary paper
+sizes can be specified via \TeX\ special commands,
+which is the recommended method.\cr
+\noalign{\smallskip}
+-l&{\it Landscape the document.} This is only
+meaningful for paper sizes specified on the command line.\cr
+\noalign{\smallskip}
+-s {\it page\_ranges}&{\it Select a subset of pages from the DVI file.}
+The {\it page\_ranges} specifier is a set of comma-separated page
+ranges---e.g., |dvipdfm -s 10-12,10-20|. If the first
+page in a range is empty (e.g., |dvipdfm -s -10|), it represents
+the beginning of the document. If
+the last page in a range is empty (e.g., |dvipdfm -s 10-|), it selects the end of the document.\cr
+\noalign{\smallskip}
+-t&{\it Embed thumbnail images.} The thumbnails must be generated by a
+separate program. Details are discussed \link{later}{thumbnails} in this document\cr
+\noalign{\smallskip}
+-d&{\it Delete thumbnail images after embedding.}\cr
+\noalign{\smallskip}
+-x {\it number}&{\it Specify the horizontal offset
+for the document.} The default is 1.0in.\cr
+\noalign{\smallskip}
+-y {\it number}&{\it Specify the vertical offset
+for the document.} The default is 1.0in.\cr
+\noalign{\smallskip}
+-z {\it number}&{\it Specify the compression level.}
+Valid compression levels range from 0 to 9, with 0 indicating
+no compression. A compression level of 9 is the default.\cr
+\noalign{\smallskip}
+-v&{\it Be verbose.} Among other things, dvipdfm
+will display complete file names as various files are opened.\cr
+\noalign{\smallskip}
+-vv&{\it Be more verbose.}\cr}}}
+\endinsert
+
+\section{General Concepts and Syntax for TeX Specials}
+Each \TeX\ |\special|
+represents a separate command to the \dvipdfm\
+driver. Each |special| must begin with ``|pdf:|''
+to identify that ||special|| as a command for the \dvipdfm\ driver.
+A |\special| beginning with any other characters is ignored
+by the driver. Leading spaces are ignored. The characters ``|pdf:|''
+are immediately followed by a \dvipdfm\ command. These commands
+are documented in \hbox{Sections~3--6}.
+
+\subsection{PDF Object Syntax and Variable Expansion}
+With one exception, the syntax used for PDF objects
+within each |\special| specials follows
+the PDF specification.
+The one exception is variable expansion.
+In the syntax specifications that follow, {\it PDF\_Object}
+means that an arbitary PDF object is expected. Similarly
+{\it PDF\_Array} indicates that a PDF array is expected, {\it PDF\_Dict}
+inciates that a PDF dictionary is expected, etc.
+See the \link{reference manual}{pdfmanual}\
+for a complete list of PDF object types.
+
+The single extension implemented in this driver
+allows a symbol name of the
+form |@|{\it name} whereever any PDF object is expected.
+The {\it name} may contain any characters allowed
+in a PDF name.
+A user-defined symbol beginning with |@| expands to an indirect
+reference to the user-defined PDF object. This feature replaces
+the |{|{\it name}|}| syntax used with pdfmarks.
+In addition to the user-defined names, some names
+are defined by the driver.
+The driver defined variables are for
+referencing objects such as the current page, future pages,
+or the current location on the current page.
+The driver defined variables appear in \link{Table~2}{drivervariables}.
+\topinsert
+{\dest{drivervariables}}
+\centerline{\colored{\blue}{\subheadingfont Table~2---List of driver
+defined variables}}
+\bigskip\nobreak
+\centerline{\vbox{\halign{{\tt #}\hskip
+1em&\vtop{\leftskip0pt\rightskip0pt\hsize=3.0in\noindent #}\cr
+\omit\hfil\it Variable\hfil&\omit\hfil \it Description \hfil\cr
+\noalign{\smallskip\begincolor\red\hrule\endcolor\smallskip}
+@catalog&A reference to the document's catalog.\cr
+\noalign{\smallskip}
+@names&A reference to the document's /Names dictionary.\cr
+\noalign{\smallskip}
+@pages&A reference to the root of the document's /Pages tree.\cr
+\noalign{\smallskip}
+@resources&A reference to the current page resource dictionary.\cr
+\noalign{\smallskip}
+@thispage&A reference to the current page.\cr
+\noalign{\smallskip}
+@page{\it n}&A reference to page {\it n}.\cr
+\noalign{\smallskip}
+@nextpage&A reference to the page following |@thispage|.\cr
+\noalign{\smallskip}
+@prevpage&A reference to the page preceding |@thispage|.\cr
+\noalign{\smallskip}
+@ypos&A {\it number} representing the current vertical position in units of PDF points.\cr
+\noalign{\smallskip}
+@xpos&A {\it number} representing the current horizontal position in units of PDF points.\cr
+}}}
+\endinsert
+
+In the syntax specifications that follow, several
+standard conventions are followed. Terminal
+characters that appear in the command
+are typeset in the |\tt| font, e.g., |object|.
+Nonterminal symbols are typeset in italics.
+Optional parameters are surrounded by brackets, e.g.,
+[{\it optional\_argument}]. An item followed
+by~``{*}'' represents an item that may appear
+zero or more times. An item followed by~``{+}''
+represents a required item that may appear multiple times.
+
+\subsection{Dimensions and transformations}
+Interaction with the |dvipdfm| driver consists
+of short commands with a few arguments delimited by white space.
+Typically the arguments are PDF objects.
+Two exceptions are dimension specifications and transformations.
+
+In the \TeX\ style, a dimension specification consists of one of the keywords
+|width|, |height|, or |depth| followed by a dimension
+consisting of a numerical value, followed by a unit for the dimension. The
+unit will typically be |pt| (which represents a \TeX\ point, not a
+PDf point) but |mm|, |cm| and |in| are also allowed.
+If the document is magnified, the ``true'' dimensions |truept|,
+|truemm|, |truecm|, and |truein| may be used. The notation
+{\it dimension\/} in a syntax description means a dimension is expected.
+
+A transformation consists of one of the keywords |scale|, |xscale|,
+|yscale|, or |rotate| followed by a numerical value. In the
+case of |rotate| the value is the rotation angle in degrees.
+The notation
+{\it transformation} means a transformation is expected.
+In the case of included images originating from
+PDF/PostScript files, a clipping or bounding box may be specified
+as part of the ``transformation.'' The bounding
+box specification consists of the keyword |bbox|
+followed by four numerical values, which are
+the standard PostScript |llx|, |lly|, |urx|, and |ury|
+coordinates of the bounding box.
+
+\section{Document Construction Commands}
+All commands are executed via \TeX\ |\special| primitives
+prefixed with the characters ``|pdf:|''.
+\example
+\begintt
+\special{ pdf: out 1 << /Title (Introduction)
+ /Dest [ 1 0 R /FitH 234 ] >>
+\endtt
+
+\dest{Annotate}
+\subsection{Annotate}
+\hbox to 0pt{\hskip-1.0in\special{pdf: ann width 3.0in height 36pt << /Type /Annot /Subtype /Text
+/Contents (This is a /Text Annotation that looks like a sticky note.) >>}\hss}
+\syntax
+{\tt annotate} [{\tt @}{\it name}] {\it dimension}+ {\it PDF\_dictionary}
+\description
+The |annotate| (|annot| or |ann|) command defines an annotation.
+Annotations are typically used for
+notes, hyperlinks, forms, or widgets.
+The parameter {\it name} is an optional alphanumeric identifier
+and {\it PDF\_dictionary} is a valid PDF dictionary after variable expansion.
+If {\tt @}{\it name} is specified, it may be used in
+other PDF objects to refer to this annotation.
+One or more {\it dimension} parameters are required
+and each consists of the keyword
+{\tt height}, {\tt width}, or {\tt depth} followed
+by an appropriate length, specified as per \TeX\null.
+The |width| must be nonzero and either the |height| or |depth|
+must be nonzero.
+Each length is a number followed by a unit, such as {\tt pt},
+{\tt in}, or {\tt cm}. Since these values
+would typically be entered by \TeX, a {\tt pt}
+is a \TeX\ point, not a PDF point.
+
+\example The annotation in this subsection
+was typeset with
+\begintt
+\special{pdf: ann width 3.0in height 36pt
+ << /Type /Annot /Subtype /Text
+ /Contents (This is a /Text Annotation
+ that looks like a sticky note.) >>}
+\endtt
+
+\subsection{Begin Annotation}
+\syntax
+{\tt beginann} {\it PDF\_dictionary}
+\description
+The |beginann| (|bann| or |bannot|) command begins a breakable annotation.
+Dvipdfm tries to determine the boundaries of the annotation automatically.
+Such an annotation may be broken over several lines (or even several pages).
+Unlike |annot|, the annotation may be not be referred to by name later,
+since there may be more than once instances of the annotation.
+The |beginann| command needs not dimension because |dvipdfm|
+computes the correct bounding box on the fly.
+
+Note: Link breaking is easily fooled at page breaks. If you have problems
+with the header or footer wanting to become part of the link, you can
+insert a |nolink| command at the beginning of the footer and a |link|
+command at the end of the footer.
+
+\subsection{End Annotation}
+\syntax
+{\tt endann}
+\description
+The |endann| (|eann| or |eannot|) terminates a breakable annotation.
+
+\subsection{Link}
+{\tt link}
+\description
+The |link| command instructs the link breaking algorithm to resume its
+operation after a |nolink| command.
+
+\subsection{Nolink}
+{\tt nolink}
+\description
+The |nolink| command instructs the link breaking algorithm to suspend
+it operation. This is only required if there is material inserted
+on the page in the {\it middle} of a link. For example, when a link
+is broken at the end of a page, the header and footer are inserted
+in the middle of the link, but are not part of the link. Material
+that is inserted between a |nolink| and |link| will not become
+part of the link. The |nolink| and |link| escapes are not necessary
+with the standard LaTeX header and footer lines, but may become necessary
+if these are changed.
+
+\subsection{Dest}
+\syntax
+{\tt dest} {\it PDF\_String} {\it PDF\_Dest}
+\description
+The |dest| command defines a named destination.
+The {\it PDF\_String} is a PDF string naming
+the destination. This string may be used in the destination
+fields of annotations and outline entries to refer to
+this destination. {\it PDF\_Dest} is a PDF
+destination object (typically an array).
+\example
+\begintt
+\special{pdf: dest (listofreferences) [ @thispage /FitH @ypos ]}
+\endtt
+
+\subsection{Docinfo}
+\syntax
+{\tt docinfo} {\it PDF\_dictionary}
+\description
+The |docinfo| command adds the keys in the specified dictionary to the
+document's |/Info| dictionary. All keys are optional, but may include
+the keys |/Author|, |/Title|, |/Keywords|, |/Subject|,
+and |/Creator|.
+\example
+\begintt
+\special{pdf: docinfo << /Author (Mark A. Wicks)
+ /Title (This Document) >>}
+\endtt
+
+\subsection{Docview}
+\syntax
+{\tt docview} {\it PDF\_dictionary}
+\description
+The |docview| command adds the keys in the specified dictionary to the
+document's |/Catalog| dictionary. All keys are optional, but may include
+the keys |/PageMode|,
+|/URI|, |/OpenAction|, |/AA|
+and |/ViewerPreferences|. See the PDF Reference Manual
+for documentation of these keys and additional keys.
+\example
+\begintt
+\special{pdf: docview << /PageMode /UseThumbs >> }
+\endtt
+
+
+\subsection{Object}
+\syntax
+{\tt object} [@{\it name}] {\it PDF\_Object}
+\description
+The |object| (also |obj|) command creates a
+PDF object. The parameter {\it PDF\_Object} is any valid PDF object. The
+parameter {\it name} may be used to provide an indirect reference
+to this object within other
+objects. It will be expanded anywhere within
+a {\tt special} where a PDF object is
+expected. Typically {\it object} is an array
+or dictionary. It may be an empty array or
+dictionary that can be constructed dynamically via
+the {\tt put} command.
+\example
+\begintt
+\special{pdf: object @mydict << /Firstpage @thispage >>}
+\endtt
+
+\subsection{Out}
+\syntax
+{\tt out} {\it number} {\it PDF\_dictionary}
+
+\description
+The |out| (also |outline|) command adds an outline (also called a ``bookmark'') entry
+to the document.
+The parameter {\it level\/} is an integer representing the
+level of the outline entry (beginning with 1) and
+{\it PDF\_dictionary\/} must contain
+the two keys {\tt /Title} and either {\tt /Dest} or {\tt /A}.
+It may also contain the {\tt /AA} key. These keys are documented
+in the PDF Reference Manual.
+\example
+\begintt
+out 1 << /Title (Section 1) /Dest [ @thispage /FitH @ypos ] >>
+\endtt
+which may be followed by
+\begintt
+out 2 << /Title (Section 1.1) /Dest [ @thispage /FitH @ypos ] >>
+\endtt
+\note
+You may not skip levels. A level~2 outline entry
+must follow a level~1 outline
+entry. A level~3 outline entry must follow a level~2 outline
+and cannot immediately follow a level 1 outline entry.
+
+\subsection{Pagesize}
+\syntax
+{\tt pagesize} {\it dimension}+
+\description
+The |pagesize| command specifies the document's physical
+paper size. The |pagesize| command must be specified on
+the first page and must precede the first annotation
+or background color specification on the page.
+In other words, it should occur as close to the
+beginning of the document as possible.
+\example
+\begintt
+pagesize width 11.0truein height 8.5truein
+\endtt
+
+\subsection{Put}
+\syntax
+\beginlist
+{\tt put} @{\it name} {\it PDF\_Object}+
+\endlist
+or
+\beginlist
+{\tt put} @{\it name} {\it PDF\_Dictionary}
+\endlist
+\description
+The |put| command modifies an existing PDF object created with |obj|,
+or one of the following internally defined objects: |@catalog|,
+|@names|, |@pages|, |@thispage|, or |@resources|.
+The first form is used when @{\it name} is an array. The second
+form is used when @{\tt name} is a dictionary. More than
+one object may be added to an array at once.
+All keys in {\it PDF\_Dictionary}
+are added to the dictionary represented by @{\it name}.
+\example
+\begintt
+\special{pdf: put @mydict << /Nextpage @thispage >>}
+\endtt
+
+\subsection{Thread}
+\syntax
+{\tt thread} {\tt @}{\it name} {\it dimension}+ [ {\it PDF\_dictionary} ]
+
+\description
+The |thread| (or |art|) command adds a bead to an article.
+An article is a collection of boxed regions in the document that should be
+read consecutively.
+Each bead using the same {\it name} belongs to the same article.
+The {\it name} parameter is required. The {\it dimension} parameter
+defined the rectangular area belonging to the bead in
+the same manner as for |annot|.
+The optional PDF dictionary
+should supplied on one of the beads. Its keys are
+similar to the |/Info| dictionary accessed via the |docinfo| command
+and would typically include the |/Title| and |/Author| keys.
+Keys in the dictionary may be overwritten by subsequent {\tt thread} commands.
+\example
+\begintt
+\special {pdf: thread @somearticle << /Title (Some title)
+ /Author (Me) >>}
+\endtt
+
+\subsection{Close}
+\syntax
+{\tt close} @{\it name}
+\description
+The |close| writes the named PDF object created with |obj| to the PDF file.
+No further |put| commands may be executed for this object.
+The object may continue to be referenced using @{\it name}
+indefinitely. If the object is never closed, it will
+be closed when |dvipdfm| finishes processing the document.
+
+\section{Form XObjects}
+The PDF specification allows an object to be stored once
+and displayed at multiple locations throughout the document.
+The following commands give access to this facility.
+
+\subsection{Beginxobj}
+\syntax
+{\tt beginxobj} @{\it name} {\it dimension}+
+\description
+The |beginxobj| (or |bxobj|) command begins the definition of
+a Form XObject. All material typeset between the
+|beginxobj| and |endxobj| commands will be captured
+into the XObject. The material can be displayed later
+at an arbitrary location with the |usexobj| command.
+The {\it name} may be used to refer to the object later,
+either via the |usexobj| command or as an indirect
+reference to the XObject if {\it name} is
+used within the context of a {\it PDF\_Object}..
+The required {\it dimension} identifies the extent
+(i.e., bounding box) of the area to be captured.
+It is specified in the same way as for |annot|.
+
+The material will not display during the object definition.
+In other words, if you are typsetting with \TeX\ you
+should place the XObject in a box of dimension 0 so
+you don't leave a white space hole where the object was
+defined.
+\example
+\begintt
+bxobj @myform width 2.0in height 24pt
+\endtt
+
+\subsection{Endxobj}
+\syntax
+{\tt endxobj}
+\description
+The |endxobj| (or |exobj|) command ends the previous
+|beginxobj| definition. Note that XObject definitions
+may not be nested. XObjects can be {\it used} within
+other XObjects, however.
+\example
+\begintt
+exobj
+\endtt
+
+\subsection{Usexobj}
+\syntax
+{\tt usexobj} @{\it name}
+\description
+The |usexobj| (or |uxobj|) command displays the
+form XObject previously defined and
+associated with {\it name}.
+\example
+\begintt
+uxobj @myform
+\endtt
+
+\section{Text Transformation Commands}
+The commands in this section deal with transformation
+of arbitrary material, which may include
+material typeset by \TeX. These
+may also be used on included graphics images
+if the commands in Section~8 won't do the job.
+
+\subsection{BeginTransform}
+\syntax
+{\tt begintransform} {\it transformation}+
+
+\description
+The |begintransform| (|btrans| or |bt|) applies
+the specified transformation to all subsequent text.
+The scaling is applied first, followed by the rotation.
+The reference point of a box following
+the |\special| remains fixed. Such transformations
+may be nested to perform rotations within rotated text, for exmaple.
+
+\example
+\begintt
+\special{pdf: bt rotate 90 xscale 2.0 }
+\endtt
+
+\subsection{BeginTransform}
+\syntax
+{\tt endtransform}
+\description
+The |endtransform| (|etrans| or |et|) concludes
+the action of the immediately preceding |begintransform|
+command. All transformations must be closed
+on the same page. The driver will close
+any pending unclosed transformations at the
+end of the page and issue a warning message.
+All material to be transformed
+should probably be enclosed in a single box
+to prevent any break.
+\example
+\begintt
+\special{pdf: et}
+\endtt
+
+
+\section{Color Commands}
+The commands in this section deal with manipulation of the color
+stack.
+
+\subsection{Setcolor}
+\syntax
+{\tt setcolor} {\it PDF\_Number$\vert$\it PDF\_Array}
+\description
+The |setcolor| (|scolor| or |sc|) command uses its
+argument to set the default color for future marking operators.
+The current color is replaced and may be retrieved
+only by a subsequent |setcolor| command. The argument
+may be a single number, which is interpreted as a grayscale
+value; a three element array, which is interpreted as an RGB
+color space coordinate; or a four element array, which
+is interpreted as a CMYK color space coordinate.
+\example
+\begintt
+\special{ pdf: sc [ 1 0 0 ] }
+\endtt
+
+\subsection{Begincolor}
+\syntax
+{\tt begincolor} {\it PDF\_Number$\vert$\it PDF\_Array}
+\description
+The |begincolor| (|bcolor| or |bc|) command uses its
+argument to set the default color for future marking operators.
+The current color is pushed on the color stack. The argument
+may be a single number, which is interpreted as a grayscale
+value; a three element array, which is interpreted as an RGB
+color space coordinate; or a four element array, which
+is interpreted as a CMYK color space coordinate.
+\example
+\begintt
+\special{ pdf: bc [ 1 0 0 ] }
+\endtt
+
+\subsection{Endcolor}
+\syntax
+{\tt endcolor}
+\description
+The |endcolor| (|ecolor| or |ec|)
+changes the default color to
+match the color on the top
+of the stack. It removes
+the color from the stack.
+\example
+\begintt
+\special{ pdf: ec }
+\endtt
+
+\subsection{Bgcolor}
+\syntax
+{\tt bgcolor} {\it PDF\_Number$\vert$\it PDF\_Array}
+\description
+The |bgcolor| (|bbc| or |bgc|) command uses the value
+of its argument to set the default color for the page
+background. The interpretation
+fo the argument is the same as for the |begincolor| command.
+The stack is not involved here. There is no way
+to go back to the previous background color.
+\example
+\begintt
+\special{ pdf: bc [ 1 0 0 ] }
+\endtt
+
+\section{Image Commands}
+The commands in this section deal with embedding
+graphics into your PDF document. The present
+driver supports PDF, PNG, and JPEG graphics inclusion.
+
+\subsection{Epdf}
+\syntax
+{\tt epdf} [|@|{\it name}] [{\it dimension}$\vert${\it transformation}]* {\it PDF\_String}
+
+\description
+The {\tt epdf} command ``encapsulates'' the first page of a PDF
+file named by {\it PDF\_String}
+into a PDF XObject. The resulting XObject is drawn
+with the lower left corner at the current location of the page.
+The optional @{\it name} parameter may be used
+to reference this object within other objects. If a
+{\it dimension} is supplied, the object will be scaled to fit
+that dimension. A {\it transformation} consists of one of the keywords
+|scale|, |xscale|, |yscale|, or |rotate|
+followed by a number representing
+the scaling factor or rotation angle in degrees. Both {\it transformation} and {\it dimension}
+parameters can be supplied as long as they are not logically
+inconsistent.
+
+Note: The object is stored as an XObject and can be redisplayed later by using the
+|usexobj| function and specifying {\it name}.
+
+\example
+\begintt
+\special{pdf:epdf yscale 0.50 width 4.0in
+ rotate 45 (circuit.pdf)}
+\endtt
+
+\subsection{Image}
+\syntax
+{\tt image} [@{\it name}] [{\it dimension} $\vert$ {\it transformation}]* {\it PDF\_String}
+
+\description
+The {\tt image} command ``encapsulates'' an image
+taken from the file named by {\it PDF\_String}.
+This command functions just like |epdf|. Value
+image types may be PDF, JPEG, or PNG images.
+This special will eventually replace the |epdf| special.
+
+Note: The object is stored as an XObject and can be redisplayed later by using the
+|usexobj| function and specifying {\it name}.
+
+\section{Raw Page Marking Commands}
+The commands in this section deal with embedding
+raw PDF graphics operators into your PDF document.
+
+\subsection{Bop}
+\syntax
+{\tt bop} {\it stream}
+\description
+The |bop| command specifies a marking
+stream to be generated at the top of each page.
+The parameter {\it stream} is any sequence
+of marking operators and is added to the page's content stream.
+The stream is applied {\it to all pages} regardless
+of where it appears in the document.
+\example The two horizontal lines appearing
+at the top of each page in this document
+were set with
+\begintt
+\special {pdf: bop q 0 w 0.8 0.5 0 RG
+ 54 740 m 504 740 l 504 740.25 l 54 740.25 l b
+ 36 760 m 504 760 l 504 760.25 l 36 760.25 l b Q }
+\endtt
+\special {pdf: bop q 0 w 0.8 0.5 0 RG
+ 54 740 m 504 740 l 504 740.25 l 54 740.25 l b
+ 36 760 m 504 760 l 504 760.25 l 36 760.25 l b Q }
+
+\subsection{Content}
+\syntax
+{\tt content} {\it stream}
+\description
+The |content| command specifies a marking
+stream to be added to the current page at
+the current location. While it
+is possible to change the color
+state, etc., with this command, it is
+not advised. Use the color management
+commands to change colors.
+
+
+\subsection{Eop}
+\syntax
+\beginlist
+{\tt eop} {\it stream}
+\endlist
+\description
+The {\tt eop} specifies a marking stream to be generated at the end
+of each page. The parameter {\it stream} is any sequence
+of marking operators and is added to the page's content stream.
+The stream is applied {\it to all pages} regardless
+of where it appears in the document.
+
+\section{Graphics Examples}
+
+The examples in this section illustrate some of the transformation
+and image inclusion capabilities of \dvipdfm.
+
+\dest{textxform}
+\subsection{Text Transformation}
+Tables with slanted entries are possible as shown
+in \link{Table~3}{rotatedtable}. This table was achieved using
+various ``|bt rotate 35|'' commands.
+
+The following line of text was done with nested
+combinations of ``|bt rotate 10|'' and ``|bt rotate -10|''.
+
+\def\up#1{\special{pdf:bt rotate 10}\hbox{#1}}
+\def\down#1{\special{pdf:bt rotate -10}\hbox{#1}}
+You \down{can} nest \down{the} \up{text}
+trans\up{form}ation \up{capa}\down{bili}ties \down{to}
+achieve \down{effects} \down{like}
+{this}.
+\special{pdf:et}\special{pdf:et}\special{pdf:et}\special{pdf:et}
+\special{pdf:et}\special{pdf:et}\special{pdf:et}\special{pdf:et}
+\special{pdf:et}
+\vskip 0.5in
+
+
+\def\rvr{\colored{\red}{\vrule}}\def\entry#1{\special{pdf:bt rotate 35}%
+{\vbox to 0pt{\vss\hbox{\quad\colored{\blue}{#1}\quad}\vskip 1pt\colored{\red}{\hrule}}\special{pdf:et}}}
+\topinsert
+\dest{rotatedtable}
+\bigskip
+\centerline{\colored{\blue}{\subheadingfont Table 3---Example of rotated
+text set in Computer Modern Roman}}
+\bigskip
+\centerline{\vbox to 0.45in{\vss\offinterlineskip\halign{#&#&#&#&#&#\cr
+\entry{1994}&
+\entry{1995}&
+\entry{1996}&
+\entry{1997}&
+\entry{1998}&
+\entry{1999}\cr
+\noalign{\colored{\red}{\hrule}}
+\strut\rvr&\rvr&\rvr&\rvr&\rvr&\rvr\crcr}}}
+\bigskip
+\endinsert
+
+\dest{imageinclude}
+\subsection{Image Inclusion}
+
+The image in \link{Figure~1}{jpegimage} was included from a JPEG file.
+The image shown in \link{Figure~2}{rotatedimage} comes from the same file,
+but is loaded at a 50\% scale and a 45$^\circ$ rotation.
+
+\topinsert
+\dest{jpegimage}
+\bigskip
+\centerline{\reserve{1.50in}{2.05in}{pdf: image (mwicks.jpeg)}}
+\medskip
+\centerline{\subheadingfont
+\begincolor{\blue}Figure~1---A JPEG image of the author.\endcolor}
+\bigskip
+\endinsert
+
+\topinsert
+\dest{rotatedimage}
+\bigskip
+\centerline{\reserve{0.75in}{1.25in}{pdf: image rotate 45 scale 0.50 (mwicks.jpeg)}}
+\medskip
+\centerline{\subheadingfont
+\begincolor{\blue}Figure~2---Image of the author scaled by 0.5 and rotated
+by 45$^\circ$.%
+\endcolor}
+\bigskip
+\endinsert
+
+By default, JPEG files are included
+at a resolution of 100dpi so if you know the pixel size
+of the image, you know how much space to reserve.
+Any \TeX\ magnification is applied to the image
+in addition to any scaling defined in the |\special|.
+For example, this document sets |\magnification=\magstephalf|,
+so the images are actually scaled by 1.095. The first
+image in this section has a printed width of 1.643in
+even though 1.50in was specified in the |\special|.
+
+Several command line utilities exist that read
+the pixel dimensions of a JPEG file. For PDF files,
+you can |grep| on |/MediaBox| to get an indication
+of the image size. The |/MediaBox| dimensions are
+in PDF points.
+
+The image in \link{Figure~3}{pdfimage} was produced by embedding a PDF file
+using |epdf|.
+
+\topinsert
+\dest{pdfimage}
+\centerline{\reserve{2.41in}{2.6in}{pdf: epdf width 2.41in (transistor.pdf)}}
+\medskip\centerline{\subheadingfont
+\begincolor{\blue}Figure~3---An embedded PDF object.
+\endcolor}
+\endinsert
+Notice that any resources required for the object
+are also embedded. In this case, the Times Roman font
+resource was embedded along with the content stream.
+
+\dest{thumbnails}\section{Thumbnails}
+Thumbnails can be inserted automatically by |dvipdfm|
+using the |-t| command line option. However, |dvipdfm|
+is unable to generate the thumbnails by itself. This
+must be done by some other program such as GhostScript.
+The typical two-pass process to include thumbnails would be
+\item{1.}
+Run |dvipdfm| without the |-t| option (probably
+using command line options optimized for speed and not space)
+\item{2.}
+Run GhostScript to generate the thumbnail images of
+each page.
+\item{3.}
+Run |dvipdfm| with the |-t| or |-dt| option.
+
+The |dvipdfm| distribution includes a sample
+shell script called |dvipdft| which is a wrapper
+for |dvipdfm| that generates thumbnails.
+
+|Dvipdfm| searches for the thumbnail images
+in the directory specified by the TMP or TEMP
+environment variables, or in the current directory.
+The thumbnails must have the same base name as the PDF output
+file with an extension indicating the number of the page.
+For example, to create a thumbnailed document named |foo.pdf|
+you would need to generate thumbnail images in files named
+|foo.1|, |foo.2|, etc.
+
+\dest{fontmap}\section{Font Mapping}
+\TeX\ font names can be
+mapped into arbitrary physical (PostScript) font names via
+the map file named |t1fonts.map|. The file is
+similar to the |psfonts.map| file used by |dvips|
+and other drivers. Each line in the
+file consists of one to three fields delimited
+by white space, followed by options that apply to that font.
+The complete list of recognized options
+appears in \link{Table~4}{options}.
+
+Sample map file lines are\nobreak
+\begintt
+cmr10 ot1 -r
+ptmro8r 8r Times-Roman -s 0.167
+pncbo8r 8r pncb8a -s 0.167
+\endtt
+
+The first field of each line
+is the \TeX\ font name. The second
+field, which is optional, is the encoding name (|.enc| will
+be appended to this name, if necessary
+to locate an encoding file). The
+encoding files have the same format
+as those used for |dvips|.
+The third optional field is {\it either} the PostScript font
+name (if one of the standard PostScript fonts) {\it or}
+the file name of a Type~1 binary font file (PFB file).
+The {}.pfb extension is assumed by the program.
+three fields. If the encoding field is unspecified,
+|dvipdfm| used the default encoding supplied with
+the Type~1 font. If the name field is unspecified,
+|dvipdfm| looks for a Type~1 binary font file
+having the same name as the \TeX\ font name.
+If there is {\it no} line in the map file,
+the behavior is as if a line was specified
+without the second or third field.
+The keywords |default| or |none| are
+recognized in the encoding field so that
+a third field may be specified while still
+having default behavior in the second field.
+
+Currently, three options may be specified for each font
+as shown in \link{Table~4}{options}.
+\topinsert
+{\dest{options}}
+\centerline{\colored{\blue}{\subheadingfont Table~4---Font options
+recognized by |dvipdfm| in the font map file}}
+\bigskip\nobreak
+\centerline{\vbox{\halign{{\tt #}\hskip
+1em\strut&\vtop{\leftskip0pt\rightskip0pt\hsize=3.5in\noindent #}\cr
+\omit\hfil\it Option\hfil&\omit\hfil \it Description \hfil\cr
+\noalign{\smallskip\begincolor\red\hrule\endcolor\smallskip}
+-r&{\it Remap the font to eliminate control characters.} This
+option attempts to work around bugs in Acrobat reader that seem
+to be triggered by characters that are encoded in certain positions.
+Unfortunately, standard \TeX encodings normally use these positions.\cr
+\noalign{\smallskip}
+-e {\it number}&{\it Extend the font horizontally, multiplying the natural
+width of the font by the specified number.} This is useful
+for generating new fonts by widening existing fonts.\cr
+\noalign{\smallskip}
+-s {\it number}&{\it Slant the font using the specified number}.
+This option is useful for building a slanted fonts from a font
+for which there is no slanted font.\cr}}}
+\endinsert
+
+\section{Configuration file}
+{\dest{configuration}}Dvipdfm reads default command line options, such
+as paper size, from a configuration
+file contained in the |dvipdfm| directory of the TeX tree.
+The format of this file is similar to the |dvips| file configuration
+file format. Each line consists of a single command line switch
+followed by any arguments. See the configuration file supplied
+with the |dvipdfm| distribution for examples.
+
+\section{Including PostScript graphics images}
+{\dest{postscript}}Dvipdfm provides support for illustrations
+contained in external PostScript files.
+It recognizes two distinct kinds of PostScript files---those
+created by MetaPost and everything else.
+
+MetaPost
+files output only a subset of PostScript and
+are interpreted {\it natively} by |dvipdfm|
+with its own internal minimal PostScript interpreter.
+Also, MetaPost output files contain \TeX\ font information in their header
+comments, so that they can be easily integrated with \TeX\ by DVI
+drivers. Dvipdfm recognizes this font information and uses the \TeX\
+fonts defined in the MetaPost header.
+
+
+All other PostScript files require an external
+program to convert the image to PDF format before
+|dvipdfm| can include the image.
+The freely available GhostScript is capabable of performing this conversion
+for most images.
+
+The user must specify the command line required
+to invoke an external program to perform this conversion.
+The command line required to invoke the conversion
+program is specified using the |-D| command
+line (or configuration file) option. The string passed to the |-D| command
+line option is a C-style string that is parsed by |dvipdfm|. Within the string,
+expansions are performed as described in \link{Table~5}{expansion}.
+For example, to use GhostScript, one might use the
+command line
+
+\bigskip
+
+{\tt -D "cat \%i \vrule\ gs -q -sDEVICE=pdfwrite -sOutputFile=\%o - -c quit" }
+
+
+\topinsert
+{\dest{expansion}}
+\centerline{\colored{\blue}{\subheadingfont Table~5---Expansions
+performed in the -D string.}}
+\bigskip\nobreak
+\centerline{\vbox{\halign{{\hfil\tt #\hfil}\hskip
+1em\strut&\vtop{\leftskip0pt\rightskip0pt\hsize=3.5in\noindent #}\cr
+\omit\hfil\it Variable\hfil&\omit\hfil \it Description \hfil\cr
+\noalign{\smallskip\begincolor\red\hrule\endcolor\smallskip}
+\%i&{\it Expanded to the full path of the EPS file to be included}\cr
+\noalign{\smallskip}
+\%o&{\it Expanded to the full path name of the PDF file to be
+generated}. The command line must be able to create a file
+with the name supplied by dvipdfm.\cr
+\noalign{\smallskip}
+\%b&{\it Expanded to the ``basename'' of the EPS file that is being included.}
+The ``basename'' is the full path of the EPS file with the
+last ``.'' and any trailing name extension removed.\cr
+}}}
+\endinsert
+
+\section{Compatibility with other DVI drivers}
+Compatibility with other DVI drivers is achieved
+by support for the following ``standard'' special calls.
+Many legacy DVI files can be processed by |dvipdfm|,
+so long as they use fairly standard special commands.
+For example, |dvipdfm| can process DVI files generated
+that use the
+|\color|, |\rotatebox|, and |\includegraphics| macros
+from the standard La\TeX\ Graphics bundle even if |dvips| was the target DVI driver,
+e.g.,
+
+\begintt
+\usepackage[dvips]{graphics}
+\usepackage[dvips]{color}
+\endtt
+
+Specifically, |dvipdfm| understands the following standard special commands:
+
+\beginlist
+\item{$\bullet$} The TPIC specials.
+
+\item{$\bullet$} The HyperTeX (HTML) hyperlink specials.
+
+\item{$\bullet$} The ``color'' specials supported by |dvips| and
+other drivers.
+
+\item{$\bullet$} The ``PSfile'' and ``plotfile'' specials for PS/EPS file inclusion
+supported by |dvips| and other drivers. Dvipdfm uses a user-specified
+external program to convert the PostScript file to PDF format
+before including it.
+
+\item{$\bullet$} The raw PostScript ``ps:'' special supported by |dvips| and
+other drivers. Only a few PostScript operators are supported;
+|dvipdfm| does not include a complete PostScript interpreter.
+Complex PostScript code, such as that embedded by the PSTricks
+package, is not supported.
+\endlist
+
+\section{LaTeX Support and Ebb}
+Support for the La\TeX\ graphics bundle and |hyperref|
+are available. A driver file named |dvipdfm.def|
+is distributed with the standard La\TeX
+graphics bundle. The latest version
+of the |dvipdfm.def| file is supplied
+with the |dvipdfm| distribution.
+The file required for |hyperref|
+support is called |hdvipdfm.def|.
+
+To facilitate La\TeX\ support, I distribute a companion program
+called |ebb|, which extracts bounding boxes from graphics files. If
+you want to include JPEG, PNG, or PDF files in your document, you can run
+|ebb| on the JPEG, PNG, or PDF file to create the |.bb| files.
+The bounding box file will be similarly named with an extension of |.bb|.
+For DOS 8+3 compatibility, an original file name extension
+of |.jpg|, |.png|, or |.pdf| is removed before creating the name of
+the |.bb| file. An extension of |.jpeg| is also recognized and similarly removed.
+
+\newpage
+\section{References}
+\tolerance=1000\hbadness=1000
+\bibitem\dest{pdfmanual}{\it Portable Document
+Format Reference Manual}, Version 1.2, Adobe Systems Incorporated, 1996.
+Available at the following URL: {\tt http://www.adobe.com}.
+
+\bibitem\dest{pdfprimer}Thomas Merz,
+{\it Web Publishing with Acrobat/PDF},
+Springer-Verlag, 1997, ISBN 3-540-63762-1. Chapter~6 of this book is available
+at the URL: |http://http://www.ifconnection.de/~tm|.
+
+\bibitem\dest{acrotex}D. P. Story, {\it AcroTeX}, The AcroTeX home page
+is located at the URL: |http://www.math.uakron.edu/~dpstory/acrotex.html|.
+
+\bye
diff --git a/Build/source/texk/dvipdfm/doc/mwicks.bb b/Build/source/texk/dvipdfm/doc/mwicks.bb
new file mode 100644
index 00000000000..b02ebbd4b84
--- /dev/null
+++ b/Build/source/texk/dvipdfm/doc/mwicks.bb
@@ -0,0 +1,5 @@
+%%Title: ./mwicks.jpeg
+%%Creator: ebb Version 0.5.2
+%%BoundingBox: 0 0 108 148
+%%CreationDate: Thu Oct 19 15:55:34 2000
+
diff --git a/Build/source/texk/dvipdfm/doc/mwicks.jpeg b/Build/source/texk/dvipdfm/doc/mwicks.jpeg
new file mode 100644
index 00000000000..5312aab5fc4
--- /dev/null
+++ b/Build/source/texk/dvipdfm/doc/mwicks.jpeg
Binary files differ
diff --git a/Build/source/texk/dvipdfm/doc/transistor.bb b/Build/source/texk/dvipdfm/doc/transistor.bb
new file mode 100644
index 00000000000..432d4debfeb
--- /dev/null
+++ b/Build/source/texk/dvipdfm/doc/transistor.bb
@@ -0,0 +1,5 @@
+%%Title: ./transistor.pdf
+%%Creator: ebb Version 0.5.2
+%%BoundingBox: 0 0 174 197
+%%CreationDate: Thu Oct 19 15:55:18 2000
+
diff --git a/Build/source/texk/dvipdfm/doc/transistor.eps b/Build/source/texk/dvipdfm/doc/transistor.eps
new file mode 100644
index 00000000000..0398ac9e286
--- /dev/null
+++ b/Build/source/texk/dvipdfm/doc/transistor.eps
@@ -0,0 +1,316 @@
+%!PS-Adobe-2.0 EPSF-2.0
+%%Title: transistor.eps
+%%Creator: fig2dev Version 3.2 Patchlevel 0-beta3
+%%CreationDate: Thu Nov 19 14:25:40 1998
+%%For: mwicks@odo.kettering.edu (Mark A. Wicks,2-943,(810) 762-7992,(810) 655-4682,)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 174 197
+%%Pages: 0
+%%BeginSetup
+%%EndSetup
+%%Magnification: 0.5000
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {0 setgray} bind def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-56.0 205.0 translate
+1 -1 scale
+
+/cp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/sa {save} bind def
+/rs {restore} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/rm {rmoveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/sh {show} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/sd {setdash} bind def
+/ff {findfont} bind def
+/sf {setfont} bind def
+/scf {scalefont} bind def
+/sw {stringwidth} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+/reencdict 12 dict def /ReEncode { reencdict begin
+/newcodesandnames exch def /newfontname exch def /basefontname exch def
+/basefontdict basefontname findfont def /newfont basefontdict maxlength dict def
+basefontdict { exch dup /FID ne { dup /Encoding eq
+{ exch dup length array copy newfont 3 1 roll put }
+{ exch newfont 3 1 roll put } ifelse } { pop pop } ifelse } forall
+newfont /FontName newfontname put newcodesandnames aload pop
+128 1 255 { newfont /Encoding get exch /.notdef put } for
+newcodesandnames length 2 idiv { newfont /Encoding get 3 1 roll put } repeat
+newfontname newfont definefont pop end } def
+/isovec [
+8#200 /grave 8#201 /acute 8#202 /circumflex 8#203 /tilde
+8#204 /macron 8#205 /breve 8#206 /dotaccent 8#207 /dieresis
+8#210 /ring 8#211 /cedilla 8#212 /hungarumlaut 8#213 /ogonek 8#214 /caron
+8#220 /dotlessi 8#230 /oe 8#231 /OE
+8#240 /space 8#241 /exclamdown 8#242 /cent 8#243 /sterling
+8#244 /currency 8#245 /yen 8#246 /brokenbar 8#247 /section 8#250 /dieresis
+8#251 /copyright 8#252 /ordfeminine 8#253 /guillemotleft 8#254 /logicalnot
+8#255 /endash 8#256 /registered 8#257 /macron 8#260 /degree 8#261 /plusminus
+8#262 /twosuperior 8#263 /threesuperior 8#264 /acute 8#265 /mu 8#266 /paragraph
+8#267 /periodcentered 8#270 /cedilla 8#271 /onesuperior 8#272 /ordmasculine
+8#273 /guillemotright 8#274 /onequarter 8#275 /onehalf
+8#276 /threequarters 8#277 /questiondown 8#300 /Agrave 8#301 /Aacute
+8#302 /Acircumflex 8#303 /Atilde 8#304 /Adieresis 8#305 /Aring
+8#306 /AE 8#307 /Ccedilla 8#310 /Egrave 8#311 /Eacute
+8#312 /Ecircumflex 8#313 /Edieresis 8#314 /Igrave 8#315 /Iacute
+8#316 /Icircumflex 8#317 /Idieresis 8#320 /Eth 8#321 /Ntilde 8#322 /Ograve
+8#323 /Oacute 8#324 /Ocircumflex 8#325 /Otilde 8#326 /Odieresis 8#327 /multiply
+8#330 /Oslash 8#331 /Ugrave 8#332 /Uacute 8#333 /Ucircumflex
+8#334 /Udieresis 8#335 /Yacute 8#336 /Thorn 8#337 /germandbls 8#340 /agrave
+8#341 /aacute 8#342 /acircumflex 8#343 /atilde 8#344 /adieresis 8#345 /aring
+8#346 /ae 8#347 /ccedilla 8#350 /egrave 8#351 /eacute
+8#352 /ecircumflex 8#353 /edieresis 8#354 /igrave 8#355 /iacute
+8#356 /icircumflex 8#357 /idieresis 8#360 /eth 8#361 /ntilde 8#362 /ograve
+8#363 /oacute 8#364 /ocircumflex 8#365 /otilde 8#366 /odieresis 8#367 /divide
+8#370 /oslash 8#371 /ugrave 8#372 /uacute 8#373 /ucircumflex
+8#374 /udieresis 8#375 /yacute 8#376 /thorn 8#377 /ydieresis] def
+/Times-Roman /Times-Roman-iso isovec ReEncode
+ /DrawEllipse {
+ /endangle exch def
+ /startangle exch def
+ /yrad exch def
+ /xrad exch def
+ /y exch def
+ /x exch def
+ /savematrix mtrx currentmatrix def
+ x y tr xrad yrad sc 0 0 1 startangle endangle arc
+ closepath
+ savematrix setmatrix
+ } def
+
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+%%EndProlog
+
+$F2psBegin
+10 setmiterlimit
+n -1000 7825 m -1000 -1000 l 8665 -1000 l 8665 7825 l cp clip
+ 0.03000 0.03000 sc
+% Polyline
+45.000 slw
+n 6300 2700 m 6300 3300 l gs col-1 s gr
+% Polyline
+30.000 slw
+n 6300 2850 m 6600 2700 l gs col-1 s gr
+% Polyline
+gs clippath
+6520 3233 m 6563 3279 l 6500 3273 l 6642 3343 l 6662 3303 l cp
+clip
+n 6300 3150 m 6612 3303 l gs col-1 s gr gr
+
+% arrowhead
+n 6520 3233 m 6563 3279 l 6500 3273 l 6510 3253 l 6520 3233 l cp gs 0.00 setgray ef gr col-1 s
+% Polyline
+45.000 slw
+n 4500 3525 m 4500 4125 l gs col-1 s gr
+% Polyline
+30.000 slw
+n 4500 3675 m 4800 3525 l gs col-1 s gr
+% Polyline
+gs clippath
+4720 4058 m 4763 4104 l 4700 4098 l 4842 4168 l 4862 4128 l cp
+clip
+n 4500 3975 m 4812 4128 l gs col-1 s gr gr
+
+% arrowhead
+n 4720 4058 m 4763 4104 l 4700 4098 l 4710 4078 l 4720 4058 l cp gs 0.00 setgray ef gr col-1 s
+15.000 slw
+% Ellipse
+n 2025 3825 75 75 0 360 DrawEllipse gs col0 s gr
+
+% Ellipse
+n 7575 3900 75 75 0 360 DrawEllipse gs col0 s gr
+
+% Polyline
+n 4800 2550 m 4800 3525 l gs col-1 s gr
+% Polyline
+30.000 slw
+n 4800 1950 m 4916 1995 l 4674 2120 l 4918 2246 l 4672 2368 l 4916 2492 l
+ 4798 2546 l gs col-1 s gr
+% Polyline
+15.000 slw
+gs clippath
+2940 942 m 3000 654 l 3060 942 l 3060 570 l 2940 570 l cp
+clip
+n 3000 1950 m 3000 600 l gs col0 s gr gr
+
+% arrowhead
+n 2940 942 m 3000 654 l 3060 942 l 3000 894 l 2940 942 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+30.000 slw
+n 3002 1954 m 3118 1999 l 2876 2124 l 3120 2250 l 2874 2372 l 3118 2496 l
+ 3000 2550 l gs col-1 s gr
+% Polyline
+15.000 slw
+gs clippath
+4740 942 m 4800 654 l 4860 942 l 4860 570 l 4740 570 l cp
+clip
+n 4800 1950 m 4800 600 l gs col-1 s gr gr
+
+% arrowhead
+n 4740 942 m 4800 654 l 4860 942 l 4800 894 l 4740 942 l cp gs 0.00 setgray ef gr col-1 s
+% Polyline
+n 4800 3000 m 6300 3000 l gs col0 s gr
+% Polyline
+n 3000 2550 m 3000 4800 l gs col-1 s gr
+% Polyline
+n 6600 3300 m 6600 4800 l gs col0 s gr
+% Polyline
+n 4800 4125 m 4800 4800 l gs col0 s gr
+% Polyline
+30.000 slw
+n 4800 4800 m 4916 4845 l 4674 4970 l 4918 5096 l 4672 5218 l 4916 5342 l
+ 4798 5396 l gs col-1 s gr
+% Polyline
+15.000 slw
+gs clippath
+4860 5958 m 4800 6246 l 4740 5958 l 4740 6330 l 4860 6330 l cp
+clip
+n 4800 5400 m 4800 6300 l gs col0 s gr gr
+
+% arrowhead
+n 4860 5958 m 4800 6246 l 4740 5958 l 4800 6006 l 4860 5958 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+30.000 slw
+n 3001 4806 m 3117 4851 l 2875 4976 l 3119 5102 l 2873 5224 l 3117 5348 l
+ 2999 5402 l gs col-1 s gr
+% Polyline
+15.000 slw
+gs clippath
+3060 5958 m 3000 6246 l 2940 5958 l 2940 6330 l 3060 6330 l cp
+clip
+n 3000 5400 m 3000 6300 l gs col0 s gr gr
+
+% arrowhead
+n 3060 5958 m 3000 6246 l 2940 5958 l 3000 6006 l 3060 5958 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+n 2100 3825 m 4500 3825 l gs col-1 s gr
+% Polyline
+30.000 slw
+n 6600 4800 m 6716 4845 l 6474 4970 l 6718 5096 l 6472 5218 l 6716 5342 l
+ 6598 5396 l gs col-1 s gr
+% Polyline
+15.000 slw
+gs clippath
+6660 5958 m 6600 6246 l 6540 5958 l 6540 6330 l 6660 6330 l cp
+clip
+n 6600 5400 m 6600 6300 l gs col0 s gr gr
+
+% arrowhead
+n 6660 5958 m 6600 6246 l 6540 5958 l 6600 6006 l 6660 5958 l cp gs 0.00 setgray ef gr col0 s
+% Polyline
+n 6600 3900 m 7500 3900 l gs col0 s gr
+% Polyline
+gs clippath
+6540 942 m 6600 654 l 6660 942 l 6660 570 l 6540 570 l cp
+clip
+n 6600 2700 m 6600 600 l gs col0 s gr gr
+
+% arrowhead
+n 6540 942 m 6600 654 l 6660 942 l 6600 894 l 6540 942 l cp gs 0.00 setgray ef gr col0 s
+/Times-Roman-iso ff 360.00 scf sf
+1875 3525 m
+gs 1 -1 sc (v) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+2280 2100 m
+gs 1 -1 sc (R) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+4155 2100 m
+gs 1 -1 sc (R) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+2550 2250 m
+gs 1 -1 sc (a) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+2025 3675 m
+gs 1 -1 sc (i) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+4350 525 m
+gs 1 -1 sc (12 V) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+4500 6825 m
+gs 1 -1 sc (-12 V) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+7275 3525 m
+gs 1 -1 sc (v) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+4155 5250 m
+gs 1 -1 sc (R) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+2280 5250 m
+gs 1 -1 sc (R) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+5880 5250 m
+gs 1 -1 sc (R) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+2550 5475 m
+gs 1 -1 sc (b) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+6150 5475 m
+gs 1 -1 sc (x) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+7425 3675 m
+gs 1 -1 sc (o) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+4425 2250 m
+gs 1 -1 sc (c) col0 sh gr
+/Times-Roman-iso ff 360.00 scf sf
+4425 5475 m
+gs 1 -1 sc (e) col0 sh gr
+$F2psEnd
+rs
diff --git a/Build/source/texk/dvipdfm/doc/transistor.fig b/Build/source/texk/dvipdfm/doc/transistor.fig
new file mode 100644
index 00000000000..6a11da3d022
--- /dev/null
+++ b/Build/source/texk/dvipdfm/doc/transistor.fig
@@ -0,0 +1,94 @@
+#FIG 3.2
+Portrait
+Center
+Inches
+Letter
+50.00
+Single
+-2
+1200 2
+6 1875 225 7725 6825
+6 6225 2625 6675 3375
+2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
+ 6300 2700 6300 3300
+2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
+ 6300 2850 6600 2700
+2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 3.00 45.00 60.00
+ 6300 3150 6612 3303
+-6
+6 4425 3450 4875 4200
+2 1 0 4 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
+ 4500 3525 4500 4125
+2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
+ 4500 3675 4800 3525
+2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 1 1 3.00 45.00 60.00
+ 4500 3975 4812 4128
+-6
+1 4 0 2 0 0 0 0 -1 0.000 1 0.0000 2025 3825 75 75 1950 3825 2100 3825
+1 4 0 2 0 0 0 0 -1 0.000 1 0.0000 7575 3900 75 75 7500 3900 7650 3900
+2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
+ 4800 2550 4800 3525
+2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 7
+ 4800 1950 4916 1995 4674 2120 4918 2246 4672 2368 4916 2492
+ 4798 2546
+2 1 0 2 0 7 0 0 -1 6.000 0 0 -1 1 0 2
+ 2 1 2.00 120.00 240.00
+ 3000 1950 3000 600
+2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 7
+ 3002 1954 3118 1999 2876 2124 3120 2250 2874 2372 3118 2496
+ 3000 2550
+2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 2 1 2.00 120.00 240.00
+ 4800 1950 4800 600
+2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2
+ 4800 3000 6300 3000
+2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
+ 3000 2550 3000 4800
+2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2
+ 6600 3300 6600 4800
+2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2
+ 4800 4125 4800 4800
+2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 7
+ 4800 4800 4916 4845 4674 4970 4918 5096 4672 5218 4916 5342
+ 4798 5396
+2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 2 1 2.00 120.00 240.00
+ 4800 5400 4800 6300
+2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 7
+ 3001 4806 3117 4851 2875 4976 3119 5102 2873 5224 3117 5348
+ 2999 5402
+2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 2 1 2.00 120.00 240.00
+ 3000 5400 3000 6300
+2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 2
+ 2100 3825 4500 3825
+2 1 0 3 -1 7 0 0 -1 0.000 0 0 -1 0 0 7
+ 6600 4800 6716 4845 6474 4970 6718 5096 6472 5218 6716 5342
+ 6598 5396
+2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 2 1 2.00 120.00 240.00
+ 6600 5400 6600 6300
+2 1 0 2 0 7 0 0 -1 6.000 0 0 -1 0 0 2
+ 6600 3900 7500 3900
+2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 2 1 2.00 120.00 240.00
+ 6600 2700 6600 600
+4 0 0 0 0 0 24 0.0000 4 180 165 1875 3525 v\001
+4 0 0 0 0 0 24 0.0000 4 255 240 2280 2100 R\001
+4 0 0 0 0 0 24 0.0000 4 255 240 4155 2100 R\001
+4 0 0 0 0 0 24 0.0000 4 180 165 2550 2250 a\001
+4 0 0 0 0 0 24 0.0000 4 255 90 2025 3675 i\001
+4 0 0 0 0 0 24 0.0000 4 255 705 4350 525 12 V\001
+4 0 0 0 0 0 24 0.0000 4 255 915 4500 6825 -12 V\001
+4 0 0 0 0 0 24 0.0000 4 180 165 7275 3525 v\001
+4 0 0 0 0 0 24 0.0000 4 255 240 4155 5250 R\001
+4 0 0 0 0 0 24 0.0000 4 255 240 2280 5250 R\001
+4 0 0 0 0 0 24 0.0000 4 255 240 5880 5250 R\001
+4 0 0 0 0 0 24 0.0000 4 255 180 2550 5475 b\001
+4 0 0 0 0 0 24 0.0000 4 180 195 6150 5475 x\001
+4 0 0 0 0 0 24 0.0000 4 180 180 7425 3675 o\001
+4 0 0 0 0 0 24 0.0000 4 180 165 4425 2250 c\001
+4 0 0 0 0 0 24 0.0000 4 180 165 4425 5475 e\001
+-6
diff --git a/Build/source/texk/dvipdfm/doc/transistor.pdf b/Build/source/texk/dvipdfm/doc/transistor.pdf
new file mode 100644
index 00000000000..c155b964637
--- /dev/null
+++ b/Build/source/texk/dvipdfm/doc/transistor.pdf
@@ -0,0 +1,473 @@
+%PDF-1.2
+%Çì¢
+4 0 obj
+<</Length 5 0 R>>
+stream
+0.1 0 0 0.1 0 0 cm
+q
+1 i
+13.5 w
+1330 1240 m
+1330 1060 l
+S
+9 w
+1330 1195 m
+1420 1240 l
+S
+Q
+q
+W
+0 0 m
+0 1970 l
+1740 1970 l
+1740 0 l
+h
+1396 1080.1 m
+1408.9 1066.3 l
+1390 1068.1 l
+1432.6 1047.1 l
+1438.6 1059.1 l
+h
+n
+1 i
+9 w
+1330 1105 m
+1423.6 1059.1 l
+S
+Q
+q
+1 i
+1396 1080.1 m
+1408.9 1066.3 l
+1390 1068.1 l
+1393 1074.1 l
+1396 1080.1 l
+f*
+9 w
+1396 1080.1 m
+1408.9 1066.3 l
+1390 1068.1 l
+1393 1074.1 l
+1396 1080.1 l
+h
+S
+13.5 w
+790 992.5 m
+790 812.5 l
+S
+9 w
+790 947.5 m
+880 992.5 l
+S
+Q
+q
+W
+0 0 m
+0 1970 l
+1740 1970 l
+1740 0 l
+h
+856 832.6 m
+868.9 818.8 l
+850 820.6 l
+892.6 799.6 l
+898.6 811.6 l
+h
+n
+1 i
+9 w
+790 857.5 m
+883.6 811.6 l
+S
+Q
+q
+1 i
+856 832.6 m
+868.9 818.8 l
+850 820.6 l
+853 826.6 l
+856 832.6 l
+f*
+9 w
+856 832.6 m
+868.9 818.8 l
+850 820.6 l
+853 826.6 l
+856 832.6 l
+h
+S
+4.5 w
+69.9995 902.5 m
+69.9995 890.074 59.926 880 47.4998 880 c
+35.0735 880 25 890.074 25 902.5 c
+25 914.926 35.0735 925 47.4998 925 c
+59.926 925 69.9995 914.926 69.9995 902.5 c
+h
+S
+1735 880 m
+1735 867.574 1724.93 857.5 1712.5 857.5 c
+1700.07 857.5 1690 867.574 1690 880 c
+1690 892.426 1700.07 902.5 1712.5 902.5 c
+1724.93 902.5 1735 892.426 1735 880 c
+h
+S
+880 1285 m
+880 992.5 l
+S
+9 w
+880 1465 m
+914.8 1451.5 l
+842.2 1414 l
+915.4 1376.2 l
+841.6 1339.6 l
+914.8 1302.4 l
+879.4 1286.2 l
+S
+Q
+q
+W
+0 0 m
+0 1970 l
+1740 1970 l
+1740 0 l
+h
+322 1767.4 m
+340 1853.8 l
+358 1767.4 l
+358 1879 l
+322 1879 l
+h
+n
+1 i
+4.5 w
+340 1465 m
+340 1870 l
+S
+Q
+q
+1 i
+322 1767.4 m
+340 1853.8 l
+358 1767.4 l
+340 1781.8 l
+322 1767.4 l
+f*
+4.5 w
+322 1767.4 m
+340 1853.8 l
+358 1767.4 l
+340 1781.8 l
+322 1767.4 l
+h
+S
+9 w
+340.6 1463.8 m
+375.4 1450.3 l
+302.8 1412.8 l
+376 1375 l
+302.2 1338.4 l
+375.4 1301.2 l
+340 1285 l
+S
+Q
+q
+W
+0 0 m
+0 1970 l
+1740 1970 l
+1740 0 l
+h
+862 1767.4 m
+880 1853.8 l
+898 1767.4 l
+898 1879 l
+862 1879 l
+h
+n
+1 i
+4.5 w
+880 1465 m
+880 1870 l
+S
+Q
+q
+1 i
+862 1767.4 m
+880 1853.8 l
+898 1767.4 l
+880 1781.8 l
+862 1767.4 l
+f*
+4.5 w
+862 1767.4 m
+880 1853.8 l
+898 1767.4 l
+880 1781.8 l
+862 1767.4 l
+h
+S
+880 1150 m
+1330 1150 l
+S
+340 1285 m
+340 610 l
+S
+1420 1060 m
+1420 610 l
+S
+880 812.5 m
+880 610 l
+S
+9 w
+880 610 m
+914.8 596.5 l
+842.2 559 l
+915.4 521.2 l
+841.6 484.6 l
+914.8 447.4 l
+879.4 431.2 l
+S
+Q
+q
+W
+0 0 m
+0 1970 l
+1740 1970 l
+1740 0 l
+h
+898 262.6 m
+880 176.2 l
+862 262.6 l
+862 151 l
+898 151 l
+h
+n
+1 i
+4.5 w
+880 430 m
+880 160 l
+S
+Q
+q
+1 i
+898 262.6 m
+880 176.2 l
+862 262.6 l
+880 248.2 l
+898 262.6 l
+f*
+4.5 w
+898 262.6 m
+880 176.2 l
+862 262.6 l
+880 248.2 l
+898 262.6 l
+h
+S
+9 w
+340.3 608.2 m
+375.1 594.7 l
+302.5 557.2 l
+375.7 519.4 l
+301.9 482.8 l
+375.1 445.6 l
+339.7 429.4 l
+S
+Q
+q
+W
+0 0 m
+0 1970 l
+1740 1970 l
+1740 0 l
+h
+358 262.6 m
+340 176.2 l
+322 262.6 l
+322 151 l
+358 151 l
+h
+n
+1 i
+4.5 w
+340 430 m
+340 160 l
+S
+Q
+q
+1 i
+358 262.6 m
+340 176.2 l
+322 262.6 l
+340 248.2 l
+358 262.6 l
+f*
+4.5 w
+358 262.6 m
+340 176.2 l
+322 262.6 l
+340 248.2 l
+358 262.6 l
+h
+S
+69.9998 902.5 m
+790 902.5 l
+S
+9 w
+1420 610 m
+1454.8 596.5 l
+1382.2 559 l
+1455.4 521.2 l
+1381.6 484.6 l
+1454.8 447.4 l
+1419.4 431.2 l
+S
+Q
+q
+W
+0 0 m
+0 1970 l
+1740 1970 l
+1740 0 l
+h
+1438 262.6 m
+1420 176.2 l
+1402 262.6 l
+1402 151 l
+1438 151 l
+h
+n
+1 i
+4.5 w
+1420 430 m
+1420 160 l
+S
+Q
+q
+1 i
+1438 262.6 m
+1420 176.2 l
+1402 262.6 l
+1420 248.2 l
+1438 262.6 l
+f*
+4.5 w
+1438 262.6 m
+1420 176.2 l
+1402 262.6 l
+1420 248.2 l
+1438 262.6 l
+h
+S
+1420 880 m
+1690 880 l
+S
+Q
+q
+W
+0 0 m
+0 1970 l
+1740 1970 l
+1740 0 l
+h
+1402 1767.4 m
+1420 1853.8 l
+1438 1767.4 l
+1438 1879 l
+1402 1879 l
+h
+n
+1 i
+4.5 w
+1420 1240 m
+1420 1870 l
+S
+Q
+q
+1 i
+1402 1767.4 m
+1420 1853.8 l
+1438 1767.4 l
+1420 1781.8 l
+1402 1767.4 l
+f*
+4.5 w
+1402 1767.4 m
+1420 1853.8 l
+1438 1767.4 l
+1420 1781.8 l
+1402 1767.4 l
+h
+S
+q 10 0 0 10 0 0 cm BT
+/R6 10.8 Tf
+1 0 0 1 0.249975 99.25 Tm(v)Tj
+12.15 42.75 Td(R)Tj
+56.25 0 Td(R)Tj
+-48.15 -4.5 Td(a)Tj
+-15.75 -42.75 Td(i)Tj
+69.75 94.5 Td(12 V)Tj
+4.5 -189 Td(-12 V)Tj
+83.25 99 Td(v)Tj
+-93.6 -51.75 Td(R)Tj
+-56.25 0 Td(R)Tj
+108 0 Td(R)Tj
+-99.9 -6.75 Td(b)Tj
+108 0 Td(x)Tj
+38.25 54 Td(o)Tj
+-90 42.75 Td(c)Tj
+0 -96.75 Td(e)Tj
+ET Q
+Q
+endstream
+endobj
+5 0 obj
+3911
+endobj
+3 0 obj
+<<
+/Type /Page
+/MediaBox [0 0 174 197]
+/Parent 2 0 R
+/Resources << /ProcSet [/PDF /Text]
+/Font <<
+/R6 6 0 R
+>>
+>>
+/Contents 4 0 R
+>>
+endobj
+6 0 obj
+<</Type/Font/Name/R6/Subtype/Type1/BaseFont/Times-Roman>>
+endobj
+2 0 obj
+<< /Type /Pages /Kids [
+3 0 R
+] /Count 1
+>>
+endobj
+1 0 obj
+<< /Type /Catalog /Pages 2 0 R
+>>
+endobj
+7 0 obj
+<< /CreationDate (D:19990919130433)
+/Producer (Aladdin Ghostscript 5.50)
+>>
+endobj
+xref
+0 8
+0000000000 65535 f
+0000004276 00000 n
+0000004217 00000 n
+0000003996 00000 n
+0000000015 00000 n
+0000003976 00000 n
+0000004144 00000 n
+0000004325 00000 n
+trailer
+<< /Size 8 /Root 1 0 R /Info 7 0 R
+>>
+startxref
+4416
+%%EOF
diff --git a/Build/source/texk/dvipdfm/dvi.c b/Build/source/texk/dvipdfm/dvi.c
new file mode 100644
index 00000000000..c91d629a3b1
--- /dev/null
+++ b/Build/source/texk/dvipdfm/dvi.c
@@ -0,0 +1,1238 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "system.h"
+#include "mem.h"
+#include "error.h"
+#include "mfileio.h"
+#include "numbers.h"
+#include "dvi.h"
+#include "dvicodes.h"
+#include "pdflimits.h"
+#include "pdfdev.h"
+#include "pdfdoc.h"
+#include "tfm.h"
+#include "vf.h"
+
+
+/* Interal Variables */
+
+static FILE *dvi_file;
+static char debug = 0;
+static unsigned num_loaded_fonts = 0, max_loaded_fonts = 0, stackdepth;
+static unsigned long *page_loc = NULL;
+static unsigned long post_location, dvi_file_size;
+static UNSIGNED_PAIR num_pages = 0;
+static UNSIGNED_QUAD media_width, media_height;
+static UNSIGNED_QUAD dvi_unit_num, dvi_unit_den, dvi_mag;
+
+
+#define PHYSICAL 1
+#define VIRTUAL 2
+#define DVI 1
+#define VF 2
+
+struct loaded_font {
+ int type; /* Type is physical or virtual */
+ int font_id; /* id returned by dev (for PHYSICAL fonts)
+ or by vf module for (VIRTUAL fonts) */
+ int tfm_id;
+ spt_t size;
+ int source; /* Source is either DVI or VF */
+} *loaded_fonts = NULL;
+
+static void need_more_fonts (unsigned n)
+{
+ if (num_loaded_fonts+n > max_loaded_fonts) {
+ max_loaded_fonts += MAX_FONTS;
+ loaded_fonts = RENEW (loaded_fonts, max_loaded_fonts, struct
+ loaded_font);
+ }
+}
+
+struct font_def
+{
+ spt_t size;
+ char *name;
+ signed long tex_id;
+ int font_id; /* index of _loaded_ font in loaded_fonts array */
+ int used;
+} *def_fonts = NULL;
+
+static unsigned num_def_fonts = 0, max_def_fonts = 0;
+
+static unsigned char verbose = 0;
+
+static unsigned char compute_boxes = 0;
+
+void dvi_set_verbose(void)
+{
+ if (verbose < 255) {
+ verbose += 1;
+ }
+}
+
+void dvi_compute_boxes (unsigned char boxes)
+{
+ compute_boxes = boxes;
+}
+
+void dvi_set_debug(void)
+{
+ debug = 1;
+}
+
+unsigned dvi_npages (void)
+{
+ return num_pages;
+}
+
+static void invalid_signature()
+{
+ ERROR ("dvi_init: Something is wrong. Are you sure this is a DVI file?\n");
+}
+
+#define range_check_loc(loc) {if ((loc) > dvi_file_size) invalid_signature();}
+
+
+static void find_post (void)
+{
+ long current;
+ int read_byte;
+
+ /* First find end of file */
+ dvi_file_size = file_size (dvi_file);
+ current = dvi_file_size;
+
+ /* Scan backwards through PADDING */
+ do {
+ current -= 1;
+ seek_absolute (dvi_file, current);
+
+ } while ((read_byte = fgetc(dvi_file)) == PADDING &&
+ current > 0);
+
+ /* file_position now points to last non padding character or beginning of file */
+ if (dvi_file_size - current < 4 ||
+ current == 0 || read_byte != DVI_ID) {
+ fprintf (stderr, "DVI ID = %d\n", read_byte);
+ invalid_signature();
+ }
+
+ /* Make sure post_post is really there */
+ current = current - 5;
+ seek_absolute (dvi_file, current);
+ if ((read_byte = fgetc(dvi_file)) != POST_POST) {
+ fprintf (stderr, "Found %d where post_post opcode should be\n", read_byte);
+ invalid_signature();
+ }
+ current = get_signed_quad (dvi_file);
+ seek_absolute (dvi_file, current);
+ if ((read_byte = fgetc(dvi_file)) != POST) {
+ fprintf (stderr, "Found %d where post_post opcode should be\n", read_byte);
+ invalid_signature();
+ }
+ post_location = current;
+}
+
+static void get_page_info (void)
+{
+ int i;
+ seek_absolute (dvi_file, post_location+27);
+ num_pages = get_unsigned_pair (dvi_file);
+ if (verbose > 2) {
+ fprintf (stderr, "Page count:\t %4d\n", num_pages);
+ }
+ if (num_pages == 0) {
+ ERROR ("dvi_init: Page count is 0!");
+ }
+ page_loc = NEW (num_pages, unsigned long);
+ seek_absolute (dvi_file, post_location+1);
+ page_loc[num_pages-1] = get_unsigned_quad(dvi_file);
+ range_check_loc(page_loc[num_pages-1]+41);
+ for (i=num_pages-2; i>=0; i--) {
+ seek_absolute (dvi_file, page_loc[i+1]+41);
+ page_loc[i] = get_unsigned_quad(dvi_file);
+ range_check_loc(page_loc[num_pages-1]+41);
+ }
+}
+
+/* Following are computed "constants" used for unit conversion */
+static double dvi2pts = 0.0, total_mag = 1.0;
+
+double dvi_tell_mag (void)
+{
+ return total_mag;
+}
+
+static void do_scales (double mag)
+{
+ total_mag = (double) dvi_mag / 1000.0 * mag;
+ dvi2pts = (double) dvi_unit_num / (double) dvi_unit_den;
+ dvi2pts *= (72.0)/(254000.0);
+}
+
+
+static void get_dvi_info (void)
+{
+ seek_absolute (dvi_file, post_location+5);
+ dvi_unit_num = get_unsigned_quad(dvi_file);
+ dvi_unit_den = get_unsigned_quad(dvi_file);
+ dvi_mag = get_unsigned_quad(dvi_file);
+ media_height = get_unsigned_quad(dvi_file);
+ media_width = get_unsigned_quad(dvi_file);
+ stackdepth = get_unsigned_pair(dvi_file);
+ if (stackdepth > DVI_MAX_STACK_DEPTH) {
+ fprintf (stderr, "DVI needs stack depth of %d,", stackdepth);
+ fprintf (stderr, "but MAX_DVI_STACK_DEPTH is %d", DVI_MAX_STACK_DEPTH);
+ ERROR ("Capacity exceeded.");
+ }
+
+ if (verbose > 2) {
+ fprintf (stderr, "DVI File Info\n");
+ fprintf (stderr, "Unit: %ld / %ld\n", dvi_unit_num, dvi_unit_den);
+ fprintf (stderr, "Mag: %ld\n", dvi_mag);
+ fprintf (stderr, "Media Height: %ld\n", media_height);
+ fprintf (stderr, "Media Width: %ld\n", media_width);
+ fprintf (stderr, "Stack Depth: %d\n", stackdepth);
+ }
+
+}
+
+static void dump_font_info (void)
+{
+ unsigned i;
+ fprintf (stderr, "\nDVI file font info\n");
+ for (i=0; i<num_def_fonts; i++) {
+ fprintf (stderr, "name: %10s, ", def_fonts[i].name);
+ fprintf (stderr, "TeX/DVI ID: %5ld, ", def_fonts[i].tex_id);
+ fprintf (stderr, "size: %5.2f pt, ", def_fonts[i].size*dvi2pts);
+ fprintf (stderr, "\n");
+ }
+}
+
+static void get_a_font_record (SIGNED_QUAD tex_id)
+{
+ UNSIGNED_BYTE dir_length, name_length;
+ UNSIGNED_QUAD checksum, size, design_size;
+ char *directory, *name;
+ if (debug) {
+ fprintf (stderr, "get_a_font_record: tex_id = %ld\n", tex_id);
+ }
+ if (num_def_fonts >= max_def_fonts) {
+ max_def_fonts += MAX_FONTS;
+ def_fonts = RENEW (def_fonts, max_def_fonts, struct font_def);
+ }
+ checksum = get_unsigned_quad (dvi_file);
+ size = get_unsigned_quad (dvi_file);
+ design_size = get_unsigned_quad (dvi_file);
+ dir_length = get_unsigned_byte (dvi_file);
+ name_length = get_unsigned_byte (dvi_file);
+ directory = NEW (dir_length+1, char);
+ if (fread (directory, 1, dir_length, dvi_file) !=
+ dir_length) {
+ invalid_signature();
+ }
+ name = NEW (name_length+1, char);
+ if (fread (name, 1, name_length, dvi_file) !=
+ name_length) {
+ invalid_signature();
+ }
+ directory[dir_length] = 0;
+ RELEASE (directory);
+ name[name_length] = 0;
+ def_fonts[num_def_fonts].name = name;
+ def_fonts[num_def_fonts].size = size;
+ def_fonts[num_def_fonts].tex_id = tex_id;
+ def_fonts[num_def_fonts].used = 0;
+ num_def_fonts +=1;
+ return;
+}
+
+static void get_dvi_fonts (void)
+{
+ UNSIGNED_BYTE code;
+ SIGNED_QUAD tex_id;
+ seek_absolute (dvi_file, post_location+29);
+ while ((code = get_unsigned_byte(dvi_file)) != POST_POST) {
+ switch (code)
+ {
+ case FNT_DEF1:
+ tex_id = get_unsigned_byte (dvi_file);
+ break;
+ case FNT_DEF2:
+ tex_id = get_unsigned_pair (dvi_file);
+ break;
+ case FNT_DEF3:
+ tex_id = get_unsigned_triple (dvi_file);
+ break;
+ case FNT_DEF4:
+ tex_id = get_signed_quad (dvi_file);
+ break;
+ default:
+ fprintf (stderr, "Unexpected op code: %3d\n", code);
+ invalid_signature();
+ }
+ get_a_font_record(tex_id);
+ }
+ if (verbose>2) {
+ dump_font_info();
+ }
+}
+
+
+void get_comment(void)
+{
+ UNSIGNED_BYTE length;
+ static char dvi_comment[257];
+ seek_absolute (dvi_file, 14);
+ length = get_unsigned_byte(dvi_file);
+ if (fread (dvi_comment, 1, length, dvi_file) != length) {
+ invalid_signature();
+ }
+ dvi_comment[length] = 0;
+ if (verbose) {
+ fprintf (stderr, "DVI Comment: %s\n", dvi_comment);
+ }
+ dev_add_comment (dvi_comment);
+}
+
+
+/* The section below this line deals with the actual processing of the
+ dvi file.
+
+ The dvi file processor state is contained in the following
+ variables: */
+
+struct dvi_registers {
+ SIGNED_QUAD h, v, w, x, y, z;
+};
+
+static struct dvi_registers dvi_state;
+static struct dvi_registers dvi_stack[DVI_MAX_STACK_DEPTH];
+static int current_font;
+static unsigned dvi_stack_depth = 0;
+static int processing_page = 0;
+
+static void clear_state (void)
+{
+ dvi_state.h = 0; dvi_state.v = 0; dvi_state.w = 0;
+ dvi_state.x = 0; dvi_state.y = 0; dvi_state.z = 0;
+ dvi_stack_depth = 0;
+ current_font = -1;
+}
+
+
+double dvi_unit_size(void)
+{
+ return dvi2pts;
+}
+
+int dvi_locate_font (char *tex_name, spt_t ptsize)
+{
+ int thisfont;
+ int font_id;
+ if (debug) {
+ fprintf (stderr, "dvi_locate_font: fontname: (%s) ptsize: %ld, dvi_id: %d\n",
+ tex_name, ptsize, num_loaded_fonts);
+ }
+ if (verbose)
+ fprintf (stderr, "<%s@%.2fpt", tex_name, ptsize*dvi2pts);
+ need_more_fonts (1);
+ /* This routine needs to be recursive/reentrant. Load current high water
+ mark into an automatic variable */
+ thisfont = num_loaded_fonts++;
+ loaded_fonts[thisfont].tfm_id = tfm_open (tex_name);
+ loaded_fonts[thisfont].source = VF; /* This will be reset later if
+ it was really generated by the
+ dvi file */
+ font_id = vf_locate_font (tex_name, ptsize);
+ loaded_fonts[thisfont].font_id = font_id;
+ if (loaded_fonts[thisfont].font_id >= 0) {
+ if (verbose)
+ fprintf (stderr, "(VF)");
+ loaded_fonts[thisfont].type = VIRTUAL;
+ } else {
+ loaded_fonts[thisfont].type = PHYSICAL;
+ font_id = dev_locate_font (tex_name, ptsize);
+ loaded_fonts[thisfont].font_id = font_id;
+ if (loaded_fonts[thisfont].font_id < 0) {
+ fprintf (stderr, "%s: Can't locate a Type 1, TTF, PK, or virtual font file\n", tex_name);
+ ERROR ("Not sure how to proceed. For now this is fatal\n\
+Maybe in the future, I'll substitute some other font.");
+ }
+ }
+ loaded_fonts[thisfont].size = ptsize;
+ if (verbose)
+ fprintf (stderr, ">");
+ return (thisfont);
+}
+
+double dvi_dev_xpos(void) {
+ return dvi_state.h*dvi2pts;
+}
+
+double dvi_dev_ypos (void)
+{
+ return -(dvi_state.v*dvi2pts);
+}
+
+static void do_moveto (SIGNED_QUAD x, SIGNED_QUAD y)
+{
+ dvi_state.h = x;
+ dvi_state.v = y;
+}
+
+void dvi_right (SIGNED_QUAD x)
+{
+ dvi_state.h += x;
+}
+
+void dvi_down (SIGNED_QUAD y)
+{
+ dvi_state.v += y;
+}
+
+static void do_string (unsigned char *s, int len)
+{
+ spt_t width = 0, height = 0, depth = 0;
+ int i;
+ struct loaded_font *p;
+ if (debug) {
+ int i;
+ fprintf (stderr, "do_string: (font: %d)\n", current_font);
+ for (i=0; i<len; i++) fputc (s[i], stderr);
+ fputc ('\n', stderr);
+ }
+
+ if (current_font < 0) {
+ ERROR ("do_string: No font selected");
+ }
+ p = loaded_fonts+current_font;
+ width = tfm_string_width (p->tfm_id, s, len);
+ width = sqxfw (p->size, width);
+ switch (p->type) {
+ case PHYSICAL:
+ dev_set_string (dvi_state.h, -dvi_state.v, s, len,
+ width, p->font_id);
+ if (compute_boxes) {
+ height = tfm_string_height (p->tfm_id, s, len);
+ depth = tfm_string_depth (p->tfm_id, s, len);
+ height = sqxfw (p->size, height);
+ depth = sqxfw (p->size, depth);
+ dev_expand_box (width, height, depth);
+ }
+ break;
+ case VIRTUAL:
+ dvi_push();
+ for (i=0; i<len; i++) {
+ dvi_set (s[i]);
+ }
+ dvi_pop();
+ }
+ dvi_state.h += width;
+}
+
+void dvi_set (SIGNED_QUAD ch)
+{
+ spt_t width, height = 0, depth = 0;
+ struct loaded_font *p;
+ unsigned char lch;
+ if (current_font < 0) {
+ ERROR ("dvi_set: No font selected");
+ }
+ /* The division by dvi2pts seems strange since we actually know the
+ "dvi" size of the fonts contained in the DVI file. In other
+ words, we converted from DVI units to pts and back again!
+ The problem comes from fonts defined in VF files where we don't know the DVI
+ size. It's keeping me sane to keep *point sizes* of *all* fonts in
+ the dev.c file and convert them back if necessary */
+ p = loaded_fonts+current_font;
+ width = tfm_get_fw_width (p->tfm_id, ch);
+ width = sqxfw (p->size, width);
+ switch (p->type) {
+ case PHYSICAL:
+ if (ch > 255) {
+ ERROR ("Tried to set a multibyte character in a non-virtual font");
+ }
+ lch = (unsigned char) ch;
+ dev_set_string (dvi_state.h, -dvi_state.v, &lch, 1, width, p->font_id);
+ if (compute_boxes) {
+ height = tfm_get_fw_height (p->tfm_id, ch);
+ depth = tfm_get_fw_depth (p->tfm_id, ch);
+ height = sqxfw (p->size, height);
+ depth = sqxfw (p->size, depth);
+ dev_expand_box (width, height, depth);
+ }
+ break;
+ case VIRTUAL:
+ {
+ vf_set_char (ch, p->font_id);
+ break;
+ }
+ }
+ dvi_state.h += width;
+}
+
+void dvi_put (SIGNED_QUAD ch)
+{
+ spt_t width, height = 0, depth = 0;
+ struct loaded_font *p;
+ unsigned char lch;
+ if (current_font < 0) {
+ ERROR ("dvi_put: No font selected");
+ }
+ p = loaded_fonts+current_font;
+ switch (p->type) {
+ case PHYSICAL:
+ width = tfm_get_fw_width (p->tfm_id, ch);
+ width = sqxfw (p->size, width);
+ /* Treat a single character as a one byte string and use the
+ string routine. The possibly multi-byte character must
+ be converted to a single-byte string */
+ if (ch > 255) {
+ ERROR ("Tried to set a multibyte character in a non-virtual font");
+ }
+ lch = (unsigned char) ch;
+ dev_set_string (dvi_state.h, -dvi_state.v, &lch, 1, width, p->font_id);
+ if (compute_boxes) {
+ height = tfm_get_fw_height (p->tfm_id, ch);
+ depth = tfm_get_fw_depth (p->tfm_id, ch);
+ height = sqxfw (p->size, height);
+ depth = sqxfw (p->size, depth);
+ dev_expand_box (width, height, depth);
+ }
+ break;
+ case VIRTUAL:
+ vf_set_char (ch, p->font_id);
+ break;
+ }
+ return;
+}
+
+
+void dvi_rule (SIGNED_QUAD width, SIGNED_QUAD height)
+{
+ do_moveto (dvi_state.h, dvi_state.v);
+ dev_rule (dvi_state.h, -dvi_state.v,
+ width, height);
+}
+
+static void do_set1(void)
+{
+ dvi_set (get_unsigned_byte(dvi_file));
+}
+
+static void do_set2(void)
+{
+ dvi_set (get_unsigned_pair(dvi_file));
+}
+
+static void do_setrule(void)
+{
+ SIGNED_QUAD width, height;
+ height = get_signed_quad (dvi_file);
+ width = get_signed_quad (dvi_file);
+ if (width > 0 && height > 0) {
+ dvi_rule (width, height);
+ }
+ dvi_right (width);
+}
+
+static void do_putrule(void)
+{
+ SIGNED_QUAD width, height;
+ height = get_signed_quad (dvi_file);
+ width = get_signed_quad (dvi_file);
+ if (width > 0 && height > 0) {
+ dvi_rule (width, height);
+ }
+}
+
+static void do_put1(void)
+{
+ dvi_put (get_unsigned_byte(dvi_file));
+}
+
+static void do_put2(void)
+{
+ dvi_put (get_unsigned_pair(dvi_file));
+}
+
+void dvi_push (void)
+{
+ if (debug) {
+ fprintf (stderr, "Pushing onto stack of depth %d\n",
+ dvi_stack_depth);
+ }
+ if (dvi_stack_depth < DVI_MAX_STACK_DEPTH) {
+ dvi_stack[dvi_stack_depth++] = dvi_state;
+ }
+ else
+ ERROR ("DVI stack exceeded");
+}
+
+void dvi_pop (void)
+{
+ if (debug) {
+ fprintf (stderr, "Popping off stack of depth %d\n",
+ dvi_stack_depth);
+ }
+ if (dvi_stack_depth > 0) {
+ dvi_state = dvi_stack[--dvi_stack_depth];
+ } else
+ ERROR ("dvi_pop: Tried to pop an empty stack");
+ do_moveto (dvi_state.h, dvi_state.v);
+}
+
+
+static void do_right1(void)
+{
+ dvi_right (get_signed_byte(dvi_file));
+}
+
+static void do_right2(void)
+{
+ dvi_right (get_signed_pair(dvi_file));
+}
+
+static void do_right3(void)
+{
+ dvi_right (get_signed_triple(dvi_file));
+}
+
+static void do_right4(void)
+{
+ dvi_right (get_signed_quad(dvi_file));
+}
+
+void dvi_w (SIGNED_QUAD ch)
+{
+ dvi_state.w = ch;
+ dvi_right (ch);
+}
+
+void dvi_w0(void)
+{
+ dvi_right (dvi_state.w);
+}
+
+static void do_w1(void)
+{
+ dvi_w (get_signed_byte(dvi_file));
+}
+
+static void do_w2(void)
+{
+ dvi_w (get_signed_pair(dvi_file));
+}
+
+static void do_w3(void)
+{
+ dvi_w (get_signed_triple(dvi_file));
+}
+
+static void do_w4(void)
+{
+ dvi_w (get_signed_quad(dvi_file));
+}
+
+void dvi_x (SIGNED_QUAD ch)
+{
+ dvi_state.x = ch;
+ dvi_right (ch);
+}
+
+void dvi_x0(void)
+{
+ dvi_right (dvi_state.x);
+}
+
+static void do_x1(void)
+{
+ dvi_x (get_signed_byte(dvi_file));
+}
+
+static void do_x2(void)
+{
+ dvi_x (get_signed_pair(dvi_file));
+}
+
+static void do_x3(void)
+{
+ dvi_x (get_signed_triple(dvi_file));
+}
+
+static void do_x4(void)
+{
+ dvi_x (get_signed_quad(dvi_file));
+}
+
+static void do_down1(void)
+{
+ dvi_down (get_signed_byte(dvi_file));
+}
+
+static void do_down2(void)
+{
+ dvi_down (get_signed_pair(dvi_file));
+}
+
+static void do_down3(void)
+{
+ dvi_down (get_signed_triple(dvi_file));
+}
+
+static void do_down4(void)
+{
+ dvi_down (get_signed_quad(dvi_file));
+}
+
+void dvi_y (SIGNED_QUAD ch)
+{
+ dvi_state.y = ch;
+ dvi_down (ch);
+}
+
+void dvi_y0(void)
+{
+ dvi_down (dvi_state.y);
+}
+
+static void do_y1(void)
+{
+ dvi_y (get_signed_byte(dvi_file));
+}
+
+static void do_y2(void)
+{
+ dvi_y (get_signed_pair(dvi_file));
+}
+
+static void do_y3(void)
+{
+ dvi_y (get_signed_triple(dvi_file));
+}
+
+static void do_y4(void)
+{
+ dvi_y (get_signed_quad(dvi_file));
+}
+
+void dvi_z (SIGNED_QUAD ch)
+{
+ dvi_state.z = ch;
+ dvi_down (ch);
+}
+
+void dvi_z0(void)
+{
+ dvi_down (dvi_state.z);
+}
+
+static void do_z1(void)
+{
+ dvi_z (get_signed_byte(dvi_file));
+}
+
+static void do_z2(void)
+{
+ dvi_z (get_signed_pair(dvi_file));
+}
+
+static void do_z3(void)
+{
+ dvi_z (get_signed_triple(dvi_file));
+}
+
+static void do_z4(void)
+{
+ dvi_z (get_signed_quad(dvi_file));
+}
+
+static void do_fntdef(void)
+{
+ int area_len, name_len, i;
+ get_signed_quad(dvi_file);
+ get_signed_quad(dvi_file);
+ get_signed_quad(dvi_file);
+ area_len = get_unsigned_byte(dvi_file);
+ name_len = get_unsigned_byte(dvi_file);
+ for (i=0; i<area_len+name_len; i++) {
+ get_unsigned_byte (dvi_file);
+ }
+}
+
+static void do_fntdef1(void)
+{
+ get_unsigned_byte(dvi_file);
+ do_fntdef();
+}
+
+static void do_fntdef2(void)
+{
+ get_unsigned_pair(dvi_file);
+ do_fntdef();
+}
+
+static void do_fntdef3(void)
+{
+ get_unsigned_triple(dvi_file);
+ do_fntdef();
+}
+
+static void do_fntdef4(void)
+{
+ get_signed_quad(dvi_file);
+ do_fntdef();
+}
+
+
+void dvi_set_font (int font_id)
+{
+ current_font = font_id;
+}
+
+static void do_fnt (SIGNED_QUAD tex_id)
+{
+ int i;
+ for (i=0; i<num_def_fonts; i++) {
+ if (def_fonts[i].tex_id == tex_id)
+ break;
+ }
+ if (i == num_def_fonts) {
+ fprintf (stderr, "fontid: %ld\n", tex_id);
+ ERROR ("dvi_do_fnt: Tried to select a font that hasn't been defined");
+ }
+ if (!def_fonts[i].used) {
+ int font_id;
+ font_id = dvi_locate_font (def_fonts[i].name, def_fonts[i].size);
+ loaded_fonts[font_id].source = DVI;
+ def_fonts[i].used = 1;
+ def_fonts[i].font_id = font_id;
+ }
+ current_font = def_fonts[i].font_id;
+}
+
+static void do_fnt1(void)
+{
+ SIGNED_QUAD font;
+ font = get_unsigned_byte(dvi_file);
+ do_fnt(font);
+}
+
+static void do_fnt2(void)
+{
+ SIGNED_QUAD font;
+ font = get_unsigned_pair(dvi_file);
+ do_fnt(font);
+}
+
+static void do_fnt3(void)
+{
+ SIGNED_QUAD font;
+ font = get_unsigned_triple(dvi_file);
+ do_fnt(font);
+}
+
+static void do_fnt4(void)
+{
+ SIGNED_QUAD font;
+ font = get_signed_quad(dvi_file);
+ do_fnt(font);
+}
+
+static void do_xxx(UNSIGNED_QUAD size)
+{
+ UNSIGNED_QUAD i;
+ Ubyte *buffer;
+ buffer = NEW (size+1, Ubyte);
+ for (i=0; i<size; i++) {
+ buffer[i] = get_unsigned_byte(dvi_file);
+ }
+ if (debug)
+ fprintf (stderr, "Special: %s\n", buffer);
+ dev_do_special (buffer, size, dvi_state.h, dvi_state.v);
+ RELEASE (buffer);
+}
+
+static void do_xxx1(void)
+{
+ SIGNED_QUAD size;
+ if (debug)
+ fprintf (stderr, "(xxx1)");
+ size = get_unsigned_byte(dvi_file);
+ do_xxx(size);
+}
+
+static void do_xxx2(void)
+{
+ SIGNED_QUAD size;
+ size = get_unsigned_pair(dvi_file);
+ do_xxx(size);
+}
+
+static void do_xxx3(void)
+{
+ SIGNED_QUAD size;
+ size = get_unsigned_triple(dvi_file);
+ do_xxx(size);
+}
+
+static void do_xxx4(void)
+{
+ SIGNED_QUAD size;
+ size = get_unsigned_quad(dvi_file);
+ do_xxx(size);
+}
+
+static void do_bop(void)
+{
+ int i;
+ if (processing_page)
+ ERROR ("dvi_do_bop: Got a bop inthe middle of a page");
+ /* For now, ignore TeX's count registers */
+ for (i=0; i<10; i++) {
+ get_signed_quad (dvi_file);
+ }
+/* Ignore previous page pointer since we have already saved this
+ information */
+ get_signed_quad (dvi_file);
+ clear_state();
+ processing_page = 1;
+ dev_bop();
+}
+
+static void do_eop(void)
+{
+ processing_page = 0;
+ if (dvi_stack_depth != 0) {
+ ERROR ("do_eop: stack_depth is not zero at end of page");
+ }
+ dev_eop();
+}
+/* Note to be absolutely certain that the string escape buffer doesn't
+ hit its limit, FORMAT_BUF_SIZE should set to 4 times S_BUFFER_SIZE
+ in pdfobj.c. Is there any application that genenerate words with
+ 1k characters? */
+
+#define S_BUFFER_SIZE 1024
+static unsigned char s_buffer[S_BUFFER_SIZE];
+static unsigned s_len = 0;
+
+void dvi_do_page(unsigned n) /* Most of the work of actually interpreting
+ the dvi file is here. */
+{
+ unsigned char opcode;
+ /* Position to beginning of page */
+ if (debug) fprintf (stderr, "Seeking to page %d @ %ld\n", n,
+ page_loc[n]);
+ seek_absolute (dvi_file, page_loc[n]);
+ dvi_stack_depth = 0;
+ for (;;) {
+ /* The most likely opcodes are individual setchars. These are
+ buffered for speed */
+ s_len = 0;
+ while ((opcode = fgetc (dvi_file)) <= SET_CHAR_127 &&
+ s_len < S_BUFFER_SIZE) {
+ s_buffer[s_len++] = opcode;
+ }
+ if (s_len > 0) {
+ do_string (s_buffer, s_len);
+ }
+ if (s_len == S_BUFFER_SIZE)
+ continue;
+ /* If we are here, we have an opcode that is something
+ other than SET_CHAR */
+ if (opcode >= FNT_NUM_0 && opcode <= FNT_NUM_63) {
+ do_fnt (opcode - FNT_NUM_0);
+ continue;
+ }
+ switch (opcode)
+ {
+ case SET1:
+ do_set1();
+ break;
+ case SET2:
+ do_set2();
+ break;
+ case SET3:
+ case SET4:
+ ERROR ("Multibyte (>16 bits) character in DVI file. I can't handle this!");
+ break;
+ case SET_RULE:
+ do_setrule();
+ break;
+ case PUT1:
+ do_put1();
+ break;
+ case PUT2:
+ do_put2();
+ break;
+ case PUT3:
+ case PUT4:
+ ERROR ("Multibyte character (>16 bits) in DVI file. I can't handle this!");
+ break;
+ case PUT_RULE:
+ do_putrule();
+ break;
+ case NOP:
+ break;
+ case BOP:
+ do_bop();
+ break;
+ case EOP:
+ do_eop();
+ return;
+ case PUSH:
+ dvi_push();
+ /* The following line needs to go here instead of in
+ dvi_push() since logical structure of document is
+ oblivous to virtual fonts. For example the last line on a
+ page could be at stack level 3 and the page footer should
+ be at stack level 3. However, if the page footer contains
+ virtual fonts (or other nested constructions), it could
+ fool the link breaker into thinking it was a continuation
+ of the link */
+ dev_stack_depth (dvi_stack_depth);
+ break;
+ case POP:
+ dvi_pop();
+ /* Above explanation holds for following line too */
+ dev_stack_depth (dvi_stack_depth);
+ break;
+ case RIGHT1:
+ do_right1();
+ break;
+ case RIGHT2:
+ do_right2();
+ break;
+ case RIGHT3:
+ do_right3();
+ break;
+ case RIGHT4:
+ do_right4();
+ break;
+ case W0:
+ dvi_w0();
+ break;
+ case W1:
+ do_w1();
+ break;
+ case W2:
+ do_w2();
+ break;
+ case W3:
+ do_w3();
+ break;
+ case W4:
+ do_w4();
+ break;
+ case X0:
+ dvi_x0();
+ break;
+ case X1:
+ do_x1();
+ break;
+ case X2:
+ do_x2();
+ break;
+ case X3:
+ do_x3();
+ break;
+ case X4:
+ do_x4();
+ break;
+ case DOWN1:
+ do_down1();
+ break;
+ case DOWN2:
+ do_down2();
+ break;
+ case DOWN3:
+ do_down3();
+ break;
+ case DOWN4:
+ do_down4();
+ break;
+ case Y0:
+ dvi_y0();
+ break;
+ case Y1:
+ do_y1();
+ break;
+ case Y2:
+ do_y2();
+ break;
+ case Y3:
+ do_y3();
+ break;
+ case Y4:
+ do_y4();
+ break;
+ case Z0:
+ dvi_z0();
+ break;
+ case Z1:
+ do_z1();
+ break;
+ case Z2:
+ do_z2();
+ break;
+ case Z3:
+ do_z3();
+ break;
+ case Z4:
+ do_z4();
+ break;
+ case FNT1:
+ do_fnt1();
+ break;
+ case FNT2:
+ do_fnt2();
+ break;
+ case FNT3:
+ do_fnt3();
+ break;
+ case FNT4:
+ do_fnt4();
+ break;
+ case XXX1:
+ do_xxx1();
+ break;
+ case XXX2:
+ do_xxx2();
+ break;
+ case XXX3:
+ do_xxx3();
+ break;
+ case XXX4:
+ do_xxx4();
+ break;
+ case FNT_DEF1:
+ do_fntdef1();
+ break;
+ case FNT_DEF2:
+ do_fntdef2();
+ break;
+ case FNT_DEF3:
+ do_fntdef3();
+ break;
+ case FNT_DEF4:
+ do_fntdef4();
+ break;
+ case PRE:
+ case POST:
+ case POST_POST:
+ ERROR("Unexpected preamble or postamble in dvi file");
+ break;
+ default:
+ ERROR("Unexpected opcode or DVI file ended prematurely");
+ }
+ }
+}
+
+error_t dvi_init (char *dvi_filename, char *pdf_filename, double mag, double x_offset, double
+ y_offset)
+{
+ if (!(dvi_file = MFOPEN (dvi_filename, FOPEN_RBIN_MODE))) {
+ ERROR ("dvi_init: Specified DVI file doesn't exist");
+ return (FATAL_ERROR);
+ }
+ /* DVI files are most easily read backwards by searching
+ for post_post and then post opcode */
+ find_post ();
+ get_dvi_info();
+ do_scales(mag);
+ dev_init(dvi2pts, x_offset, y_offset);
+ get_page_info();
+ pdf_doc_init (pdf_filename);
+ get_comment();
+ get_dvi_fonts();
+ clear_state();
+ return (NO_ERROR);
+}
+
+void dvi_close (void)
+{
+ int i;
+ /* We add comment in dvi_close instead of dvi_init so user has
+ a change to overwrite it. The docinfo dictionary is
+ treated as a write-once record */
+
+ /* Do some house cleaning */
+ MFCLOSE (dvi_file);
+ for (i=0; i<num_def_fonts; i++) {
+ RELEASE (def_fonts[i].name);
+ }
+ if (def_fonts)
+ RELEASE (def_fonts);
+ RELEASE (page_loc);
+ num_loaded_fonts = 0;
+ if (loaded_fonts)
+ RELEASE (loaded_fonts);
+ num_pages = 0;
+ dvi_file = NULL;
+ dev_close_all_fonts();
+ vf_close_all_fonts();
+ tfm_close_all();
+ dev_close();
+ pdf_doc_close();
+}
+
+/* The following are need to implement virtual fonts
+ According to documentation, the vf "subroutine"
+ must have state pushed and must have
+ w,v,y, and z set to zero. The current font
+ is determined by the virtual font header, which
+ may be undefined */
+
+static int saved_dvi_font[MAX_VF_NESTING];
+static int num_saved_fonts = 0;
+
+void dvi_vf_init (int dev_font_id)
+{
+ dvi_push ();
+ dvi_state.w = 0; dvi_state.x = 0;
+ dvi_state.y = 0; dvi_state.z = 0;
+ if (num_saved_fonts < MAX_VF_NESTING) {
+ saved_dvi_font[num_saved_fonts++] = current_font;
+ } else
+ ERROR ("Virtual fonts nested too deeply!");
+ current_font = dev_font_id;
+}
+
+/* After VF subroutine is finished, we simply pop the DVI stack */
+void dvi_vf_finish (void)
+{
+ dvi_pop();
+ if (num_saved_fonts > 0)
+ current_font = saved_dvi_font[--num_saved_fonts];
+ else
+ ERROR ("Tried to pop an empty font stack");
+}
diff --git a/Build/source/texk/dvipdfm/dvi.h b/Build/source/texk/dvipdfm/dvi.h
new file mode 100644
index 00000000000..06ef5137a7d
--- /dev/null
+++ b/Build/source/texk/dvipdfm/dvi.h
@@ -0,0 +1,67 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#ifndef _DVI_H_
+#define _DVI_H_
+
+#include "error.h"
+#include "numbers.h"
+#include "pdfdev.h"
+
+extern error_t dvi_init (char *dvi_filename, char *pdf_filename, double mag, double x_offset,
+ double y_offset);
+
+extern void dvi_set_verbose (void);
+extern void dvi_set_debug (void);
+
+extern void dvi_close (void); /* Closes data structures created by dvi_open */
+extern double dvi_tell_mag (void);
+extern double dvi_unit_size (void);
+
+extern void dvi_vf_init (int dev_font_id);
+extern void dvi_vf_finish (void);
+
+extern void dvi_set_font (int font_id);
+extern void dvi_set (SIGNED_QUAD ch);
+extern void dvi_rule (SIGNED_QUAD width, SIGNED_QUAD height);
+extern void dvi_right (SIGNED_QUAD x);
+extern void dvi_put (SIGNED_QUAD ch);
+extern void dvi_push (void);
+extern void dvi_pop (void);
+extern void dvi_w0 (void);
+extern void dvi_w (SIGNED_QUAD ch);
+extern void dvi_x0(void);
+extern void dvi_x (SIGNED_QUAD ch);
+extern void dvi_down (SIGNED_QUAD y);
+extern void dvi_y (SIGNED_QUAD ch);
+extern void dvi_y0(void);
+extern void dvi_z (SIGNED_QUAD ch);
+extern void dvi_z0(void);
+extern double dvi_dev_xpos(void);
+extern double dvi_dev_ypos(void);
+extern unsigned dvi_npages (void);
+extern void dvi_do_page(unsigned n);
+extern int dvi_locate_font (char *name, spt_t ptsize);
+extern void dvi_compute_boxes (unsigned char boxes);
+#endif /* _DVI_H_ */
diff --git a/Build/source/texk/dvipdfm/dvicodes.h b/Build/source/texk/dvipdfm/dvicodes.h
new file mode 100644
index 00000000000..87d164e26ea
--- /dev/null
+++ b/Build/source/texk/dvipdfm/dvicodes.h
@@ -0,0 +1,115 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+/* DVI op codes */
+#define SET_CHAR_0 0
+#define SET_CHAR_1 1
+/* etc. */
+#define SET_CHAR_127 127
+#define SET1 128 /* Typesets its single operand between 128 and 255 */
+#define SET2 129 /* Typesets its single two byte unsigned operand */
+#define SET3 130 /* Typesets its single three byte unsigned operand */
+#define SET4 131 /* Typesets its single four byte unsigned operand */
+#define SET_RULE 132 /* Sets a rule of height param1(four bytes) and width param2(four bytes) */
+ /* These are *signed*. Nothing typeset for nonpositive values */
+ /* However, negative value *do* change current point */
+#define PUT1 133 /* Like SET1, but point doesn't change */
+#define PUT2 134 /* Like SET2 */
+#define PUT3 135 /* Like SET3 */
+#define PUT4 136 /* Like SET4 */
+#define PUT_RULE 137 /* Like SET_RULE */
+#define NOP 138
+#define BOP 139 /* Followed by 10 four byte count registers (signed?). Last parameter points to */
+ /* previous BOP (backward linked, first BOP has -1). BOP clears stack and resets current point. */
+#define EOP 140
+#define PUSH 141 /* Pushes h,v,w,x,y,z */
+#define POP 142 /* Opposite of push*/
+#define RIGHT1 143 /* Move right by one byte signed operand */
+#define RIGHT2 144 /* Move right by two byte signed operand */
+#define RIGHT3 145 /* Move right by three byte signed operand */
+#define RIGHT4 146 /* Move right by four byte signed operand */
+#define W0 147 /* Move right w */
+#define W1 148 /* w <- single byte signed operand. Move right by same amount */
+#define W2 149 /* Same as W1 with two byte signed operand */
+#define W3 150 /* Three byte signed operand */
+#define W4 151 /* Four byte signed operand */
+#define X0 152 /* Move right x */
+#define X1 153 /* Like W1 */
+#define X2 154 /* Like W2 */
+#define X3 155 /* Like W3 */
+#define X4 156 /* Like W4 */
+#define DOWN1 157 /* Move down by one byte signed operand */
+#define DOWN2 158 /* Two byte signed operand */
+#define DOWN3 159 /* Three byte signed operand */
+#define DOWN4 160 /* Four byte signed operand */
+#define Y0 161 /* Move down by y */
+#define Y1 162 /* Move down by one byte signed operand, which replaces Y */
+#define Y2 163 /* Two byte signed operand */
+#define Y3 164 /* Three byte signed operand */
+#define Y4 165 /* Four byte signed operand */
+#define Z0 166 /* Like Y0, but use z */
+#define Z1 167 /* Like Y1 */
+#define Z2 168 /* Like Y2 */
+#define Z3 169 /* Like Y3 */
+#define Z4 170 /* Like Y4 */
+#define FNT_NUM_0 171 /* Switch to font 0 */
+#define FNT_NUM_1 172 /* Switch to font 1 */
+/* etc. */
+#define FNT_NUM_63 234 /* Switch to font 63 */
+#define FNT1 235 /* Switch to font described by single byte unsigned operand */
+#define FNT2 236 /* Switch to font described by two byte unsigned operand */
+#define FNT3 237 /* Three byte font descriptor */
+#define FNT4 238 /* Four byte operator (Knuth says signed, but what would be the point? */
+#define XXX1 239 /* Special. Operand is one byte length. Special follows immediately */
+#define XXX2 240 /* Two byte operand */
+#define XXX3 241 /* Three byte operand */
+#define XXX4 242 /* Four byte operand (Knuth says TeX uses only XXX1 and XXX4 */
+#define FNT_DEF1 243 /* One byte font number, four byte checksum, four byte magnified size (DVI units),
+ four byte designed size, single byte directory length, single byte name length,
+ followed by complete name (area+name) */
+#define FNT_DEF2 244 /* Same for two byte font number */
+#define FNT_DEF3 245 /* Same for three byte font number */
+#define FNT_DEF4 246 /* Four byte font number (Knuth says signed) */
+#define PRE 247 /* Preamble:
+ one byte DVI version (should be 2)
+ four byte unsigned numerator
+ four byte unsigned denominator -- one DVI unit = den/num*10^(-7) m
+ four byte magnification (multiplied by 1000)
+ one byte unsigned comment length followed by comment. */
+#define DVI_ID 2 /* ID Byte for current DVI file */
+#define POST 248 /* Postamble- -- similar to preamble
+ four byte pointer to final bop
+ four byte numerator
+ four byte denominator
+ four byte mag
+ four byte maximum height (signed?)
+ four byte maximum width
+ two byte max stack depth required to process file
+ two byte number of pages */
+#define POST_POST 249 /* End of postamble
+ four byte pointer to POST command
+ Version byte (same as preamble)
+ Padded by four or more 223's to the end of the file. */
+#define PADDING 223
+
diff --git a/Build/source/texk/dvipdfm/dvipdfm.1 b/Build/source/texk/dvipdfm/dvipdfm.1
new file mode 100644
index 00000000000..674a15790a0
--- /dev/null
+++ b/Build/source/texk/dvipdfm/dvipdfm.1
@@ -0,0 +1,322 @@
+.de EX
+.sp
+.in +5
+.nf
+.ft CW
+..
+.de EE
+.in -5
+.ft R
+.sp
+.fi
+..
+.TH dvipdfm 1 5/28/2001
+.SH NAME
+dvipdfm \- Produce PDF files directly from DVI files
+
+.SH SYNOPSIS
+.B dvipdfm
+.RI [ options ]
+.IR file [.dvi]
+
+.SH DESCRIPTION
+The program
+.B dvipdfm
+generates a
+.SM PDF
+file from a
+.SM DVI
+file.
+.SM DVI
+files are the output format
+produced by TeX.
+Output from
+.B groff
+can be converted to
+.SM DVI
+format
+using
+.BR grodvi .
+
+The program
+.B dvipdfm
+recognizes several commonly used
+.BR \especial
+commands, which are extensions to the
+.SM DVI
+format.
+Specifically, it understands
+color specials, papersize specials,
+tpic specials (which allow it to be used with
+.BR pic ),
+hypertex specials, and some PostScript
+specials. These extensions allow documents
+to contain color, figures, and hyperlinks.
+The program tries to mimic
+the behavior of
+.B dvips
+so that many
+macro packages produced for use with
+.B dvips
+will work with
+.B dvipdfm.
+Dvipdfm understands its own specific
+.B \especial
+commands to allow access to PDF features
+such as annotations and bookmarks.
+For more details, consult the
+.I "Dvipdfm User's Manual,"
+which is distributed with
+.B dvipdfm.
+
+.SH OPTIONS
+
+.TP 5
+.B \-\^c
+Ignore color
+.BR \especials .
+The
+.B \-\^c
+toggles a flag that disables color
+.B \especial
+processing.
+Unless changed in the configuration file,
+that flag is off, and color
+.BR \especial "s"
+are interpreted normally.
+The
+.B \-\^c
+option may be used to produce a black and white document
+from a document containing color TeX
+.B \especial
+commands.
+
+.TP 5
+.B \-\^d
+Remove thumbnail images after including them.
+(See the
+.B \-\^t
+option for more information.)
+
+.TP 5
+.B \-\^e
+Toggle partial font embedding flag. If partial
+font embedding is off, embedded fonts are
+.I fully
+embedded.
+The default, if not changed in the configuration file,
+is to embed only those glyphs actually used in the document.
+
+.TP 5
+.B \-\^f map_file
+Set the name of the font map file to
+.IR map_file .
+The format of the font map file
+is documented in the
+.IR "Dvipdfm User's Manual" .
+
+.TP 5
+.B \-\^l
+Select landscape mode. In other words, exchange the
+.I x
+and
+.I y
+dimensions of the paper.
+
+.TP 5
+.B \-\^m " mag"
+Magnify the input document by
+.IR mag .
+
+.TP 5
+.B \-\^o " name"
+Generate PDF output file having the name
+.IR name .
+By default, the name of the output
+file is
+.IR file .pdf.
+
+.TP 5
+.B \-\^p " paper"
+Select the papersize by name (e.g.,
+.BR letter ", " legal ", " ledger ", " tabloid ", " a3 ", " a4 ", or " a5
+)
+
+.TP 5
+.B \-\^r " size"
+Set resolution of bitmapped fonts to
+.B size
+dots per inch. Bitmapped fonts are generated
+by the Kpathsea library, which uses MetaFont. Bitmapped
+fonts are included as type 3 fonts in the PDF output file.
+
+.TP 5
+.B \-\^s " page_specifications"
+Select the pages of the
+.SM DVI
+file to be converted.
+The
+.I page_specifications
+consists of a comma separated list of
+.I page_ranges:
+
+.EX
+.IR "page_specifications := page_specification" "[," page_specifications "]"
+.EE
+
+where
+
+.EX
+.IR "page_specification := single_page" | page_range
+
+.IR "page_range := " [ first_page ]\^\-\^[ last_page ]
+.EE
+
+An empty
+.I first_page
+is implied to be the first page of the
+.SM DVI
+file.
+An empty
+.I last_page
+is treated as the last page of the
+.SM DVI
+file.
+
+Examples:
+.RS
+.TP 5
+.B "\-\^s 1,3,5"
+includes pages 1, 3, and 5;
+.TP 5
+.B "\-\^s \-"
+includes all pages;
+.TP 5
+.B "\-\^s \-,\-"
+includes two copies of all pages in the
+.SM DVI
+file;
+and
+.TP 5
+.B "\-\^s 1\-10"
+includes the first ten pages of the
+.SM DVI
+file.
+.RE
+.TP 5
+.B \-\^t
+Search for thumbnail images of each page
+in the directory named by the
+.B TMPDIR
+environment variable.
+The thumbnail images must be named in a specific format.
+They must have the same base name
+as the
+.SM DVI
+file and they must have the page number as the extension
+to the file name. Dvipdfm does not
+generate the thumbnails itself, but it is distributed with a wrapper
+program named
+.B dvipdft
+that does so.
+
+.TP 5
+.B \-\^v
+Increase verbosity.
+Results of the
+.B \-\^v
+option are cumulative (e.g.,
+.B \-\^vv
+) increases the verbosity by two increments.
+
+.TP 5
+.B \-\^x x_offset
+Set the left margin to
+.IR x_offset .
+The default left margin is
+.BR 1.0in .
+The dimension may be specified in any units understood by TeX (e.g.,
+.BR bpt ", " pt ", " in ", " cm
+)
+
+.TP 5
+.B \-\^y y_offset
+Set the top margin to
+.IR y_offset .
+The default top margin is
+.BR 1.0in .
+The dimension may be specified in any units understood by TeX (e.g.,
+.BR bpt ", " pt ", " in ", " cm
+)
+
+.TP 5
+.B \-\^z compression_level
+Set the compression level to
+.IR compression_level .
+Compressions levels range from 0 (no compression) to
+9 (maximum compression) and correspond to the values understood by zlib.
+
+.SH ENVIRONMENT
+
+.B Dvipdfm
+uses the
+.B kpathsea
+library for locating the files that it opens. Hence,
+the environment variables documented in the
+.I Kpathsea library
+documentation influence
+.B dvipdfm.
+
+Dvipdfm also reads the following environment variables:
+
+.TP 5
+TMP
+The directory to search for thumbnail images of each page.
+
+.SH FILES
+The precise location of the following files is determined by the
+.I Kpathsea library
+configuration. The location may be determined by using kpsewhich, e.g.,
+.nf
+.B kpsewhich \-progname=dvipdfm \-format='other text files' config
+.fi
+
+.TP 5
+.I config
+Startup options
+
+.TP 5
+.I t1fonts.map
+The default font map file (this name may be changed in the config file).
+
+.TP 5
+.I *.tfm
+TeX font metrics
+
+.TP 5
+.I *.vf
+TeX virtual font files
+
+.TP 5
+.I *.pfb
+PostScript Type 1 font files
+
+.TP 5
+.I
+texmf.cnf
+The Kpathsea library configuration file.
+The location of this file may be found by typing
+.nf
+.B kpsewhich texmf.cnf
+.fi
+
+
+.SH "SEE ALSO"
+.BR tex "(1), " dvips "(1), " groff "(1), " grodvi "(1), " pic "(1), "
+and the
+.I "Kpathsea library"
+info documentation.
+
+.SH AUTHOR
+Mark A. Wicks <mwicks@kettering.edu>
+
diff --git a/Build/source/texk/dvipdfm/dvipdfm.c b/Build/source/texk/dvipdfm/dvipdfm.c
new file mode 100644
index 00000000000..4044a6e1223
--- /dev/null
+++ b/Build/source/texk/dvipdfm/dvipdfm.c
@@ -0,0 +1,649 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <ctype.h>
+#include "config.h"
+#include "system.h"
+#include "mem.h"
+#include "mfileio.h"
+#include "dvi.h"
+#include "pdfdoc.h"
+#include "pdfdev.h"
+#include "encodings.h"
+#include "type1.h"
+#include "ttf.h"
+#include "colorsp.h"
+#include "pdfspecial.h"
+#include "pdfparse.h"
+#include "vf.h"
+#include "pkfont.h"
+#include "thumbnail.h"
+#include "psimage.h"
+#include "tfm.h"
+
+struct rect
+{
+ double width;
+ double height;
+};
+typedef struct rect rect;
+
+struct
+{
+ char *s;
+ struct rect data;
+} paper_sizes[] = {
+ {"letter" , { 612.0, 792.0}},
+ {"legal" , { 612.0, 1008.0}},
+ {"ledger" , { 1224.0, 792.0}},
+ {"tabloid" , { 792.0, 1224.0}},
+ {"a5" , { 420.91, 595.27}},
+ {"a4" , { 595.27, 841.82}},
+ {"a3" , { 841.82, 1190.16}}};
+
+static rect get_paper_size (char *string)
+{
+ int i;
+ for (i=0; i<sizeof(paper_sizes)/sizeof(paper_sizes[0]); i++) {
+ if (!strcmp (string, paper_sizes[i].s))
+ break;
+ }
+ if (i == sizeof(paper_sizes)/sizeof(paper_sizes[0]))
+ ERROR ("Paper size is invalid");
+ return paper_sizes[i].data;
+}
+
+
+char *dvi_filename = NULL, *pdf_filename = NULL;
+static void set_default_pdf_filename(void)
+{
+ const char *dvi_base;
+#ifdef HAVE_XBASENAME
+ dvi_base = xbasename (dvi_filename);
+#else
+ dvi_base = basename (dvi_filename);
+#endif
+ if (strlen (dvi_base) < 5 || strncmp (".dvi", dvi_base+strlen(dvi_base)-4, 4))
+ {
+ pdf_filename = NEW (strlen(dvi_base)+5, char);
+ strcpy (pdf_filename, dvi_base);
+ strcat (pdf_filename, ".pdf");
+ } else
+ {
+ pdf_filename = NEW (strlen(dvi_base)+1, char);
+ strncpy (pdf_filename, dvi_base, strlen(dvi_base)-4);
+ strcpy (pdf_filename+strlen(dvi_base)-4, ".pdf");
+ }
+}
+static void usage (void)
+{
+ fprintf (stdout, "\n%s, version %s, Copyright (C) 1998, 1999 by Mark A. Wicks\n", PACKAGE, VERSION);
+ fprintf (stdout, "dvipdfm comes with ABSOLUTELY NO WARRANTY.\n");
+ fprintf (stdout, "This is free software, and you are welcome to redistribute it\n");
+ fprintf (stdout, "under certain conditions. Details are distributed with the software.\n");
+ fprintf (stdout, "\nUsage: dvipdfm [options] dvifile\n");
+ fprintf (stdout, "-c \tIgnore color specials (for B&W printing)\n");
+ fprintf (stdout, "-f filename\tSet font map file name [t1fonts.map]\n");
+ fprintf (stdout, "-o filename\tSet output file name [dvifile.pdf]\n");
+ fprintf (stdout, "-l \t\tLandscape mode\n");
+ fprintf (stdout, "-m number\tSet additional magnification\n");
+ fprintf (stdout, "-p papersize\tSet papersize (letter, legal,\n");
+ fprintf (stdout, " \tledger, tabloid, a4, or a3) [letter]\n");
+ fprintf (stdout, "-r resolution\tSet resolution (in DPI) for raster fonts [600]\n");
+ fprintf (stdout, "-s pages\tSelect page ranges (-)\n");
+ fprintf (stdout, "-t \tEmbed thumbnail images\n");
+ fprintf (stdout, "-d \tRemove thumbnail images when finished\n");
+ fprintf (stdout, "-x dimension\tSet horizontal offset [1.0in]\n");
+ fprintf (stdout, "-y dimension\tSet vertical offset [1.0in]\n");
+ fprintf (stdout, "-e \tDisable partial font embedding [default is enabled])\n");
+ fprintf (stdout, "-z number\tSet compression level (0-9) [default is 9])\n");
+ fprintf (stdout, "-v \tBe verbose\n");
+ fprintf (stdout, "-vv \tBe more verbose\n");
+ fprintf (stdout, "\nAll dimensions entered on the command line are \"true\" TeX dimensions.\n");
+ fprintf (stdout, "Argument of \"-s\" lists physical page ranges separated by commas, e.g., \"-s 1-3,5-6\"\n\n");
+ exit(1);
+}
+
+static double paper_width = 612.0, paper_height = 792.0;
+static char landscape_mode = 0;
+static char ignore_colors = 0;
+static double mag = 1.0, x_offset=72.0, y_offset=72.0;
+static int font_dpi = 600;
+static int really_quiet = 0;
+
+struct page_range
+{
+ unsigned int first, last;
+} *page_ranges = NULL;
+int max_page_ranges = 0, num_page_ranges = 0;
+
+void set_landscape_mode (void)
+{
+ dev_set_page_size (paper_height, paper_width);
+}
+
+#define pop_arg() {argv += 1; argc -= 1;}
+static void do_args (int argc, char *argv[])
+{
+ char *flag;
+ while (argc > 0 && *argv[0] == '-') {
+ for (flag=argv[0]+1; *flag != 0; flag++) {
+ switch (*flag) {
+ case 'D':
+ if (argc < 2) {
+ fprintf (stderr, "PS->PDF conversion command line template missing\n\n");
+ usage();
+ }
+ set_distiller_template(argv[1]);
+ pop_arg();
+ break;
+ case 'r':
+ if (argc < 2) {
+ fprintf (stderr, "\nResolution specification missing a number\n\n");
+ usage();
+ }
+ {
+ char *result, *end, *start = argv[1];
+ end = start + strlen(argv[1]);
+ result = parse_number (&start, end);
+ if (result != NULL && start == end) {
+ font_dpi = (int) atof (result);
+ }
+ else {
+ fprintf (stderr, "\nError in number following resolution specification\n\n");
+ usage();
+ }
+ if (result != NULL) {
+ RELEASE (result);
+ }
+ }
+ pop_arg();
+ break;
+ case 'm':
+ if (argc < 2) {
+ fprintf (stderr, "\nMagnification specification missing a number\n\n");
+ usage();
+ }
+ {
+ char *result, *end, *start = argv[1];
+ end = start + strlen(argv[1]);
+ result = parse_number (&start, end);
+ if (result != NULL && start == end) {
+ mag = atof (result);
+ }
+ else {
+ fprintf (stderr, "\nError in number following magnification specification\n\n");
+ usage();
+ }
+ if (result != NULL) {
+ RELEASE (result);
+ }
+ }
+ pop_arg();
+ break;
+ case 'g':
+ if (argc < 2) {
+ fprintf (stderr, "\nAnnotation \"grow\" specification missing a number\n\n");
+ usage();
+ }
+ {
+ char *result, *end, *start = argv[1];
+ end = start + strlen(argv[1]);
+ result = parse_number (&start, end);
+ if (result != NULL && start == end) {
+ pdf_special_set_grow (atof (result));
+ }
+ else {
+ fprintf (stderr, "\nError in number following magnification specification\n\n");
+ usage();
+ }
+ if (result != NULL) {
+ RELEASE (result);
+ }
+ }
+ pop_arg();
+ break;
+ case 'x':
+ if (argc < 2) {
+ fprintf (stderr, "\nX Offset specification missing a number\n\n");
+ usage();
+ }
+ {
+ char *result, *end, *start = argv[1];
+ double unit;
+ end = start + strlen(argv[1]);
+ result = parse_number (&start, end);
+ if (result != NULL) {
+ x_offset = atof (result);
+ }
+ else {
+ fprintf (stderr, "\nError in number following xoffset specification\n\n");
+ usage();
+ }
+ if (result != NULL) {
+ RELEASE (result);
+ }
+ unit = parse_one_unit(&start, end);
+ if (unit > 0.0) {
+ x_offset *= unit;
+ }
+ else {
+ fprintf (stderr, "\nError in dimension specification following xoffset\n\n");
+ usage();
+ }
+ }
+ pop_arg();
+ break;
+ case 'y':
+ if (argc < 2) {
+ fprintf (stderr, "\nY offset specification missing a number\n\n");
+ usage();
+ }
+ {
+ char *result, *end, *start = argv[1];
+ double unit;
+ end = start + strlen(argv[1]);
+ result = parse_number (&start, end);
+ if (result != NULL) {
+ y_offset = atof (result);
+ }
+ else {
+ fprintf (stderr, "\nError in number following yoffset specification\n\n");
+ usage();
+ }
+ if (result != NULL) {
+ RELEASE (result);
+ }
+ unit = parse_one_unit(&start, end);
+ if (unit > 0.0) {
+ y_offset *= unit;
+ }
+ else {
+ fprintf (stderr, "\nError in dimension specification following yoffset\n\n");
+ usage();
+ }
+ }
+ pop_arg();
+ break;
+ case 'o':
+ if (argc < 2)
+ ERROR ("Missing output file name");
+ pdf_filename = NEW (strlen(argv[1])+1,char);
+ strcpy (pdf_filename, argv[1]);
+ pop_arg();
+ break;
+ case 's':
+ {
+ char *result, *end, *start = argv[1];
+ if (argc < 2)
+ ERROR ("Missing page selection specification");
+ end = start + strlen (argv[1]);
+ while (start < end) {
+ /* Enlarge page range table if necessary */
+ if (num_page_ranges >= max_page_ranges) {
+ max_page_ranges += 4;
+ page_ranges = RENEW (page_ranges, max_page_ranges,
+ struct page_range);
+ }
+ skip_white (&start, end);
+ page_ranges[num_page_ranges].first = 0;
+ if ((result = parse_unsigned (&start, end))) {
+ page_ranges[num_page_ranges].first = atoi(result)-1;
+ page_ranges[num_page_ranges].last =
+ page_ranges[num_page_ranges].first;
+ RELEASE(result);
+ }
+ skip_white (&start, end);
+ if (*start == '-') {
+ start += 1;
+ page_ranges[num_page_ranges].last = UINT_MAX;
+ skip_white (&start, end);
+ if (start < end &&
+ ((result = parse_unsigned (&start, end)))) {
+ page_ranges[num_page_ranges].last = atoi(result)-1;
+ RELEASE (result);
+ }
+ }
+ num_page_ranges += 1;
+ skip_white (&start, end);
+ if (start < end && *start == ',') {
+ start += 1;
+ continue;
+ }
+ skip_white (&start, end);
+ if (start < end) {
+ fprintf (stderr, "Page selection? %s", start);
+ ERROR ("Bad page range specification");
+ }
+ }
+ pop_arg();
+ }
+ break;
+ case 't':
+ {
+#ifdef HAVE_LIBPNG
+ pdf_doc_enable_thumbnails ();
+#else
+ ERROR ("The thumbnail option requires libpng, which you apparently don't have.");
+#endif /* HAVE_LIBPNG */
+ }
+ break;
+ case 'd':
+ {
+#ifdef HAVE_LIBPNG
+ thumb_remove ();
+#else
+ ERROR ("The thumbnail option requires libpng, which you apparently don't have.");
+#endif /* HAVE_LIBPNG */
+ }
+ break;
+ case 'p':
+ {
+ struct rect paper_size;
+ if (argc < 2)
+ ERROR ("Missing paper size");
+ paper_size = get_paper_size (argv[1]);
+ paper_width = paper_size.width;
+ paper_height = paper_size.height;
+ pop_arg();
+ }
+ break;
+ case 'c':
+ ignore_colors = 1;
+ break;
+ case 'l':
+ landscape_mode = 1;
+ break;
+ case 'f':
+ dev_read_mapfile (argv[1]);
+ pop_arg();
+ break;
+ case 'e':
+ type1_disable_partial();
+ break;
+ case 'q':
+ really_quiet = 1;
+ break;
+ case 'v':
+ encoding_set_verbose();
+ dev_set_verbose();
+ dvi_set_verbose();
+ type1_set_verbose();
+ vf_set_verbose();
+ pk_set_verbose();
+ pdf_obj_set_verbose();
+ pdf_doc_set_verbose();
+ tfm_set_verbose();
+#ifdef HAVE_TTF_FORMATS
+ ttf_set_verbose();
+#endif
+ break;
+ case 'V':
+ {
+ unsigned level = 2;
+ if (isdigit (*(flag+1))) {
+ level = *(++flag) - '0';
+ } else {
+ char *result, *end, *start = argv[1];
+ if (argc < 2) {
+ fprintf (stderr, "\nVersion specification missing number (2 or 3)\n\n");
+ usage();
+ }
+ end = start + strlen(argv[1]);
+ result = parse_number (&start, end);
+ if (result != NULL && start == end) {
+ level = (int) atof (result);
+ }
+ else {
+ fprintf (stderr, "\nError in number following version specification\n\n");
+ usage();
+ }
+ if (result != NULL) {
+ RELEASE (result);
+ }
+ pop_arg();
+ }
+ if (level >= 2 && level <= 3) {
+ pdf_set_version(level);
+ } else {
+ fprintf (stderr, "\nNumber following version specification is out of range\n\n");
+ }
+ }
+ break;
+ case 'z':
+ {
+ int level = 9;
+#ifndef HAVE_ZLIB
+ fprintf (stderr, "\nYou don't have compression compiled in. Possibly libz wasn't found by configure.\nCompression specification will be ignored.\n\n");
+#endif /* HAVE_ZLIB */
+ if (isdigit (*(flag+1))) {
+ level = *(++flag) - '0';
+ } else {
+ char *result, *end, *start = argv[1];
+ if (argc < 2) {
+ fprintf (stderr, "\nCompression specification missing number for level\n\n");
+ usage();
+ }
+ end = start + strlen(argv[1]);
+ result = parse_number (&start, end);
+ if (result != NULL && start == end) {
+ level = (int) atof (result);
+ }
+ else {
+ fprintf (stderr, "\nError in number following compression specification\n\n");
+ usage();
+ }
+ if (result != NULL) {
+ RELEASE (result);
+ }
+ pop_arg();
+ }
+ if (level >= 0 && level <= 9) {
+ pdf_obj_set_compression(level);
+ } else {
+ fprintf (stderr, "\nNumber following compression specification is out of range\n\n");
+ }
+ }
+ break;
+ default:
+ usage();
+ }
+ }
+ argc -= 1 ;
+ argv += 1;
+ }
+ if (argc > 1) {
+ fprintf (stderr, "\nMultiple dvi filenames?\n\n");
+ usage();
+ }
+ /* The only legitimate way to have argc == 0 here is
+ is do_args was called from config file. In that case, there is
+ no dvi file name. Check for that case */
+ if (argc > 0) {
+ if (strncmp (".dvi", argv[0]+strlen(argv[0])-4, 4)) {
+ dvi_filename = NEW (strlen (argv[0])+1+4, char);
+ strcpy (dvi_filename, argv[0]);
+ strcat (dvi_filename, ".dvi");
+ }
+ else {
+ dvi_filename = NEW (strlen (argv[0])+1, char);
+ strcpy (dvi_filename, argv[0]);
+ }
+ }
+}
+
+
+static void cleanup(void)
+{
+ RELEASE (dvi_filename);
+ RELEASE (pdf_filename);
+ if (page_ranges)
+ RELEASE (page_ranges);
+ psimage_close();
+}
+
+static char *config_file_name = "config";
+static void read_config_file (void)
+{
+ char *full_config_name, *start, *end;
+ char *argv[2], *option;
+ FILE *config_file;
+
+ if ((full_config_name = kpse_find_file (config_file_name,
+ kpse_program_text_format,
+ true)) == NULL) {
+ return;
+ }
+ if (!(config_file = MFOPEN (full_config_name, FOPEN_R_MODE))) {
+ fprintf (stderr, "\nError opening configuration file. Continuing with defaults.\n");
+ return;
+ }
+ while ((start = mfgets (work_buffer, WORK_BUFFER_SIZE,
+ config_file))) {
+ int argc = 0;
+ end = work_buffer+strlen(work_buffer);
+ skip_white (&start, end);
+ if (start >= end)
+ continue;
+ /* Build up an argument list as if it were passed on the command
+ line */
+ if ((option = parse_ident (&start, end))) {
+ argc = 1;
+ argv[0] = NEW (strlen(option)+2, char);
+ strcpy (argv[0]+1, option);
+ RELEASE (option);
+ *argv[0] = '-';
+ skip_white (&start, end);
+ if (start < end) {
+ argc += 1;
+ if (*start == '"') {
+ argv[1] = parse_c_string (&start, end);
+ }
+ else
+ argv[1] = parse_ident (&start, end);
+ }
+ }
+ do_args (argc, argv);
+ while (argc > 0) {
+ RELEASE (argv[--argc]);
+ }
+ }
+}
+
+void error_cleanup (void)
+{
+ pdf_error_cleanup();
+ remove (pdf_filename);
+ fprintf (stderr, "\nOutput file removed.\n");
+}
+
+int CDECL main (int argc, char *argv[])
+{
+ int i;
+ int at_least_one_page = 0;
+ if (argc < 2) {
+ fprintf (stderr, "\nNo dvi filename specified.\n\n");
+ usage();
+ return 1;
+ }
+#ifdef KPATHSEA
+ kpse_set_program_name (argv[0], NULL);
+#endif
+
+ argv+=1;
+ argc-=1;
+
+ /* Process config file, if any */
+ read_config_file();
+
+ do_args (argc, argv);
+
+#ifdef KPATHSEA
+ kpse_init_prog ("", font_dpi, NULL, NULL);
+ pk_set_dpi (font_dpi);
+ kpse_set_program_enabled (kpse_pk_format, true, kpse_src_texmf_cnf);
+#endif
+
+ if (!dvi_filename) {
+ fprintf (stderr, "\nNo dvi filename specified.\n\n");
+ usage();
+ }
+
+ /* Check for ".dvi" at end of argument name */
+ if (pdf_filename == NULL)
+ set_default_pdf_filename();
+
+ if (!really_quiet)
+ fprintf (stdout, "\n%s -> %s\n", dvi_filename, pdf_filename);
+
+ dvi_init (dvi_filename, pdf_filename, mag, x_offset, y_offset);
+
+ if (ignore_colors) {
+ color_special_ignore_colors();
+ pdf_special_ignore_colors();
+ }
+
+ if (landscape_mode)
+ dev_set_page_size (paper_height, paper_width);
+ else
+ dev_set_page_size (paper_width, paper_height);
+
+ if ((num_page_ranges))
+ for (i=0; i<num_page_ranges; i++) {
+ unsigned j;
+ if (page_ranges[i].first <= page_ranges[i].last)
+ for (j=page_ranges[i].first; j<=page_ranges[i].last && j<dvi_npages(); j++) {
+ fprintf (stderr, "[%d", j+1);
+ dvi_do_page (j);
+ at_least_one_page = 1;
+ fprintf (stderr, "]");
+ }
+ else
+ for (j=page_ranges[i].first;
+ j>=page_ranges[i].last && j<dvi_npages(); j--) {
+ fprintf (stderr, "[%d", j+1);
+ dvi_do_page (j);
+ at_least_one_page = 1;
+ fprintf (stderr, "]");
+ }
+ }
+ if (!at_least_one_page && num_page_ranges) {
+ fprintf (stderr, "No pages fall in range!\nFalling back to entire document.\n");
+ }
+ if (!at_least_one_page) /* Fall back to entire document */
+ for (i=0; i<dvi_npages(); i++) {
+ fprintf (stderr, "[%d", i+1);
+ dvi_do_page (i);
+ fprintf (stderr, "]");
+ }
+ dvi_close();
+ fprintf (stderr, "\n");
+ cleanup();
+ return 0;
+}
+
diff --git a/Build/source/texk/dvipdfm/dvipdfm.h b/Build/source/texk/dvipdfm/dvipdfm.h
new file mode 100644
index 00000000000..7aa012d4387
--- /dev/null
+++ b/Build/source/texk/dvipdfm/dvipdfm.h
@@ -0,0 +1,33 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#ifndef DVIDPFM_H
+#define DVIPDFM_H
+
+extern void set_landscape_mode (void);
+
+#endif /* DVIPDFM_H */
+
+
+
diff --git a/Build/source/texk/dvipdfm/dvipdfm.rc b/Build/source/texk/dvipdfm/dvipdfm.rc
new file mode 100644
index 00000000000..12a878f7bc4
--- /dev/null
+++ b/Build/source/texk/dvipdfm/dvipdfm.rc
@@ -0,0 +1,34 @@
+/* dvipdfm.rc: dvipdfm resources -*- C++ -*-
+
+ Copyright (C) 1996-2003 Fabrice Popineau <fabrice.popineau@supelec.fr>
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ This file is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this file; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#include <texlive-version.h>
+
+#define VER_FILEVERSION TEXLIVE_MAJOR_VERSION,TEXLIVE_MINOR_VERSION,TEXLIVE_BETA_NUMBER,TEXLIVE_ALPHA_NUMBER
+#define VER_FILEVERSION_STR TEXLIVE_PRODUCTVERSION_STR " dvipdfm(k) 0.13.2c"
+
+#define VER_INTERNALNAME_STR "dvipdfm"
+#define VER_ORIGINALFILENAME_STR "dvipdfm.exe"
+
+#define VER_LEGALCOPYRIGHT_STR "Copyright (C) 1998, 99 Mark Wicks"
+
+#define VER_FILEDESCRIPTION_STR "DVI-to-PDF Converter"
+
+#include <texlive.version>
+
+/* dvipdfm.rc ends here */
diff --git a/Build/source/texk/dvipdfm/dvipdft b/Build/source/texk/dvipdfm/dvipdft
new file mode 100755
index 00000000000..db53bd2f5a0
--- /dev/null
+++ b/Build/source/texk/dvipdfm/dvipdft
@@ -0,0 +1,130 @@
+#!/bin/sh
+
+#
+# dvipdft, completely rewtitten by Thomas Esser for teTeX after an
+# original script by Mark A. Wicks
+#
+# Thomas Esser. Public Domain.
+#
+
+# This script makes a first (fast) run with dvipdfm, then calls gs on
+# the resulting pdf file to get the thumbnails and finally calls dvipdfm.
+
+test -f /bin/sh5 && test -z "$RUNNING_SH5" \
+ && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \
+ && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; }
+unset RUNNING_SH5
+
+test -f /bin/bsh && test -z "$RUNNING_BSH" \
+ && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \
+ && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; }
+unset RUNNING_BSH
+
+# hack around a bug in zsh:
+test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"'
+
+progname=dvipdft
+version=1111942378 # seconds since `00:00:00 1970-01-01 UTC'
+ # date '+%s' (with GNU date)
+
+help="Usage: $progname [options] dvifile
+ $progname --help
+ $progname --version"
+
+tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/$progname.$$
+
+quoteit()
+{
+ echo "x$1" | sed "s@.@@; s@'@'\\\\''@; s@^@'@; s@\$@'@"
+}
+
+# process args 1 to (n-1) and scan for a -o argument keep a properly
+# quoted backup of the options, so that they can be restored later
+unset s outfile
+while test $# -gt 1; do
+ case $1 in
+ -o) outfile=$2;;
+ esac
+ s="$s${s+ }"`quoteit "$1"`
+ shift
+done
+
+# check for last argument
+case $1 in
+ --help)
+ echo "$help"
+ exit 0
+ ;;
+ --version)
+ echo "$progname version $version by Thomas Esser"
+ exit 0
+ ;;
+ "")
+ echo "$help"
+ exit 1
+ ;;
+esac
+
+# args 1 to (n-1) are gone, last one must be the dvifile
+dvifile=$1
+
+# outfile comes from -o argument, else it is derived from the input file
+test -n "$outfile" \
+ || outfile=`echo "$dvifile" | sed 's@.*/@@; s@\.dvi$@@; s@$@.pdf@'`
+
+# outBase is part of the thumbname files just as dvipdfm expects them:
+outBase=`echo "$outfile" | sed 's@\.pdf$@@'`
+
+# restore args 1 to (n-1):
+eval set x "$s"; shift
+
+# Run dvipdfm with the fastest options for the first pass
+echo "$progname: running dvipdfm $@ -e -z0 $dvifile" >&2
+dvipdfm ${1+"$@"} -e -z0 "$dvifile" || {
+ echo "$progname: dvipdfm failed." >&2
+ exit 1
+}
+
+# before we create the tmpdir, set trap for cleanup
+trap '
+ rm -rf $tmpdir
+ exit 1
+' 1 2 3 7 13 15
+
+mkdir "$tmpdir" || {
+ echo "$progname: failed to create temp directory." >&2
+ exit 1
+}
+
+# if outBase contains a /, we might need to create a directory
+case $outBase in
+ */*)
+ fq=`echo "$tmpdir/$outBase" | sed 's@//@/@g; s@/[^/]*$@@'`
+ test -d "$fq" || mkdir -p "$fq" || {
+ echo "$progname: failed to create temp thumbnail directory." >&2
+ rm -rf $tmpdir
+ exit 1
+ }
+ ;;
+esac
+
+# run gs
+echo "$progname: running gs" >&2
+gs -r10 -dNOPAUSE -dBATCH -sDEVICE=png256 \
+ -sOutputFile="$tmpdir/$outBase.%d" "$outfile" || {
+ echo "$progname: gs failed." >&2
+ rm -rf $tmpdir
+ exit 1
+}
+
+# run dvipdfm with the users specified options for the last pass
+echo "$progname: running dvipdfm -dt $@ $dvifile" >&2
+TMP=$tmpdir dvipdfm -dt ${1+"$@"} "$dvifile" || {
+ echo "$progname: dvipdfm failed." >&2
+ rm -rf $tmpdir
+ exit 1
+}
+
+# nothing failed, so cleanup and report success to caller
+rm -rf $tmpdir
+exit 0
diff --git a/Build/source/texk/dvipdfm/dvipdft.1 b/Build/source/texk/dvipdfm/dvipdft.1
new file mode 100644
index 00000000000..803db249e4e
--- /dev/null
+++ b/Build/source/texk/dvipdfm/dvipdft.1
@@ -0,0 +1,36 @@
+.TH "dvipdft" "1" "May 2004" "teTeX" "teTeX"
+.PP
+.SH "NAME"
+dvipdft \- create thumbnail images for use with dvipdfm
+.PP
+.SH "SYNOPSIS"
+.PP
+\fBdvipdft\fP [ \fI DVIPDFM-OPTIONS\fP \&.\&.\&. ] \fI filename.dvi\fP
+.PP
+.SH "DESCRIPTION"
+.PP
+\fBdvipdft\fP creates thumbnail pictures of the pages in your file
+and subsequently runs dvipdfm to create a PDF file with these
+thumbnails.
+.PP
+.SH "OPTIONS"
+.HP
+All options are simply handed on to dvipdfm
+.HP
+.SH "SEE ALSO"
+.IP
+\fBdvipdfm\fP(1)
+.PP
+.SH "BUGS"
+.PP
+None known\&.
+.PP
+.SH "AUTHOR"
+.PP
+\fBdvipdft\fP was written by Mark A. Wicks and Thomas Esser.
+.PP
+This manual page was written by Frank Küster <frank@kuesterei\&.ch>,
+for the Debian GNU/Linux system\&. It may be used by others without
+contacting the author\&. Any mistakes or omissions in the manual page
+are my fault; inquiries about or corrections to this manual page
+should be directed to me (and not to the primary author)\&.
diff --git a/Build/source/texk/dvipdfm/dvipdft.rc b/Build/source/texk/dvipdfm/dvipdft.rc
new file mode 100644
index 00000000000..04ac0f84484
--- /dev/null
+++ b/Build/source/texk/dvipdfm/dvipdft.rc
@@ -0,0 +1,34 @@
+/* dvipdft.rc: dvipdft resources -*- C++ -*-
+
+ Copyright (C) 1996-2003 Fabrice Popineau <fabrice.popineau@supelec.fr>
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ This file is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this file; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#include <texlive-version.h>
+
+#define VER_FILEVERSION TEXLIVE_MAJOR_VERSION,TEXLIVE_MINOR_VERSION,TEXLIVE_BETA_NUMBER,TEXLIVE_ALPHA_NUMBER
+#define VER_FILEVERSION_STR TEXLIVE_PRODUCTVERSION_STR " dvipdft(k) 0.13.1c"
+
+#define VER_INTERNALNAME_STR "dvipdft"
+#define VER_ORIGINALFILENAME_STR "dvipdft.exe"
+
+#define VER_LEGALCOPYRIGHT_STRMark "Copyright (C) 2000-2002 Christian Schenk"
+
+#define VER_FILEDESCRIPTION_STR "DVI-to-PDF Thumbnail Converter"
+
+#include <texlive.version>
+
+/* dvipdft.rc ends here */
diff --git a/Build/source/texk/dvipdfm/ebb.1 b/Build/source/texk/dvipdfm/ebb.1
new file mode 100644
index 00000000000..1a44ed97e20
--- /dev/null
+++ b/Build/source/texk/dvipdfm/ebb.1
@@ -0,0 +1,34 @@
+.TH "ebb" "1" "May 2004" "teTeX" "teTeX"
+.PP
+.SH "NAME"
+ebb \- extract a bounding box from JPEG, PNG, and PDF files
+.PP
+.SH "SYNOPSIS"
+.PP
+\fBebb\fP [ \fI -v\fP | \fI-b\fP ] \fI graphic_file\fP
+.PP
+.SH "DESCRIPTION"
+.PP
+\fBebb\fP extracts the bounding box from JPEG, PNG, and PDF files
+(with lower- or uppercase extensions) and writes it into a file with
+the extension \fB.bb\fP, together with some header information. These
+files can then be used by \fBdvipdfm\fP or other programs.
+.PP
+.SH "OPTIONS"
+.HP
+\fB\-v\fR : be verbose
+.HP
+\fB\-b\fR : Write .bb file in binary mode (has no effect on Linux and
+other systems conforming to POSIX).
+.HP
+.PP
+.SH "AUTHOR"
+.PP
+\fBebb\fP was written by Mark A. Wicks.
+.PP
+This manual page was written by Frank Küster <frank@kuesterei\&.ch>,
+for the Debian GNU/Linux system\&. It may be used and modified by
+others without contacting the author\&. Any mistakes or omissions in
+the manual page are my fault; inquiries about or corrections to this
+manual page should be directed to me (and not to the primary
+author)\&.
diff --git a/Build/source/texk/dvipdfm/ebb.c b/Build/source/texk/dvipdfm/ebb.c
new file mode 100644
index 00000000000..6cc3f32a054
--- /dev/null
+++ b/Build/source/texk/dvipdfm/ebb.c
@@ -0,0 +1,327 @@
+/* $Header$
+
+ This is ebb, a bounding box extraction program.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+#include <stdio.h>
+#include <time.h>
+#include <string.h>
+#include "system.h"
+#include "mem.h"
+#include "mfileio.h"
+#include "numbers.h"
+#include "pdfobj.h"
+#include "jpeg.h"
+#include "pdfparse.h"
+
+#include "config.h"
+
+#ifdef HAVE_LIBPNG
+#include "pngimage.h"
+#include <png.h>
+#endif
+
+#define EBB_PROGRAM "ebb"
+#define EBB_VERSION "Version 0.5.2"
+
+static void usage (void)
+{
+ fprintf (stderr, "%s, version %s, Copyright (C) 1998, 1999 by Mark A. Wicks\n",
+ EBB_PROGRAM, EBB_VERSION);
+ fprintf (stderr, "ebb comes with ABSOLUTELY NO WARRANTY.\n");
+ fprintf (stderr, "This is free software, and you are welcome to redistribute it\n");
+ fprintf (stderr, "under certain conditions. Details are distributed with the software.\n");
+ fprintf (stderr, "\nUsage: ebb [-v] [-b] [files]\n");
+ fprintf (stderr, "\t-b\t\tWrite .bb file in binary mode\n");
+ fprintf (stderr, "\t-v\t\tVerbose\n");
+ exit(1);
+}
+
+static char verbose = 0;
+
+static void do_time(FILE *file)
+{
+ time_t current_time;
+ struct tm *bd_time;
+ time(&current_time);
+ bd_time = localtime(&current_time);
+ fprintf (file, "%%%%CreationDate: %s\n", asctime (bd_time));
+}
+
+char *extensions[] = {
+ ".jpeg", ".JPEG", ".jpg", ".JPG", ".pdf", ".PDF", ".png", ".PNG"
+};
+
+static char *make_bb_filename (const char *name)
+{
+ int i;
+ char *result;
+#ifdef HAVE_XBASENAME
+ name = xbasename (name);
+#else
+ name = basename (name);
+#endif
+ for (i=0; i<sizeof(extensions)/sizeof(extensions[0]); i++) {
+ if (strlen (extensions[i]) < strlen(name) &&
+ !strncmp (name+strlen(name)-strlen(extensions[i]),
+ extensions[i], strlen(extensions[i])))
+ break;
+ }
+ if (i == sizeof(extensions)/sizeof(extensions[0])) {
+ fprintf (stderr,
+ "ebb: Warning: %s: Filename does not end in a recognizeable extension.\n",
+ name);
+ result = NEW (strlen(name)+3, char);
+ strcpy (result, name);
+ }
+ else { /* Remove extension */
+ result = NEW (strlen(name)+3-strlen(extensions[i])+1, char);
+ strncpy (result, name, strlen(name)-strlen(extensions[i]));
+ result[strlen(name)-strlen(extensions[i])] = 0;
+ }
+ strcat (result, ".bb");
+ return result;
+}
+
+static char *bb_file_mode = FOPEN_W_MODE;
+
+static void write_bb (char *filename, int bbllx, int bblly, int bburx,
+ int bbury)
+{
+ char *bbfilename;
+ FILE *bbfile;
+ if (verbose)
+ fprintf (stderr, "okay\n");
+ bbfilename = make_bb_filename (filename);
+ if ((bbfile = MFOPEN (bbfilename, bb_file_mode)) == NULL) {
+ fprintf (stderr, "Unable to open output file: %s\n", bbfilename);
+ return;
+ }
+ if (verbose) {
+ fprintf (stderr, "Writing to %s: ", bbfilename);
+ fprintf (stderr, "Bounding box: %d %d %d %d\n", bbllx, bblly,
+ bburx, bbury);
+ }
+ fprintf (bbfile, "%%%%Title: %s\n", filename);
+ fprintf (bbfile, "%%%%Creator: %s %s\n", EBB_PROGRAM, EBB_VERSION);
+ fprintf (bbfile, "%%%%BoundingBox: %d %d %d %d\n",
+ bbllx, bblly, bburx, bbury);
+ do_time(bbfile);
+ RELEASE (bbfilename);
+ MFCLOSE (bbfile);
+ return;
+}
+
+
+#define PIX2PT (72.0/100.0)
+void do_jpeg (FILE *file, char *filename)
+{
+ struct jpeg *jpeg;
+ if (verbose) {
+ fprintf (stderr, "%s looks like a JPEG file...", filename);
+ }
+ jpeg = NEW (1, struct jpeg);
+ jpeg -> file = file;
+ if (!jpeg_headers (jpeg)) {
+ fprintf (stderr, "\n%s: Corrupt JPEG file?\n", filename);
+ MFCLOSE (file);
+ RELEASE (jpeg);
+ return;
+ }
+ write_bb (filename, 0, 0,
+ ROUND(jpeg -> width * PIX2PT,1.0),
+ ROUND(jpeg -> height * PIX2PT,1.0));
+ RELEASE (jpeg);
+ return;
+}
+#ifdef HAVE_LIBPNG
+void do_png (FILE *file, char *filename)
+{
+ png_structp png_ptr;
+ png_infop info_ptr;
+ unsigned long width, height;
+ rewind (file);
+ if (verbose) {
+ fprintf (stderr, "%s looks like a PNG file...", filename);
+ }
+ if (!(png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
+ NULL, NULL, NULL)) ||
+ !(info_ptr = png_create_info_struct (png_ptr))) {
+ fprintf (stderr, "\n\n%s: Corrupt PNG file?\n", filename);
+ if (png_ptr)
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
+ MFCLOSE (file);
+ return;
+ }
+ png_init_io (png_ptr, file);
+ /* Read PNG header */
+ png_read_info (png_ptr, info_ptr);
+ width = png_get_image_width(png_ptr, info_ptr);
+ height = png_get_image_height(png_ptr, info_ptr);
+ write_bb (filename, 0, 0,
+ ROUND(width * PIX2PT,1.0),
+ ROUND(height * PIX2PT,1.0));
+ if (info_ptr)
+ png_destroy_info_struct(png_ptr, &info_ptr);
+ if (png_ptr)
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
+ return;
+}
+#endif /* HAVE_LIBPNG */
+
+void do_pdf (FILE *file, char *filename)
+{
+ pdf_obj *trailer, *catalog, *page_tree, *media_box, *crop_box;
+ pdf_obj *kids_ref, *kids, *tmp1;
+ if (verbose) {
+ fprintf (stderr, "%s looks like a PDF file...", filename);
+ }
+ if ((trailer = pdf_open (file)) == NULL) {
+ fprintf (stderr, "%s: Corrupt PDF file?\n", filename);
+ return;
+ };
+ if ((catalog = pdf_deref_obj(pdf_lookup_dict (trailer,"Root"))) ==
+ NULL) {
+ fprintf (stderr, "\nCatalog isn't where I expect it.\n");
+ return;
+ }
+ /* Got catalog, so done with trailer */
+ pdf_release_obj (trailer);
+ /* Lookup page tree in catalog */
+ page_tree = pdf_deref_obj (pdf_lookup_dict (catalog, "Pages"));
+ pdf_release_obj (catalog);
+ /* Media box can be inherited so start looking for it now */
+ media_box = pdf_deref_obj (pdf_lookup_dict (page_tree, "MediaBox"));
+ crop_box = pdf_deref_obj (pdf_lookup_dict (page_tree, "CropBox"));
+ while ((kids_ref = pdf_lookup_dict (page_tree, "Kids")) != NULL) {
+ kids = pdf_deref_obj (kids_ref);
+ pdf_release_obj (page_tree);
+ page_tree = pdf_deref_obj (pdf_get_array(kids, 0));
+ pdf_release_obj (kids);
+ /* Replace MediaBox if it's here */
+ tmp1 = pdf_deref_obj(pdf_lookup_dict (page_tree, "MediaBox"));
+ if (tmp1 && media_box)
+ pdf_release_obj (media_box);
+ if (tmp1)
+ media_box = tmp1;
+ /* Likewise for CropBox */
+ tmp1 = pdf_deref_obj(pdf_lookup_dict (page_tree, "CropBox"));
+ if (tmp1 && crop_box)
+ pdf_release_obj (crop_box);
+ if (tmp1)
+ crop_box = tmp1;
+ }
+ /* At this point, we should have the media box for the first page */
+ {
+ pdf_obj *bbllx, *bblly, *bburx, *bbury;
+ if (crop_box) {
+ pdf_release_obj (media_box);
+ media_box = crop_box;
+ crop_box = NULL;
+ }
+ if ((bbllx = pdf_get_array (media_box, 0)) == NULL ||
+ (bblly = pdf_get_array (media_box, 1)) == NULL ||
+ (bburx = pdf_get_array (media_box, 2)) == NULL ||
+ (bbury = pdf_get_array (media_box, 3)) == NULL) {
+ fprintf (stderr, "Invalid mediabox\n");
+ } else
+ write_bb (filename,
+ (int) pdf_number_value (bbllx), (int) pdf_number_value (bblly),
+ (int) pdf_number_value (bburx), (int) pdf_number_value (bbury));
+ }
+ pdf_release_obj (media_box);
+ pdf_release_obj (page_tree);
+ pdf_close();
+}
+
+FILE *inputfile;
+
+int main (int argc, char *argv[])
+{
+ kpse_set_program_name (argv[0], NULL);
+ argc -= 1;
+ argv += 1;
+ if (argc == 0)
+ usage();
+ while (argc > 0 && *argv[0] == '-') {
+ switch (*(argv[0]+1)) {
+ case 'b':
+ bb_file_mode = FOPEN_WBIN_MODE;
+ case 'v':
+ verbose = 1;
+ argc -= 1;
+ argv += 1;
+ break;
+ case 'h':
+ usage();
+ argc -= 1;
+ argv += 1;
+ break;
+ default:
+ usage();
+ }
+ }
+ for (; argc > 0; argc--, argv++) {
+ char *kpse_file_name;
+ if (!(kpse_file_name = kpse_find_pict(argv[0])) ||
+ (inputfile = MFOPEN (kpse_file_name, FOPEN_RBIN_MODE)) == NULL) {
+ fprintf (stderr, "Can't find file (%s)...skipping\n", argv[0]);
+ continue;
+ }
+ if (check_for_jpeg (inputfile)) {
+ do_jpeg(inputfile, kpse_file_name);
+ MFCLOSE (inputfile);
+ continue;
+ }
+ if (check_for_pdf (inputfile)) {
+ do_pdf(inputfile, kpse_file_name);
+ MFCLOSE (inputfile);
+ continue;
+ }
+#ifdef HAVE_LIBPNG
+ if (check_for_png (inputfile)) {
+ do_png(inputfile, kpse_file_name);
+ MFCLOSE (inputfile);
+ continue;
+ }
+#endif /* HAVE_LIBPNG */
+ fprintf (stderr, "Can't handle file type for file named %s\n",
+ argv[0]);
+ }
+ return 0;
+}
+
+/* The following is here to prevent a link error. Other routines
+ that get linked with ebb call this, but it isn't actually needed
+ for ebb */
+
+pdf_obj *get_reference (char **start, char *end)
+{
+ fprintf (stderr, "get_reference(): This should never have been called\n");
+ return NULL;
+}
+
+void error_cleanup(void)
+{
+ /* For now, this is a do nothing routine, but the stub is required
+ by error.h */
+ return;
+}
diff --git a/Build/source/texk/dvipdfm/ebb.rc b/Build/source/texk/dvipdfm/ebb.rc
new file mode 100644
index 00000000000..75d2eaa33e0
--- /dev/null
+++ b/Build/source/texk/dvipdfm/ebb.rc
@@ -0,0 +1,36 @@
+/* ebb.rc: ebb resources -*- C++ -*-
+
+ Copyright (C) 1996-2003 Fabrice Popineau <fabrice.popineau@supelec.fr>
+
+ This file is part of dvipdfm.
+
+ dvipdfm is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ dvipdfm is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with dvipdfm; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#include <texlive-version.h>
+
+#define VER_FILEVERSION TEXLIVE_MAJOR_VERSION,TEXLIVE_MINOR_VERSION,TEXLIVE_BETA_NUMBER,TEXLIVE_ALPHA_NUMBER
+#define VER_FILEVERSION_STR TEXLIVE_PRODUCTVERSION_STR " ebb 0.5.2"
+
+#define VER_INTERNALNAME_STR "ebb"
+#define VER_ORIGINALFILENAME_STR "ebb.exe"
+
+#define VER_LEGALCOPYRIGHT_STRMark "Copyright (C) 1998, 99 Mark Wicks"
+
+#define VER_FILEDESCRIPTION_STR "Bounding Box Extractor"
+
+#include <texlive.version>
+
+/* ebb.rc ends here */
diff --git a/Build/source/texk/dvipdfm/encodings.c b/Build/source/texk/dvipdfm/encodings.c
new file mode 100755
index 00000000000..aece0f785dc
--- /dev/null
+++ b/Build/source/texk/dvipdfm/encodings.c
@@ -0,0 +1,224 @@
+
+#include <stdio.h>
+#include "pdflimits.h"
+#include "pdfobj.h"
+#include "mem.h"
+#include "error.h"
+#include "mfileio.h"
+#include "pdfparse.h"
+#include "encodings.h"
+
+
+static unsigned char verbose = 0;
+
+void encoding_set_verbose(void)
+{
+ if (verbose < 255) {
+ verbose += 1;
+ }
+}
+
+struct encoding {
+ char *enc_name;
+ /* The following array isn't very efficient. It is constructed
+ by peeling the names from the encoding object. It makes
+ it easier to construct an array in this format when the
+ encoding must be obtained directly from the PFB file */
+ char *glyphs[256];
+ pdf_obj *encoding_ref;
+} *encodings;
+int num_encodings = 0, max_encodings=0;
+
+#include "winansi.h"
+
+pdf_obj *find_encoding_differences (pdf_obj *encoding)
+{
+ char filling = 0;
+ int i;
+ pdf_obj *result = pdf_new_array ();
+ pdf_obj *tmp;
+ for (i=0; i<256; i++) {
+ tmp = pdf_get_array (encoding, i);
+ if (tmp == NULL || tmp -> type != PDF_NAME) {
+ ERROR ("Encoding file may be incorrect\n");
+ }
+ if (!strcmp (winansi_encoding[i],
+ pdf_name_value(tmp)))
+ filling = 0;
+ else{
+ if (!filling)
+ pdf_add_array (result, pdf_new_number (i));
+ filling = 1;
+ pdf_add_array (result, pdf_link_obj(tmp));
+ }
+ }
+ return result;
+}
+
+pdf_obj *make_differences_encoding (pdf_obj *encoding)
+{
+ int i;
+ int skipping = 1;
+ pdf_obj *tmp, *result = pdf_new_array ();
+ for (i=0; i<256; i++) {
+ tmp = pdf_get_array (encoding, i);
+ if (tmp && tmp -> type == PDF_NAME) {
+ if (strcmp (".notdef", pdf_name_value (tmp))) { /* If not
+ .notdef */
+ if (skipping) {
+ pdf_add_array (result, pdf_new_number (i));
+ }
+ pdf_add_array (result, pdf_link_obj(tmp));
+ skipping = 0;
+ } else {
+ skipping = 1;
+ }
+ } else {
+ ERROR ("Encoding file may be incorrect\n");
+ }
+ }
+ return result;
+}
+
+static void save_glyphs (char **glyph, pdf_obj *encoding)
+{
+ int i;
+ char *glyph_name;
+ for (i=0; i<256; i++) {
+ glyph_name = pdf_string_value (pdf_get_array(encoding, i));
+ glyph[i] = NEW (strlen(glyph_name)+1, char);
+ strcpy (glyph[i], glyph_name);
+ }
+}
+
+int get_encoding (const char *enc_name)
+{
+ FILE *encfile = NULL;
+ char *full_enc_filename, *tmp;
+ pdf_obj *result, *result_ref;
+ long filesize;
+ int i;
+ /* See if we already have this saved */
+ for (i=0; i<num_encodings; i++)
+ if (!strcmp (enc_name, encodings[i].enc_name))
+ return i;
+ /* Guess not.. */
+ /* Try base name before adding .enc. Someday maybe kpse will do
+ this */
+ strcpy (tmp = NEW (strlen(enc_name)+5, char), enc_name);
+ strcat (tmp, ".enc");
+ if ((full_enc_filename = kpse_find_file (enc_name,
+ kpse_enc_format,
+ 1)) == NULL &&
+ (full_enc_filename = kpse_find_file (enc_name,
+ kpse_program_text_format,
+ 1)) == NULL &&
+ (full_enc_filename = kpse_find_file (tmp,
+ kpse_enc_format,
+ 1)) == NULL &&
+ (full_enc_filename = kpse_find_file (tmp,
+ kpse_program_text_format,
+ 1)) == NULL) {
+ sprintf (work_buffer, "Can't find encoding file: %s", enc_name) ;
+ ERROR (work_buffer);
+ }
+ RELEASE (tmp);
+ if ((encfile = MFOPEN (full_enc_filename, FOPEN_R_MODE)) == NULL ||
+ (filesize = file_size (encfile)) == 0) {
+ sprintf (work_buffer, "Error opening encoding file: %s", enc_name) ;
+ ERROR (work_buffer);
+ }
+ if (verbose == 1)
+ fprintf (stderr, "(ENC:%s", enc_name);
+ if (verbose > 1)
+ fprintf (stderr, "(ENC:%s", full_enc_filename);
+ { /* Got one and opened it */
+ char *buffer, *start, *end, *junk_ident;
+ pdf_obj *junk_obj, *encoding, *differences;
+ buffer = NEW (filesize, char);
+ fread (buffer, sizeof (char), filesize, encfile);
+ MFCLOSE (encfile);
+ start = buffer;
+ end = buffer + filesize;
+ start[filesize-1] = 0;
+ skip_white (&start, end);
+ while (start < end && *start != '[') {
+ if ((junk_ident = parse_ident (&start, end)) != NULL)
+ RELEASE (junk_ident);
+ else if ((junk_obj = parse_pdf_object (&start, end)) != NULL)
+ pdf_release_obj (junk_obj);
+ skip_white(&start, end);
+ }
+ if (start >= end ||
+ (encoding = parse_pdf_array (&start, end)) == NULL) {
+ fprintf (stderr, "%s: ", enc_name);
+ ERROR ("Can't find an encoding in this file!\n");
+ }
+ RELEASE (buffer);
+ /* Done reading file */
+ if (verbose) {
+ fprintf (stderr, ")");
+ }
+ /* differences = find_encoding_differences (encoding); */
+ differences = make_differences_encoding (encoding);
+ /* Put the glyph names into a conventional array */
+ if (num_encodings >= max_encodings) {
+ max_encodings += MAX_ENCODINGS;
+ encodings = RENEW (encodings, max_encodings, struct encoding);
+ }
+ save_glyphs (encodings[num_encodings].glyphs, encoding);
+ pdf_release_obj (encoding);
+ result = pdf_new_dict();
+ pdf_add_dict (result, pdf_new_name ("Type"),
+ pdf_new_name ("Encoding"));
+ /* Some software doesn't like BaseEncoding key (e.g., FastLane)
+ so this code is commented out for the moment. It may reemerge in the
+ future */
+ /* pdf_add_dict (result, pdf_new_name ("BaseEncoding"),
+ pdf_new_name ("WinAnsiEncoding")); */
+ pdf_add_dict (result, pdf_new_name ("Differences"),
+ differences);
+ }
+ {
+ result_ref = pdf_ref_obj (result);
+ pdf_release_obj (result);
+ encodings[num_encodings].encoding_ref = result_ref;
+ encodings[num_encodings].enc_name = NEW (strlen(enc_name)+1, char);
+ strcpy (encodings[num_encodings].enc_name, enc_name);
+ return num_encodings++;
+ }
+}
+
+pdf_obj *encoding_ref (int encoding_id)
+{
+ pdf_obj *result = NULL;
+ if (encoding_id >=0 && encoding_id < num_encodings) {
+ result = pdf_link_obj (encodings[encoding_id].encoding_ref);
+ }
+ return result;
+}
+
+void encoding_flush_all (void)
+{
+ int i, j;
+ for (i=0; i<num_encodings; i++) {
+ RELEASE (encodings[i].enc_name);
+ pdf_release_obj (encodings[i].encoding_ref);
+ /* Release glyph names for this encoding */
+ for (j=0; j<256; j++) {
+ RELEASE ((encodings[i].glyphs)[j]);
+ }
+ }
+ if (encodings)
+ RELEASE (encodings);
+}
+
+char *encoding_glyph (int encoding_id, unsigned code)
+{
+ char *result = NULL;
+ if (encoding_id >= 0 && encoding_id < num_encodings &&
+ code < 256) {
+ result = (encodings[encoding_id].glyphs)[code];
+ }
+ return result;
+}
diff --git a/Build/source/texk/dvipdfm/encodings.h b/Build/source/texk/dvipdfm/encodings.h
new file mode 100755
index 00000000000..e90d788d26b
--- /dev/null
+++ b/Build/source/texk/dvipdfm/encodings.h
@@ -0,0 +1,19 @@
+#ifndef ENCODINGS_H
+
+#define ENCODINGS_H
+
+extern void encoding_set_verbose(void);
+extern pdf_obj *find_encoding_differences (pdf_obj *encoding);
+extern pdf_obj *make_differences_encoding (pdf_obj *encoding);
+extern int get_encoding (const char *enc_name);
+extern void encoding_flush_all (void);
+extern char *encoding_glyph (int encoding_id, unsigned code);
+extern pdf_obj *encoding_ref (int encoding_id);
+
+#endif
+
+
+
+
+
+
diff --git a/Build/source/texk/dvipdfm/epdf.c b/Build/source/texk/dvipdfm/epdf.c
new file mode 100644
index 00000000000..a2e3d00c89d
--- /dev/null
+++ b/Build/source/texk/dvipdfm/epdf.c
@@ -0,0 +1,159 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include "system.h"
+#include "mem.h"
+#include "mfileio.h"
+#include "pdfobj.h"
+#include "pdfdoc.h"
+#include "pdfspecial.h"
+#include "epdf.h"
+
+pdf_obj *pdf_include_page(FILE *image_file, struct xform_info *p, char *res_name)
+{
+ pdf_obj *trailer = NULL, *catalog = NULL, *page_tree = NULL;
+ pdf_obj *kids_ref, *kids;
+ pdf_obj *media_box = NULL, *crop_box = NULL, *resources = NULL,
+ *contents = NULL, *contents_ref = NULL;
+ pdf_obj *tmp1;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if (!(trailer = pdf_open (image_file))) {
+ fprintf (stderr, "\nCorrupt PDF file?\n");
+ }
+
+ /* Now just lookup catalog location */
+ /* Deref catalog */
+ if (trailer && (catalog = pdf_deref_obj(pdf_lookup_dict (trailer,"Root"))) ==
+ NULL) {
+ fprintf (stderr, "\nCatalog isn't where I expect it.\n");
+ }
+ if (trailer)
+ pdf_release_obj (trailer);
+
+ /* Lookup page tree in catalog */
+ if (catalog) {
+ page_tree = pdf_deref_obj (pdf_lookup_dict (catalog, "Pages"));
+ /* Should be finished with catalog */
+ pdf_release_obj (catalog);
+ }
+ /* Media box and resources can be inherited so start looking for
+ them here */
+ if (page_tree) {
+ if ((tmp1 = pdf_lookup_dict (page_tree, "CropBox")))
+ crop_box = pdf_deref_obj (tmp1);
+ if ((tmp1 = pdf_lookup_dict (page_tree, "MediaBox")))
+ media_box = pdf_deref_obj (tmp1);
+ resources = pdf_deref_obj (pdf_lookup_dict (page_tree, "Resources"));
+ if (resources == NULL) {
+ resources = pdf_new_dict();
+ }
+ while ((kids_ref = pdf_lookup_dict (page_tree, "Kids")) != NULL) {
+ kids = pdf_deref_obj (kids_ref);
+ pdf_release_obj (page_tree);
+ page_tree = pdf_deref_obj (pdf_get_array(kids, 0));
+ pdf_release_obj (kids);
+ /* Replace MediaBox if it's here */
+ tmp1 = pdf_deref_obj(pdf_lookup_dict (page_tree, "MediaBox"));
+ if (tmp1 && media_box)
+ pdf_release_obj (media_box);
+ if (tmp1)
+ media_box = tmp1;
+ /* Do same for CropBox */
+ tmp1 = pdf_deref_obj(pdf_lookup_dict (page_tree, "CropBox"));
+ if (tmp1 && crop_box)
+ pdf_release_obj (crop_box);
+ if (tmp1)
+ crop_box = tmp1;
+ /* Add resources if they're here */
+ tmp1 = pdf_deref_obj (pdf_lookup_dict (page_tree, "Resources"));
+ if (tmp1) {
+ pdf_merge_dict (tmp1, resources);
+ pdf_release_obj (resources);
+ resources = tmp1;
+ }
+ }
+ /* At this point, page_tree contains the first page. media_box,
+ crop_box, and resources should also be set. */
+ /* If there's a crop_box, replace media_box with crop_box.
+ The rest of this routine assumes crop_box has been released */
+ if (crop_box) {
+ pdf_release_obj (media_box);
+ media_box = crop_box;
+ crop_box = NULL;
+ }
+ /* This gets bit confusing. In the following code,
+ media_box is the box the image is cropped to.
+ The bounding box is the box the image is scaled to */
+ /* If user did not supply bounding box, use media_box
+ (which may really be cropbox) as bounding box */
+ /* Set the crop box parameters in the xform_info structure */
+ p->c_llx = pdf_number_value (pdf_get_array (media_box, 0));
+ p->c_lly = pdf_number_value (pdf_get_array (media_box, 1));
+ p->c_urx = pdf_number_value (pdf_get_array (media_box, 2));
+ p->c_ury = pdf_number_value (pdf_get_array (media_box, 3));
+
+ /* Adjust scaling and clipping information as necessary */
+ pdf_scale_image (p);
+
+ /* Set the media box to whatever pdf_scale_image() decided
+ for the crop box (which may be unchanged) */
+ pdf_release_obj (media_box);
+ media_box = pdf_new_array ();
+ pdf_add_array (media_box, pdf_new_number (p->c_llx));
+ pdf_add_array (media_box, pdf_new_number (p->c_lly));
+ pdf_add_array (media_box, pdf_new_number (p->c_urx));
+ pdf_add_array (media_box, pdf_new_number (p->c_ury));
+
+ if ((contents =
+ pdf_deref_obj(pdf_lookup_dict(page_tree,"Contents")))==NULL) {
+ fprintf (stderr, "\nNo Contents found\n");
+ return NULL;
+ }
+ pdf_release_obj (page_tree);
+ }
+ /* Arrays of contents must be handled very differently (not implemented) */
+ if (contents && contents -> type != PDF_ARRAY) {
+ doc_make_form_xobj (contents, media_box,
+ p->user_bbox? p->u_llx: 0.0,
+ p->user_bbox? p->u_lly: 0.0,
+ 1.0, 1.0,
+ resources, res_name);
+ } else {
+ fprintf (stderr, "\nIgnoring stream with with multiple segments\n");
+ contents = NULL;
+ }
+ if (contents) {
+ contents_ref = pdf_ref_obj (contents);
+ pdf_release_obj (contents);
+ }
+ pdf_close ();
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return (contents_ref);
+}
+
+
diff --git a/Build/source/texk/dvipdfm/epdf.h b/Build/source/texk/dvipdfm/epdf.h
new file mode 100644
index 00000000000..7dfc10d005f
--- /dev/null
+++ b/Build/source/texk/dvipdfm/epdf.h
@@ -0,0 +1,11 @@
+#ifndef _EPDF_H_
+#define _EPDF_H_
+
+#include <stdio.h>
+#include "pdfspecial.h"
+#include "pdfobj.h"
+
+extern pdf_obj *pdf_include_page (FILE *file, struct xform_info *p,
+ char *res_name);
+
+#endif /* _EPDF_H_ */
diff --git a/Build/source/texk/dvipdfm/error.h b/Build/source/texk/dvipdfm/error.h
new file mode 100644
index 00000000000..6841bec087a
--- /dev/null
+++ b/Build/source/texk/dvipdfm/error.h
@@ -0,0 +1,45 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef _ERROR_H_
+#define _ERROR_H_
+
+#include "system.h"
+
+extern void error_cleanup();
+
+#define FATAL_ERROR -1
+#define NO_ERROR 0
+
+#define ERROR(string) { \
+ fprintf(stderr, "\n"); \
+ fprintf (stderr, string); \
+ fprintf (stderr, "\n"); \
+ error_cleanup(); \
+ exit(1);}
+typedef int error_t;
+
+#endif /* _ERROR_H_ */
+
diff --git a/Build/source/texk/dvipdfm/htex.c b/Build/source/texk/dvipdfm/htex.c
new file mode 100644
index 00000000000..3ad35594bee
--- /dev/null
+++ b/Build/source/texk/dvipdfm/htex.c
@@ -0,0 +1,258 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "system.h"
+#include "mem.h"
+#include "mfileio.h"
+#include "dvi.h"
+#include "htex.h"
+#include "pdfparse.h"
+#include "pdfdoc.h"
+
+static int is_htex_special (char **start, char *end)
+{
+ skip_white(start, end);
+ if (end-*start >= strlen ("html:") &&
+ !strncmp (*start, "html:", strlen("html:"))) {
+ *start += strlen("html:");
+ return 1;
+ }
+ return 0;
+}
+
+static void downcase (char *s)
+{
+ while (*s != 0) {
+ if (*s >= 'A' && *s <= 'Z')
+ *s = (*s-'A')+'a';
+ s += 1;
+ }
+}
+
+
+#define ANCHOR 0
+#define IMAGE 1
+#define BASE 2
+#define END_ANCHOR 3
+
+static char *tags[] = {"a", "img", "base" };
+
+static int parse_html_tag (char **start, char *end)
+{
+ int result = -1;
+ char *token = NULL;
+ int closing = 0;
+ skip_white(start, end);
+ if (*start < end) {
+ if (**start == '/') {
+ (*start)++;
+ closing = 1;
+ }
+ if (*start < end && (token = parse_ident (start, end))) {
+ downcase (token);
+ {
+ int i;
+ for (i=0; i<sizeof(tags)/sizeof(tags[0]); i++) {
+ if (!strcmp (token, tags[i])) {
+ result = i;
+ if (closing)
+ result += sizeof(tags)/sizeof(tags[0]);
+ }
+ break;
+ }
+ if (i>=sizeof(tags)/sizeof(tags[0]))
+ result = -1;
+ }
+ RELEASE (token);
+ }
+ }
+ return result;
+}
+
+#define HREF 1
+#define NAME 2
+static pdf_obj *link_dict = NULL;
+static unsigned pending_type = 0;
+
+char *base_value = NULL;
+static void html_make_link_dict (char *name)
+{
+ pdf_obj *color;
+ if (!link_dict) {
+ link_dict = pdf_new_dict();
+ pdf_add_dict(link_dict, pdf_new_name("Type"), pdf_new_name ("Annot"));
+ pdf_add_dict(link_dict, pdf_new_name("Subtype"), pdf_new_name ("Link"));
+ color = pdf_new_array ();
+ pdf_add_array (color, pdf_new_number (0));
+ pdf_add_array (color, pdf_new_number (1));
+ pdf_add_array (color, pdf_new_number (1));
+ pdf_add_dict(link_dict, pdf_new_name("C"), color);
+ if (name && *name == '#' && !(base_value)) {
+ pdf_add_dict (link_dict, pdf_new_name("Dest"), pdf_new_string(name+1,strlen(name+1)));
+ } else if (name) { /* Assume its a URL */
+ char *url;
+ int len;
+ pdf_obj *action;
+ len = strlen(name)+1;
+ if (base_value)
+ len+=strlen(base_value);
+ url = NEW (len, char);
+ if (base_value)
+ strcpy (url, base_value);
+ else
+ url[0] = 0;
+ strcat (url, name);
+ action = pdf_new_dict();
+ pdf_add_dict (action, pdf_new_name ("Type"), pdf_new_name ("Action"));
+ pdf_add_dict (action, pdf_new_name ("S"), pdf_new_name ("URI"));
+ pdf_add_dict (action, pdf_new_name ("URI"),
+ pdf_new_string (url, len));
+ pdf_add_dict (link_dict, pdf_new_name ("A"), pdf_ref_obj (action));
+ pdf_release_obj (action);
+ RELEASE (url);
+ }
+ pdf_doc_begin_annot (link_dict);
+ } else {
+ fprintf (stderr, "\nAttempt to nest links\n");
+ }
+}
+
+void html_make_dest (char *name)
+{
+ pdf_obj *array;
+ array = pdf_new_array ();
+ pdf_add_array (array, pdf_doc_this_page_ref());
+ pdf_add_array (array, pdf_new_name("XYZ"));
+ pdf_add_array (array, pdf_new_null());
+ pdf_add_array (array, pdf_new_number(dev_phys_y()+24.0));
+ pdf_add_array (array, pdf_new_null());
+ pdf_doc_add_dest (name, strlen(name), pdf_ref_obj(array));
+ pdf_release_obj (array);
+}
+
+void html_start_anchor (char *key, char *value)
+{
+ if (pending_type <= 0 && !link_dict) {
+ downcase (key);
+ if (!strcmp (key, "href")) {
+ html_make_link_dict (value);
+ pending_type = HREF;
+ } else if (!strcmp (key, "name")) {
+ html_make_dest (value);
+ pending_type = NAME;
+ } else {
+ fprintf (stderr, "\nUnrecognized keyword in anchor tag: %s\n",
+ key);
+ }
+ } else {
+ fprintf (stderr, "\nWarning: Nested html anchors\n");
+ }
+ if (key)
+ RELEASE (key);
+ if (value) {
+ RELEASE (value);
+ }
+}
+
+void html_end_anchor (void)
+{
+ switch (pending_type) {
+ case HREF:
+ if (link_dict) {
+ pdf_doc_end_annot ();
+ pdf_release_obj (link_dict);
+ link_dict = NULL;
+ pending_type = 0;
+ } else {
+ fprintf (stderr, "\nhtml_end_anchor: Ending anchor tag without starting tag!\n");
+ }
+ break;
+ case NAME:
+ pending_type = 0;
+ break;
+ }
+}
+
+void html_set_base (char *value)
+{
+ if (base_value)
+ RELEASE (base_value);
+ base_value = value;
+}
+
+
+
+int htex_parse_special(char *buffer, UNSIGNED_QUAD size)
+{
+ int result = 0;
+ char *key, *value;
+ char *save = buffer;
+ char *end = buffer + size;
+ int htmltag;
+ skip_white (&buffer, end);
+ if (is_htex_special(&buffer, end)) {
+ result = 1; /* Must be html special (doesn't mean it will succeed) */
+ skip_white (&buffer, end);
+ if (buffer < end && *(buffer++) == '<' ) {
+ htmltag = parse_html_tag(&buffer, end);
+ switch (htmltag) {
+ case ANCHOR:
+ parse_key_val (&buffer, end, &key, &value);
+ if (key && value)
+ html_start_anchor (key, value);
+ break;
+ case IMAGE:
+ fprintf (stderr, "\nImage html tag not yet implemented\n");
+ parse_key_val (&buffer, end, &key, &value);
+ if (key) RELEASE (key);
+ if (value) RELEASE (value);
+ break;
+ case BASE:
+ parse_key_val (&buffer, end, &key, &value);
+ if (key && value)
+ html_set_base (value);
+ if (key)
+ RELEASE (key);
+ break;
+ case END_ANCHOR:
+ html_end_anchor ();
+ break;
+ default:
+ fprintf (stderr, "Invalid tag\n");
+ dump (save, end);
+ }
+ }
+ skip_white(&buffer, end);
+ if (buffer >= end || *buffer != '>') {
+ fprintf (stderr, "\nBadly terminated tag..\n");
+ }
+ }
+ return result;
+}
+
+
+
diff --git a/Build/source/texk/dvipdfm/htex.h b/Build/source/texk/dvipdfm/htex.h
new file mode 100644
index 00000000000..5ff60c6a726
--- /dev/null
+++ b/Build/source/texk/dvipdfm/htex.h
@@ -0,0 +1,37 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef _HTEX_H_
+
+#define _HTEX_H_
+
+#include "numbers.h"
+
+extern int htex_parse_special(char *buffer, UNSIGNED_QUAD size);
+
+#endif /* _HTEX_H */
+
+
+
diff --git a/Build/source/texk/dvipdfm/jpeg.c b/Build/source/texk/dvipdfm/jpeg.c
new file mode 100644
index 00000000000..c9c8c1d6e02
--- /dev/null
+++ b/Build/source/texk/dvipdfm/jpeg.c
@@ -0,0 +1,136 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <stdio.h>
+#include "system.h"
+#include "mem.h"
+#include "mfileio.h"
+#include "numbers.h"
+#include "dvi.h"
+#include "jpeg.h"
+#include "pdfobj.h"
+#include "pdfspecial.h"
+
+#define verbose 0
+
+#define SOF0 0xc0
+#define SOF1 0xc1
+#define SOF2 0xc2
+#define SOF3 0xc3
+#define SOF5 0xc5
+#define SOF6 0xc6
+#define SOF7 0xc7
+#define SOF9 0xc9
+#define SOF10 0xca
+#define SOF11 0xcb
+#define SOF13 0xcd
+#define SOF14 0xce
+#define SOF15 0xcf
+#define SOI 0xd8
+#define EOI 0xd9
+#define SOS 0xda
+#define COM 0xfe
+
+int check_for_jpeg(FILE *file)
+{
+ rewind (file);
+ if (get_unsigned_byte (file) != 0xff ||
+ get_unsigned_byte (file) != SOI)
+ return 0;
+ return 1;
+}
+
+int jpeg_headers (struct jpeg *jpeg)
+{
+ UNSIGNED_BYTE byte;
+ UNSIGNED_PAIR length;
+ int i, done;
+ done = 0;
+ while (!done) {
+ if ((byte = get_unsigned_byte (jpeg -> file)) != 0xff)
+ return 0;
+ while ((byte = get_unsigned_byte (jpeg -> file)) == 0xff);
+ length = get_unsigned_pair (jpeg -> file);
+ length -= 2;
+ switch (byte) {
+ case SOF0:
+ case SOF1:
+ case SOF2:
+ case SOF3:
+ case SOF5:
+ case SOF6:
+ case SOF7:
+ case SOF9:
+ case SOF10:
+ case SOF11:
+ case SOF13:
+ case SOF14:
+ case SOF15:
+ jpeg -> bits_per_color = get_unsigned_byte (jpeg -> file);
+ jpeg -> height = get_unsigned_pair (jpeg -> file);
+ jpeg -> width = get_unsigned_pair (jpeg -> file);
+ jpeg -> colors = get_unsigned_byte (jpeg -> file);
+ if (verbose) {
+ fprintf (stderr, "ht=%d,wd=%d,co=%d,bpc=%d\n",
+ jpeg->height,jpeg->width,jpeg->colors,jpeg->bits_per_color);
+ }
+
+ done = 1;
+ return 1;
+ default:
+ for (i=0; i<length; i++) {
+ get_unsigned_byte(jpeg -> file);
+ }
+ }
+ }
+ return 0; /* Not reached */
+}
+
+struct jpeg *jpeg_open (FILE *file)
+{
+ struct jpeg *jpeg;
+ if (!check_for_jpeg(file)) {
+ fprintf (stderr, "\nNot a JPEG file\n");
+ return NULL;
+ }
+ jpeg = NEW (1, struct jpeg);
+ jpeg -> file = file;
+ if (!jpeg_headers(jpeg)) {
+ fprintf (stderr, "\nCorrupt JPEG file?\n");
+ RELEASE (jpeg);
+ return NULL;
+ }
+ return jpeg;
+}
+
+void jpeg_close (struct jpeg *jpeg)
+{
+ if (jpeg == NULL) {
+ fprintf (stderr, "jpeg_closed: passed invalid pointer\n");
+ }
+ RELEASE (jpeg);
+ return;
+}
+
+
diff --git a/Build/source/texk/dvipdfm/jpeg.h b/Build/source/texk/dvipdfm/jpeg.h
new file mode 100644
index 00000000000..907a718ad6f
--- /dev/null
+++ b/Build/source/texk/dvipdfm/jpeg.h
@@ -0,0 +1,47 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef JPEG_H
+
+#define JPEG_H
+
+#include <stdio.h>
+#include "pdfobj.h"
+#include "pdfspecial.h"
+
+struct jpeg
+{
+ unsigned width, height;
+ unsigned bits_per_color;
+ FILE *file;
+ unsigned colors;
+};
+
+extern struct jpeg *jpeg_open (FILE *file);
+extern int jpeg_headers (struct jpeg *jpeg);
+extern void jpeg_close (struct jpeg *jpeg);
+extern int check_for_jpeg (FILE *file);
+
+#endif /* JPEG_H */
diff --git a/Build/source/texk/dvipdfm/macglyphs.h b/Build/source/texk/dvipdfm/macglyphs.h
new file mode 100755
index 00000000000..62a75cc04a4
--- /dev/null
+++ b/Build/source/texk/dvipdfm/macglyphs.h
@@ -0,0 +1,57 @@
+char *macglyphorder[258] = {
+ "notdef", ".null", "CR", "space", "exclam",
+ "quotedbl", "numbersign", "dollar", "percent", "ampersand",
+ "quotesingle", "parenleft", "parenright", "asterisk", "plus",
+ "comma", "hyphen", "period", "slash", "zero",
+ "one", "two", "three", "four", "five",
+ "six", "seven", "eight", "nine", "colon",
+ "semicolon", "less", "equal", "greater", "question",
+ "at", "A", "B", "C", "D",
+ "E", "F", "G", "H", "I",
+ "J", "K", "L", "M", "N",
+ "O", "P", "Q", "R", "S",
+ "T", "U", "V", "W", "X",
+ "Y", "Z", "bracketleft", "backslash", "bracketright",
+ "asciicircum", "underscore", "grave", "a", "b",
+ "c", "d", "e", "f", "g",
+ "h", "i", "j", "k", "l",
+ "m", "n", "o", "p", "q",
+ "r", "s", "t", "u", "v",
+ "w", "x", "y", "z", "braceleft",
+ "bar", "braceright", "asciitilde", "Adieresis", "Aring", /* 95-99 */
+ "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", /* 100-104 */
+ "aacute", "agrave", "acircumflex", "adieresis", "atilde", /* 105-109 */
+ "aring", "ccedilla", "eacute", "egrave", "ecircumflex", /* 110-114 */
+ "edieresis", "iacute", "igrave", "icircumflex", "idieresis", /* 115-119 */
+ "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", /* 120-124 */
+ "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", /* 125-129 */
+ "dagger", "degree", "cent", "sterling", "section", /* 130-134 */
+ "bullet", "paragraph", "germandbls", "registered", "copyright", /* 135-139 */
+ "trademark", "acute", "dieresis", "notequal", "AE", /* 140-144 */
+ "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", /* 145-149 */
+ "yen", "mu1", "partialdiff", "summation", "product", /* 150-154 */
+ "pi", "integral", "ordfeminine", "ordmasculine", "Ohm", /* 155-159 */
+ "ae", "oslash", "questiondown", "exclamdown", "logicalnot", /* 160-164 */
+ "radical", "florin", "approxequal", "increment", "guillemotleft", /* 165-169 */
+ "guillemotright", "ellipsis", "nbspace", "Agrave", "Atilde", /* 170-174 */
+ "Otilde", "OE", "oe", "endash", "emdash", /* 175-179 */
+ "quotedblleft", "quotedblright", "quoteleft", "quoteright", /* 180-184 */
+ "divide",
+ "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", /* 185-189 */
+ "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", /* 190-194 */
+ "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", /* 195-199 */
+ "Acircumflex",
+ "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", /* 200-204 */
+ "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex",/* 205-209 */
+ "applelogo", "Ograve", "Uacute", "Ucircumflex", "Ugrave", /* 210-214 */
+ "dotlessi", "circumflex", "tilde", "overscore", "breve", /* 215-219 */
+ "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", /* 220-224 */
+ "caron", "Lslash", "Islash", "Scaron", "scaron", /* 225-229 */
+ "Zcaron", "zcaron", "brokenbar", "Eth", "eth", /* 230-234 */
+ "Yacute", "yacture", "Thorn", "thorn", "minus", /* 235-239 */
+ "multiply", "onesuperior", "twosuperior", "threesuperior",
+ "onehalf", /* 240-244 */
+ "onequarter", "threequarters", "franc", "Gbreve", "gbreve", /* 245-249 */
+ "ldot", "Scedilla", "scedilla", "Cacute", "cacute", /* 250-254 */
+ "Ccaron", "ccaron", "dmacron" /* 255-257 */
+};
diff --git a/Build/source/texk/dvipdfm/mem.c b/Build/source/texk/dvipdfm/mem.c
new file mode 100644
index 00000000000..c3c33875d07
--- /dev/null
+++ b/Build/source/texk/dvipdfm/mem.c
@@ -0,0 +1,95 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "mem.h"
+
+#ifdef MEM_DEBUG
+FILE *debugfile = NULL;
+static long int event = 0;
+#endif /* MEM_DEBUG */
+
+
+#ifdef MEM_DEBUG
+void mem_debug_init(void)
+{
+ if (debugfile == NULL) {
+ debugfile = fopen ("malloc.log", "w");
+ fprintf (stderr, "*** Memory Debugging Log started ***\n");
+ }
+}
+#endif /* MEM_DEBUG */
+
+void *new (size_t size, char *function, int line)
+{
+ void *result;
+ if ((result = malloc (size)) == NULL) {
+ fprintf (stderr, "Out of memory in %s:%d\n", function, line);
+ fprintf (stderr, "Asked for %lu\n", (unsigned long) size);
+ exit (1);
+ }
+
+#ifdef MEM_DEBUG
+ mem_debug_init();
+ event += 1;
+ fprintf (debugfile, "%p %07ld [new] %s:%d\n", result, event, function, line);
+#endif /* MEM_DEBUG */
+
+ return result;
+}
+
+void *renew (void *mem, size_t size, char *function, int line)
+{
+ void *result;
+#ifdef MEM_DEBUG
+ mem_debug_init();
+ event += 1;
+ if (mem)
+ fprintf (debugfile, "%p %07ld [fre] %s:%d\n", mem,
+ event, function, line);
+#endif /* MEM_DEBUG */
+ if ((result = realloc (mem, size)) == NULL) {
+ fprintf (stderr, "Out of memory!\n");
+ exit (1);
+ }
+#ifdef MEM_DEBUG
+ if (result)
+ fprintf (debugfile, "%p %07ld [new] %s:%d\n", result, event, function, line);
+#endif /* MEM_DEBUG */
+ return result;
+}
+
+void release (void *mem, char *function, int line)
+{
+
+#ifdef MEM_DEBUG
+ mem_debug_init();
+ event += 1;
+ fprintf (debugfile, "%p %07ld [fre] %s:%d\n", mem, event, function, line);
+#endif /* MEM_DEBUG */
+
+ free (mem);
+}
+
diff --git a/Build/source/texk/dvipdfm/mem.h b/Build/source/texk/dvipdfm/mem.h
new file mode 100644
index 00000000000..3ad5ea8a274
--- /dev/null
+++ b/Build/source/texk/dvipdfm/mem.h
@@ -0,0 +1,50 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef MEM_H
+#define MEM_H
+
+#include <stdlib.h>
+
+extern void *new (size_t size, char *function, int line);
+extern void *renew (void *p, size_t size, char *function, int line);
+extern void release (void *mem, char *function, int line);
+
+#ifdef MEM_DEBUG
+extern void mem_debug_init(void);
+extern FILE *debugfile;
+#define NEW(n,type) (type *)(new (((size_t) (n))*sizeof(type),__FUNCTION__,__LINE__))
+#define RENEW(p,n,type) (type *)(renew ((p),(n)*sizeof(type),__FUNCTION__,__LINE__))
+#define RELEASE(p) release ((p),__FUNCTION__,__LINE__)
+#define MEM_START {mem_debug_init();fprintf (debugfile, "Entered %s\n", __FUNCTION__);}
+#define MEM_END fprintf (debugfile, "Leaving %s\n", __FUNCTION__);
+#else /* MEM_DEBUG */
+#define MEM_START
+#define MEM_END
+#define NEW(n,type) (type *)(new (((size_t) (n))*sizeof(type),NULL,0))
+#define RENEW(p,n,type) (type *)(renew ((p),(n)*sizeof(type),NULL,0))
+#define RELEASE(p) release ((p),NULL,0)
+#endif /* MEM_DEBUG */
+#endif /* MEM_H */
diff --git a/Build/source/texk/dvipdfm/mfileio.c b/Build/source/texk/dvipdfm/mfileio.c
new file mode 100644
index 00000000000..908fcb02eca
--- /dev/null
+++ b/Build/source/texk/dvipdfm/mfileio.c
@@ -0,0 +1,128 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "system.h"
+#include "mfileio.h"
+#include "error.h"
+
+#ifdef IODEBUG
+static FILE *iodebug_file = NULL;
+static long event = 0;
+static void io_debug_init(void)
+{
+ if (!iodebug_file) {
+ iodebug_file = fopen ("fopen.log", "wb");
+ fprintf (stderr, "\n*** File IO debugging started ***\n");
+ }
+ if (!iodebug_file) {
+ fprintf (stderr, "\nError opening io log\n");
+ }
+}
+#endif
+
+#ifdef IODEBUG
+FILE *mfopen(const char *name, const char *mode, const char *function, int line)
+{
+ FILE *tmp;
+ io_debug_init();
+ tmp = fopen (name, mode);
+ event += 1;
+ fprintf(iodebug_file, "%p %07ld [fopen] %s:%d\n", tmp, event,
+ function, line);
+ return tmp;
+}
+int mfclose(FILE *file, const char *function, int line)
+{
+ io_debug_init();
+ event += 1;
+ fprintf(iodebug_file, "%p %07ld [fclose] %s:%d\n", file, event,
+ function, line);
+ return fclose(file);
+}
+#endif
+
+static void os_error()
+{
+ ERROR ("io: An OS command failed that should not have.\n");
+}
+
+void seek_absolute (FILE *file, long pos)
+{
+ if (fseek(file, pos, SEEK_SET)) {
+ os_error();
+ }
+}
+
+void seek_relative (FILE *file, long pos)
+{
+ if (fseek(file, pos, SEEK_CUR)) {
+ os_error();
+ }
+}
+
+
+void seek_end (FILE *file)
+{
+ if (fseek(file, 0L, SEEK_END)) {
+ os_error();
+ }
+}
+
+long tell_position (FILE *file)
+{
+ long size;
+ if ((size = ftell (file)) < 0) {
+ os_error();
+ }
+ return size;
+}
+
+long file_size (FILE *file)
+{
+ long size;
+ /* Seek to end */
+ seek_end (file);
+ size = tell_position (file);
+ rewind (file);
+ return (size);
+}
+
+/* Unlike fgets, mfgets works with \r, \n, or \r\n end of lines. */
+char *mfgets (char *buffer, unsigned long length, FILE *file)
+{
+ int ch = 0, i = 0;
+ while (i < length-1 && (ch = fgetc (file)) >= 0 && ch != '\n' && ch != '\r')
+ buffer[i++] = ch;
+ buffer[i] = 0;
+ if (ch < 0 && i == 0)
+ return NULL;
+ if (ch == '\r' && (ch = fgetc (file)) >= 0 && (ch != '\n'))
+ ungetc (ch, file);
+ return buffer;
+}
+
+char work_buffer[WORK_BUFFER_SIZE];
+
diff --git a/Build/source/texk/dvipdfm/mfileio.h b/Build/source/texk/dvipdfm/mfileio.h
new file mode 100644
index 00000000000..5a0fd59a7e8
--- /dev/null
+++ b/Build/source/texk/dvipdfm/mfileio.h
@@ -0,0 +1,59 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#include <stdio.h>
+#include "numbers.h"
+#define IODEBUG
+#undef IODEBUG
+
+#ifdef IODEBUG
+FILE *mfopen (const char *name, const char *mode,
+ const char *function, int line);
+int mfclose (FILE *file, const char *function, int line);
+#define MFOPEN(name,mode) \
+ mfopen((name),(mode),__FUNCTION__,__LINE__)
+#define MFCLOSE(file) \
+ mfclose((file),__FUNCTION__,__LINE__)
+#else
+#define MFOPEN(name,mode) fopen((name),(mode))
+#define MFCLOSE(file) fclose(file)
+#endif
+
+extern UNSIGNED_BYTE read_byte (FILE *);
+
+extern void seek_absolute (FILE *file, long pos);
+extern void seek_relative (FILE *file, long pos);
+
+extern void seek_end (FILE *file);
+
+extern long tell_position (FILE *file);
+
+extern long file_size (FILE *file);
+
+extern char *mfgets (char *buffer, unsigned long size, FILE *file);
+
+extern char work_buffer[];
+
+#define WORK_BUFFER_SIZE 1024
diff --git a/Build/source/texk/dvipdfm/mpost.c b/Build/source/texk/dvipdfm/mpost.c
new file mode 100644
index 00000000000..4f84393312c
--- /dev/null
+++ b/Build/source/texk/dvipdfm/mpost.c
@@ -0,0 +1,1365 @@
+/* $Header: SCCS/s.mpost.c 1.1 00/08/05 01:52:14-00:00 mwicks@gaspra $
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <math.h>
+#include <string.h>
+#include "system.h"
+#include "mem.h"
+#include "error.h"
+#include "mfileio.h"
+#include "dvi.h"
+#include "pdfobj.h"
+#include "pdfspecial.h"
+#include "pdfparse.h"
+#include "mpost.h"
+#include "pdfparse.h"
+#include "pdflimits.h"
+#include "pdfdev.h"
+#include "pdfdoc.h"
+
+int check_for_mp (FILE *image_file)
+{
+ rewind (image_file);
+ /* For now, this is an exact test that must be passed, character for
+ character */
+ mfgets (work_buffer, WORK_BUFFER_SIZE, image_file);
+ if (strncmp (work_buffer, "%!PS", 4))
+ return 0;
+ mfgets (work_buffer, WORK_BUFFER_SIZE, image_file);
+ if (strncmp (work_buffer, "%%BoundingBox", strlen("%%BoundingBox")))
+ return 0;
+ mfgets (work_buffer, WORK_BUFFER_SIZE, image_file);
+ if (strncmp (work_buffer, "%%Creator: MetaPost", strlen("%%Creator: MetaPost")))
+ return 0;
+ return 1;
+}
+
+static struct mp_fonts
+{
+ char *tex_name;
+ int font_id;
+ double pt_size;
+} *mp_fonts = NULL;
+
+int n_mp_fonts = 0, max_mp_fonts = 0;
+
+static void need_more_mp_fonts (unsigned n)
+{
+ if (n_mp_fonts + n > max_mp_fonts) {
+ max_mp_fonts += MAX_FONTS;
+ mp_fonts = RENEW (mp_fonts, max_mp_fonts, struct mp_fonts);
+ }
+}
+
+
+
+int mp_locate_font (char *tex_name, double pt_size)
+{
+ int result=-1, i;
+ for (i=0; i<n_mp_fonts; i++) {
+ if (!strcmp (tex_name, mp_fonts[i].tex_name) &&
+ mp_fonts[i].pt_size == pt_size)
+ break;
+ }
+ need_more_mp_fonts (1);
+ if (i == n_mp_fonts) {
+ n_mp_fonts += 1;
+ mp_fonts[i].tex_name = NEW (strlen(tex_name)+1, char);
+ strcpy (mp_fonts[i].tex_name, tex_name);
+ mp_fonts[i].pt_size = pt_size;
+ /* The following line is a bit of a kludge. MetaPost inclusion
+ was an afterthought */
+ mp_fonts[i].font_id = dev_locate_font (tex_name,
+ pt_size/dvi_unit_size());
+ result = mp_fonts[i].font_id;
+ } else
+ result = -1;
+ return result;
+}
+
+static void release_fonts (void)
+{
+ int i;
+ for (i=0; i<n_mp_fonts; i++) {
+ RELEASE (mp_fonts[i].tex_name);
+ }
+ if (mp_fonts) {
+ RELEASE (mp_fonts);
+ mp_fonts = NULL;
+ }
+ n_mp_fonts = 0;
+ max_mp_fonts = 0;
+}
+
+int mp_is_font_name (char *tex_name)
+{
+ int i;
+ for (i=0; i<n_mp_fonts; i++) {
+ if (!strcmp (tex_name, mp_fonts[i].tex_name))
+ break;
+ }
+ if (i < n_mp_fonts)
+ return 1;
+ else
+ return 0;
+}
+
+int mp_fontid (char *tex_name, double pt_size)
+{
+ int i;
+ for (i=0; i<n_mp_fonts; i++) {
+ if (!strcmp (tex_name, mp_fonts[i].tex_name) &&
+ (mp_fonts[i].pt_size == pt_size))
+ break;
+ }
+ if (i < n_mp_fonts) {
+ return i;
+ }
+ else {
+ return -1;
+ }
+}
+
+static int mp_parse_headers (FILE *image_file, struct xform_info *p)
+{
+ int error = 0;
+ char *start, *end, *token, *name;
+ char *llx = NULL, *lly = NULL, *urx = NULL, *ury = NULL;
+ unsigned long save_position;
+#ifdef MEM_DEBUG
+ MEM_START
+#endif
+ /* Scan for bounding box record */
+ for (;;) {
+ mfgets (work_buffer, WORK_BUFFER_SIZE, image_file);
+ if (work_buffer[0] != '%' ||
+ !strncmp (work_buffer, "%%BoundingBox:",
+ strlen("%%BoundingBox")))
+ break;
+ }
+ if (work_buffer[0] == '%') { /* Found %%BoundingBox */
+ start = work_buffer + strlen("%%BoundingBox:");
+ end = start+strlen(start);
+ skip_white (&start, end);
+ /* Expect 4 numbers or fail */
+ if ((llx = parse_number (&start, end)) &&
+ (lly = parse_number (&start, end)) &&
+ (urx = parse_number (&start, end)) &&
+ (ury = parse_number (&start, end))) {
+ /* Set the crop box to the true bounding box specified in the
+ file */
+ p->c_llx = atof (llx);
+ p->c_lly = atof (lly);
+ p->c_urx = atof (urx);
+ p->c_ury = atof (ury);
+ } else{
+ fprintf (stderr, "\nMissing expected number in bounding box specification:\n");
+ dump (start, end);
+ error = 1;
+ }
+ } else { /* Didn't find Bounding box */
+ fprintf (stderr, "\nFailed to find an expected BoundingBox record.\n");
+ error = 1;
+ }
+ if (llx) RELEASE(llx);
+ if (lly) RELEASE(lly);
+ if (urx) RELEASE(urx);
+ if (ury) RELEASE(ury);
+ /* Got four numbers */
+ /* Read all headers--act on *Font records */
+ save_position = tell_position(image_file);
+ while (!error && !feof(image_file) && mfgets (work_buffer, WORK_BUFFER_SIZE,
+ image_file)) {
+ if (*work_buffer != '%') {
+ seek_absolute (image_file, save_position);
+ break;
+ }
+ save_position = tell_position (image_file);
+ if (*(work_buffer+1) == '*' &&
+ !strncmp (work_buffer+2, "Font:", strlen("Font:"))) {
+ double ps_ptsize;
+ start = work_buffer+strlen("%*Font:");
+ end = start+strlen(start);
+ skip_white (&start, end);
+ if ((name = parse_ident (&start, end))) {
+ skip_white (&start, end);
+ } else {
+ fprintf (stderr, "\nMissing expected font name:\n");
+ dump (start, end);
+ error = 1;
+ break;
+ }
+ if ((token = parse_number (&start, end))) {
+ ps_ptsize = atof (token);
+ RELEASE (token);
+ } else {
+ fprintf (stderr, "\nMissing expected font point size specification:\n");
+ dump (start, end);
+ error = 1;
+ break;
+ }
+ mp_locate_font (name, ps_ptsize);
+ RELEASE (name);
+ }
+ }
+#ifdef MEM_DEBUG
+ MEM_END
+#endif
+ return !error;
+}
+
+struct point {
+ double x, y;
+};
+
+struct curve {
+ double x[3], y[3];
+};
+
+static struct path_element
+{
+ char type;
+ void *element;
+} *path = NULL;
+static int n_path_pts = 0, max_path_pts = 0;
+static int path_clip = 0, path_close = 0;
+
+#define MORE_PATH_POINTS 64
+
+static void need_points (int n)
+{
+ if (n_path_pts+n > max_path_pts) {
+ max_path_pts += MORE_PATH_POINTS;
+ path = RENEW (path, max_path_pts, struct path_element);
+ }
+ return;
+}
+
+static void clip_path (void)
+{
+ path_clip = 1;
+}
+
+static void close_path (void)
+{
+ path_close = 1;
+}
+
+static void add_point_to_path (double x, double y, char type)
+{
+ struct point *p;
+ need_points (1);
+ path[n_path_pts].type = type;
+ p = NEW (1, struct point);
+ p->x = x; p->y = y;
+ path[n_path_pts].element = p;
+ n_path_pts += 1;
+ return;
+}
+
+static void add_curve_to_path (double x0, double y0,
+ double x1, double y1,
+ double x2, double y2)
+{
+ struct curve *c;
+ need_points (1);
+ c = NEW (1, struct curve);
+ path[n_path_pts].type = 'c';
+ (c->x)[0] = x0; (c->y)[0] = y0;
+ (c->x)[1] = x1; (c->y)[1] = y1;
+ (c->x)[2] = x2; (c->y)[2] = y2;
+ path[n_path_pts].element = c;
+ n_path_pts += 1;
+ return;
+}
+
+static void void_path (void)
+{
+ int i;
+ for (i=0; i<n_path_pts; i++) {
+ RELEASE (path[i].element);
+ }
+ path_clip = 0;
+ path_close = 0;
+ n_path_pts = 0;
+}
+
+static void flush_path (void)
+{
+ int i, len;
+ for (i=0; i<n_path_pts; i++) {
+ switch (path[i].type) {
+ case 'm': /* moveto */
+ /* Moveto must start a new path */
+ /* void_path (); */
+ case 'l': /* lineto */
+ {
+ struct point *p;
+ p = path[i].element;
+ sprintf (work_buffer, "\n%g %g %c",
+ ROUND(p->x, 0.001), ROUND(p->y, 0.001),
+ path[i].type);
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ RELEASE (p);
+ }
+ break;
+ case 'c': /* curveto */
+ {
+ struct curve *p;
+ p = path[i].element;
+ sprintf (work_buffer, "\n%g %g %g %g %g %g c",
+ ROUND((p->x)[0], 0.001), ROUND((p->y)[0], 0.001),
+ ROUND((p->x)[1], 0.001), ROUND((p->y)[1], 0.001),
+ ROUND((p->x)[2], 0.001), ROUND((p->y)[2], 0.001));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ RELEASE (p);
+ }
+ break;
+ default: /* This shouldn't happen! */
+ ERROR ("Internal error in mpost.c, flush_path ()");
+ }
+ }
+ n_path_pts = 0;
+ if (path_close) {
+ pdf_doc_add_to_page (" h", 2);
+ path_close = 0;
+ }
+ if (path_clip) {
+ pdf_doc_add_to_page (" W", 2);
+ path_clip = 0;
+ }
+ return;
+}
+
+static void transform_path (double a, double b, double c, double d,
+ double e, double f)
+{
+ double an, bn, cn, dn, en, fn, delta, xn, yn;
+ unsigned i;
+ delta = a*d-b*c;
+ if (delta == 0.0) {
+ ERROR ("Determinant exactly zero in transform_path()");
+ }
+ an=d/delta; bn=-b/delta; cn=-c/delta; dn=a/delta;
+ en=(c*f-e*d)/delta, fn=(b*e-a*f)/delta;
+ for (i=0; i<n_path_pts; i++) {
+ switch (path[i].type) {
+ case 'l':
+ case 'm':
+ {
+ struct point *p;
+ p = path[i].element;
+ xn = an*(p->x)+cn*(p->y)+en;
+ yn = bn*(p->x)+dn*(p->y)+fn;
+ p->x = xn;
+ p->y = yn;
+ }
+ break;
+ case 'c':
+ {
+ int j;
+ struct curve *c;
+ c = path[i].element;
+ for (j=0; j<3; j++) {
+ xn = an*(c->x)[j]+cn*(c->y)[j]+en;
+ yn = bn*(c->x)[j]+dn*(c->y)[j]+fn;
+ (c->x)[j] = xn; (c->y)[j] = yn;
+ }
+ }
+ }
+ }
+}
+static void dump_path (void)
+{
+ unsigned i;
+ for (i=0; i<n_path_pts; i++) {
+ switch (path[i].type) {
+ case 'l':
+ case 'm':
+ {
+ struct point *p;
+ p = path[i].element;
+ fprintf (stderr, "\t%g %g %c\n", p->x, p->y, path[i].type);
+ }
+ break;
+ case 'c':
+ {
+ struct curve *c;
+ int j;
+ c = path[i].element;
+ for (j=0; j<3; j++) {
+ fprintf (stderr, "\t%g %g\n", (c->x)[j], (c->y)[j]);
+ }
+ fprintf (stderr, "\t\t\tcurveto\n");
+ break;
+ }
+ }
+ }
+}
+
+#define PS_STACK_SIZE 1024
+static pdf_obj *stack[PS_STACK_SIZE];
+static unsigned top_stack;
+
+double x_state, y_state;
+static int state = 0;
+static int num_saves = 0;
+
+#define PUSH(o) { \
+ if (top_stack<PS_STACK_SIZE) { \
+ stack[top_stack++] = o; \
+ } else { \
+ fprintf (stderr, "PS stack overflow including MetaPost file or inline PS code"); \
+ error=1; \
+ break; \
+ } \
+ }
+
+#define POP_STACK() (top_stack>0?stack[--top_stack]:NULL)
+
+void dump_stack()
+{
+ int i;
+ fprintf (stderr, "\ndump_stack\n");
+ for (i=0; i<top_stack; i++) {
+ pdf_write_obj (stderr, stack[i]);
+ fprintf (stderr, "\n");
+ }
+}
+#define ADD 1
+#define CLIP 2
+#define CLOSEPATH 3
+#define CONCAT 4
+#define CURVETO 5
+#define DIV 6
+#define DTRANSFORM 7
+#define EXCH 8
+#define FILL 9
+#define FSHOW 10
+#define GSAVE 11
+#define GRESTORE 12
+#define IDTRANSFORM 13
+#define LINETO 14
+#define MOVETO 15
+#define MUL 16
+#define NEWPATH 17
+#define POP 18
+#define RLINETO 19
+#define SCALE 20
+#define SETCMYKCOLOR 21
+#define SETDASH 22
+#define SETGRAY 23
+#define SETLINECAP 24
+#define SETLINEJOIN 25
+#define SETLINEWIDTH 26
+#define SETMITERLIMIT 27
+#define SETRGBCOLOR 28
+#define SHOW 29
+#define SHOWPAGE 30
+#define STROKE 31
+#define SUB 32
+#define TRANSLATE 33
+#define TRUNCATE 34
+#define CURRENTPOINT 35
+#define NEG 36
+#define ROTATE 37
+#define TEXFIG 38
+#define ETEXFIG 39
+#define FONTNAME 99
+
+struct operators
+{
+ char *t;
+ int v;
+} operators[] = {
+ {"add", ADD},
+ {"clip", CLIP},
+ {"closepath", CLOSEPATH},
+ {"concat", CONCAT},
+ {"curveto", CURVETO},
+ {"currentpoint", CURRENTPOINT}, /* This is here for rotate
+ support in graphics package-not MP support */
+ {"div", DIV},
+ {"dtransform", DTRANSFORM},
+ {"exch", EXCH},
+ {"fill", FILL},
+ {"fshow", FSHOW},
+ {"gsave", GSAVE},
+ {"grestore", GRESTORE},
+ {"idtransform", IDTRANSFORM},
+ {"lineto", LINETO},
+ {"moveto", MOVETO},
+ {"mul", MUL},
+ {"neg", NEG},
+ {"newpath", NEWPATH},
+ {"pop", POP},
+ {"rlineto", RLINETO},
+ {"rotate", ROTATE},
+ {"scale", SCALE},
+ {"setcmykcolor", SETCMYKCOLOR},
+ {"setdash", SETDASH},
+ {"setgray", SETGRAY},
+ {"setlinecap", SETLINECAP},
+ {"setlinejoin", SETLINEJOIN},
+ {"setlinewidth", SETLINEWIDTH},
+ {"setmiterlimit", SETMITERLIMIT},
+ {"setrgbcolor", SETRGBCOLOR},
+ {"show", SHOW},
+ {"showpage", SHOWPAGE},
+ {"startTexFig", TEXFIG},
+ {"endTexFig", ETEXFIG},
+ {"stroke", STROKE},
+ {"sub", SUB},
+ {"translate", TRANSLATE},
+ {"truncate", TRUNCATE}
+};
+
+static int lookup_operator(char *token)
+{
+ int i, operator;
+ operator = -1;
+ for (i=0; i<sizeof(operators)/sizeof(operators[0]); i++) {
+ if (!strcmp (token, operators[i].t)) {
+ operator = operators[i].v;
+ break;
+ }
+ }
+ if (i == sizeof(operators)/sizeof(operators[0]) &&
+ mp_is_font_name (token)) {
+ operator = FONTNAME;
+ }
+ return operator;
+}
+
+
+/* Following needed to save texfig state */
+
+static long next_fig = 1;
+static pdf_obj *fig_xobj = NULL;
+struct xform_info *fig_p;
+static char fig_res_name[16];
+
+static int do_operator(char *token,
+ double x_user, double y_user)
+ /* Again, the only piece that needs x_user and y_user is
+ that piece dealing with texfig */
+{
+ int operator, error = 0;
+ pdf_obj *tmp1=NULL, *tmp2=NULL, *tmp3=NULL, *tmp4 = NULL;
+ pdf_obj *tmp5=NULL, *tmp6=NULL;
+ int len;
+ /* PS to PDF conversion is not so simple. We maintain
+ state so we can change "gsave fill grestore stroke" to "B".
+ We need to keep track of what we have seen. This code is not
+ too smart and could be easily fooled by real postscript.
+ It makes some assumptions since it is only looking at MetaPost
+
+ States are as follows:
+ 0: Nothing special
+ 1: Started a path
+ 2: Saw gsave in path
+ 3: Saw a painting operator in state 2(fill, stroke, or newpath)
+ 4: Saw a grestore in state 3
+ */
+ operator = lookup_operator (token);
+ switch (operator) {
+ case ADD:
+ tmp1 = POP_STACK();
+ tmp2 = POP_STACK();
+ if (tmp1 && tmp2)
+ pdf_set_number (tmp1,
+ pdf_number_value(tmp1)+pdf_number_value(tmp2));
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ if (tmp1)
+ PUSH(tmp1);
+ break;
+ case CLIP:
+ clip_path();
+ break;
+ case CLOSEPATH:
+ close_path();
+ break;
+ case CONCAT:
+ tmp1 = POP_STACK();
+ if (tmp1 && tmp1 -> type == PDF_ARRAY) {
+ int i, len = 0;
+ for (i=0; i<6; i++) {
+ if (!(tmp2 = pdf_get_array(tmp1, i)))
+ break;
+ if (i == 0) {
+ sprintf (work_buffer+len, "\n");
+ len += strlen (work_buffer+len);
+ } else {
+ sprintf (work_buffer+len, " ");
+ len += strlen (work_buffer+len);
+ }
+ sprintf (work_buffer+len, "%g",
+ ROUND(pdf_number_value(tmp2),0.0001));
+ len += strlen (work_buffer+len);
+ }
+ sprintf (work_buffer+len, " cm");
+ len += strlen (work_buffer+len);
+ pdf_doc_add_to_page (work_buffer, len);
+ /* Transform pending path, if any */
+ transform_path (pdf_number_value(pdf_get_array(tmp1, 0)),
+ pdf_number_value(pdf_get_array(tmp1, 1)),
+ pdf_number_value(pdf_get_array(tmp1, 2)),
+ pdf_number_value(pdf_get_array(tmp1, 3)),
+ pdf_number_value(pdf_get_array(tmp1, 4)),
+ pdf_number_value(pdf_get_array(tmp1, 5)));
+ } else {
+ fprintf (stderr, "\nMissing array before \"concat\"\n");
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ break;
+ case CURRENTPOINT:
+ state = 0;
+ PUSH (pdf_new_number (x_user)); /* Remember that x_user and y_user */
+ PUSH (pdf_new_number (y_user)); /* are off by 0.02 % */
+ break;
+ case CURVETO:
+ if (state <= 1) /* In path now */
+ state = 1;
+ else {
+ fprintf (stderr, "\nUnexpected path segment\n");
+ }
+ if ((tmp6 = POP_STACK()) && tmp6->type == PDF_NUMBER &&
+ (tmp5 = POP_STACK()) && tmp5->type == PDF_NUMBER &&
+ (tmp4 = POP_STACK()) && tmp4->type == PDF_NUMBER &&
+ (tmp3 = POP_STACK()) && tmp3->type == PDF_NUMBER &&
+ (tmp2 = POP_STACK()) && tmp2->type == PDF_NUMBER &&
+ (tmp1 = POP_STACK()) && tmp1->type == PDF_NUMBER) {
+ add_curve_to_path (pdf_number_value(tmp1),
+ pdf_number_value(tmp2),
+ pdf_number_value(tmp3),
+ pdf_number_value(tmp4),
+ pdf_number_value(tmp5),
+ pdf_number_value(tmp6));
+ x_state = pdf_number_value (tmp5);
+ y_state = pdf_number_value (tmp6);
+ } else {
+ fprintf (stderr, "\nMissing number(s) before \"curveto\"\n");
+ }
+ if (tmp1) pdf_release_obj (tmp1);
+ if (tmp2) pdf_release_obj (tmp2);
+ if (tmp3) pdf_release_obj (tmp3);
+ if (tmp4) pdf_release_obj (tmp4);
+ if (tmp5) pdf_release_obj (tmp5);
+ if (tmp6) pdf_release_obj (tmp6);
+ break;
+ case DIV:
+ tmp2 = POP_STACK();
+ tmp1 = POP_STACK();
+ if (tmp1 && tmp2)
+ pdf_set_number (tmp1,
+ pdf_number_value(tmp1)/pdf_number_value(tmp2));
+ if (tmp1)
+ PUSH(tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ break;
+ case DTRANSFORM:
+ if ((tmp2 = POP_STACK()) && tmp2 -> type == PDF_NUMBER &&
+ (tmp1 = POP_STACK()) && tmp1 -> type == PDF_NUMBER) {
+ pdf_set_number (tmp1, pdf_number_value(tmp1)*100.0);
+ pdf_set_number (tmp2, pdf_number_value(tmp2)*100.0);
+ PUSH(tmp1);
+ PUSH(tmp2);
+ } else {
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ fprintf (stderr, "\nExpecting two numbers before \"dtransform\"");
+ }
+ break;
+ case EXCH:
+ if ((tmp1 = POP_STACK()) &&
+ (tmp2 = POP_STACK())) {
+ PUSH (tmp1);
+ PUSH (tmp2);
+ } else {
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ }
+ break;
+ case FILL:
+ switch (state) {
+ case 0:
+ state = 0;
+ break;
+ case 1:
+ flush_path ();
+ pdf_doc_add_to_page (" f", 2);
+ state = 0;
+ break;
+ case 2:
+ state = 3;
+ break;
+ case 3:
+ fprintf (stderr, "\nUnexpected fill\n");
+ break;
+ case 4:
+ flush_path ();
+ pdf_doc_add_to_page (" B", 2);
+ state = 0;
+ break;
+ }
+ break;
+ case FSHOW:
+ {
+ int fontid;
+ if ((tmp3 = POP_STACK()) && (tmp3->type == PDF_NUMBER) &&
+ (tmp2 = POP_STACK()) && (tmp2->type == PDF_STRING) &&
+ (tmp1 = POP_STACK()) && (tmp1->type == PDF_STRING)) {
+ if ((fontid = mp_fontid (pdf_string_value(tmp2),
+ pdf_number_value(tmp3))) < 0) {
+ fprintf (stderr, "\n\"fshow\": Missing font in MetaPost file? %s@%g\n",
+ (char *) pdf_string_value(tmp2), pdf_number_value(tmp3));
+ }
+ dev_set_string (x_state/dvi_unit_size(), y_state/dvi_unit_size(),
+ pdf_string_value(tmp1),
+ pdf_string_length(tmp1), 0, mp_fonts[fontid].font_id);
+ graphics_mode();
+ }
+ /* Treat fshow as a path terminator of sorts */
+ state = 0;
+
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ if (tmp3)
+ pdf_release_obj (tmp3);
+ }
+ break;
+ case GSAVE:
+ switch (state) {
+ case 0:
+ pdf_doc_add_to_page ("\nq", 2);
+ num_saves += 1;
+ break;
+ case 1:
+ state = 2;
+ break;
+ case 4:
+ state = 2;
+ break;
+ default:
+ fprintf (stderr, "\nUnexpected gsave\n");
+ break;
+ }
+ break;
+ case GRESTORE:
+ switch (state) {
+ case 0:
+ if (num_saves > 0) {
+ num_saves -= 1;
+ pdf_doc_add_to_page ("\nQ", 2);
+ /* Unfortunately, the following two lines are necessary in case of a font or color
+ change inside of the save/restore pair. Anything that was done
+ there must be redone, so in effect, we make no assumptions about
+ what fonts are active. We act like we are starting a new page */
+ dev_reselect_font();
+ /* The following line was causing trouble - 1/30/01 */
+ /* dev_do_color(); */
+ }
+ else {
+ fprintf (stderr, "PS special: \"grestore\" ignored. More restores than saves on a page.\n");
+ }
+ break;
+ case 2:
+ state = 1;
+ break;
+ case 3:
+ state = 4;
+ break;
+ default:
+ fprintf (stderr, "\nUnexpected grestore\n");
+ break;
+ }
+ break;
+ case IDTRANSFORM:
+ if ((tmp2 = POP_STACK()) && tmp2 -> type == PDF_NUMBER &&
+ (tmp1 = POP_STACK()) && tmp1 -> type == PDF_NUMBER) {
+ pdf_set_number (tmp1, pdf_number_value(tmp1)/100.0);
+ pdf_set_number (tmp2, pdf_number_value(tmp2)/100.0);
+ PUSH(tmp1);
+ PUSH(tmp2);
+ } else {
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ fprintf (stderr, "\nExpecting two numbers before \"idtransform\"");
+ }
+ break;
+ case LINETO:
+ {
+ if (state <= 1) /* In path now */
+ state = 1;
+ else {
+ fprintf (stderr, "\nUnexpected path segment\n");
+ }
+ if ((tmp2 = POP_STACK()) && tmp2-> type == PDF_NUMBER &&
+ (tmp1 = POP_STACK()) && tmp1-> type == PDF_NUMBER) {
+ x_state = pdf_number_value (tmp1);
+ y_state = pdf_number_value (tmp2);
+ add_point_to_path (x_state, y_state, 'l');
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ }
+ break;
+ case MOVETO:
+ if (state <= 1) /* In path now */
+ state = 1;
+ else {
+ fprintf (stderr, "\nUnexpected path segment\n");
+ }
+ if ((tmp2 = POP_STACK()) && tmp2-> type == PDF_NUMBER &&
+ (tmp1 = POP_STACK()) && tmp1-> type == PDF_NUMBER) {
+ /* MetaPost likes to ship out a moveto before displayed text.
+ Save the results so we know where to place the text. Save
+ the move but don't actually do it unless the next operator is
+ a graphics operator */
+ x_state = pdf_number_value (tmp1);
+ y_state = pdf_number_value (tmp2);
+ add_point_to_path (x_state, y_state, 'm');
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ break;
+ case MUL:
+ tmp2 = POP_STACK();
+ tmp1 = POP_STACK();
+ if (tmp1 && tmp2)
+ pdf_set_number (tmp1,
+ pdf_number_value(tmp1)*pdf_number_value(tmp2));
+ if (tmp1)
+ PUSH(tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ break;
+ case NEG:
+ tmp1 = POP_STACK();
+ if (tmp1 && tmp1 -> type == PDF_NUMBER) {
+ pdf_set_number (tmp1, -pdf_number_value(tmp1));
+ PUSH (tmp1);
+ }
+ break;
+ case NEWPATH:
+ flush_path ();
+ pdf_doc_add_to_page ("\nn", 2);
+ break;
+ case POP:
+ tmp1 = POP_STACK();
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ break;
+ case RLINETO:
+ if (state <= 1) /* In path now */
+ state = 1;
+ else {
+ fprintf (stderr, "\nUnexpected path segment\n");
+ }
+ if ((tmp2 = POP_STACK()) && tmp2->type == PDF_NUMBER &&
+ (tmp1 = POP_STACK()) && tmp1->type == PDF_NUMBER) {
+ x_state += pdf_number_value (tmp1);
+ y_state += pdf_number_value (tmp2);
+ add_point_to_path (x_state, y_state, 'l');
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ break;
+ case SCALE:
+ if ((tmp2 = POP_STACK()) && tmp2->type == PDF_NUMBER &&
+ (tmp1 = POP_STACK()) && tmp1->type == PDF_NUMBER) {
+ sprintf (work_buffer, "\n%g 0 0 %g 0 0 cm",
+ ROUND(pdf_number_value (tmp1),0.01),
+ ROUND(pdf_number_value (tmp2),0.01));
+ len = strlen (work_buffer);
+ transform_path (pdf_number_value(tmp1), 0.0,
+ 0.0, pdf_number_value(tmp2), 0.0, 0.0);
+ pdf_doc_add_to_page (work_buffer, len);
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ break;
+ case SETCMYKCOLOR:
+ if ((tmp4 = POP_STACK()) && tmp4->type == PDF_NUMBER &&
+ (tmp3 = POP_STACK()) && tmp3->type == PDF_NUMBER &&
+ (tmp2 = POP_STACK()) && tmp2->type == PDF_NUMBER &&
+ (tmp1 = POP_STACK()) && tmp1->type == PDF_NUMBER) {
+ sprintf (work_buffer, "\n%g %g %g %g k",
+ ROUND(pdf_number_value (tmp1),0.001),
+ ROUND(pdf_number_value (tmp2),0.001),
+ ROUND(pdf_number_value (tmp3),0.001),
+ ROUND(pdf_number_value (tmp4),0.001));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ sprintf (work_buffer, "\n%g %g %g %g K",
+ ROUND(pdf_number_value (tmp1),0.001),
+ ROUND(pdf_number_value (tmp2),0.001),
+ ROUND(pdf_number_value (tmp3),0.001),
+ ROUND(pdf_number_value (tmp4),0.001));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ } else {
+ fprintf (stderr, "\nExpecting four numbers before \"setcmykcolor\"\n");
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ if (tmp3)
+ pdf_release_obj (tmp3);
+ if (tmp4)
+ pdf_release_obj (tmp4);
+ break;
+ case SETDASH:
+ if ((tmp2 = POP_STACK()) && tmp2->type == PDF_NUMBER &&
+ (tmp1 = POP_STACK()) && tmp1->type == PDF_ARRAY) {
+ int i;
+ pdf_doc_add_to_page ("\n[", 2);
+ for (i=0;; i++) {
+ if ((tmp3 = pdf_get_array (tmp1, i)) &&
+ tmp3 -> type == PDF_NUMBER) {
+ sprintf (work_buffer, " %g", ROUND(pdf_number_value(tmp3),0.01));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ } else
+ break;
+ }
+ pdf_doc_add_to_page (" ]", 2);
+ if (tmp2 -> type == PDF_NUMBER) {
+ sprintf (work_buffer, " %g d", ROUND(pdf_number_value(tmp2),0.01));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ }
+ } else {
+ fprintf (stderr, "\nExpecting array and number before \"setdash\"");
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ break;
+ case SETGRAY:
+ if ((tmp1 = POP_STACK()) && tmp1->type == PDF_NUMBER) {
+ sprintf (work_buffer, "\n%g g",
+ ROUND(pdf_number_value (tmp1),0.001));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ sprintf (work_buffer, " %g G",
+ ROUND(pdf_number_value (tmp1),0.001));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ } else {
+ fprintf (stderr, "\nExpecting a number before \"setgray\"\n");
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ break;
+ case SETLINECAP:
+ if ((tmp1 = POP_STACK()) && tmp1->type == PDF_NUMBER) {
+ sprintf (work_buffer, "\n%g J", pdf_number_value (tmp1));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ } else {
+ fprintf (stderr, "\nExpecting a number before \"setlinecap\"\n");
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ break;
+ case SETLINEJOIN:
+ if ((tmp1 = POP_STACK()) && tmp1->type == PDF_NUMBER) {
+ sprintf (work_buffer, "\n%g j", pdf_number_value (tmp1));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ } else {
+ fprintf (stderr, "\nExpecting a number before \"setlinejoin\"\n");
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ break;
+ case SETLINEWIDTH:
+ if ((tmp1 = POP_STACK()) && tmp1->type == PDF_NUMBER) {
+ sprintf (work_buffer, "\n%g w", ROUND(pdf_number_value (tmp1),0.01));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ } else {
+ fprintf (stderr, "\nExpecting a number before \"setlinewidth\"\n");
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ break;
+ case SETMITERLIMIT:
+ if ((tmp1 = POP_STACK()) && tmp1->type == PDF_NUMBER) {
+ sprintf (work_buffer, "\n%g M", ROUND(pdf_number_value
+ (tmp1),0.01));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ } else {
+ fprintf (stderr, "\nExpecting a number before \"setmiterlimit\"\n");
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ break;
+ case SETRGBCOLOR:
+ if ((tmp3 = POP_STACK()) && tmp3->type == PDF_NUMBER &&
+ (tmp2 = POP_STACK()) && tmp2->type == PDF_NUMBER &&
+ (tmp1 = POP_STACK()) && tmp1->type == PDF_NUMBER) {
+ sprintf (work_buffer, "\n%g %g %g rg",
+ ROUND(pdf_number_value (tmp1),0.001),
+ ROUND(pdf_number_value (tmp2),0.001),
+ ROUND(pdf_number_value (tmp3),0.001));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ sprintf (work_buffer, "\n%g %g %g RG",
+ ROUND(pdf_number_value (tmp1),0.001),
+ ROUND(pdf_number_value (tmp2),0.001),
+ ROUND(pdf_number_value (tmp3),0.001));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ } else {
+ fprintf (stderr, "\nExpecting three numbers before \"setrgbcolor\"\n");
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ if (tmp3)
+ pdf_release_obj (tmp3);
+ break;
+ case SHOWPAGE:
+ /* Let's ignore this for now */
+ void_path ();
+ break;
+ case STROKE:
+ switch (state) {
+ case 0:
+ state = 0;
+ break;
+ case 1:
+ flush_path ();
+ pdf_doc_add_to_page (" S", 2);
+ state = 0;
+ break;
+ case 2:
+ state = 3;
+ break;
+ case 3:
+ fprintf (stderr, "\nUnexpected fill\n");
+ break;
+ case 4:
+ flush_path ();
+ pdf_doc_add_to_page (" B", 2);
+ state = 0;
+ break;
+ }
+ break;
+ case SUB:
+ tmp2 = POP_STACK();
+ tmp1 = POP_STACK();
+ if (tmp1 && tmp2)
+ pdf_set_number (tmp1,
+ pdf_number_value(tmp1)-pdf_number_value(tmp2));
+ if (tmp1)
+ PUSH(tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ break;
+ case ROTATE:
+ if ((tmp1 = POP_STACK()) && (tmp1 -> type == PDF_NUMBER)) {
+ double theta = pdf_number_value(tmp1)*M_PI/180.0;
+ sprintf (work_buffer, "\n%.4f %.4f %.4f %.4f 0 0 cm",
+ cos(theta), -sin(theta),
+ sin(theta), cos(theta));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ break;
+ case TEXFIG:
+ if ((tmp6 = POP_STACK()) && (tmp6 -> type == PDF_NUMBER) &&
+ (tmp5 = POP_STACK()) && (tmp5 -> type == PDF_NUMBER) &&
+ (tmp4 = POP_STACK()) && (tmp4 -> type == PDF_NUMBER) &&
+ (tmp3 = POP_STACK()) && (tmp3 -> type == PDF_NUMBER) &&
+ (tmp2 = POP_STACK()) && (tmp2 -> type == PDF_NUMBER) &&
+ (tmp1 = POP_STACK()) && (tmp1 -> type == PDF_NUMBER)) {
+ double dvi2pts = dvi_unit_size();
+ fig_p = new_xform_info ();
+ fig_p -> width = pdf_number_value(tmp1)*dvi2pts;
+ fig_p -> height = pdf_number_value(tmp2)*dvi2pts;
+ fig_p -> c_llx = pdf_number_value(tmp3)*dvi2pts;
+ fig_p -> c_lly = pdf_number_value(tmp4)*dvi2pts;
+ fig_p -> c_urx = pdf_number_value(tmp5)*dvi2pts;
+ fig_p -> c_ury = pdf_number_value(tmp6)*dvi2pts;
+ pdf_scale_image (fig_p);
+ sprintf (fig_res_name, "Tf%ld", next_fig);
+ fig_xobj = begin_form_xobj (fig_p->c_llx, -fig_p->c_ury, fig_p->c_llx, -fig_p->c_lly,
+ fig_p->c_urx, -fig_p->c_ury, fig_res_name);
+ }
+ if (tmp1) pdf_release_obj(tmp1);
+ if (tmp2) pdf_release_obj(tmp2);
+ if (tmp3) pdf_release_obj(tmp3);
+ if (tmp4) pdf_release_obj(tmp4);
+ if (tmp5) pdf_release_obj(tmp5);
+ if (tmp6) pdf_release_obj(tmp6);
+ break;
+ case ETEXFIG:
+ if (fig_xobj) {
+ next_fig += 1;
+ end_form_xobj ();
+ pdf_doc_add_to_page_xobjects (fig_res_name, pdf_ref_obj(fig_xobj));
+ pdf_release_obj (fig_xobj);
+ fig_xobj = NULL;
+ pdf_doc_add_to_page ("\nq", 2);
+ add_xform_matrix (x_user, y_user, fig_p->xscale, -fig_p->yscale, fig_p->rotate);
+ if (fig_p->depth != 0.0)
+ add_xform_matrix (0.0, -fig_p->depth, 1.0, -1.0, 0.0);
+ release_xform_info (fig_p);
+ sprintf (work_buffer, " /%s Do Q", fig_res_name);
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ } else {
+ fprintf (stderr, "\nendTexFig without valid startTexFig ignored\n");
+ }
+ break;
+ case TRANSLATE:
+ if ((tmp2 = POP_STACK()) && tmp2->type == PDF_NUMBER &&
+ (tmp1 = POP_STACK()) && tmp1->type == PDF_NUMBER) {
+ sprintf (work_buffer, "\n1 0 0 1 %g %g cm",
+ ROUND(pdf_number_value (tmp1),0.01),
+ ROUND(pdf_number_value (tmp2),0.01));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ transform_path (1.0, 0.0, 0.0, 1.0,
+ pdf_number_value (tmp1),
+ pdf_number_value (tmp2));
+ }
+ if (tmp1)
+ pdf_release_obj (tmp1);
+ if (tmp2)
+ pdf_release_obj (tmp2);
+ break;
+ case TRUNCATE:
+ if ((tmp1 = POP_STACK()) && tmp1->type == PDF_NUMBER) {
+ double val=pdf_number_value(tmp1);
+ pdf_set_number (tmp1, val>0? floor(val): ceil(val));
+ PUSH (tmp1);
+ } else if (tmp1)
+ pdf_release_obj (tmp1);
+ break;
+ case FONTNAME:
+ PUSH (pdf_new_string (token, strlen(token)));
+ break;
+ default:
+ fprintf (stderr,
+ "\nIgnoring remaining special text following unknown PS operator: \"%s\"\n", token);
+ error = 1;
+ break;
+ }
+ return !error;
+}
+
+static int do_one_ps_line (char **start, char *end,
+ double x_user, double y_user)
+ /* the only sections that need to know x_user and y _user are those
+ dealing with texfig */
+{
+ char *token, *save = NULL;
+ pdf_obj *obj;
+ int error = 0;
+ skip_white (start, end);
+ while (*start < end && !error) {
+ save = *start;
+ if (isdigit (**start) || **start == '-' || **start == '.' ) {
+ token = parse_number (start, end);
+ PUSH (pdf_new_number(atof(token)));
+ RELEASE (token);
+ } else if (**start == '[' && /* This code assumes that arrays are contained on one line */
+ (obj = parse_pdf_array (start, end))) {
+ PUSH (obj);
+ } else if (**start == '(' &&
+ (obj = parse_pdf_string (start, end))) {
+ PUSH (obj);
+ } else if (**start == '/') {
+ fprintf (stderr, "\nUnable to handle names in raw PS code.");
+ dump (*start, end);
+ error = 1;
+ } else {
+ token = parse_ident (start, end);
+ if (!token || !do_operator (token, x_user, y_user)) {
+ error = 1;
+ }
+ if (token)
+ RELEASE (token);
+ }
+ skip_white (start, end);
+ }
+ if (*start < end) {
+ fprintf (stderr, "\nRemainder of line unparsed.");
+ dump (*start, end);
+ }
+ return !error;
+}
+
+static char line_buffer[1024];
+int parse_contents (FILE *image_file)
+{
+ int error = 0;
+ top_stack = 0;
+ x_state = 0.0;
+ y_state = 0.0;
+ state = 0;
+ while (!feof(image_file) && mfgets (line_buffer, sizeof(line_buffer),
+ image_file)) {
+ char *start, *end;
+ start = line_buffer;
+ end = start+strlen(line_buffer);
+ if (!do_one_ps_line (&start, end, 0.0, 0.0)) {
+ error = 1;
+ break;
+ }
+ }
+ return !error;
+}
+
+int do_raw_ps_special (char **start, char* end, int cleanup,
+ double x_user, double y_user)
+{
+ int error = 0;
+ state = 0;
+ do_one_ps_line (start, end, x_user, y_user);
+ if (cleanup)
+ mp_cleanup(1);
+ return !error;
+}
+
+void mp_cleanup (int sloppy_ok)
+{
+ release_fonts();
+ if (state != 0) {
+ if (!sloppy_ok)
+ fprintf (stderr, "mp_cleanup(): State not zero\n");
+ state = 0;
+ }
+ if (top_stack != 0) {
+ if (!sloppy_ok)
+ fprintf (stderr, "\nPS/MetaPost: PS stack not empty at end of figure!\n");
+ }
+ /* Cleanup paths */
+ while (top_stack > 0) {
+ pdf_obj *p;
+ if ((p=POP_STACK()))
+ pdf_release_obj (p);
+ }
+ if (n_path_pts > 0) {
+ if (!sloppy_ok) {
+ fprintf (stderr, "\nPS/MetaPost: Pending path at end of figure!\n");
+ dump_path ();
+ }
+ void_path ();
+ }
+ if (max_path_pts > 0) {
+ RELEASE (path);
+ path = NULL;
+ max_path_pts = 0;
+ }
+}
+
+void mp_eop_cleanup(void)
+{
+ mp_cleanup(1);
+ num_saves = 0;
+}
+
+
+/* mp inclusion is a bit of a hack. The routine
+ * starts a form at the lower left corner of
+ * the page and then calls begin_form_xobj telling
+ * it to record the image drawn there and bundle it
+ * up in an xojbect. This allows us to use the coordinates
+ * in the MP file directly. This appears to be the
+ * easiest way to be able to use the dev_set_string()
+ * command (with its scaled and extended fonts) without
+ * getting all confused about the coordinate system.
+ * After the xobject is created, the whole thing can
+ * be scaled any way the user wants */
+
+pdf_obj *mp_include (FILE *image_file, struct xform_info *p,
+ char *res_name, double x_user, double y_user)
+{
+ pdf_obj *xobj = NULL;
+ rewind (image_file);
+ if (mp_parse_headers (image_file, p)) {
+ /* Looks like an MP file. Setup xobj "capture" */
+ pdf_scale_image (p);
+ xobj = begin_form_xobj (p->u_llx,p->u_lly, p->c_llx, p->c_lly,
+ p->c_urx, p->c_ury, res_name);
+ if (!xobj)
+ return NULL;
+ /* Flesh out the contents */
+ if (!parse_contents (image_file)) {
+ fprintf (stderr, "Errors occured while interpreting MetaPost file.\n\n");
+ }
+ /* Finish off the form */
+ end_form_xobj();
+ } else {
+ fprintf (stderr, "\nErrors occured while scanning MetaPost file headers.\n");
+ }
+ mp_cleanup(0);
+ return xobj;
+}
+
+/* struct xform_info *texfig_info (void)
+{
+ struct xform_info *p;
+ p = new_xform_info ();
+ p -> user_bbox = 1;
+ p -> width = fig_width;
+ p -> height = fig_height;
+ p -> u_llx = fig_llx;
+ p -> u_lly = fig_lly;
+ p -> u_urx = fig_urx;
+ p -> u_ury = fig_ury;
+ return p;
+} */
diff --git a/Build/source/texk/dvipdfm/mpost.h b/Build/source/texk/dvipdfm/mpost.h
new file mode 100644
index 00000000000..2fe9f9538c6
--- /dev/null
+++ b/Build/source/texk/dvipdfm/mpost.h
@@ -0,0 +1,40 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include "pdfobj.h"
+#include "pdfspecial.h"
+
+#ifndef MPOST_H
+# define MPOST_H
+extern int check_for_mp (FILE *image_file);
+extern pdf_obj *mp_include (FILE *image_file, struct xform_info *p,
+ char *res_name, double x_user, double y_user);
+extern int do_raw_ps_special (char **start, char *end, int cleanup,
+ double x_user, double y_user);
+extern void mp_cleanup(int sloppy_is_okay);
+extern struct xform_info *texfig_info (void);
+extern void mp_eop_cleanup(void);
+#endif /* MPOST_H */
+
+
diff --git a/Build/source/texk/dvipdfm/numbers.c b/Build/source/texk/dvipdfm/numbers.c
new file mode 100644
index 00000000000..02f9e2869cf
--- /dev/null
+++ b/Build/source/texk/dvipdfm/numbers.c
@@ -0,0 +1,317 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include "system.h"
+#include "error.h"
+#include "mfileio.h"
+#include "numbers.h"
+
+UNSIGNED_BYTE get_unsigned_byte (FILE *file)
+{
+ int ch;
+ if ((ch = fgetc (file)) < 0)
+ ERROR ("File ended prematurely\n");
+ return (UNSIGNED_BYTE) ch;
+}
+
+UNSIGNED_BYTE sget_unsigned_byte (char *s)
+{
+ return *((unsigned char *) s);
+}
+
+SIGNED_BYTE get_signed_byte (FILE *file)
+{
+ int byte;
+ byte = get_unsigned_byte(file);
+ if (byte >= 0x80)
+ byte -= 0x100;
+ return (SIGNED_BYTE) byte;
+}
+
+UNSIGNED_PAIR get_unsigned_pair (FILE *file)
+{
+ int i;
+ UNSIGNED_BYTE byte;
+ UNSIGNED_PAIR pair = 0;
+ for (i=0; i<2; i++) {
+ byte = get_unsigned_byte(file);
+ pair = pair*0x100u + byte;
+ }
+ return pair;
+}
+
+UNSIGNED_PAIR sget_unsigned_pair (unsigned char *s)
+{
+ int i;
+ UNSIGNED_BYTE byte;
+ UNSIGNED_PAIR pair = 0;
+ for (i=0; i<2; i++) {
+ byte = *(s++);
+ pair = pair*0x100u + byte;
+ }
+ return pair;
+}
+
+SIGNED_PAIR get_signed_pair (FILE *file)
+{
+ int i;
+ long pair = 0;
+ for (i=0; i<2; i++) {
+ pair = pair*0x100 + get_unsigned_byte(file);
+ }
+ if (pair >= 0x8000) {
+ pair -= 0x10000l;
+ }
+ return (SIGNED_PAIR) pair;
+}
+
+
+UNSIGNED_TRIPLE get_unsigned_triple(FILE *file)
+{
+ int i;
+ long triple = 0;
+ for (i=0; i<3; i++) {
+ triple = triple*0x100u + get_unsigned_byte(file);
+ }
+ return (UNSIGNED_TRIPLE) triple;
+}
+
+SIGNED_TRIPLE get_signed_triple(FILE *file)
+{
+ int i;
+ long triple = 0;
+ for (i=0; i<3; i++) {
+ triple = triple*0x100 + get_unsigned_byte(file);
+ }
+ if (triple >= 0x800000l)
+ triple -= 0x1000000l;
+ return (SIGNED_TRIPLE) triple;
+}
+
+SIGNED_QUAD get_signed_quad(FILE *file)
+{
+ int byte, i;
+ long quad = 0;
+
+ /* Check sign on first byte before reading others */
+ byte = get_unsigned_byte(file);
+ quad = byte;
+ if (quad >= 0x80)
+ quad = byte - 0x100;
+ for (i=0; i<3; i++) {
+ quad = quad*0x100 + get_unsigned_byte(file);
+ }
+ return (SIGNED_QUAD) quad;
+}
+
+UNSIGNED_QUAD get_unsigned_quad(FILE *file)
+{
+ int i;
+ unsigned long quad = 0;
+ for (i=0; i<4; i++) {
+ quad = quad*0x100u + get_unsigned_byte(file);
+ }
+ return (UNSIGNED_QUAD) quad;
+}
+
+SIGNED_QUAD sqxfw (SIGNED_QUAD sq, fixword fw)
+{
+ int sign = 1;
+ unsigned long a, b, c, d, ad, bd, bc, ac;
+ unsigned long e, f, g, h, i, j, k;
+ unsigned long result;
+ /* Make positive. */
+ if (sq < 0) {
+ sign = -sign;
+ sq = -sq;
+ }
+ if (fw < 0) {
+ sign = -sign;
+ fw = -fw;
+ }
+ a = ((unsigned long) sq) >> 16u;
+ b = ((unsigned long) sq) & 0xffffu;
+ c = ((unsigned long) fw) >> 16u;
+ d = ((unsigned long) fw) & 0xffffu;
+ ad = a*d; bd = b*d; bc = b*c; ac = a*c;
+ e = bd >> 16u;
+ f = ad >> 16u;
+ g = ad & 0xffffu;
+ h = bc >> 16u;
+ i = bc & 0xffffu;
+ j = ac >> 16u;
+ k = ac & 0xffffu;
+ result = (e+g+i + (1<<3)) >> 4u; /* 1<<3 is for rounding */
+ result += (f+h+k) << 12u;
+ result += j << 28u;
+ return (sign>0)?result:-result;
+}
+
+SIGNED_QUAD axboverc (SIGNED_QUAD n1, SIGNED_QUAD n2, SIGNED_QUAD div)
+{
+ int sign = 1;
+ unsigned long a, b, c, d, ad, bd, bc, ac, e, f, g, h, i, j, o;
+ unsigned long high, low;
+ SIGNED_QUAD result = 0;
+ /* Make positive. */
+ if (n1 < 0) {
+ sign = -sign;
+ n1 = -n1;
+ }
+ if (n2 < 0) {
+ sign = -sign;
+ n2 = -n2;
+ }
+ if (div < 0) {
+ sign = -sign;
+ div = -div;
+ }
+ a = ((unsigned long) n1) >> 16u;
+ b = ((unsigned long) n1) & 0xffffu;
+ c = ((unsigned long) n2) >> 16u;
+ d = ((unsigned long) n2) & 0xffffu;
+ ad = a*d; bd = b*d; bc = b*c; ac = a*c;
+ e = bd >> 16u; f = bd & 0xffffu;
+ g = ad >> 16u; h = ad & 0xffffu;
+ i = bc >> 16u; j = bc & 0xffffu;
+ o = e+h+j;
+ high = g+i+(o>>16u)+ac; o &= 0xffffu;
+ low = (o << 16) + f;
+ if (high >= div)
+ ERROR ("Overflow in axboc");
+ {
+ int i;
+ for (i=0; i<32; i++) {
+ high *= 2;
+ result *= 2;
+ if (low >= 0x80000000) {
+ low -= 0x80000000;
+ high += 1;
+ }
+ low *= 2;
+ if (high > div) {
+ high -= div;
+ result += 1;
+ }
+ }
+ }
+ high *= 2;
+ if (high >= div)
+ result += 1;
+ return (sign>0)?result:-result;
+}
+
+/* Create a private_itoa to be used internally in the
+ hopes that a good optimizing compiler will use it inline */
+static int private_itoa (char *s, long int n, int mindigits)
+{
+ int j, nwhole;
+ char *p = s;
+ if (n<0) {
+ *(p++) = '-';
+ n = -n;
+ }
+ /* Generate at least one digit in reverse order */
+ nwhole = 0;
+ do {
+ p[nwhole++] = n%10 + '0';
+ n /= 10;
+ } while (n != 0 || nwhole < mindigits);
+ /* Reverse the digits */
+ for (j=0; j<nwhole/2; j++) {
+ char tmp = p[j];
+ p[j] = p[nwhole-j-1];
+ p[nwhole-j-1]=tmp;
+ }
+ p += nwhole;
+ *p = 0;
+ return (p-s);
+}
+
+int inttoa (char *s, long int i)
+{
+ /* Call the private one */
+ return private_itoa (s, i, 0);
+}
+
+int centi_u_to_a (char *s, long int n)
+{
+ char *p = s;
+ unsigned long whole_part;
+ int frac_part;
+ if (n<0) {
+ *(p++) = '-';
+ n = -n;
+ }
+ whole_part = ((unsigned long) n) / 100;
+ frac_part = ((unsigned long) n) % 100;
+ /* Print the whole part */
+ p += private_itoa (p, whole_part, 0);
+ if (frac_part) {
+ int mindigits = 2;
+ *(p++) = '.';
+ while (!(frac_part % 10)) {
+ frac_part /= 10;
+ mindigits -= 1;
+ }
+ p += private_itoa (p, frac_part, mindigits);
+ }
+ return (p-s);
+}
+
+int fixnumtoa (char *s, long int n)
+{
+ int j, thresh;
+ char *p = s;
+ unsigned long whole_part, frac_part;
+ if (n<0) {
+ *(p++) = '-';
+ n = -n;
+ }
+ whole_part = ((unsigned long) n) / (65536l);
+ frac_part = ((unsigned long) n) % 65536l;
+ /* Print the whole part */
+ p += private_itoa (p, whole_part, 0);
+
+ #define BASE ((unsigned long)(256*65536l))
+ frac_part *= 256;
+ thresh = BASE / 10000;
+ /* Round last digit */
+ frac_part += thresh/2;
+ if (frac_part > thresh) {
+ *(p++) = '.';
+ }
+ for (j=0; j<4 && frac_part> thresh; j++) {
+ char next_digit;
+ next_digit = (10*frac_part)/BASE;
+ frac_part = (10*frac_part)%BASE;
+ *(p++) = next_digit + '0';
+ thresh *= 10;
+ }
+ *p = 0;
+ return (p-s);
+}
+
+
+
diff --git a/Build/source/texk/dvipdfm/numbers.h b/Build/source/texk/dvipdfm/numbers.h
new file mode 100644
index 00000000000..b35ebf46278
--- /dev/null
+++ b/Build/source/texk/dvipdfm/numbers.h
@@ -0,0 +1,85 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef NUMBERS_H
+#define NUMBERS_H
+
+#include <stdio.h>
+#include <math.h>
+
+typedef unsigned char Ubyte;
+
+typedef int UNSIGNED_BYTE, SIGNED_BYTE, SIGNED_PAIR;
+typedef unsigned UNSIGNED_PAIR;
+typedef long UNSIGNED_TRIPLE, SIGNED_TRIPLE, SIGNED_QUAD;
+typedef unsigned long UNSIGNED_QUAD;
+
+extern UNSIGNED_BYTE get_unsigned_byte (FILE *);
+
+extern UNSIGNED_BYTE sget_unsigned_byte (char *);
+
+extern SIGNED_BYTE get_signed_byte (FILE *);
+
+extern UNSIGNED_PAIR get_unsigned_pair (FILE *);
+
+extern UNSIGNED_PAIR sget_unsigned_pair (unsigned char *);
+
+extern SIGNED_PAIR get_signed_pair (FILE *);
+
+extern UNSIGNED_TRIPLE get_unsigned_triple (FILE *);
+
+extern SIGNED_TRIPLE get_signed_triple (FILE *);
+
+extern SIGNED_QUAD get_signed_quad (FILE *);
+
+extern UNSIGNED_QUAD get_unsigned_quad (FILE *);
+
+#define ROUND(n,acc) (floor(((double)n)/(acc)+0.5)*(acc))
+#ifndef MAX
+ #define MAX(a,b) ((a)>(b)?(a):(b))
+#endif
+#ifndef MIN
+ #define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+
+#define ISODD(n) (((n)/2)*2!=(n))
+#define ISEVEN(n) (((n)/2)*2==(n))
+
+typedef signed long fixword;
+
+extern SIGNED_QUAD sqxfw (SIGNED_QUAD sq, fixword fw);
+extern SIGNED_QUAD axboverc (SIGNED_QUAD n1, SIGNED_QUAD n2,
+ SIGNED_QUAD div);
+
+int fixnumtoa (char *s, long int i);
+int inttoa (char *s, long int i);
+int centi_u_to_a (char *s, long int i);
+
+#define IDIVRND(a,b) ((a)>0? ((a)+(b)/2)/(b): -((-(a)+(b)/2)/(b)))
+
+#define IDIV(a,b) ((a)>0? (a)/(b): -(-(a))/(b))
+
+#endif /* NUMBERS_H */
+
diff --git a/Build/source/texk/dvipdfm/pdfdev.c b/Build/source/texk/dvipdfm/pdfdev.c
new file mode 100644
index 00000000000..461881d606a
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pdfdev.c
@@ -0,0 +1,1343 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include "config.h"
+#include <math.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include "system.h"
+#include "mem.h"
+#include "error.h"
+#include "mfileio.h"
+#include "numbers.h"
+#include "dvi.h"
+#include "tfm.h"
+#include "pdfdev.h"
+#include "pdfdoc.h"
+#include "pdfobj.h"
+#include "type1.h"
+#include "ttf.h"
+#include "pkfont.h"
+#include "pdfspecial.h"
+#include "pdfparse.h"
+#include "tpic.h"
+#include "htex.h"
+#include "mpost.h"
+#include "psspecial.h"
+#include "colorsp.h"
+#include "pdflimits.h"
+#include "twiddle.h"
+#include "encodings.h"
+
+/* Internal functions */
+static void dev_clear_color_stack (void);
+static void dev_clear_xform_stack (void);
+
+double hoffset = 72.0, voffset=72.0;
+
+static double dvi2pts = 0.0;
+
+ /* Acrobat doesn't seem to like coordinate systems
+ that involve scalings around 0.01, so we use
+ a scaline of 1.0. In other words, device units = pts */
+/* Following dimensions in virtual device coordinates,
+which are points */
+
+static double page_width=612.0, page_height=792.0;
+int page_size_readonly = 0;
+
+void dev_set_page_size (double width, double height)
+{
+ if (page_size_readonly) {
+ fprintf (stderr, "\nSorry. Too late to change page size\n");
+ } else {
+ page_width = width;
+ page_height = height;
+ }
+}
+
+double dev_page_width(void)
+{
+ page_size_readonly = 1;
+ return page_width;
+}
+
+double dev_page_height(void)
+{
+ page_size_readonly = 1;
+ return page_height;
+}
+
+static int debug = 0, verbose = 0;
+
+void dev_set_verbose (void)
+{
+ verbose += 1;
+}
+void dev_set_debug (void)
+{
+ debug = 1;
+}
+
+#define GRAPHICS_MODE 1
+#define TEXT_MODE 2
+#define STRING_MODE 3
+
+int motion_state = GRAPHICS_MODE; /* Start in graphics mode */
+
+#define FORMAT_BUF_SIZE 4096
+static char format_buffer[FORMAT_BUF_SIZE];
+
+/* The coordinate system in the pdf file is setup so that 1 unit in the
+ PDF content stream's coordinate system represents 65,800 DVI units.
+ This choice was made so that a PDF coordinate represented only
+ to the hundredths place represents an exact integer number of DVI units.
+ Doing so allows relative motions in a PDF file to be known
+ precisely in DVI units, and allows us to keep track of relative motions
+ using integer arithmetic. Relative motions in the PDF file are
+ represented in decimal with no more than two digits after the decimal
+ point. In the PDF stream, a PDF user coordinate of 0.01 represents
+ exactly 658 DVI units.
+
+ The "pdfdev" module is the only module that knows the
+ relationship between PDF units and true points. It provides
+ pdf_dev_scale() to inform other modules of the scale.
+ Modules that render PDF marking operators (such as those
+ that render tpic specials or PS specials) need this value.
+ The overhead of this call is a slight performance hit for
+ rendering images, but allows dvipdfm to set text blazingly fast
+
+
+ Some constants related to this representation follow: */
+
+#define PDF_U 65800L /* Number of DVI units in a PDF unit */
+#define CENTI_PDF_U 658 /* Number of DVI units in a centi PDF unit */
+
+/* pdf_dev_scale() returns the factor by which a PDF unit
+ * must be multiplied to produce an Adobe point (big point) */
+
+double pdf_dev_scale (void)
+{
+ return 65800.0*dvi2pts;
+}
+
+
+ /* Device coordinates are relative to upper left of page. One of the
+ first things appearing in the page stream is a coordinate transformation
+ matrix that forces this to be true. This coordinate
+ transformation is the only place where the paper size is required.
+ Unfortunately, positive is up, which doesn't agree with TeX's convention. */
+
+static spt_t text_xorigin = 0, text_yorigin = 0,
+ text_offset = 0;
+double text_slant = 0.0, text_extend = 1.0;
+
+unsigned num_dev_fonts = 0;
+unsigned num_phys_fonts = 0;
+int current_font = -1;
+
+#define PHYSICAL 1
+#define VIRTUAL 2
+
+#define TYPE1 1
+#define PK 2
+#define TRUETYPE 3
+
+#define DEFAULT_MAP_FILE "dvipdfm.map"
+
+static struct dev_font {
+ char short_name[7]; /* Needs to be big enough to hold name "Fxxx"
+ where xxx is number of largest font */
+ unsigned char used_on_this_page, format;
+ char *tex_name;
+ spt_t sptsize;
+ pdf_obj *font_resource;
+ char *used_chars;
+ double extend, slant;
+ int remap;
+} *dev_font = NULL;
+
+static unsigned max_device_fonts = 0;
+
+void dev_fonts_need (unsigned n)
+{
+ if (n > max_device_fonts) {
+ max_device_fonts = MAX(max_device_fonts+MAX_FONTS, n);
+ dev_font = RENEW (dev_font, max_device_fonts, struct dev_font);
+ }
+}
+
+struct map_record {
+ char *tex_name, *font_name, *enc_name;
+ double slant, extend;
+ int remap;
+} *font_map = NULL;
+
+unsigned int num_font_map = 0, max_font_map = 0;
+
+static void font_maps_need (int n)
+{
+ if (n > max_font_map) {
+ max_font_map = MAX(max_font_map+MAX_FONTS, n);
+ font_map = RENEW (font_map, max_font_map, struct map_record);
+ }
+ return;
+}
+
+static void init_map_record (struct map_record *r)
+{
+ r->tex_name = NULL;
+ r->enc_name = NULL;
+ r->font_name = NULL;
+ r->slant = 0.0;
+ r->extend = 1.0;
+ r->remap = 0.0;
+ return;
+}
+
+static void release_map_record (struct map_record *r)
+{
+ if (r && r->tex_name)
+ RELEASE (r->tex_name);
+ if (r && r->enc_name)
+ RELEASE (r->enc_name);
+ if (r && r->font_name)
+ RELEASE (r->font_name);
+}
+
+
+static void fill_in_defaults (struct map_record *this_map_record)
+{
+ if (this_map_record -> enc_name != NULL &&
+ (!strcmp (this_map_record->enc_name, "default") ||
+ !strcmp (this_map_record->enc_name, "none"))) {
+ RELEASE(this_map_record->enc_name);
+ this_map_record -> enc_name = NULL;
+ }
+ if (this_map_record -> font_name != NULL &&
+ (!strcmp (this_map_record->font_name, "default") ||
+ !strcmp (this_map_record->font_name, "none"))) {
+ RELEASE(this_map_record->font_name);
+ this_map_record -> font_name = NULL;
+ }
+ /* We *must* fill in a font_name either explicitly or by default
+ (the tex_name) */
+ if (this_map_record -> font_name == NULL) {
+ this_map_record -> font_name = NEW (strlen(this_map_record->tex_name)+1, char);
+ strcpy (this_map_record->font_name, this_map_record->tex_name);
+ }
+ return;
+}
+
+void dev_read_mapfile (char *filename)
+{
+ FILE *mapfile;
+ char *full_map_filename, *start = NULL, *end, *tex_name;
+ if (verbose > 0)
+ fprintf (stderr, "<%s", filename);
+ full_map_filename = kpse_find_file (filename, kpse_fontmap_format,
+ 0);
+ if (full_map_filename == NULL ||
+ (mapfile = MFOPEN (full_map_filename, FOPEN_R_MODE)) == NULL) {
+ fprintf (stderr, "Warning: Couldn't open font map file %s\n", filename);
+ mapfile = NULL;
+ }
+ if (mapfile) {
+ while ((start = mfgets (work_buffer, WORK_BUFFER_SIZE, mapfile)) !=
+ NULL) {
+ end = work_buffer + strlen(work_buffer);
+ skip_white (&start, end);
+ if (start >= end)
+ continue;
+ if (*start == '%')
+ continue;
+ if ((tex_name = parse_ident (&start, end)) == NULL)
+ continue;
+ /* Parse record line in map file. First two fields (after TeX font
+ name) are position specific. Arguments start at the first token
+ beginning with a '-' */
+ font_maps_need (num_font_map+1);
+ init_map_record(font_map+num_font_map);
+ font_map[num_font_map].tex_name = tex_name;
+ skip_white (&start, end);
+ if (*start != '-') {
+ font_map[num_font_map].enc_name = parse_ident (&start, end); /* May be null */
+ skip_white (&start, end);
+ }
+ if (*start != '-') {
+ font_map[num_font_map].font_name = parse_ident (&start, end); /* May be null */
+ skip_white (&start, end);
+ }
+ /* Parse any remaining arguments */
+ while (start+1 < end && *start == '-') {
+ char *number;
+ switch (*(start+1)) {
+ case 's': /* Slant option */
+ start += 2;
+ skip_white (&start, end);
+ if (start < end &&
+ (number = parse_number(&start, end))) {
+ font_map[num_font_map].slant = atof (number);
+ RELEASE (number);
+ } else {
+ fprintf (stderr, "\n\nMissing slant value in map file for %s\n\n",
+ tex_name);
+ }
+ break;
+ case 'e': /* Extend option */
+ start += 2;
+ skip_white (&start, end);
+ if (start < end &&
+ (number = parse_number(&start, end))) {
+ font_map[num_font_map].extend = atof (number);
+ RELEASE (number);
+ } else {
+ fprintf (stderr, "\n\nMissing extend value in map file for %s\n\n",
+ tex_name);
+ }
+ break;
+ case 'r': /* Remap option */
+ start += 2;
+ skip_white (&start, end);
+ font_map[num_font_map].remap = 1;
+ break;
+ default:
+ fprintf (stderr, "\n\nWarning: Unrecognized option in map file %s: -->%s<--\n\n",
+ tex_name, start);
+ start = end;
+ }
+ skip_white (&start, end);
+ }
+ fill_in_defaults (font_map+num_font_map);
+ num_font_map += 1;
+ }
+ MFCLOSE (mapfile);
+ if (verbose > 0)
+ fprintf (stderr, ">");
+ }
+ return;
+}
+
+struct map_record *get_map_record (const char *tex_name)
+{
+ struct map_record *result = NULL;
+ int tried_default = 0;
+ unsigned int i;
+ if (!font_map && !tried_default) {
+ dev_read_mapfile (DEFAULT_MAP_FILE);
+ tried_default = 1;
+ }
+ if (!font_map)
+ return result;
+ for (i=0; i<num_font_map; i++) {
+ if (!strcmp (font_map[i].tex_name, tex_name)) {
+ result = font_map+i;
+ break;
+ }
+ }
+ return result;
+}
+
+/*
+ * reset_text_state() outputs a BT
+ * and does any necessary coordinate transformations
+ * to get ready to ship out text
+ */
+
+static void reset_text_state(void)
+{
+ int len;
+ text_xorigin = 0;
+ text_yorigin = 0;
+ text_offset = 0;
+ /*
+ * We need to reset the line matrix to handle slanted fonts
+ */
+ sprintf (format_buffer, " BT");
+ len = strlen (format_buffer);
+ if (current_font >= 0 && /* If not at top of page */
+ (dev_font[current_font].slant != 0.0 ||
+ dev_font[current_font].extend != 1.0)) {
+ sprintf (format_buffer+len, " %.7g 0 %.3g 1 ",
+ dev_font[current_font].extend,
+ dev_font[current_font].slant);
+ len += strlen (format_buffer+len);
+ len += centi_u_to_a (format_buffer+len, IDIVRND (text_xorigin, CENTI_PDF_U));
+ format_buffer[len++] = ' ';
+ len += centi_u_to_a (format_buffer+len, IDIVRND (text_yorigin, CENTI_PDF_U));
+ format_buffer[len++] = ' ';
+ format_buffer[len++] = 'T';
+ format_buffer[len++] = 'm';
+ }
+ pdf_doc_add_to_page (format_buffer, len);
+}
+
+static void text_mode (void)
+{
+ switch (motion_state) {
+ case STRING_MODE:
+ pdf_doc_add_to_page (")]TJ", 4);
+ case TEXT_MODE:
+ break;
+ case GRAPHICS_MODE:
+ reset_text_state();
+ break;
+ }
+ motion_state = TEXT_MODE;
+ text_offset = 0;
+ return;
+}
+
+void graphics_mode (void)
+{
+ switch (motion_state) {
+ case GRAPHICS_MODE:
+ break;
+ case STRING_MODE:
+ pdf_doc_add_to_page (")]TJ", 4);
+ case TEXT_MODE:
+ pdf_doc_add_to_page (" ET", 3);
+ break;
+ }
+ motion_state = GRAPHICS_MODE;
+ return;
+}
+
+static void string_mode (spt_t xpos, spt_t ypos, double slant, double extend)
+{
+ spt_t delx, dely;
+ int len = 0;
+ switch (motion_state) {
+ case STRING_MODE:
+ break;
+ case GRAPHICS_MODE:
+ reset_text_state();
+ /* Fall through now... */
+ /* Following may be necessary after a rule (and also after
+ specials) */
+ case TEXT_MODE:
+ delx = xpos - text_xorigin;
+ {
+ spt_t rounded_delx, desired_delx;
+ spt_t rounded_dely, desired_dely;
+ spt_t dvi_xerror, dvi_yerror;
+
+ /* First round dely (it is needed for delx) */
+ dely = ypos - text_yorigin;
+ desired_dely = dely;
+ rounded_dely = IDIVRND(desired_dely, CENTI_PDF_U) * CENTI_PDF_U;
+ /* Next round delx, precompensating for line transformation matrix */
+ desired_delx = (delx-desired_dely*slant)/extend;
+ rounded_delx = IDIVRND(desired_delx, CENTI_PDF_U) * CENTI_PDF_U;
+ /* Estimate errors in DVI units */
+ dvi_yerror = (desired_dely - rounded_dely);
+ dvi_xerror = (extend*(desired_delx - rounded_delx)+slant*dvi_yerror);
+ format_buffer[len++] = ' ';
+ len += centi_u_to_a (format_buffer+len, rounded_delx/CENTI_PDF_U);
+ format_buffer[len++] = ' ';
+ len += centi_u_to_a (format_buffer+len, rounded_dely/CENTI_PDF_U);
+ pdf_doc_add_to_page (format_buffer, len);
+ len = 0;
+ pdf_doc_add_to_page (" TD[(", 5);
+ text_xorigin = xpos-dvi_xerror;
+ text_yorigin = ypos-dvi_yerror;
+ }
+ text_offset = 0;
+ break;
+ }
+ motion_state = STRING_MODE;
+ return;
+}
+
+/* The purpose of the following routine is to force a Tf only
+ when it's actually necessary. This became a problem when the
+ VF code was added. The VF spec says to instantiate the
+ first font contained in the VF file before drawing a virtual
+ character. However, that font may not be used for
+ many characters (e.g. small caps fonts). For this reason,
+ dev_select_font() should not force a "physical" font selection.
+ This routine prevents a PDF Tf font selection until there's
+ really a character in that font. */
+
+static void dev_set_font (int font_id)
+{
+ int len = 0;
+ text_mode();
+ sprintf (format_buffer, "/%s ", dev_font[font_id].short_name);
+ len = strlen (format_buffer);
+ len += centi_u_to_a (format_buffer+len, IDIVRND(dev_font[font_id].sptsize, CENTI_PDF_U));
+ format_buffer[len++] = ' ';
+ format_buffer[len++] = 'T';
+ format_buffer[len++] = 'f';
+ if (dev_font[font_id].slant != text_slant ||
+ dev_font[font_id].extend != text_extend) {
+ sprintf (format_buffer+len, " %.7g 0 %.3g 1 ",
+ dev_font[font_id].extend,
+ dev_font[font_id].slant);
+ len += strlen (format_buffer+len);
+ len += centi_u_to_a (format_buffer+len, IDIVRND(text_xorigin, CENTI_PDF_U));
+ format_buffer[len++] = ' ';
+ len += centi_u_to_a (format_buffer+len, IDIVRND(text_yorigin, CENTI_PDF_U));
+ format_buffer[len++] = ' ';
+ format_buffer[len++] = 'T';
+ format_buffer[len++] = 'm';
+ /* There's no longer any uncertainty about where we are */
+ text_slant = dev_font[font_id].slant;
+ text_extend = dev_font[font_id].extend;
+ }
+ pdf_doc_add_to_page (format_buffer, len);
+ /* Add to Font list in Resource dictionary for this page */
+ if (!dev_font[font_id].used_on_this_page) {
+ pdf_doc_add_to_page_fonts (dev_font[font_id].short_name,
+ pdf_link_obj(dev_font[font_id].font_resource));
+ dev_font[font_id].used_on_this_page = 1;
+ }
+ current_font = font_id;
+ return;
+}
+
+void dev_set_string (spt_t xpos, spt_t ypos, unsigned char *s, int
+ length, spt_t width, int font_id)
+{
+ int len = 0;
+ long kern;
+
+ if (font_id != current_font)
+ dev_set_font(font_id); /* Force a Tf since we are actually trying
+ to write a character */
+ /* Kern is in units of character units, i.e., 1000 = 1 em. */
+ /* The following formula is of the form a*x/b where a, x, and b are
+ long integers. Since in integer arithmetic (a*x) could overflow
+ and a*(x/b) would not be accurate, we use floating point
+ arithmetic rather than trying to do this all with integer
+ arithmetic. */
+ kern =
+ (1000.0/dev_font[font_id].extend*(text_xorigin+text_offset-xpos))/dev_font[font_id].sptsize;
+
+ if (labs(ypos-text_yorigin) > CENTI_PDF_U || /* CENTI_PDF_U is smallest resolvable dimension */
+ abs(kern) > 32000) { /* Some PDF Readers fail on large kerns */
+ text_mode();
+ kern = 0;
+ }
+ if (motion_state != STRING_MODE)
+ string_mode(xpos, ypos, dev_font[font_id].slant, dev_font[font_id].extend);
+ else if (kern != 0) {
+ text_offset -=
+ kern*dev_font[font_id].extend*(dev_font[font_id].sptsize/1000.0);
+ /* Same issues as earlier. Use floating point for simplicity */
+ /* This routine needs to be fast, so we don't call sprintf() or
+ strcpy() */
+ format_buffer[len++] = ')';
+ len += inttoa (format_buffer+len, kern);
+ format_buffer[len++] = '(';
+ pdf_doc_add_to_page (format_buffer, len);
+ len = 0;
+ }
+ len += pdfobj_escape_str (format_buffer+len, FORMAT_BUF_SIZE-len, s,
+ length,
+ dev_font[font_id].remap);
+ pdf_doc_add_to_page (format_buffer, len);
+
+ /* Record characters used for partial font embedding */
+ /* Fonts without pfbs don't get counted and have used_chars set to
+ null */
+ if (dev_font[font_id].used_chars != NULL) {
+ int i;
+ if (dev_font[font_id].remap)
+ for (i=0; i<length; i++){
+ (dev_font[font_id].used_chars)[twiddle(s[i])] = 1;
+ }
+ else
+ for (i=0; i<length; i++){
+ (dev_font[font_id].used_chars)[s[i]] = 1;
+ }
+ }
+ text_offset += width;
+}
+
+void dev_init (double scale, double x_offset, double y_offset)
+{
+ dvi2pts = scale;
+ hoffset = x_offset;
+ voffset = y_offset;
+ if (debug) fprintf (stderr, "dev_init:\n");
+ graphics_mode();
+ dev_clear_color_stack();
+ dev_clear_xform_stack();
+}
+
+void dev_close (void)
+{
+ /* Set page origin now that user has had plenty of time
+ to set page size */
+ pdf_doc_set_origin((double) hoffset, (double)
+ dev_page_height()-voffset);
+}
+
+void dev_add_comment (char *comment)
+{
+ pdf_doc_creator (comment);
+}
+
+
+/* BOP, EOP, and FONT section.
+ BOP and EOP manipulate some of the same data structures
+ as the font stuff */
+
+#define GRAY 1
+#define RGB 2
+#define CMYK 3
+struct color {
+ int colortype;
+ double c1, c2, c3, c4;
+} colorstack[MAX_COLORS], background = {GRAY, 1.0, 1.0, 1.0, 1.0},
+ default_color = {GRAY, 0.0, 0.0, 0.0, 0.0};
+
+#include "colors.h"
+
+struct color color_by_name (char *s)
+{
+ int i;
+ struct color result;
+ for (i=0; i<sizeof(colors_by_name)/sizeof(colors_by_name[0]); i++) {
+ if (!strcmp (s, colors_by_name[i].name)) {
+ break;
+ }
+ }
+ if (i == sizeof(colors_by_name)/sizeof(colors_by_name[0])) {
+ fprintf (stderr, "Color \"%s\" no known. Using \"Black\" instead.\n", s);
+ result = default_color;
+ } else {
+ result = colors_by_name[i].color;
+ }
+ return result;
+}
+
+static int num_colors = 0;
+
+static void fill_page (void)
+{
+ if (background.colortype == GRAY && background.c1 == 1.0)
+ return;
+ switch (background.colortype) {
+ case GRAY:
+ sprintf (format_buffer, " q 0 w %.3f g %.3f G", background.c1, background.c1);
+ break;
+ case RGB:
+ sprintf (format_buffer, " q 0 w %.3f %.3f %.3f rg %.3f %.3f %.3f RG",
+ background.c1, background.c2, background.c3,
+ background.c1, background.c2, background.c3);
+ break;
+ case CMYK:
+ sprintf (format_buffer, " q 0 w %.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K ",
+ background.c1, background.c2, background.c3, background.c4,
+ background.c1, background.c2, background.c3, background.c4);
+ break;
+ }
+ pdf_doc_this_bop (format_buffer, strlen(format_buffer));
+ sprintf (format_buffer,
+ " 0 0 m %.2f 0 l %.2f %.2f l 0 %.2f l b Q ",
+ dev_page_width(), dev_page_width(), dev_page_height(),
+ dev_page_height());
+ pdf_doc_this_bop (format_buffer, strlen(format_buffer));
+ return;
+}
+
+void dev_bg_rgb_color (double r, double g, double b)
+{
+ background.colortype = RGB;
+ background.c1 = r;
+ background.c2 = g;
+ background.c3 = b;
+ return;
+}
+
+void dev_bg_cmyk_color (double c, double m, double y, double k)
+{
+ background.colortype = CMYK;
+ background.c1 = c;
+ background.c2 = m;
+ background.c3 = y;
+ background.c4 = k;
+ return;
+}
+
+void dev_bg_gray (double value)
+{
+ background.colortype = GRAY;
+ background.c1 = value;
+ return;
+}
+
+void dev_bg_named_color (char *s)
+{
+ struct color color = color_by_name (s);
+ switch (color.colortype) {
+ case GRAY:
+ dev_bg_gray (color.c1);
+ break;
+ case RGB:
+ dev_bg_rgb_color (color.c1, color.c2, color.c3);
+ break;
+ case CMYK:
+ dev_bg_cmyk_color (color.c1, color.c2, color.c3, color.c4);
+ break;
+ }
+ return;
+}
+
+static void dev_clear_color_stack (void)
+{
+ num_colors = 0;
+ return;
+}
+static void dev_set_color (struct color color)
+{
+ switch (color.colortype) {
+ int len;
+ case RGB:
+ sprintf (format_buffer, " %.2f %.2f %.2f",
+ color.c1,
+ color.c2,
+ color.c3);
+ len = strlen (format_buffer);
+ pdf_doc_add_to_page (format_buffer, len);
+ pdf_doc_add_to_page (" rg", 3);
+ pdf_doc_add_to_page (format_buffer, len);
+ pdf_doc_add_to_page (" RG", 3);
+ break;
+ case CMYK:
+ sprintf (format_buffer, " %.2f %.2f %.2f %.2f",
+ color.c1,
+ color.c2,
+ color.c3,
+ color.c4);
+ len = strlen (format_buffer);
+ pdf_doc_add_to_page (format_buffer, len);
+ pdf_doc_add_to_page (" k", 2);
+ pdf_doc_add_to_page (format_buffer, len);
+ pdf_doc_add_to_page (" K ", 3);
+ break;
+ case GRAY:
+ sprintf (format_buffer, " %.2f", color.c1);
+ len = strlen (format_buffer);
+ pdf_doc_add_to_page (format_buffer, len);
+ pdf_doc_add_to_page (" g", 2);
+ pdf_doc_add_to_page (format_buffer, len);
+ pdf_doc_add_to_page (" G", 2);
+ break;
+ default:
+ ERROR ("Internal error: Invalid default color item");
+ }
+}
+
+
+void dev_do_color (void)
+{
+ if (num_colors == 0) {
+ dev_set_color (default_color);
+ } else {
+ dev_set_color (colorstack[num_colors-1]);
+ }
+ return;
+}
+
+void dev_set_def_rgb_color (double r, double g, double b)
+{
+ default_color.c1 = r;
+ default_color.c2 = g;
+ default_color.c3 = b;
+ default_color.colortype = RGB;
+ dev_do_color();
+ return;
+}
+
+void dev_set_def_gray (double g)
+{
+ default_color.c1 = g;
+ default_color.colortype = GRAY;
+ dev_do_color();
+ return;
+}
+
+void dev_set_def_named_color (char *s)
+{
+ struct color color = color_by_name (s);
+ switch (color.colortype) {
+ case GRAY:
+ dev_set_def_gray (color.c1);
+ break;
+ case RGB:
+ dev_set_def_rgb_color (color.c1, color.c2, color.c3);
+ break;
+ case CMYK:
+ dev_set_def_cmyk_color (color.c1, color.c2, color.c3, color.c4);
+ break;
+ }
+ return;
+}
+
+void dev_set_def_cmyk_color (double c, double m, double y, double k)
+{
+ default_color.c1 = c;
+ default_color.c2 = m;
+ default_color.c3 = y;
+ default_color.c4 = k;
+ default_color.colortype = CMYK;
+ dev_do_color();
+ return;
+}
+
+void dev_begin_named_color (char *s)
+{
+ struct color color = color_by_name (s);
+ switch (color.colortype) {
+ case GRAY:
+ dev_begin_gray (color.c1);
+ break;
+ case RGB:
+ dev_begin_rgb_color (color.c1, color.c2, color.c3);
+ break;
+ case CMYK:
+ dev_begin_cmyk_color (color.c1, color.c2, color.c3, color.c4);
+ break;
+ }
+ return;
+}
+
+void dev_begin_rgb_color (double r, double g, double b)
+{
+ if (num_colors >= MAX_COLORS) {
+ fprintf (stderr, "\ndev_set_color: Exceeded depth of color stack\n");
+ return;
+ }
+ colorstack[num_colors].c1 = r;
+ colorstack[num_colors].c2 = g;
+ colorstack[num_colors].c3 = b;
+ colorstack[num_colors].colortype = RGB;
+ num_colors+= 1;
+ dev_do_color();
+}
+
+void dev_begin_cmyk_color (double c, double m, double y, double k)
+{
+ if (num_colors >= MAX_COLORS) {
+ fprintf (stderr, "\ndev_set_color: Exceeded depth of color stack\n");
+ return;
+ }
+ colorstack[num_colors].c1 = c;
+ colorstack[num_colors].c2 = m;
+ colorstack[num_colors].c3 = y;
+ colorstack[num_colors].c4 = k;
+ colorstack[num_colors].colortype = CMYK;
+ num_colors+= 1;
+ dev_do_color();
+}
+
+void dev_begin_gray (double value)
+{
+ if (num_colors >= MAX_COLORS) {
+ fprintf (stderr, "\ndev_begin_gray: Exceeded depth of color stack\n");
+ return;
+ }
+ colorstack[num_colors].c1 = value;
+ colorstack[num_colors].colortype = GRAY;
+ num_colors+= 1;
+ dev_do_color();
+}
+
+void dev_end_color (void)
+{
+ if (num_colors <= 0) {
+ fprintf (stderr, "\ndev_set_color: End color with no corresponding begin color\n");
+ return;
+ }
+ num_colors -= 1;
+ dev_do_color();
+}
+
+static int num_transforms = 0;
+
+static void dev_clear_xform_stack (void)
+{
+ num_transforms = 0;
+ return;
+}
+
+void dev_begin_xform (double xscale, double yscale, double rotate,
+ double x_user, double y_user)
+{
+ double c, s;
+ if (num_transforms >= MAX_TRANSFORMS) {
+ fprintf (stderr, "\ndev_begin_xform: Exceeded depth of transformation stack\n");
+ return;
+ }
+ c = ROUND (cos(rotate),1e-5);
+ s = ROUND (sin(rotate),1e-5);
+ sprintf (work_buffer, " q %g %g %g %g %.2f %.2f cm",
+ xscale*c, xscale*s, -yscale*s, yscale*c,
+ (1.0-xscale*c)*x_user+yscale*s*y_user,
+ -xscale*s*x_user+(1.0-yscale*c)*y_user);
+ pdf_doc_add_to_page (work_buffer, strlen(work_buffer));
+ num_transforms += 1;
+ return;
+}
+
+void dev_end_xform (void)
+{
+ if (num_transforms <= 0) {
+ fprintf (stderr, "\ndev_end_xform: End transform with no corresponding begin\n");
+ return;
+ }
+ pdf_doc_add_to_page (" Q", 2);
+ num_transforms -= 1;
+ /* Unfortunately, the following two lines are necessary in case of a font or color
+ change inside of the save/restore pair. Anything that was done
+ there must be redone, so in effect, we make no assumptions about
+ what fonts. We act like we are starting a new page */
+ dev_reselect_font();
+ dev_do_color();
+ return;
+}
+
+int dev_xform_depth (void)
+{
+ return num_transforms;
+}
+
+void dev_close_all_xforms (int depth)
+{
+ if (num_transforms > depth) {
+ fprintf (stderr, "\nspecial: Closing pending transformations at end of page/XObject\n");
+ while (num_transforms > depth) {
+ num_transforms -= 1;
+ pdf_doc_add_to_page (" Q", 2);
+ }
+ dev_reselect_font();
+ dev_do_color();
+ }
+ return;
+}
+
+
+/* The following routine is here for forms. Since
+ a form is self-contained, it will need its own Tf command
+ at the beginningg even if it is continuing to set type
+ in the current font. This routine simply forces reinstantiation
+ of the current font. */
+void dev_reselect_font(void)
+{
+ int i;
+ current_font = -1;
+ for (i=0; i<num_dev_fonts; i++) {
+ dev_font[i].used_on_this_page = 0;
+ }
+ text_slant = 0.0;
+ text_extend = 1.0;
+}
+
+static void bop_font_reset(void)
+{
+ dev_reselect_font();
+}
+
+void dev_bop (void)
+{
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if (debug) {
+ fprintf (stderr, "dev_bop:\n");
+ }
+ pdf_doc_new_page ();
+ graphics_mode();
+ {
+ text_slant = 0.0;
+ text_extend = 1.0;
+ }
+ bop_font_reset();
+ /* This shouldn't be necessary because line widths are now
+ explicitly set for each rule */
+ /* pdf_doc_add_to_page ("0 w", 3); */
+ dev_do_color(); /* Set text color since new page loses color state */
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+}
+
+void dev_eop (void)
+{
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if (debug) {
+ fprintf (stderr, "dev_eop:\n");
+ }
+ graphics_mode();
+ dev_close_all_xforms(0);
+ fill_page();
+ pdf_doc_finish_page ();
+ /* Finish any pending PS specials */
+ mp_eop_cleanup();
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+}
+
+int dev_locate_font (const char *tex_name, spt_t ptsize)
+{
+ int i;
+ int this_font;
+
+ if (ptsize == 0) {
+ ERROR ("locate_dev_font() called with ptsize = 0");
+ }
+ /* Make sure we have room for a new one, even though we
+ may not actually create one */
+ dev_fonts_need (num_dev_fonts+1);
+ this_font = num_dev_fonts;
+
+ for (i=0; i<this_font; i++) {
+ /* PK must match in name and size to resolve to the same device
+ font */
+ if (dev_font[i].tex_name &&
+ strcmp (tex_name, dev_font[i].tex_name) == 0 &&
+ dev_font[i].sptsize == ptsize &&
+ dev_font[i].format == PK)
+ break;
+ /* Scaleable fonts must match in name; however, this routine
+ must return a different id if the ptsize is different */
+ if (dev_font[i].tex_name &&
+ strcmp (tex_name, dev_font[i].tex_name) == 0 &&
+ dev_font[i].format != PK)
+ break;
+ }
+ if (i == this_font) { /* There is no physical font we can use */
+ struct map_record *map_record;
+ int font_id = -1, font_format = -1, tfm_id = -1, encoding_id = -1;
+ int remap = 0;
+ double extend= 1.0, slant = 0.0;
+ const char *font_name;
+ char short_name[7];
+ /* Get appropriate info from map file (yes, PK fonts at two
+ different point sizes would be looked up twice unecessarily) */
+ if ((map_record = get_map_record (tex_name))) {
+ remap = map_record -> remap;
+ slant = map_record -> slant;
+ extend = map_record -> extend;
+ font_name = map_record -> font_name;
+ } else {
+ font_name = tex_name;
+ }
+ if (verbose>1){
+ if (map_record) {
+ fprintf (stderr, "\nfontmap: %s -> %s", tex_name,
+ map_record->font_name);
+ if (map_record->enc_name)
+ fprintf (stderr, "(%s)", map_record->enc_name);
+ if (map_record->slant)
+ fprintf (stderr, "[slant=%g]", map_record->slant);
+ if (map_record->extend != 1.0)
+ fprintf (stderr, "[extend=%g]", map_record->extend);
+ if (map_record->remap)
+ fprintf (stderr, "[remap]");
+ fprintf (stderr, "\n");
+ } else {
+ fprintf (stderr, "\nfontmap: %s (no map)\n", tex_name);
+ }
+ }
+ /* If this font has an encoding specified on the record, get its id */
+ if (map_record && map_record -> enc_name != NULL) {
+ encoding_id = get_encoding (map_record -> enc_name);
+ } else { /* Otherwise set the encoding_id to -1 */
+ encoding_id = -1;
+ }
+ tfm_id = tfm_open (tex_name);
+ /* We assume, for now that we will find this as a physical font,
+ as opposed to a vf, so we need a device name to tell the
+ lower-level routines what we want this to be called. We'll
+ blast this name away later if we don't need it. */
+ short_name[0] = 'F';
+ inttoa (short_name+1, num_phys_fonts+1);
+ if ((font_id = type1_font (font_name, tfm_id,
+ short_name, encoding_id, remap))>=0) {
+ font_format = TYPE1;
+#ifdef HAVE_TTF_FORMATS
+ } else if ((font_id = ttf_font (font_name, tfm_id,
+ short_name, encoding_id, remap))>=0) {
+ font_format = TRUETYPE;
+#endif /* HAVE_TTF_FORMATS */
+ } else if ((font_id = pk_font (font_name, ptsize*dvi2pts,
+ tfm_id,
+ short_name))>=0) {
+ font_format = PK;
+ }
+ if (font_format >= 0) { /* This is a new physical font and we found a physical
+ font we can use */
+ strcpy (dev_font[this_font].short_name, short_name);
+ dev_font[this_font].tex_name = NEW (strlen (tex_name)+1, char);
+ strcpy (dev_font[this_font].tex_name, tex_name);
+ dev_font[this_font].sptsize = ptsize;
+ dev_font[this_font].format = font_format;
+ dev_font[this_font].slant = slant;
+ dev_font[this_font].extend = extend;
+ dev_font[this_font].remap = remap;
+ dev_font[this_font].used_on_this_page = 0;
+ switch (font_format) {
+ case TYPE1:
+ dev_font[this_font].font_resource =
+ type1_font_resource(font_id);
+ dev_font[this_font].used_chars = type1_font_used(font_id);
+ break;
+#ifdef HAVE_TTF_FORMATS
+ case TRUETYPE:
+ dev_font[this_font].font_resource =
+ ttf_font_resource(font_id);
+ dev_font[this_font].used_chars = ttf_font_used(font_id);
+ break;
+#endif /* HAVE_TTF_FORMATS */
+ case PK:
+ dev_font[this_font].font_resource = pk_font_resource (font_id);
+ dev_font[this_font].used_chars = pk_font_used(font_id);
+ break;
+ default:
+ ERROR ("Impossible font format in dev_locate_font()");
+ }
+ num_phys_fonts += 1;
+ } else { /* No appropriate physical font exists */
+ this_font = -1; /* A flag indicating no physical font */
+ }
+ } else { /* A previously existing physical font can be used;
+ however, this routine must return a distinct ID if the
+ ptsizes are different. Copy the information from the
+ previous record to the new record */
+ strcpy (dev_font[this_font].short_name, dev_font[i].short_name);
+ dev_font[this_font].tex_name = NEW (strlen (tex_name)+1, char);
+ strcpy (dev_font[this_font].tex_name, tex_name);
+ dev_font[this_font].sptsize = ptsize;
+ dev_font[this_font].format = dev_font[i].format;
+ dev_font[this_font].used_chars = dev_font[i].used_chars;
+ dev_font[this_font].slant = dev_font[i].slant;
+ dev_font[this_font].extend = dev_font[i].extend;
+ dev_font[this_font].remap = dev_font[i].remap;
+ /* The value in useD_on_this_page will be incorrect if the font
+ has already been used on a page in a different point size.
+ It's too hard to do right. The only negative consequence is
+ that there will be an attempt to add the resource to the page
+ resource dict. However, the second attempt will do nothing */
+ dev_font[this_font].used_on_this_page = 0;
+ dev_font[this_font].font_resource = pdf_link_obj(dev_font[i].font_resource);
+ /* These two fonts are treated as having the same physical
+ "used_chars" */
+ dev_font[this_font].used_chars = dev_font[i].used_chars;
+ }
+ if (this_font >= 0)
+ num_dev_fonts += 1;
+ return this_font;
+}
+
+void dev_close_all_fonts(void)
+{
+ int i;
+ for (i=0; i<num_dev_fonts; i++) {
+ pdf_release_obj (dev_font[i].font_resource);
+ RELEASE (dev_font[i].tex_name);
+ }
+ if (dev_font)
+ RELEASE (dev_font);
+
+ /* Release all map entries */
+ for (i=0; i<num_font_map; i++) {
+ release_map_record (font_map+i);
+ }
+
+ if (font_map)
+ RELEASE (font_map);
+ /* Close the various font handlers */
+ type1_close_all();
+ pk_close_all();
+#ifdef HAVE_TTF_FORMATS
+ ttf_close_all();
+#endif
+
+ /* Now do encodings. */
+ encoding_flush_all();
+}
+
+void dev_rule (spt_t xpos, spt_t ypos, spt_t width, spt_t height)
+{
+ int len = 0;
+ long w, p1, p2, p3, p4;
+ graphics_mode();
+ /* Is using a real stroke the right thing to do? It seems to preserve
+ the logical meaning of a "rule" as opposed to a filled rectangle.
+ I am assume the reader can more intelligently render a rule than a filled rectangle */
+ if (width> height) { /* Horizontal stroke? */
+ w = IDIVRND(height, CENTI_PDF_U);
+ p1 = IDIVRND(xpos, CENTI_PDF_U);
+ p2 = IDIVRND (2*ypos+height, 2*CENTI_PDF_U);
+ p3 = IDIVRND(xpos+width,CENTI_PDF_U);
+ p4 = IDIVRND (2*ypos+height, 2*CENTI_PDF_U);
+ } else { /* Vertical stroke */
+ w = IDIVRND(width,CENTI_PDF_U);
+ p1 = IDIVRND (2*xpos+width, 2*CENTI_PDF_U);
+ p2 = IDIVRND(ypos, CENTI_PDF_U);
+ p3 = IDIVRND (2*xpos+width, 2*CENTI_PDF_U);
+ p4 = IDIVRND(ypos+height,CENTI_PDF_U);
+ }
+ /* This needs to be quick */
+ {
+ format_buffer[len++] = ' ';
+ len += centi_u_to_a (format_buffer+len, w);
+ format_buffer[len++] = ' ';
+ format_buffer[len++] = 'w';
+ format_buffer[len++] = ' ';
+ len += centi_u_to_a (format_buffer+len, p1);
+ format_buffer[len++] = ' ';
+ len += centi_u_to_a (format_buffer+len, p2);
+ format_buffer[len++] = ' ';
+ format_buffer[len++] = 'm';
+ format_buffer[len++] = ' ';
+ len += centi_u_to_a (format_buffer+len, p3);
+ format_buffer[len++] = ' ';
+ len += centi_u_to_a (format_buffer+len, p4);
+ format_buffer[len++] = ' ';
+ format_buffer[len++] = 'l';
+ format_buffer[len++] = ' ';
+ format_buffer[len++] = 'S';
+ }
+ pdf_doc_add_to_page (format_buffer, len);
+}
+
+/* The following routines tell the coordinates in true Adobe points
+ with the coordinate system having its origin at the bottom
+ left of the page. */
+
+double dev_phys_x (void)
+{
+ return dvi_dev_xpos()*dvi_tell_mag() + hoffset;
+}
+
+double dev_phys_y (void)
+{
+ return dev_page_height() + dvi_tell_mag()*dvi_dev_ypos() -voffset;
+}
+
+static int src_special (char *buffer, UNSIGNED_QUAD size) {
+ char *start = buffer;
+ char *end = buffer + size;
+ int result = 0;
+ skip_white (&start, end);
+ if ((start+3 < end) &&
+ (!strncmp ("src:", start, 4)))
+ result = 1;
+ return result;
+}
+
+void dev_do_special (void *buffer, UNSIGNED_QUAD size, spt_t x_user,
+ spt_t y_user)
+{
+ double dev_xuser, dev_yuser;
+ dev_xuser = ((double) x_user) / ((double) PDF_U);
+ dev_yuser = ((double) -y_user) / ((double) PDF_U);
+ graphics_mode();
+ if (!pdf_parse_special (buffer, size, dev_xuser, dev_yuser) &&
+ !tpic_parse_special (buffer, size, dev_xuser, dev_yuser) &&
+ !htex_parse_special (buffer, size) &&
+ !color_special (buffer, size) &&
+ !ps_parse_special (buffer, size, dev_xuser, dev_yuser) &&
+ !src_special (buffer, size)) {
+ fprintf (stderr, "\nUnrecognized special ignored");
+ dump (buffer, ((char *)buffer)+size);
+ }
+}
+
+static unsigned dvi_stack_depth = 0;
+static int dvi_tagged_depth = -1;
+static unsigned char link_annot = 1;
+
+void dev_link_annot (unsigned char flag)
+{
+ link_annot = flag;
+}
+
+void dev_stack_depth (unsigned int depth)
+{
+ /* If decreasing below tagged_depth */
+ if (link_annot &&
+ dvi_stack_depth == dvi_tagged_depth &&
+ depth == dvi_tagged_depth - 1) {
+ /* See if this appears to be the end of a "logical unit"
+ that's been broken. If so, flush the logical unit */
+ pdf_doc_flush_annot();
+ }
+ dvi_stack_depth = depth;
+ return;
+}
+
+/* The following routines setup and tear down a callback at
+ a certain stack depth. This is used to handle broken (linewise)
+ links */
+
+void dev_tag_depth (void)
+{
+ dvi_tagged_depth = dvi_stack_depth;
+ dvi_compute_boxes (1);
+ return;
+}
+
+void dev_untag_depth (void)
+{
+ dvi_tagged_depth = -1;
+ dvi_compute_boxes (0);
+ return;
+}
+
+void dev_expand_box (spt_t width, spt_t height, spt_t depth)
+{
+ double phys_width, phys_height, phys_depth, scale;
+ if (link_annot && dvi_stack_depth >= dvi_tagged_depth) {
+ scale = dvi2pts*dvi_tell_mag();
+ phys_width = scale*width;
+ phys_height = scale*height;
+ phys_depth = scale*depth;
+ pdf_doc_expand_box (dev_phys_x(), dev_phys_y()-phys_depth,
+ dev_phys_x()+phys_width,
+ dev_phys_y()+phys_height);
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Build/source/texk/dvipdfm/pdfdev.h b/Build/source/texk/dvipdfm/pdfdev.h
new file mode 100644
index 00000000000..050584ad4d3
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pdfdev.h
@@ -0,0 +1,91 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef PDFDEV_H
+#define PDFDEV_H
+
+#include "numbers.h"
+#include "pdfobj.h"
+
+typedef signed long spt_t;
+
+extern void dev_init(double scale, double x_offset, double y_offset);
+extern void dev_set_verbose (void);
+extern double pdf_dev_scale (void);
+extern void dev_close (void);
+extern void dev_read_mapfile (char *filename);
+extern int dev_locate_font (const char *name, spt_t ptsize);
+extern int dev_font_tfm (int dev_font_id);
+extern spt_t dev_font_sptsize (int dev_font_id);
+extern void dev_close_all_fonts (void);
+extern void dev_bop (void);
+extern void dev_eop (void);
+extern void dev_reselect_font (void);
+extern void dev_set_string (spt_t xpos, spt_t ypos, unsigned char *ch,
+ int len, spt_t width, int font_id);
+extern void dev_set_page_size (double width, double height);
+extern void dev_rule (spt_t xpos, spt_t ypos, spt_t width, spt_t height);
+extern double dev_phys_x (void);
+extern double dev_phys_y (void);
+extern void dev_begin_rgb_color (double r, double g, double b);
+extern void dev_set_def_rgb_color (double r, double g, double b);
+extern void dev_begin_cmyk_color (double c, double m, double y, double k);
+extern void dev_set_def_cmyk_color (double c, double m, double y, double k);
+extern void dev_begin_gray (double value);
+extern void dev_set_def_gray (double value);
+extern void dev_begin_named_color (char *s);
+extern void dev_set_def_named_color (char *s);
+extern void dev_end_color (void);
+extern void dev_do_color(void);
+extern void dev_bg_rgb_color (double r, double g, double b);
+extern void dev_bg_cmyk_color (double c, double m, double y, double k);
+extern void dev_bg_gray (double value);
+extern void dev_bg_named_color (char *s);
+extern void dev_begin_xform (double xscale, double yscale, double
+ rotate, double x_user, double y_user);
+extern void dev_end_xform (void);
+extern int dev_xform_depth (void);
+extern void dev_close_all_xforms (int depth);
+
+extern void dev_add_comment (char *comment);
+extern void dev_do_special (void *buffer, UNSIGNED_QUAD size,
+ spt_t x_user, spt_t y_user);
+extern double dev_page_height(void);
+extern double dev_page_width(void);
+/* graphics_mode() would normally be local, but it is needed by the
+ MetaPost inclusion routine */
+extern void graphics_mode (void);
+extern void dev_stack_depth (unsigned int depth);
+extern void dev_tag_depth (void);
+extern void dev_set_box (void);
+extern void dev_untag_depth (void);
+extern void dev_expand_box (spt_t width, spt_t height, spt_t depth);
+extern void dev_link_annot (unsigned char flag);
+#endif /* PDFDEV_H */
+
+
+
+
+
diff --git a/Build/source/texk/dvipdfm/pdfdoc.c b/Build/source/texk/dvipdfm/pdfdoc.c
new file mode 100644
index 00000000000..7aa20f72a02
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pdfdoc.c
@@ -0,0 +1,1284 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include "system.h"
+#include "config.h"
+#include "mem.h"
+#include "error.h"
+#include "mfileio.h"
+#include "numbers.h"
+#include "dvi.h"
+#include "pdflimits.h"
+#include "pdfobj.h"
+#include "pdfdev.h"
+#include "pdfdoc.h"
+#include "pdfspecial.h"
+
+#ifdef HAVE_LIBPNG
+#include "thumbnail.h"
+#endif
+
+static pdf_obj *catalog = NULL;
+static pdf_obj *docinfo = NULL;
+static pdf_obj *page_tree = NULL, *page_tree_ref = NULL;
+
+int outline_depth=0;
+static struct
+{
+ int kid_count;
+ pdf_obj *entry;
+} outline[MAX_OUTLINE_DEPTH];
+
+
+static pdf_obj *current_page_resources = NULL;
+static pdf_obj *this_page_contents = NULL;
+static pdf_obj *glob_page_bop, *glob_page_eop;
+static pdf_obj *coord_xform_stream = NULL, *coord_xform_ref = NULL;
+static pdf_obj *this_page_bop = NULL;
+static pdf_obj *this_page_beads = NULL;
+static pdf_obj *this_page_annots = NULL;
+static pdf_obj *this_page_xobjects = NULL, *this_page_fonts = NULL;
+static pdf_obj *tmp1;
+
+static unsigned long page_count = 0;
+static struct pages {
+ pdf_obj *page_dict;
+ pdf_obj *page_ref;
+} *pages = NULL;
+static unsigned long max_pages = 0;
+
+static void start_page_tree (void);
+static void create_catalog (void);
+static void start_current_page_resources (void);
+static void finish_page_tree(void);
+static void start_name_tree(void);
+static void finish_dests_tree(void);
+static void finish_pending_xobjects(void);
+static void start_articles(void);
+
+static unsigned char verbose = 0, debug=0;
+
+void pdf_doc_set_verbose(void)
+{
+ if (verbose < 255)
+ verbose += 1;
+}
+
+void pdf_doc_set_debug(void)
+{
+ debug = 1;
+}
+
+static void resize_pages (unsigned long newsize)
+{
+ unsigned long i;
+ if (newsize > max_pages) {
+ pages = RENEW (pages, newsize, struct pages);
+ for (i=max_pages; i<newsize; i++) {
+ pages[i].page_dict = NULL;
+ pages[i].page_ref = NULL;
+ }
+ max_pages = newsize;
+ }
+}
+
+static pdf_obj *type_name, *page_name, *pages_name, *contents_name, *annots_name,
+ *resources_name, *bead_name, *count_name, *kids_name, *parent_name,
+ *mediabox_name, *limits_name, *thumb_name;
+
+static void make_short_cuts(void)
+{
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ /* Define some shorthand for names that will conserve memory (and time)
+ (similar to the latex \@ne trick */
+ type_name = pdf_new_name("Type");
+ page_name = pdf_new_name("Page");
+ pages_name = pdf_new_name("Pages");
+ count_name = pdf_new_name("Count");
+ kids_name = pdf_new_name("Kids");
+ parent_name = pdf_new_name("Parent");
+ contents_name = pdf_new_name("Contents");
+ annots_name = pdf_new_name("Annots");
+ resources_name = pdf_new_name ("Resources");
+ bead_name = pdf_new_name ("B");
+ mediabox_name = pdf_new_name ("MediaBox");
+ limits_name = pdf_new_name ("Limits");
+ thumb_name = pdf_new_name ("Thumb");
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+}
+static void release_short_cuts(void)
+{
+ /* Release those shorthand name we created */
+ pdf_release_obj (type_name);
+ pdf_release_obj (page_name);
+ pdf_release_obj (pages_name);
+ pdf_release_obj (count_name);
+ pdf_release_obj (kids_name);
+ pdf_release_obj (parent_name);
+ pdf_release_obj (contents_name);
+ pdf_release_obj (annots_name);
+ pdf_release_obj (resources_name);
+ pdf_release_obj (bead_name);
+ pdf_release_obj (mediabox_name);
+ pdf_release_obj (limits_name);
+ pdf_release_obj (thumb_name);
+}
+
+static void start_page_tree (void)
+{
+ if (debug) {
+ fprintf (stderr, "(start_page_tree)");
+ }
+ /* Create empty page tree */
+ page_tree = pdf_new_dict();
+ page_tree_ref = pdf_ref_obj (page_tree);
+ /* Both page_tree and page_tree_ref are kept open until the
+ document is closed. This allows the user to write to page_tree
+ if he so choses. */
+ /* Link /Pages into the catalog
+ and poing it to indirect reference since we
+ haven't built the tree yet */
+ glob_page_bop = pdf_new_stream(0);
+ glob_page_eop = pdf_new_stream(0);
+ coord_xform_stream = pdf_new_stream(0);
+ coord_xform_ref = pdf_ref_obj (coord_xform_stream);
+ return;
+}
+
+void pdf_doc_bop (char *string, unsigned length)
+{
+ if (length > 0)
+ pdf_add_stream (glob_page_bop, string, length);
+}
+
+void pdf_doc_this_bop (char *string, unsigned length)
+{
+ if (this_page_bop == NULL)
+ this_page_bop = pdf_new_stream (STREAM_COMPRESS);
+ if (length > 0)
+ pdf_add_stream (this_page_bop, string, length);
+}
+
+void pdf_doc_set_origin (double x, double y)
+{
+ int len;
+ static char first = 1;
+ if (first) {
+ sprintf (work_buffer, "%g 0 0 %g %g %g cm\n",
+ dvi_tell_mag()*pdf_dev_scale(), dvi_tell_mag()*pdf_dev_scale(),
+ x, y);
+ len = strlen (work_buffer);
+ pdf_add_stream (coord_xform_stream, work_buffer, len);
+ first = 0;
+ }
+}
+
+
+void pdf_doc_eop (char *string, unsigned length)
+{
+ if (length > 0)
+ pdf_add_stream (glob_page_eop, string, length);
+}
+
+static void start_outline_tree (void)
+{
+ if (debug) {
+ fprintf (stderr, "(start_outline_tree)");
+ }
+ /* Create empty outline tree */
+ outline[outline_depth].entry = pdf_new_dict();
+ outline[outline_depth].kid_count = 0;
+ return;
+}
+
+static pdf_obj *names_dict;
+
+static void start_name_tree (void)
+{
+ if (debug) {
+ fprintf (stderr, "(start_name_tree)");
+ }
+ names_dict = pdf_new_dict ();
+}
+
+static char *asn_date (void)
+{
+#ifndef HAVE_TIMEZONE
+ #ifdef TM_GM_TOFF
+ #define timezone (bdtime->gm_toff)
+ #else
+ #define timezone 0l
+#endif /* TM_GM_TOFF */
+#endif /* HAVE_TIMEZONE */
+ static char date_string[24];
+ time_t current_time;
+ struct tm *bd_time;
+ if (debug) {
+ fprintf (stderr, "(asn_date)");
+ }
+ time(&current_time);
+ bd_time = localtime(&current_time);
+ sprintf (date_string, "D:%04d%02d%02d%02d%02d%02d%+03ld'%02ld'",
+ bd_time -> tm_year+1900, bd_time -> tm_mon+1, bd_time -> tm_mday,
+ bd_time -> tm_hour, bd_time -> tm_min, bd_time -> tm_sec,
+ -timezone/3600, timezone%3600);
+ return date_string;
+}
+
+#define BANNER "dvipdfm %s, Copyright \251 1998, by Mark A. Wicks"
+static void create_docinfo (void)
+{
+ /* Create an empty Info entry and make it
+ be the root object */
+ if (debug) {
+ fprintf (stderr, "(create_docinfo)");
+ }
+ docinfo = pdf_new_dict ();
+ pdf_set_info (docinfo);
+ return;
+}
+
+static void finish_docinfo(void)
+{
+ char *time_string, *banner;
+ banner = NEW (strlen(BANNER)+20,char);
+ sprintf(banner, BANNER, VERSION);
+ pdf_add_dict (docinfo,
+ pdf_new_name ("Producer"),
+ pdf_new_string (banner, strlen (banner)));
+ RELEASE (banner);
+ time_string = asn_date();
+ pdf_add_dict (docinfo,
+ pdf_new_name ("CreationDate"),
+ pdf_new_string (time_string, strlen (time_string)));
+ pdf_release_obj (docinfo);
+ return;
+}
+
+void pdf_doc_merge_with_docinfo (pdf_obj *dictionary)
+{
+ pdf_merge_dict (docinfo, dictionary);
+}
+
+void pdf_doc_merge_with_catalog (pdf_obj *dictionary)
+{
+ pdf_merge_dict (catalog, dictionary);
+}
+
+static void create_catalog (void)
+{
+ if (debug) {
+ fprintf (stderr, "(create_catalog)");
+ }
+ catalog = pdf_new_dict ();
+ pdf_set_root (catalog);
+ /* Create /Type attribute */
+ pdf_add_dict (catalog,
+ pdf_link_obj (type_name),
+ pdf_new_name("Catalog"));
+ /* Create only those parts of the page tree required for the catalog.
+ That way, the rest of the page tree can be finished at any time */
+ start_page_tree();
+ /* Likewise for outline tree */
+ start_outline_tree ();
+ start_name_tree();
+ start_articles();
+ return;
+}
+
+static void start_current_page_resources (void)
+{
+ /* work on resources to put in Pages */
+ if (debug) {
+ fprintf (stderr, "(start_current_page_resources)");
+ }
+ current_page_resources = pdf_new_dict ();
+ tmp1 = pdf_new_array ();
+ pdf_add_array (tmp1, pdf_new_name ("PDF"));
+ pdf_add_array (tmp1, pdf_new_name ("Text"));
+ pdf_add_array (tmp1, pdf_new_name ("ImageC"));
+ pdf_add_dict (current_page_resources,
+ pdf_new_name ("ProcSet"),
+ tmp1);
+ return;
+}
+
+void pdf_doc_add_to_page_fonts (const char *name, pdf_obj
+ *resource)
+{
+#ifdef MEM_DEBUG
+ MEM_START;
+#endif
+
+ if (debug) {
+ fprintf (stderr, "(pdf_doc_add_to_page_fonts)");
+ }
+ if (this_page_fonts == NULL)
+ this_page_fonts = pdf_new_dict();
+ pdf_add_dict (this_page_fonts,
+ pdf_new_name (name), resource);
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+}
+
+void pdf_doc_add_to_page_xobjects (const char *name, pdf_obj
+ *resource)
+{
+ if (debug) {
+ fprintf (stderr, "(pdf_doc_add_to_page_xojects)");
+ }
+ if (this_page_xobjects == NULL)
+ this_page_xobjects = pdf_new_dict ();
+ pdf_add_dict (this_page_xobjects,
+ pdf_new_name (name),
+ resource);
+}
+
+
+void pdf_doc_add_to_page_resources (const char *name, pdf_obj *resource)
+{
+ if (debug) {
+ fprintf (stderr, "(pdf_doc_add_to_page_resources)");
+ }
+ pdf_add_dict (current_page_resources,
+ pdf_new_name (name),
+ resource);
+}
+
+void pdf_doc_add_to_page_annots (pdf_obj *annot)
+{
+ if (debug) {
+ fprintf (stderr, "(pdf_doc_add_to_page_annots)");
+ }
+ if (this_page_annots == NULL)
+ this_page_annots = pdf_new_array ();
+ pdf_add_array (this_page_annots,
+ annot);
+}
+
+static pdf_obj *page_subtree (struct pages *pages, unsigned long npages,
+ pdf_obj *parent_ref)
+{
+#define PAGE_CLUSTER 4
+ pdf_obj *self, *self_ref, *kid_array;
+ self = pdf_new_dict();
+ /* This is a slight kludge which allow the subtree
+ dictionary generated by this routine to be merged with the
+ real page_tree dictionary, while keeping the indirect
+ object references right */
+ if (parent_ref == NULL)
+ self_ref = pdf_ref_obj (page_tree);
+ else
+ self_ref = pdf_ref_obj (self);
+ pdf_add_dict (self, pdf_link_obj (type_name),
+ pdf_link_obj (pages_name));
+ pdf_add_dict (self, pdf_link_obj (count_name),
+ pdf_new_number((double) npages));
+ kid_array = pdf_new_array();
+ pdf_add_dict (self, pdf_link_obj (kids_name),
+ kid_array);
+ if (parent_ref != NULL) {
+ pdf_add_dict (self, pdf_link_obj(parent_name),
+ parent_ref);
+ }
+ if (npages > 0 && npages <= PAGE_CLUSTER) {
+ int i;
+ for (i=0; i<npages; i++) {
+ pdf_add_array (kid_array, pdf_link_obj(pages[i].page_ref));
+ pdf_add_dict (pages[i].page_dict, pdf_link_obj (parent_name),
+ pdf_link_obj(self_ref));
+ pdf_release_obj (pages[i].page_dict);
+ pdf_release_obj (pages[i].page_ref);
+ pages[i].page_dict = NULL;
+ pages[i].page_ref = NULL;
+ }
+ } else if (npages > 0) {
+ int i;
+ for (i=0; i<PAGE_CLUSTER; i++) {
+ pdf_obj *subtree;
+ unsigned long start, end;
+ start = (i*npages)/PAGE_CLUSTER;
+ end = ((i+1)*npages)/PAGE_CLUSTER;
+ if (end-start>1) {
+ subtree = page_subtree (pages+start, end-start, pdf_link_obj(self_ref));
+ pdf_add_array (kid_array, pdf_ref_obj (subtree));
+ pdf_release_obj (subtree);
+ }
+ else {
+ pdf_add_array (kid_array, pdf_link_obj(pages[start].page_ref));
+ pdf_add_dict (pages[start].page_dict, pdf_link_obj(parent_name),
+ pdf_link_obj (self_ref));
+ pdf_release_obj (pages[start].page_dict);
+ pdf_release_obj (pages[start].page_ref);
+ pages[start].page_dict = NULL;
+ pages[start].page_ref = NULL;
+ }
+ }
+ }
+ pdf_release_obj (self_ref);
+ return self;
+}
+
+static void finish_page_tree(void)
+{
+ pdf_obj *subtree;
+ if (debug) {
+ fprintf (stderr, "(finish_page_tree)");
+ }
+
+ subtree = page_subtree (pages, page_count, NULL);
+ pdf_merge_dict (page_tree, subtree);
+ pdf_release_obj (subtree);
+ /* Generate media box at root of page tree and let the
+ other pages inherit it */
+ {
+ tmp1 = pdf_new_array ();
+ pdf_add_array (tmp1, pdf_new_number (0));
+ pdf_add_array (tmp1, pdf_new_number (0));
+ pdf_add_array (tmp1, pdf_new_number (ROUND(dev_page_width(),1.0)));
+ pdf_add_array (tmp1, pdf_new_number (ROUND(dev_page_height(),1.0)));
+ pdf_add_dict (page_tree, pdf_link_obj (mediabox_name), tmp1);
+ }
+ pdf_release_obj (page_tree);
+ pdf_add_dict (catalog,
+ pdf_link_obj (pages_name),
+ pdf_link_obj (page_tree_ref));
+ pdf_release_obj (page_tree_ref);
+ RELEASE (pages);
+ pdf_add_stream (glob_page_bop, "\n", 1);
+ pdf_release_obj (glob_page_bop);
+ pdf_add_stream (glob_page_eop, "\n", 1);
+ pdf_release_obj (glob_page_eop);
+ pdf_release_obj (coord_xform_stream);
+ pdf_release_obj (coord_xform_ref);
+ return;
+}
+
+void pdf_doc_change_outline_depth(int new_depth)
+{
+ int i;
+ if (debug) {
+ fprintf (stderr, "(change_outline_depth)");
+ }
+ if (outline_depth >= MAX_OUTLINE_DEPTH -1)
+ ERROR ("Outline is too deep.");
+ if (new_depth == outline_depth)
+ /* Nothing to do */
+ return;
+ if (new_depth > outline_depth+1)
+ ERROR ("Can't increase outline depth by more than one at a time\n");
+ if (outline[outline_depth].entry == NULL)
+ ERROR ("change_outline_depth: Fix me, I'm broke. This shouldn't happen!");
+ /* Terminate all entries above this depth */
+ for (i=outline_depth-1; i>=new_depth; i--) {
+ pdf_add_dict (outline[i].entry,
+ pdf_new_name ("Last"),
+ pdf_ref_obj (outline[i+1].entry));
+ if (i > 0)
+ tmp1 = pdf_new_number (-outline[i].kid_count);
+ else
+ tmp1 = pdf_new_number (outline[i].kid_count);
+
+ pdf_add_dict (outline[i].entry,
+ pdf_link_obj (count_name),
+ tmp1);
+ }
+ /* Flush out all entries above this depth */
+ for (i=new_depth+1; i<=outline_depth; i++) {
+ pdf_release_obj (outline[i].entry);
+ outline[i].entry = NULL;
+ outline[i].kid_count = 0;
+ }
+ outline_depth = new_depth;
+}
+
+static void finish_outline(void)
+{
+ if (debug)
+ fprintf (stderr, "(finish_outline)");
+ /* Link it into the catalog */
+ /* Point /Outline attribute to indirect reference */
+ pdf_doc_change_outline_depth (0);
+ pdf_add_dict (catalog,
+ pdf_new_name ("Outlines"),
+ pdf_ref_obj(outline[outline_depth].entry));
+ pdf_release_obj (outline[0].entry);
+ outline[0].entry = NULL;
+}
+
+
+void pdf_doc_add_outline (pdf_obj *dict)
+{
+ pdf_obj *new_entry;
+ if (outline_depth < 1)
+ ERROR ("Can't add to outline at depth < 1");
+ new_entry = pdf_new_dict ();
+ pdf_merge_dict (new_entry, dict);
+ /* Caller doesn't know we don't actually use the dictionary,
+ so he *gave* dict to us. We have to free it */
+ pdf_release_obj (dict);
+ /* Tell it where its parent is */
+ pdf_add_dict (new_entry,
+ pdf_link_obj (parent_name),
+ pdf_ref_obj (outline[outline_depth-1].entry));
+ /* Give mom and dad the good news */
+ outline[outline_depth-1].kid_count += 1;
+
+ /* Is this the first entry at this depth? */
+ if (outline[outline_depth].entry == NULL) {
+ /* Is so, tell the parent we are first born */
+ pdf_add_dict (outline[outline_depth-1].entry,
+ pdf_new_name ("First"),
+ pdf_ref_obj (new_entry));
+ }
+ else {
+ /* Point us back to sister */
+ pdf_add_dict (new_entry,
+ pdf_new_name ("Prev"),
+ pdf_ref_obj (outline[outline_depth].entry));
+ /* Point our elder sister toward us */
+ pdf_add_dict (outline[outline_depth].entry,
+ pdf_new_name ("Next"),
+ pdf_ref_obj (new_entry));
+ /* Bye-Bye sis */
+ pdf_release_obj (outline[outline_depth].entry);
+ }
+ outline[outline_depth].entry = new_entry;
+ /* Just born, so don't have any kids */
+ outline[outline_depth].kid_count = 0;
+}
+
+struct dests
+{
+ char *name;
+ unsigned length;
+ pdf_obj *array;
+};
+typedef struct dests dest_entry;
+static dest_entry *dests = NULL;
+unsigned long max_dests = 0;
+
+static int CDECL cmp_dest (const void *d1, const void *d2)
+{
+ unsigned length;
+ int tmp;
+ length = MIN (((dest_entry *) d1) -> length, ((dest_entry *) d2) ->
+ length);
+ if ((tmp = memcmp (((dest_entry *) d1) -> name, ((dest_entry *) d2)
+ -> name, length)) != 0)
+ return tmp;
+ if (((dest_entry *) d1) -> length == ((dest_entry *) d2) -> length)
+ return 0;
+ return (((dest_entry *) d1) -> length < ((dest_entry *) d2) -> length ? -1 : 1 );
+}
+
+static pdf_obj *name_subtree (dest_entry *dests, unsigned long ndests)
+{
+#define CLUSTER 4
+ pdf_obj *result, *name_array, *limit_array, *kid_array;
+ result = pdf_new_dict();
+ limit_array = pdf_new_array();
+ pdf_add_dict (result, pdf_link_obj(limits_name), limit_array);
+ pdf_add_array (limit_array, pdf_new_string(dests[0].name,
+ dests[0].length));
+ pdf_add_array (limit_array, pdf_new_string(dests[ndests-1].name,
+ dests[ndests-1].length));
+ if (ndests > 0 && ndests <= CLUSTER) {
+ int i;
+ name_array = pdf_new_array();
+ pdf_add_dict (result, pdf_new_name ("Names"),
+ name_array);
+ for (i=0; i<ndests; i++) {
+ pdf_add_array (name_array, pdf_new_string (dests[i].name,
+ dests[i].length));
+ RELEASE (dests[i].name);
+ pdf_add_array (name_array, dests[i].array);
+ }
+ } else if (ndests > 0) {
+ int i;
+ kid_array = pdf_new_array();
+ pdf_add_dict (result, pdf_link_obj (kids_name), kid_array);
+ for (i=0; i<CLUSTER; i++) {
+ pdf_obj *subtree;
+ unsigned long start, end;
+ start = (i*ndests)/CLUSTER;
+ end = ((i+1)*ndests)/CLUSTER;
+ subtree = name_subtree (dests+start, end-start);
+ pdf_add_array (kid_array, pdf_ref_obj (subtree));
+ pdf_release_obj (subtree);
+ }
+ }
+ return result;
+}
+
+static unsigned long number_dests = 0;
+
+static void finish_dests_tree (void)
+{
+ pdf_obj *kid;
+ if (number_dests > 0) {
+ /* Sort before writing any /Dests entries */
+ qsort(dests, number_dests, sizeof(dests[0]), cmp_dest);
+ kid = name_subtree (dests, number_dests);
+ /* Each entry in dests has been assigned to another object, so
+ we can free the entire array without freeing the entries. */
+ RELEASE (dests);
+ pdf_add_dict (names_dict,
+ pdf_new_name ("Dests"),
+ pdf_ref_obj (kid));
+ pdf_release_obj (kid);
+ }
+}
+
+void pdf_doc_add_dest (char *name, unsigned length, pdf_obj *array_ref)
+{
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if (number_dests >= max_dests) {
+ max_dests += DESTS_ALLOC_SIZE;
+ dests = RENEW (dests, max_dests, dest_entry);
+ }
+ dests[number_dests].name = NEW (length, char);
+ memcpy (dests[number_dests].name, name, length);
+ dests[number_dests].length = length;
+ dests[number_dests].array = array_ref;
+ number_dests++;
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return;
+}
+
+struct articles
+{
+ char *name;
+ pdf_obj *info;
+ pdf_obj *first;
+ pdf_obj *last;
+ pdf_obj *this;
+};
+
+typedef struct articles article_entry;
+static article_entry articles[MAX_ARTICLES];
+static unsigned long number_articles = 0;
+
+static pdf_obj *articles_array;
+static void start_articles (void)
+{
+ articles_array = pdf_new_array();
+}
+
+void pdf_doc_start_article (char *name, pdf_obj *info)
+{
+ if (number_articles >= MAX_ARTICLES) {
+ ERROR ("pdf_doc_add_article: Too many articles\n");
+ }
+ if (name == NULL || strlen (name) == 0)
+ ERROR ("pdf_doc_start_article called null name");
+ articles[number_articles].name = NEW (strlen(name)+1, char);
+ strcpy (articles[number_articles].name, name);
+ articles[number_articles].info = info;
+ articles[number_articles].first = NULL;
+ articles[number_articles].last = NULL;
+ /* Start dictionary for this article even though we can't finish it
+ until we get the first bead */
+ articles[number_articles].this = pdf_new_dict();
+ number_articles++;
+ return;
+}
+
+void pdf_doc_add_bead (char *article_name, pdf_obj *partial_dict)
+{
+ /* partial_dict should have P (Page) and R (Rect) already filled in */
+ /* See if the specified article exists */
+ int i;
+ for (i=0; i<number_articles; i++) {
+ if (!strcmp (articles[i].name, article_name))
+ break;
+ }
+ if (i == number_articles) {
+ fprintf (stderr, "Bead specified thread that doesn't exist\n");
+ return;
+ }
+ /* Is this the first bead? */
+ if (articles[i].last == NULL) {
+ articles[i].first = pdf_link_obj (partial_dict);
+ /* Add pointer to its first object */
+ pdf_add_dict (articles[i].this,
+ pdf_new_name ("F"),
+ pdf_ref_obj (articles[i].first));
+ /* Next add pointer to its Info dictionary */
+ pdf_add_dict (articles[i].this,
+ pdf_new_name ("I"),
+ pdf_ref_obj (articles[i].info));
+ /* Point first bead to parent article */
+ pdf_add_dict (partial_dict,
+ pdf_new_name ("T"),
+ pdf_ref_obj (articles[i].this));
+ /* Ship it out and forget it */
+ pdf_add_array (articles_array, pdf_ref_obj (articles[i].this));
+ pdf_release_obj (articles[i].this);
+ articles[i].this = NULL;
+ } else {
+ /* Link it in... */
+ /* Point last object to this one */
+ pdf_add_dict (articles[i].last,
+ pdf_new_name ("N"),
+ pdf_ref_obj (partial_dict));
+ /* Point this one to last */
+ pdf_add_dict (partial_dict,
+ pdf_new_name ("V"),
+ pdf_ref_obj (articles[i].last));
+ pdf_release_obj (articles[i].last);
+ }
+ articles[i].last = partial_dict;
+ if (this_page_beads == NULL)
+ this_page_beads = pdf_new_array();
+ pdf_add_array (this_page_beads,
+ pdf_ref_obj (partial_dict));
+}
+
+void finish_articles(void)
+{
+ int i;
+ pdf_add_dict (catalog,
+ pdf_new_name ("Threads"),
+ pdf_ref_obj (articles_array));
+ pdf_release_obj (articles_array);
+ for (i=0; i<number_articles; i++) {
+ if (articles[i].last == NULL) {
+ fprintf (stderr, "Article started, but no beads\n");
+ break;
+ }
+ /* Close the loop */
+ pdf_add_dict (articles[i].last,
+ pdf_new_name ("N"),
+ pdf_ref_obj (articles[i].first));
+ pdf_add_dict (articles[i].first,
+ pdf_new_name ("V"),
+ pdf_ref_obj (articles[i].last));
+ pdf_release_obj (articles[i].first);
+ pdf_release_obj (articles[i].last);
+ pdf_release_obj (articles[i].info);
+ RELEASE (articles[i].name);
+ }
+}
+
+#ifdef HAVE_LIBPNG
+static char thumbnail_opt = 0;
+static char *thumb_basename = NULL;
+
+void pdf_doc_enable_thumbnails(void)
+{
+ thumbnail_opt = 1;
+}
+
+#endif
+
+void pdf_doc_finish_page ()
+{
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if (debug) {
+ fprintf (stderr, "(pdf_doc_finish_page)");
+ }
+ finish_pending_xobjects();
+ /* Flush this page */
+ /* Page_count is the index of the current page, starting at 1 */
+ tmp1 = pdf_new_array ();
+ pdf_add_array (tmp1, pdf_ref_obj (glob_page_bop));
+ if (this_page_bop) {
+ pdf_add_array (tmp1, pdf_ref_obj (this_page_bop));
+ }
+ pdf_add_array (tmp1, pdf_link_obj (coord_xform_ref));
+ pdf_add_array (tmp1, pdf_ref_obj (this_page_contents));
+ pdf_add_array (tmp1, pdf_ref_obj (glob_page_eop));
+ pdf_add_dict (pages[page_count].page_dict,
+ pdf_link_obj(contents_name), tmp1);
+ /* We keep .page_dict open because we don't know the parent yet */
+ if (this_page_bop != NULL) {
+ pdf_add_stream (this_page_bop, "\n", 1);
+ pdf_release_obj (this_page_bop);
+ this_page_bop = NULL;
+ }
+ if (this_page_contents != NULL) {
+ pdf_add_stream (this_page_contents, "\n", 1);
+ pdf_release_obj (this_page_contents);
+ this_page_contents = NULL;
+ }
+ if (this_page_annots != NULL) {
+ pdf_add_dict (pages[page_count].page_dict,
+ pdf_link_obj(annots_name),
+ pdf_ref_obj (this_page_annots));
+ pdf_release_obj (this_page_annots);
+ this_page_annots = NULL;
+ }
+ if (this_page_beads != NULL) {
+ pdf_add_dict (pages[page_count].page_dict,
+ pdf_link_obj (bead_name),
+ pdf_ref_obj (this_page_beads));
+ pdf_release_obj (this_page_beads);
+ this_page_beads = NULL;
+ }
+ if (this_page_fonts != NULL) {
+ pdf_add_dict (current_page_resources,
+ pdf_new_name ("Font"),
+ pdf_ref_obj (this_page_fonts));
+ pdf_release_obj (this_page_fonts);
+ this_page_fonts = NULL;
+ }
+ if (this_page_xobjects != NULL) {
+ pdf_add_dict (current_page_resources,
+ pdf_new_name ("XObject"),
+ pdf_ref_obj (this_page_xobjects));
+ pdf_release_obj (this_page_xobjects);
+ this_page_xobjects = NULL;
+ }
+ if (current_page_resources != NULL) {
+ pdf_release_obj (current_page_resources);
+ current_page_resources = NULL;
+ }
+#ifdef HAVE_LIBPNG
+ if (thumbnail_opt) {
+ char *thumb_filename;
+ pdf_obj *thumbnail;
+ thumb_filename = NEW (strlen(thumb_basename)+7, char);
+ sprintf (thumb_filename, "%s.%ld", thumb_basename,
+ page_count%99999+1L);
+ thumbnail = do_thumbnail (thumb_filename);
+ RELEASE (thumb_filename);
+ if (thumbnail)
+ pdf_add_dict (pages[page_count].page_dict,
+ pdf_link_obj (thumb_name),
+ thumbnail);
+ }
+#endif
+ page_count += 1;
+#ifdef MEM_DEBUG
+ MEM_END;
+#endif
+}
+
+pdf_obj *pdf_doc_current_page_resources (void)
+{
+ return current_page_resources;
+}
+
+
+static int highest_page_ref = 0;
+pdf_obj *pdf_doc_ref_page (unsigned long page_no)
+{
+ if (debug)
+ fprintf (stderr, "(doc_ref_page:page_no=%ld)", page_no);
+ if (page_no >= max_pages) {
+ resize_pages (page_no+PAGES_ALLOC_SIZE);
+ }
+ /* Has this page been referenced yet? */
+ if (pages[page_no-1].page_dict == NULL) {
+ /* If not, create it */
+ pages[page_no-1].page_dict = pdf_new_dict ();
+ /* and reference it */
+ pages[page_no-1].page_ref = pdf_ref_obj (pages[page_no-1].page_dict);
+ }
+ if (page_no > highest_page_ref)
+ highest_page_ref = page_no;
+ return pdf_link_obj (pages[page_no-1].page_ref);
+}
+
+pdf_obj *pdf_doc_names (void)
+{
+ return names_dict;
+}
+
+pdf_obj *pdf_doc_page_tree (void)
+{
+ return page_tree;
+}
+
+pdf_obj *pdf_doc_catalog (void)
+{
+ return catalog;
+}
+
+pdf_obj *pdf_doc_this_page (void)
+{
+ return pages[page_count].page_dict;
+}
+
+pdf_obj *pdf_doc_this_page_ref (void)
+{
+ return pdf_doc_ref_page(page_count+1);
+}
+
+pdf_obj *pdf_doc_prev_page_ref (void)
+{
+ if (page_count < 1) {
+ ERROR ("Reference to previous page, but no pages have been completed yet");
+ }
+ return pdf_doc_ref_page(page_count>0?page_count:1);
+}
+
+pdf_obj *pdf_doc_next_page_ref (void)
+{
+ return pdf_doc_ref_page(page_count+2);
+}
+
+void pdf_doc_new_page (void)
+{
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if (debug) {
+ fprintf (stderr, "(pdf_doc_new_page)");
+ fprintf (stderr, "page_count=%ld, max_pages=%ld\n", page_count,
+ max_pages);
+ }
+ /* See if we need more pages allocated yet */
+ if (page_count >= max_pages) {
+ resize_pages(max_pages+PAGES_ALLOC_SIZE);
+ }
+ /* Was this page already instantiated by a forward reference to it? */
+ if (pages[page_count].page_ref == NULL) {
+ /* If not, create it. */
+ pages[page_count].page_dict = pdf_new_dict ();
+ /* and reference it */
+ pages[page_count].page_ref = pdf_ref_obj(pages[page_count].page_dict);
+ }
+ pdf_add_dict (pages[page_count].page_dict,
+ pdf_link_obj(type_name), pdf_link_obj(page_name));
+ /* start the contents stream for the new page */
+ this_page_contents = pdf_new_stream(STREAM_COMPRESS);
+ start_current_page_resources();
+ pdf_add_dict (pages[page_count].page_dict,
+ pdf_link_obj (resources_name),
+ pdf_ref_obj (current_page_resources));
+ /* Contents are still available as this_page_contents until next
+ page is started */
+ /* Even though the page is gone, a Reference to this page is kept
+ until program ends */
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+}
+
+void pdf_doc_add_to_page (char *buffer, unsigned length)
+{
+ pdf_add_stream (this_page_contents, buffer, length);
+}
+
+void pdf_doc_init (char *filename)
+{
+#ifdef MEM_DEBUG
+ MEM_START
+#endif
+ if (debug) fprintf (stderr, "pdf_doc_init:\n");
+ pdf_out_init (filename);
+#ifdef HAVE_LIBPNG
+ /* Create a default name for thumbnail image files */
+ if (thumbnail_opt) {
+ if (strlen(filename)>4 && !strncmp (".pdf", filename+strlen(filename)-4,4)) {
+ thumb_basename = NEW (strlen(filename)+1-4, char);
+ strncpy (thumb_basename, filename, strlen(filename)-4);
+ thumb_basename[strlen(filename)-4] = 0;
+ } else {
+ thumb_basename = NEW (strlen(filename)+1, char);
+ strcpy (thumb_basename, filename);
+ }
+ }
+#endif /* HAVE_LIBPNG */
+ make_short_cuts();
+ create_docinfo ();
+ create_catalog ();
+#ifdef MEM_DEBUG
+ MEM_END
+#endif
+}
+
+void pdf_doc_creator (char *s)
+{
+ pdf_add_dict (docinfo, pdf_new_name ("Creator"),
+ pdf_new_string (s, strlen(s)));
+}
+
+void pdf_doc_close ()
+{
+ if (debug) fprintf (stderr, "pdf_doc_finish:\n");
+#ifdef HAVE_LIBPNG
+ if (thumb_basename)
+ RELEASE (thumb_basename);
+#endif /* HAVE_LIBPNG */
+ /* Following things were kept around so user can add dictionary
+ items */
+ finish_docinfo();
+ finish_page_tree();
+ /* Add names dict to catalog */
+ finish_outline();
+ finish_dests_tree();
+ finish_articles();
+ pdf_add_dict (catalog,
+ pdf_new_name ("Names"),
+ pdf_ref_obj (names_dict));
+ pdf_release_obj (names_dict);
+ pdf_release_obj (catalog);
+ /* Do consistency check on forward references to pages */
+ if (highest_page_ref > page_count) {
+ unsigned long i;
+ fprintf (stderr, "\nWarning: Nonexistent page(s) referenced\n");
+ fprintf (stderr, " (PDF file may not work right)\n");
+ for (i=page_count; i<highest_page_ref; i++) {
+ if (pages[i].page_dict) {
+ pdf_release_obj (pages[i].page_dict);
+ pdf_release_obj (pages[i].page_ref);
+ }
+ }
+ }
+ pdf_finish_specials();
+ release_short_cuts();
+ pdf_out_flush ();
+}
+
+static pdf_obj *build_scale_array (double a, double b, double c,
+ double d, double e, double f)
+{
+ pdf_obj *result;
+ result = pdf_new_array();
+ pdf_add_array (result, pdf_new_number (a));
+ pdf_add_array (result, pdf_new_number (b));
+ pdf_add_array (result, pdf_new_number (c));
+ pdf_add_array (result, pdf_new_number (d));
+ pdf_add_array (result, pdf_new_number (ROUND(e,0.01)));
+ pdf_add_array (result, pdf_new_number (ROUND(f,0.01)));
+ return result;
+}
+
+/* All this routine does is give the form a name
+ and add a unity scaling matrix. It fills
+ in required fields. The caller must initialize
+ the stream */
+
+
+void doc_make_form_xobj (pdf_obj *this_form_contents, pdf_obj *bbox,
+ double refptx, double refpty,
+ double xscale, double yscale,
+ pdf_obj *resources, char *form_name)
+{
+ pdf_obj *xobj_dict, *tmp1;
+ xobj_dict = pdf_stream_dict (this_form_contents);
+
+ pdf_add_dict (xobj_dict, pdf_new_name ("Name"), pdf_new_name(form_name));
+ pdf_add_dict (xobj_dict, pdf_link_obj (type_name),
+ pdf_new_name ("XObject"));
+ pdf_add_dict (xobj_dict, pdf_new_name ("Subtype"),
+ pdf_new_name ("Form"));
+ pdf_add_dict (xobj_dict, pdf_new_name ("BBox"), bbox);
+ pdf_add_dict (xobj_dict, pdf_new_name ("FormType"),
+ pdf_new_number(1.0));
+ /* The reference point of an Xobject is at the lower left corner
+ of the bounding box. Since we would like to have an arbitrary
+ reference point, we use a transformation matrix, translating
+ the reference point to (0,0) */
+ tmp1 = build_scale_array (xscale, 0, 0, yscale, -xscale*refptx, -yscale*refpty);
+ pdf_add_dict (xobj_dict, pdf_new_name ("Matrix"), tmp1);
+ pdf_add_dict (xobj_dict, pdf_link_obj (resources_name), resources);
+ return;
+}
+
+struct resource_stack
+{
+ pdf_obj *save_page_contents, *save_page_fonts;
+ pdf_obj *save_page_xobjects, *save_page_resources;
+ int xform_depth;
+} res_stack[4];
+
+static int xobjects_pending = 0;
+
+/* begin_form_xobj creates an xobject with its "origin" at
+ xpos and ypos that is clipped to the specified bbox. Note
+ that the origin is not the lower left corner of the bbox */
+pdf_obj *begin_form_xobj (double xpos, double ypos,
+ double bbllx, double bblly,
+ double bburx, double bbury, char *res_name)
+{
+ pdf_obj *bbox;
+ if (xobjects_pending >= sizeof(res_stack)/sizeof(res_stack[0])) {
+ fprintf (stderr, "\nForm XObjects nested too deeply. Limit is %d\n",
+ sizeof(res_stack)/sizeof(res_stack[0]));
+ return NULL;
+ }
+ /* This is a real hack. We basically treat each xobj as a separate mini
+ page unto itself. Save all the page structures and reinitialize
+ them when we finish this xobject. */
+ res_stack[xobjects_pending].save_page_resources = current_page_resources;
+ current_page_resources = NULL;
+ res_stack[xobjects_pending].save_page_xobjects = this_page_xobjects;
+ this_page_xobjects = NULL;
+ res_stack[xobjects_pending].save_page_fonts = this_page_fonts;
+ this_page_fonts = NULL;
+ res_stack[xobjects_pending].save_page_contents = this_page_contents;
+ this_page_contents = NULL;
+ res_stack[xobjects_pending].xform_depth = dev_xform_depth();
+ xobjects_pending += 1;
+ start_current_page_resources(); /* Starts current_page_resources */
+ this_page_contents = pdf_new_stream (STREAM_COMPRESS);
+ /* Make a bounding box for this Xobject */
+ /* Translate coordinate system so reference point of object
+ is at 0 */
+ bbox = pdf_new_array ();
+ pdf_add_array (bbox, pdf_new_number (ROUND(bbllx,0.01)));
+ pdf_add_array (bbox, pdf_new_number (ROUND(bblly,0.01)));
+ pdf_add_array (bbox, pdf_new_number (ROUND(bburx,0.01)));
+ pdf_add_array (bbox, pdf_new_number (ROUND(bbury,0.01)));
+ /* Resource is already made, so call doc_make_form_xobj() */
+ doc_make_form_xobj (this_page_contents, bbox,
+ xpos, ypos, 1.0, 1.0,
+ pdf_ref_obj(current_page_resources), res_name);
+ /* Make sure the object is self-contained by adding the
+ current font to the object stream */
+ dev_reselect_font();
+ /* Likewise for color */
+ dev_do_color();
+ return pdf_link_obj (this_page_contents);
+}
+
+void end_form_xobj (void)
+{
+ if (xobjects_pending>0) {
+ xobjects_pending -= 1;
+ dev_close_all_xforms(res_stack[xobjects_pending].xform_depth);
+ if (this_page_xobjects) {
+ pdf_add_dict (current_page_resources, pdf_new_name ("XObject"),
+ pdf_ref_obj (this_page_xobjects));
+ pdf_release_obj (this_page_xobjects);
+ }
+ if (this_page_fonts) {
+ pdf_add_dict (current_page_resources, pdf_new_name ("Font"),
+ pdf_ref_obj (this_page_fonts));
+ pdf_release_obj (this_page_fonts);
+ }
+ if (current_page_resources)
+ pdf_release_obj (current_page_resources);
+ if (this_page_contents)
+ pdf_release_obj (this_page_contents);
+ current_page_resources = res_stack[xobjects_pending].save_page_resources;
+ this_page_xobjects = res_stack[xobjects_pending].save_page_xobjects;
+ this_page_fonts = res_stack[xobjects_pending].save_page_fonts;
+ this_page_contents = res_stack[xobjects_pending].save_page_contents;
+ /* Must reselect the font again in case there was a font change in
+ the object */
+ dev_reselect_font();
+ /* Must reselect color too */
+ dev_do_color();
+ } else{
+ fprintf (stderr, "\nSpecial: exobj: Tried to close a nonexistent xobject\n");
+ }
+ return;
+}
+
+void finish_pending_xobjects (void)
+{
+ if (xobjects_pending) {
+ fprintf (stderr, "\nFinishing a pending form XObject at end of page\n");
+ while (xobjects_pending--) {
+ end_form_xobj();
+ }
+ }
+ return;
+}
+
+static struct
+{
+ pdf_obj *annot_dict;
+ unsigned char dirty;
+ double llx, lly, urx, ury;
+} breaking_state = {NULL, 0};
+
+void pdf_doc_set_box (void)
+{
+ breaking_state.llx = dev_page_width();
+ breaking_state.urx = 0;
+ breaking_state.lly = dev_page_height();
+ breaking_state.ury = 0;
+ breaking_state.dirty = 0;
+ return;
+}
+
+void pdf_doc_begin_annot (pdf_obj *dict)
+{
+ breaking_state.annot_dict = dict;
+ pdf_doc_set_box ();
+ dev_tag_depth ();
+ return;
+}
+
+void pdf_doc_end_annot (void)
+{
+ pdf_doc_flush_annot();
+ breaking_state.annot_dict = NULL;
+ dev_untag_depth ();
+ return;
+}
+
+void pdf_doc_flush_annot (void)
+{
+ pdf_obj *rectangle, *new_dict;
+ double grow;
+ grow = pdf_special_tell_grow ();
+ if (breaking_state.dirty) {
+ rectangle = pdf_new_array ();
+ pdf_add_array (rectangle, pdf_new_number(ROUND(breaking_state.llx-grow, 0.01)));
+ pdf_add_array (rectangle, pdf_new_number(ROUND(breaking_state.lly-grow, 0.01)));
+ pdf_add_array (rectangle, pdf_new_number(ROUND(breaking_state.urx+grow, 0.01)));
+ pdf_add_array (rectangle, pdf_new_number(ROUND(breaking_state.ury+grow, 0.01)));
+ new_dict = pdf_new_dict ();
+ pdf_add_dict (new_dict, pdf_new_name ("Rect"),
+ rectangle);
+ pdf_merge_dict (new_dict, breaking_state.annot_dict);
+ pdf_doc_add_to_page_annots (pdf_ref_obj (new_dict));
+ pdf_release_obj (new_dict);
+ }
+ pdf_doc_set_box();
+ return;
+}
+
+void pdf_doc_expand_box (double llx, double lly, double urx, double
+ ury)
+{
+ breaking_state.llx = MIN (breaking_state.llx, llx);
+ breaking_state.lly = MIN (breaking_state.lly, lly);
+ breaking_state.urx = MAX (breaking_state.urx, urx);
+ breaking_state.ury = MAX (breaking_state.ury, ury);
+ breaking_state.dirty = 1;
+ return;
+}
diff --git a/Build/source/texk/dvipdfm/pdfdoc.h b/Build/source/texk/dvipdfm/pdfdoc.h
new file mode 100644
index 00000000000..56f4c902140
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pdfdoc.h
@@ -0,0 +1,96 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef PDFDOC_H
+#define PDFDOC_H
+
+#include "pdfobj.h"
+extern void pdf_doc_new_page (void);
+extern void pdf_doc_finish_page (void);
+extern pdf_obj *pdf_doc_this_page_ref (void);
+extern pdf_obj *pdf_doc_this_page (void);
+extern pdf_obj *pdf_doc_page_tree (void);
+extern pdf_obj *pdf_doc_catalog (void);
+extern void pdf_doc_creator (char *s);
+extern pdf_obj *pdf_doc_names (void);
+extern pdf_obj *pdf_doc_next_page_ref (void);
+extern pdf_obj *pdf_doc_prev_page_ref (void);
+extern pdf_obj *pdf_doc_ref_page (unsigned long page_no);
+
+extern void pdf_doc_add_to_page_resources (const char *name, pdf_obj
+ *resources);
+extern void pdf_doc_add_to_page_fonts (const char *name, pdf_obj
+ *font);
+extern void pdf_doc_add_to_page_xobjects (const char *name, pdf_obj
+ *xobject);
+extern pdf_obj *pdf_doc_current_page_resources(void);
+
+extern void pdf_doc_add_to_page_annots (pdf_obj *annot);
+
+extern void pdf_doc_add_dest (char *name, unsigned length, pdf_obj *array);
+
+extern void pdf_doc_start_article (char *name, pdf_obj *info);
+extern void pdf_doc_add_bead (char *name, pdf_obj *partial_dict);
+
+extern void pdf_doc_merge_with_docinfo (pdf_obj *dictionary);
+extern void pdf_doc_merge_with_catalog (pdf_obj *dictionary);
+
+extern void pdf_doc_add_to_page (char *buffer, unsigned length);
+
+extern void pdf_doc_change_outline_depth (int new_depth);
+extern void pdf_doc_add_outline (pdf_obj *dict);
+
+extern void pdf_doc_init (char *filename);
+extern void pdf_doc_close (void);
+
+extern void pdf_doc_comment (char *comment);
+
+extern void pdf_doc_set_verbose(void);
+extern void pdf_doc_set_debug(void);
+
+extern void pdf_doc_bop (char *string, unsigned length);
+extern void pdf_doc_eop (char *string, unsigned length);
+extern void pdf_doc_set_origin (double x, double y);
+extern void pdf_doc_this_bop (char *string, unsigned length);
+extern void pdf_doc_set_origin (double x, double y);
+extern void pdf_doc_this_eop (char *string, unsigned length);
+
+extern void doc_make_form_xobj (pdf_obj *stream, pdf_obj *bbox,
+ double refptx, double refpty,
+ double xscale, double yscale,
+ pdf_obj *resources, char *form_name);
+extern pdf_obj *begin_form_xobj (double xpos, double ypos,
+ double bbllx, double bblly,
+ double bburx, double bbury, char *form_name);
+extern void end_form_xobj (void);
+extern void pdf_doc_enable_thumbnails (void);
+extern void pdf_doc_begin_annot (pdf_obj *dict);
+extern void pdf_doc_set_box (void);
+extern void pdf_doc_end_annot (void);
+extern void pdf_doc_flush_annot (void);
+extern void pdf_doc_expand_box (double llx, double lly, double urx,
+ double ury);
+#endif /* PDFDOC_H */
+
diff --git a/Build/source/texk/dvipdfm/pdflimits.h b/Build/source/texk/dvipdfm/pdflimits.h
new file mode 100644
index 00000000000..5aba4e4725f
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pdflimits.h
@@ -0,0 +1,39 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#define MAX_FONTS 4u /* Font group allocation size, not a hard maximum */
+#define DVI_MAX_STACK_DEPTH 256u
+#define MAX_VF_NESTING 16u
+#define MAX_COLORS 32u
+#define MAX_TRANSFORMS 32u
+#define MAX_OUTLINE_DEPTH 32u
+#define MAX_ARTICLES 64u
+#define MAX_ENCODINGS 8u
+#define IND_OBJECTS_ALLOC_SIZE 1024u
+#define PAGES_ALLOC_SIZE 128u
+#define DESTS_ALLOC_SIZE 1024u
+#define NAMED_OBJ_ALLOC_SIZE 128u
+#define VF_ALLOC_SIZE 16u
+#define STREAM_ALLOC_SIZE 4096u
+#define ARRAY_ALLOC_SIZE 256
diff --git a/Build/source/texk/dvipdfm/pdfobj.c b/Build/source/texk/dvipdfm/pdfobj.c
new file mode 100644
index 00000000000..69ad6aadf1e
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pdfobj.c
@@ -0,0 +1,1738 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#include <ctype.h>
+#include <string.h>
+#include "system.h"
+#include "config.h"
+#include "mem.h"
+#include "error.h"
+#include "mfileio.h"
+#include "pdflimits.h"
+#include "pdfobj.h"
+#include "pdfspecial.h"
+#include "pdfparse.h"
+#include "twiddle.h"
+
+#ifdef HAVE_ZLIB
+#include <zlib.h>
+#endif /* HAVE_ZLIB */
+
+FILE *pdf_output_file = NULL;
+FILE *pdf_input_file = NULL;
+unsigned long pdf_output_file_position = 0, compression_saved = 0;
+int pdf_output_line_position = 0;
+#define FORMAT_BUF_SIZE 4096
+char format_buffer[FORMAT_BUF_SIZE];
+
+static struct xref_entry
+{
+ unsigned long file_position;
+ pdf_obj *pdf_obj;
+} *output_xref = NULL;
+static unsigned long pdf_max_ind_objects = 0;
+static unsigned long next_label = 1;
+
+static unsigned long startxref;
+
+static unsigned pdf_root_obj = 0, pdf_info_obj = 0;
+
+/* Internal static routines */
+
+static void pdf_flush_obj (FILE *file, const pdf_obj *object);
+static void pdf_label_obj (pdf_obj *object);
+
+static void pdf_out_char (FILE *file, char c);
+static void pdf_out (FILE *file, void *buffer, int length);
+
+static void release_indirect (pdf_indirect *data);
+static void write_indirect (FILE *file, const pdf_indirect *indirect);
+
+static void release_boolean (pdf_obj *data);
+static void write_boolean (FILE *file, const pdf_boolean *data);
+
+static void write_null (FILE *file);
+static void release_null (void *data);
+
+static void release_number (pdf_number *data);
+static void write_number (FILE *file, const pdf_number
+ *number);
+
+static void write_string (FILE *file, const pdf_string *string);
+static void release_string (pdf_string *data);
+
+static void write_name (FILE *file, const pdf_name *name);
+static void release_name (pdf_name *data);
+
+static void write_array (FILE *file, const pdf_array *array);
+static void release_array (pdf_array *data);
+
+static void write_dict (FILE *file, const pdf_dict *dict);
+static void release_dict (pdf_dict *data);
+
+static void write_stream (FILE *file, pdf_stream *stream);
+static void release_stream (pdf_stream *stream);
+static int pdf_match_name (const pdf_obj *name_obj, const char *name); /* Name does not include the / */
+
+static unsigned char debug = 0, verbose = 0;
+static char compression_level = 9;
+
+void pdf_obj_set_compression (int level)
+{
+ if (level >= 0 && level <= 9)
+ compression_level = level;
+ else {
+ ERROR("set_compression: compression level");
+ }
+#ifndef HAVE_ZLIB_COMPRESS2
+ if (level != 0)
+ fprintf (stderr, "Unable to set compression level--your zlib doesn't have compress2()\n");
+#endif
+ return;
+}
+
+static unsigned pdf_version = 3;
+void pdf_set_version (unsigned version)
+{
+ if (version >= 2 && version <= 3) {
+ pdf_version = version;
+ }
+}
+
+void pdf_obj_set_debug(void)
+{
+ debug = 1;
+}
+
+void pdf_obj_set_verbose(void)
+{
+ if (verbose < 255)
+ verbose += 1;
+}
+
+
+void pdf_out_init (const char *filename)
+{
+ char v;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if (!(pdf_output_file = MFOPEN (filename, FOPEN_WBIN_MODE))) {
+ if (strlen(filename) < 128) {
+ sprintf (format_buffer, "Unable to open %s\n", filename);
+ } else
+ sprintf (format_buffer, "Unable to open file");
+ ERROR (format_buffer);
+ }
+ pdf_out (pdf_output_file, "%PDF-1.", strlen("%PDF-1."));
+ v = '0'+pdf_version;
+ pdf_out (pdf_output_file, &v, 1);
+ pdf_out (pdf_output_file, "\n", 1);
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+}
+
+static void dump_xref(void)
+{
+ int length;
+ unsigned long i;
+ startxref = pdf_output_file_position; /* Record where this xref is for
+ trailer */
+ pdf_out (pdf_output_file, "xref\n", 5);
+ sprintf (format_buffer, "%d %lu\n", 0, next_label);
+ length = strlen (format_buffer);
+ pdf_out (pdf_output_file, format_buffer, length);
+ sprintf (format_buffer, "%010ld %05ld f \n", 0L, 65535L);
+ length = strlen (format_buffer);
+ /* Every space counts. The space after the 'f' and 'n' is
+ *essential*. The PDF spec says the lines must be 20 characters
+ long including the end of line character. */
+ pdf_out (pdf_output_file, format_buffer, length);
+ for (i=1; i<next_label; i++){
+ sprintf (format_buffer, "%010ld %05ld n \n",
+ output_xref[i-1].file_position, 0L);
+ length = strlen (format_buffer);
+ pdf_out (pdf_output_file, format_buffer, length);
+ }
+ /* Done with xref table */
+ RELEASE (output_xref);
+}
+
+static void dump_trailer(void)
+{
+ int length;
+ unsigned long starttrailer;
+ starttrailer = pdf_output_file_position;
+ pdf_out (pdf_output_file, "trailer\n", 8);
+ pdf_out (pdf_output_file, "<<\n", 3);
+ sprintf (format_buffer, "/Size %lu\n",
+ next_label);
+ length = strlen (format_buffer);
+ pdf_out (pdf_output_file, format_buffer, length);
+ if (pdf_root_obj == 0)
+ ERROR ("dump_trailer: Invalid root object");
+ sprintf (format_buffer, "/Root %u %u R\n", pdf_root_obj, 0);
+ length = strlen (format_buffer);
+ pdf_out (pdf_output_file, format_buffer, length);
+ if (pdf_info_obj != 0) {
+ sprintf (format_buffer, "/Info %u %u R\n", pdf_info_obj, 0);
+ length = strlen (format_buffer);
+ pdf_out (pdf_output_file, format_buffer, length);
+ }
+ pdf_out (pdf_output_file, ">>\n", 3);
+ pdf_out (pdf_output_file, "startxref\n", 10);
+ sprintf (format_buffer, "%lu\n", startxref);
+ length = strlen (format_buffer);
+ pdf_out (pdf_output_file, format_buffer, length);
+ pdf_out (pdf_output_file, "%%EOF\n", 6);
+}
+
+void pdf_out_flush (void)
+{
+ if (pdf_output_file) {
+ if (debug) fprintf (stderr, "pdf_obj_out_flush: dumping xref\n");
+ dump_xref();
+ if (debug) fprintf (stderr, "pdf_obj_out_flush: dumping trailer\n");
+ dump_trailer();
+ if (verbose) {
+ if (compression_level>0) {
+ fprintf (stderr, "\nCompression eliminated approximately %lu bytes",
+ compression_saved);
+ }
+ }
+ fprintf (stderr, "\n%lu bytes written",
+ pdf_output_file_position);
+ MFCLOSE (pdf_output_file);
+ }
+}
+
+void pdf_error_cleanup (void)
+{
+ /* This routine is the cleanup required for an abnormal exit.
+ For now, simply close the file. */
+ if (pdf_output_file)
+ MFCLOSE (pdf_output_file);
+}
+
+
+void pdf_set_root (pdf_obj *object)
+{
+ if (pdf_root_obj != 0) {
+ ERROR ("pdf_set_root: root object already set");
+ }
+ if (object -> label == 0) { /* Make sure this object has a label */
+ pdf_label_obj (object);
+ }
+ pdf_root_obj = object -> label;
+}
+
+void pdf_set_info (pdf_obj *object)
+{
+ if (pdf_info_obj != 0) {
+ ERROR ("pdf_set_info: info object already set");
+ }
+ if (object -> label == 0) { /* Make sure this object has a label */
+ pdf_label_obj (object);
+ }
+ pdf_info_obj = object -> label;
+}
+
+static void pdf_out_char (FILE *file, char c)
+{
+ fputc (c, file);
+ /* Keep tallys for xref table *only* if writing a pdf file */
+ if (file == pdf_output_file) {
+ pdf_output_file_position += 1;
+ pdf_output_line_position += 1;
+ }
+ if (file == pdf_output_file && c == '\n')
+ pdf_output_line_position = 0;
+}
+
+static void pdf_out (FILE *file, void *buffer, int length)
+{
+ fwrite (buffer, 1, length, file);
+ /* Keep tallys for xref table *only* if writing a pdf file */
+ if (file == pdf_output_file) {
+ pdf_output_file_position += length;
+ pdf_output_line_position += length;
+ if (length > 0 && ((char *)buffer)[length-1] == '\n')
+ pdf_output_line_position = 0;
+ }
+}
+
+static void pdf_out_white (FILE *file)
+{
+ if (file == pdf_output_file && pdf_output_line_position >= 80) {
+ pdf_out_char (file, '\n');
+ } else {
+ pdf_out_char (file, ' ');
+ }
+ return;
+}
+
+pdf_obj *pdf_new_obj(pdf_obj_type type)
+{
+ pdf_obj *result;
+ result = NEW (1, pdf_obj);
+ result -> type = type;
+ result -> data = NULL;
+ result -> label = 0;
+ result -> generation = 0;
+ result -> refcount = 1;
+ return result;
+}
+
+static void pdf_label_obj (pdf_obj *object)
+{
+ if (object == NULL)
+ return;
+ if (next_label > pdf_max_ind_objects) {
+ pdf_max_ind_objects += IND_OBJECTS_ALLOC_SIZE;
+ output_xref = RENEW (output_xref, pdf_max_ind_objects,
+ struct xref_entry);
+ }
+ if (object -> label == 0) { /* Don't change label on an already labeled
+ object. Ignore such calls */
+ /* Save so we can lookup this object by its number */
+ output_xref[next_label-1].pdf_obj = object;
+ object -> label = next_label++;
+ object -> generation = 0;
+ }
+}
+
+/* This doesn't really copy the object, but allows
+ it to be used without fear that somebody else will free it */
+
+pdf_obj *pdf_link_obj (pdf_obj *object)
+{
+ if (object == NULL)
+ ERROR ("pdf_link_obj passed null pointer");
+ object -> refcount += 1;
+ return object;
+}
+
+
+pdf_obj *pdf_ref_obj(pdf_obj *object)
+{
+ pdf_obj *result;
+ pdf_indirect *indirect;
+
+ if (object == NULL)
+ ERROR ("pdf_ref_obj passed null pointer");
+
+ if (object -> refcount == 0) {
+ fprintf (stderr, "\npdf_ref_obj: Called with already released object");
+ pdf_write_obj (stderr, object);
+ ERROR ("Fatal Error\n");
+ }
+ result = pdf_new_obj (PDF_INDIRECT);
+ indirect = NEW (1, pdf_indirect);
+ result -> data = indirect;
+ if (object -> type == PDF_INDIRECT) { /* If an object is already an indirect reference,
+ reference the original
+ object, not the indirect
+ one */
+ indirect -> label = ((pdf_indirect *) (object -> data)) -> label;
+ indirect -> generation = ((pdf_indirect *) (object -> data)) -> generation;
+ indirect -> dirty = ((pdf_indirect *) (object -> data)) -> dirty;
+ indirect -> dirty_file = ((pdf_indirect *) (object -> data)) -> dirty_file;
+ } else {
+ if (object -> label == 0) {
+ pdf_label_obj (object);
+ }
+ indirect -> label = object -> label;
+ indirect -> generation = object -> generation;
+ indirect -> dirty = 0;
+ indirect -> dirty_file = NULL;
+ }
+ return result;
+}
+
+static void release_indirect (pdf_indirect *data)
+{
+ RELEASE (data);
+}
+
+static void write_indirect (FILE *file, const pdf_indirect *indirect)
+{
+ int length;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if (indirect -> dirty) {
+ if (file == stderr) {
+ pdf_out (file, "{d}", 3);
+ sprintf (format_buffer, "%d %d R", indirect -> label,
+ indirect -> generation);
+ length = strlen (format_buffer);
+ pdf_out (file, format_buffer, length);
+ }
+ else {
+ pdf_obj *clean;
+ if (indirect -> dirty_file != pdf_input_file) {
+ fprintf (stderr, "\nwrite_indirect, label=%d, from_file=%p, current_file=%p\n", indirect -> label, indirect->dirty_file, pdf_input_file);
+ ERROR ("write_indirect: input PDF file doesn't match object");
+ }
+ clean = pdf_ref_file_obj (indirect -> label);
+ pdf_write_obj (file, clean);
+ pdf_release_obj (clean);
+ }
+ } else {
+ sprintf (format_buffer, "%d %d R", indirect -> label,
+ indirect -> generation);
+ length = strlen (format_buffer);
+ pdf_out (file, format_buffer, length);
+ }
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+}
+
+pdf_obj *pdf_new_null (void)
+{
+ pdf_obj *result;
+ result = pdf_new_obj (PDF_NULL);
+ result -> data = NULL;
+ return result;
+}
+
+static void release_null (void *data)
+{
+ return;
+}
+
+static void write_null (FILE *file)
+{
+ pdf_out (file, "null", 4);
+}
+
+pdf_obj *pdf_new_boolean (char value)
+{
+ pdf_obj *result;
+ pdf_boolean *data;
+ result = pdf_new_obj (PDF_BOOLEAN);
+ data = NEW (1, pdf_boolean);
+ result -> data = data;
+ data -> value = value;
+ return result;
+}
+
+static void release_boolean (pdf_obj *data)
+{
+ RELEASE (data);
+}
+
+static void write_boolean (FILE *file, const pdf_boolean *data)
+{
+ if (data -> value) {
+ pdf_out (file, "true", 4);
+ }
+ else {
+ pdf_out (file, "false", 5);
+ }
+}
+
+void pdf_set_boolean (pdf_obj *object, char value)
+{
+ if (object == NULL || object -> type != PDF_BOOLEAN) {
+ ERROR ("pdf_set_boolean: Passed non-boolean object");
+ }
+ ((pdf_boolean *) (object -> data)) -> value = value;
+}
+
+pdf_obj *pdf_new_number (double value)
+{
+ pdf_obj *result;
+ pdf_number *data;
+ result = pdf_new_obj (PDF_NUMBER);
+ data = NEW (1, pdf_number);
+ result -> data = data;
+ data -> value = value;
+ return result;
+}
+
+static void release_number (pdf_number *data)
+{
+ RELEASE (data);
+}
+
+static void write_number (FILE *file, const pdf_number *number)
+{
+ int count;
+ sprintf (format_buffer, "%.10g", number -> value);
+ count = strlen (format_buffer);
+ pdf_out (file, format_buffer, count);
+}
+
+
+void pdf_set_number (pdf_obj *object, double value)
+{
+ if (object == NULL || object -> type != PDF_NUMBER) {
+ ERROR ("pdf_set_number: Passed non-number object");
+ }
+ ((pdf_number *) (object -> data)) -> value = value;
+}
+
+double pdf_number_value (pdf_obj *object)
+{
+ if (object == NULL || object -> type != PDF_NUMBER) {
+ ERROR ("pdf_obj_number_value: Passed non-number object");
+ }
+ return ((pdf_number *)(object -> data)) -> value;
+}
+
+pdf_obj *pdf_new_string (const void *string, unsigned length)
+{
+ pdf_obj *result;
+ pdf_string *data;
+ result = pdf_new_obj (PDF_STRING);
+ data = NEW (1, pdf_string);
+ result -> data = data;
+ if (length != 0) {
+ data -> length = length;
+ data -> string = NEW (length+1, unsigned char);
+ memcpy (data -> string, string, length);
+ data -> string[length] = 0;
+ } else {
+ data -> length = 0;
+ data -> string = NULL;
+ }
+ return result;
+}
+
+void *pdf_string_value (pdf_obj *a_pdf_string)
+{
+ pdf_string *data;
+ data = a_pdf_string -> data;
+ return data -> string;
+}
+
+unsigned int pdf_string_length (pdf_obj *a_pdf_string)
+{
+ pdf_string *data;
+ data = a_pdf_string -> data;
+ return (data -> length);
+}
+
+/* This routine escapes non printable characters and control
+ characters in an output string. It optionally remaps
+ the problem characters in the encoding */
+
+int pdfobj_escape_str (char *buffer, int bufsize, unsigned char *s,
+ int len, int remap)
+{
+ int result = 0, i;
+ unsigned char ch;
+ for (i=0; i<len; i++) {
+ ch = remap? twiddle(s[i]): s[i];
+ /* Exit as fast as possible for printable characters */
+ if (result+4 > bufsize)
+ ERROR ("pdfobj_escape_str: Buffer overflow");
+ if (ch < 32 || ch > 126) {
+ buffer[result++] = '\\';
+ sprintf (buffer+result, "%03o", ch);
+ result += strlen (buffer+result);
+ continue;
+ }
+ switch (ch) {
+ case '(':
+ buffer[result++] = '\\';
+ buffer[result++] = '(';
+ break;
+ case ')':
+ buffer[result++] = '\\';
+ buffer[result++] = ')';
+ break;
+ case '\\':
+ buffer[result++] = '\\';
+ buffer[result++] = '\\';
+ break;
+ default:
+ buffer[result++] = ch;
+ break;
+ }
+ }
+ return result;
+}
+
+
+static void write_string (FILE *file, const pdf_string *string)
+{
+ unsigned char *s = string -> string;
+ int count, i;
+ pdf_out_char (file, '(');
+ /* This section of code probably isn't speed critical. Escaping the
+ characters in the string one at a time may seem slow, but it's
+ safe if the formatted string length exceeds FORMAT_BUF_SIZE.
+ Occasionally you see some long strings in PDF. pdfobj_escape_str
+ is also used for strings of text with no kerning. These must be
+ handled as quickly as possible since there are so many of them. */
+ for (i=0; i<string->length; i++) {
+ count = pdfobj_escape_str (format_buffer, FORMAT_BUF_SIZE, s+i,
+ 1, 0);
+ pdf_out (file, format_buffer, count);
+ }
+ pdf_out_char (file, ')');
+}
+
+static void release_string (pdf_string *data)
+{
+ if (data -> string != NULL)
+ RELEASE (data -> string);
+ RELEASE (data);
+}
+
+void pdf_set_string (pdf_obj *object, unsigned char *string, unsigned length)
+{
+ pdf_string *data;
+ if (object == NULL || object -> type != PDF_STRING) {
+ ERROR ("pdf_set_string: Passed non-string object");
+ }
+ data = object -> data;
+ if (data -> length != 0) {
+ RELEASE (data -> string);
+ }
+ if (length != 0) {
+ data -> length = length;
+ data -> string = NEW (length+1, unsigned char);
+ memcpy (data -> string, string, length);
+ (data->string)[length] = 0;
+ } else {
+ data -> length = 0;
+ data -> string = NULL;
+ }
+ return;
+}
+
+int pdf_check_name(const char *name)
+{
+ static char *valid_chars =
+ "!\"$&'*+,-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^_`abcdefghijklmnopqrstuvwxyz|~";
+ if (strspn (name, valid_chars) == strlen (name))
+ return 1;
+ else
+ return 0;
+}
+
+pdf_obj *pdf_new_name (const char *name) /* name does *not* include the / */
+{
+ pdf_obj *result;
+ unsigned length = strlen (name);
+ pdf_name *data;
+ if (!pdf_check_name (name)) {
+ fprintf (stderr, "Invalid PDF name \"%s\"\n", name);
+ ERROR ("pdf_new_name: invalid PDF name");
+ }
+ result = pdf_new_obj (PDF_NAME);
+ data = NEW (1, pdf_name);
+ result -> data = data;
+ if (length != 0) {
+ data -> name = NEW (length+1, char);
+ memcpy (data -> name, name, length);
+ (data->name)[length] = 0;
+ } else
+ data -> name = NULL;
+ return result;
+}
+
+static void write_name (FILE *file, const pdf_name *name)
+{
+ char *s = name -> name;
+ int i, length;
+ pdf_out_char (file, '/');
+ if (name -> name == NULL)
+ length = 0;
+ else
+ length = strlen (name -> name);
+ for (i=0; i < length; i++) {
+ if (isprint (s[i]) &&
+ s[i] != '/' &&
+ s[i] != '%' &&
+ s[i] != '(' &&
+ s[i] != ')' &&
+ s[i] != '[' &&
+ s[i] != ']' &&
+ s[i] != '#')
+ pdf_out_char (file, s[i]);
+ }
+}
+
+
+static void release_name (pdf_name *data)
+{
+ if (data -> name != NULL)
+ RELEASE (data -> name);
+ RELEASE (data);
+}
+
+void pdf_set_name (pdf_obj *object, char *name)
+{
+ pdf_name *data;
+ unsigned length = strlen (name);
+ if (object == NULL || object -> type != PDF_NAME) {
+ ERROR ("pdf_set_name: Passed non-name object");
+ }
+ data = object -> data;
+ if (data -> name != NULL) {
+ RELEASE (data -> name);
+ }
+ if (length != 0) {
+ data -> name = NEW (length+1, char);
+ memcpy (data -> name, name, length);
+ (data->name)[length] = 0;
+ } else {
+ data -> name = NULL;
+ }
+}
+
+char *pdf_name_value (pdf_obj *object)
+{
+ pdf_name *data;
+ if (object == NULL || object -> type != PDF_NAME) {
+ ERROR ("pdf_name_value: Passed non-name object");
+ }
+ data = object -> data;
+ if (data -> name == NULL)
+ return NULL;
+ return data -> name;
+}
+
+
+pdf_obj *pdf_new_array (void)
+{
+ pdf_obj *result;
+ pdf_array *data;
+ result = pdf_new_obj (PDF_ARRAY);
+ data = NEW (1, pdf_array);
+ data -> values = NULL;
+ data -> max = 0;
+ data -> size = 0;
+ result -> data = data;
+ return result;
+}
+
+static void write_array (FILE *file, const pdf_array *array)
+{
+ if (array -> size > 0) {
+ unsigned long i;
+ pdf_out_char (file, '[');
+ for (i=0; i<array->size; i++) {
+ if (i != 0 &&
+ ((array->values)[i]->type) != PDF_STRING &&
+ ((array->values)[i]->type) != PDF_NAME &&
+ ((array->values)[i]->type) != PDF_ARRAY)
+ pdf_out_white (file);
+ pdf_write_obj (file, (array->values)[i]);
+ }
+ pdf_out_char (file, ']');
+ } else {
+ write_null (file);
+ }
+}
+
+pdf_obj *pdf_get_array (pdf_obj *array, unsigned long index)
+{
+ pdf_array *data;
+ pdf_obj *result = NULL;
+ if (array == NULL) {
+ ERROR ("pdf_get_array: passed NULL object");
+ }
+ if (array -> type != PDF_ARRAY) {
+ ERROR ("pdf_get_array: passed non array object");
+ }
+ data = array -> data;
+ if (index < data -> size) {
+ result = (data->values)[index];
+ }
+ return result;
+}
+
+static void release_array (pdf_array *data)
+{
+ unsigned long i;
+ for (i=0; i<data->size; i++) {
+ pdf_release_obj ((data ->values)[i]);
+ }
+ if (data->size > 0)
+ RELEASE (data->values);
+ RELEASE (data);
+}
+
+void pdf_add_array (pdf_obj *array, pdf_obj *object) /* Array is ended
+ by a node with NULL
+ this pointer */
+{
+ pdf_array *data;
+ if (array == NULL || array -> type != PDF_ARRAY) {
+ ERROR ("pdf_add_array: Passed non-array object");
+ }
+ data = array -> data;
+ if (data -> size >= data -> max) {
+ data->max += ARRAY_ALLOC_SIZE;
+ data->values = RENEW (data->values, data->max, pdf_obj *);
+ }
+ (data->values)[data->size++] = object;
+ return;
+}
+
+
+static void write_dict (FILE *file, const pdf_dict *dict)
+{
+ pdf_out (file, "<<\n", 3);
+ while (dict -> key != NULL) {
+ pdf_write_obj (file, dict -> key);
+ if (((dict -> value) -> type) == PDF_BOOLEAN ||
+ ((dict -> value) -> type) == PDF_NUMBER ||
+ ((dict -> value) -> type) == PDF_INDIRECT ||
+ ((dict -> value) -> type) == PDF_NULL)
+ pdf_out_white (file);
+ pdf_write_obj (file, dict -> value);
+ dict = dict -> next;
+ pdf_out_char (file, '\n');
+ }
+ pdf_out (file, ">>", 2);
+}
+
+pdf_obj *pdf_new_dict (void)
+{
+ pdf_obj *result;
+ pdf_dict *data;
+ result = pdf_new_obj (PDF_DICT);
+ data = NEW (1, pdf_dict);
+ data -> key = NULL;
+ data -> value = NULL;
+ data -> next = NULL;
+ result -> data = data;
+ return result;
+}
+
+static void release_dict (pdf_dict *data)
+{
+ pdf_dict *next;
+ while (data != NULL && data -> key != NULL) {
+ pdf_release_obj (data -> key);
+ pdf_release_obj (data -> value);
+ next = data -> next;
+ RELEASE (data);
+ data = next;
+ }
+ RELEASE (data);
+}
+
+void pdf_add_dict (pdf_obj *dict, pdf_obj *key, pdf_obj *value) /* Array is ended
+ by a node with NULL
+ this pointer */
+{
+ pdf_dict *data;
+ pdf_dict *new_node;
+ if (key == NULL || key -> type != PDF_NAME ) {
+ ERROR ("pdf_add_dict: Passed invalid key");
+ }
+ if (value != NULL &&
+ (value -> type == 0 || value -> type > PDF_INDIRECT )) {
+ ERROR ("pdf_add_dict: Passed invalid value");
+ }
+ if (dict == NULL || dict -> type != PDF_DICT) {
+ fprintf (stderr, "key:");
+ pdf_write_obj (stderr, key);
+ fprintf (stderr, "value:");
+ pdf_write_obj (stderr, value);
+ ERROR ("pdf_add_dict: Passed non-dict object");
+ }
+ data = dict -> data;
+ /* If this key already exists, simply replace the value */
+ while (data -> key != NULL) {
+ if (!strcmp (pdf_name_value(key), pdf_name_value(data->key))) {
+ /* Release the old value */
+ pdf_release_obj (data->value);
+ /* Release the new key (we don't need it) */
+ pdf_release_obj (key);
+ data->value = value;
+ break;
+ }
+ data = data -> next;
+ }
+ /* If we didn't find the key, build a new "end" node and add
+ the new key just before the end */
+ if (data -> key == NULL) {
+ new_node = NEW (1, pdf_dict);
+ new_node -> key = NULL;
+ new_node -> value = NULL;
+ new_node -> next = NULL;
+ data -> next = new_node;
+ data -> key = key;
+ data -> value = value;
+ }
+ return;
+}
+
+/* pdf_merge_dict makes a link for each item in dict2 before
+ stealing it */
+void pdf_merge_dict (pdf_obj *dict1, pdf_obj *dict2)
+{
+ pdf_dict *data;
+ if (dict1 == NULL || dict1 -> type != PDF_DICT)
+ ERROR ("pdf_merge_dict: Passed invalid first dictionary");
+ if (dict2 == NULL || dict2 -> type != PDF_DICT)
+ ERROR ("pdf_merge_dict: Passed invalid second dictionary");
+ data = dict2 -> data;
+ while (data -> key != NULL) {
+ pdf_add_dict (dict1, pdf_link_obj(data -> key),
+ pdf_link_obj (data -> value));
+ data = data -> next;
+ }
+}
+
+static int pdf_match_name (const pdf_obj *name_obj, const char *name_string)
+{
+ pdf_name *data;
+ data = name_obj -> data;
+ return (!strcmp (data -> name, name_string));
+}
+
+pdf_obj *pdf_lookup_dict (const pdf_obj *dict, const char *name)
+{
+ pdf_dict *data;
+ if (dict == NULL || dict ->type != PDF_DICT)
+ ERROR ("pdf_lookup_dict: Passed invalid dictionary");
+ data = dict -> data;
+ while (data -> key != NULL) {
+ if (pdf_match_name (data -> key, name))
+ return data -> value;
+ data = data -> next;
+ }
+ return NULL;
+}
+
+void pdf_remove_dict (pdf_obj *dict, const char *name)
+{
+ pdf_dict *data, **data_p;
+ if (dict == NULL || dict->type != PDF_DICT)
+ ERROR ("pdf_remove_dict: Passed invalid dictionary");
+ data = (dict -> data);
+ data_p = (pdf_dict **) &(dict->data);
+ while (data->key != NULL) {
+ if (pdf_match_name (data -> key, name)) {
+ pdf_release_obj (data -> key);
+ pdf_release_obj (data -> value);
+ *data_p = data -> next;
+ RELEASE (data);
+ break;
+ }
+ data_p = &(data->next);
+ data = data -> next;
+ }
+ return;
+}
+
+char *pdf_get_dict (const pdf_obj *dict, int index)
+{
+ pdf_dict *data;
+ char *result;
+ if (dict == NULL) {
+ ERROR ("pdf_get_dict: passed NULL object");
+ }
+ if (dict -> type != PDF_DICT) {
+ ERROR ("pdf_get_dict: passed non array object");
+ }
+ data = dict -> data;
+ while (index-- > 0 && data -> next != NULL)
+ data = data -> next;
+ if (data -> next == NULL)
+ return NULL;
+ result = pdf_name_value (data -> key);
+ return result;
+}
+
+pdf_obj *pdf_new_stream (int flags)
+{
+ pdf_obj *result;
+#ifdef HAVE_ZLIB
+ pdf_obj *filters = NULL;
+#endif /* HAVE_ZLIB */
+ pdf_stream *data;
+ result = pdf_new_obj (PDF_STREAM);
+ data = NEW (1, pdf_stream);
+ result -> data = data;
+ data -> dict = pdf_new_dict (); /* Although we are using an arbitrary
+ pdf_object here, it must have
+ type=PDF_DICT and cannot be an
+ indirect reference. This will
+ be checked by the output routine
+ */
+ data -> _flags = flags;
+#ifdef HAVE_ZLIB
+ if ((flags & STREAM_COMPRESS) && compression_level > 0) {
+ if (!filters) {
+ filters = pdf_new_array();
+ pdf_add_dict (data -> dict, pdf_new_name ("Filter"), filters);
+ }
+ pdf_add_array (filters, pdf_new_name ("FlateDecode"));
+ }
+#endif /* HAVE_ZLIB */
+
+ data -> stream_length = 0;
+ data -> max_length = 0;
+ data -> stream = NULL;
+ return result;
+}
+
+
+static void write_stream (FILE *file, pdf_stream *stream)
+{
+#define COMPRESS_LEVEL 9
+#define THRESHOLD 100
+ unsigned char *filtered;
+ unsigned long filtered_length;
+#ifdef HAVE_ZLIB
+ unsigned long buffer_length;
+ unsigned char *buffer;
+#endif /* HAVE_ZLIB */
+ /* Always work from a copy of the stream */
+ /* All filters read from "filtered" and leave their result in
+ "filtered" */
+ filtered = NEW (stream->stream_length+1, unsigned char);
+ memcpy (filtered, stream->stream, stream->stream_length);
+ filtered_length = stream->stream_length;
+
+#ifdef HAVE_ZLIB
+ /* Apply compression filter if requested */
+ if ((stream -> _flags & STREAM_COMPRESS) && compression_level > 0) {
+ buffer_length = filtered_length + filtered_length/1000 + 14;
+ buffer = NEW (buffer_length, unsigned char);
+#ifdef HAVE_ZLIB_COMPRESS2
+ if (compress2 (buffer, &buffer_length, filtered,
+ filtered_length, compression_level))
+ ERROR ("Zlib error");
+#else
+ if (compress (buffer, &buffer_length, filtered,
+ filtered_length))
+ ERROR ("Zlib error");
+#endif /* HAVE_ZLIB_COMPRESS2 */
+ RELEASE (filtered);
+ filtered = buffer;
+ compression_saved += (filtered_length-buffer_length)-strlen("/Filter [/FlateDecode]\n");
+ filtered_length = buffer_length;
+ }
+#endif /* HAVE_ZLIB */
+ /* Add a '\n' if the last character wasn't one */
+ if (filtered_length > 0 && filtered[filtered_length-1] != '\n') {
+ filtered[filtered_length++] = '\n';
+ }
+ pdf_add_dict (stream->dict,
+ pdf_new_name ("Length"),
+ pdf_new_number(filtered_length));
+ pdf_write_obj (file, stream -> dict);
+ pdf_out (file, "\nstream\n", 8);
+
+ if (filtered_length > 0) {
+ pdf_out (file, filtered, filtered_length);
+ }
+
+ RELEASE (filtered);
+ /* This stream length "object" gets reset every time write_stream is
+ called for the stream object */
+ /* If this stream gets written more than once with different
+ filters, this could be a problem */
+ pdf_out (file, "endstream", 9);
+ return;
+}
+
+static void release_stream (pdf_stream *stream)
+{
+ pdf_release_obj (stream -> dict);
+ if (stream -> stream_length > 0)
+ RELEASE (stream -> stream);
+ RELEASE (stream);
+}
+
+pdf_obj *pdf_stream_dict (pdf_obj *stream)
+{
+ pdf_stream *data;
+ if (stream == NULL || stream -> type != PDF_STREAM) {
+ ERROR ("pdf_stream_dict: Passed non-stream object");
+ }
+ data = stream -> data;
+ return data -> dict;
+}
+
+void pdf_add_stream (pdf_obj *stream, char *stream_data, unsigned length)
+{
+ pdf_stream *data;
+ if (stream == NULL || stream -> type != PDF_STREAM) {
+ ERROR ("pdf_add_stream: Passed non-stream object");
+ }
+ if (length == 0)
+ return;
+ data = stream -> data;
+ if (data -> stream_length + length > data -> max_length) {
+ data -> max_length += length + STREAM_ALLOC_SIZE;
+ data -> stream = RENEW (data -> stream, data->max_length, char);
+ }
+ memcpy ((data->stream)+(data->stream_length), stream_data,
+ length);
+ data->stream_length += length;
+}
+
+void pdf_write_obj (FILE *file, const pdf_obj *object)
+{
+ if (object == NULL) {
+ write_null(file);
+ return;
+ }
+ if (object -> type > PDF_INDIRECT) {
+ fprintf (stderr, "Object type = %d\n", object -> type);
+ ERROR ("pdf_write_obj: Called with invalid object");
+ }
+ if (file == stderr)
+ fprintf (stderr, "{%d}", object -> refcount);
+ switch (object -> type) {
+ case PDF_BOOLEAN:
+ write_boolean (file, object -> data);
+ break;
+ case PDF_NUMBER:
+ write_number (file, object -> data);
+ break;
+ case PDF_STRING:
+ write_string (file, object -> data);
+ break;
+ case PDF_NAME:
+ write_name (file, object -> data);
+ break;
+ case PDF_ARRAY:
+ write_array (file, object -> data);
+ break;
+ case PDF_DICT:
+ write_dict (file, object -> data);
+ break;
+ case PDF_STREAM:
+ write_stream (file, object -> data);
+ break;
+ case PDF_NULL:
+ write_null (file);
+ break;
+ case PDF_INDIRECT:
+ write_indirect (file, object -> data);
+ break;
+ }
+}
+
+static void pdf_flush_obj (FILE *file, const pdf_obj *object)
+ /* Write the object to the file */
+{
+ int length;
+ /* Record file position. No object is numbered 0, so subtract 1
+ when using as an array index */
+ output_xref[object->label-1].file_position = pdf_output_file_position;
+ sprintf (format_buffer, "%lu %d obj\n", object -> label ,
+ object -> generation);
+ length = strlen (format_buffer);
+ pdf_out (file, format_buffer, length);
+ pdf_write_obj (file, object);
+ pdf_out (file, "\nendobj\n", 8);
+}
+
+
+void pdf_release_obj (pdf_obj *object)
+{
+ if (object == NULL)
+ return;
+ if (object -> type > PDF_INDIRECT ||
+ object -> refcount <= 0) {
+ fprintf (stderr, "pdf_release_obj: object = %p, type = %d\n", object, object ->
+ type);
+ pdf_write_obj (stderr, object);
+ ERROR ("pdf_release_obj: Called with invalid object");
+ }
+ object -> refcount -= 1;
+ if (object -> refcount == 0) { /* Nothing is using this object so it's okay to
+ remove it */
+ /* Nonzero "label" means object needs to be written before it's destroyed*/
+ if (object -> label && pdf_output_file != NULL) {
+ pdf_flush_obj (pdf_output_file, object);
+ }
+ switch (object -> type) {
+ case PDF_BOOLEAN:
+ release_boolean (object -> data);
+ break;
+ case PDF_NULL:
+ release_null (object -> data);
+ break;
+ case PDF_NUMBER:
+ release_number (object -> data);
+ break;
+ case PDF_STRING:
+ release_string (object -> data);
+ break;
+ case PDF_NAME:
+ release_name (object -> data);
+ break;
+ case PDF_ARRAY:
+ release_array (object -> data);
+ break;
+ case PDF_DICT:
+ release_dict (object -> data);
+ break;
+ case PDF_STREAM:
+ release_stream (object -> data);
+ break;
+ case PDF_INDIRECT:
+ release_indirect (object -> data);
+ break;
+ }
+ /* This might help detect freeing already freed objects */
+ /* object -> type = -1;*/
+ RELEASE (object);
+ }
+}
+
+static int backup_line (void)
+{
+ int ch;
+ ch = -1;
+ if (debug) {
+ fprintf (stderr, "\nbackup_line:\n");
+ }
+ /* Note: this code should work even if \r\n is eol.
+ It could fail on a machine where \n is eol and
+ there is a \r in the stream---Highly unlikely
+ in the last few bytes where this is likely to be used.
+ */
+ if (tell_position (pdf_input_file) > 1)
+ do {
+ seek_relative (pdf_input_file, -2);
+ if (debug)
+ fprintf (stderr, "%c", ch);
+ } while (tell_position (pdf_input_file) > 0 &&
+ (ch = fgetc (pdf_input_file)) >= 0 &&
+ (ch != '\n' && ch != '\r' ));
+ if (debug)
+ fprintf (stderr, "<-\n");
+ if (ch < 0) {
+ return 0;
+ }
+ return 1;
+}
+
+static unsigned long pdf_file_size = 0;
+
+static long find_xref(void)
+{
+ long currentpos, xref_pos;
+ int tries = 10;
+ char *start, *end, *number;
+ if (debug)
+ fprintf (stderr, "(find_xref");
+ seek_end (pdf_input_file);
+ pdf_file_size = tell_position (pdf_input_file);
+ do {
+ if (!backup_line()) {
+ tries = 0;
+ break;
+ }
+ currentpos = tell_position(pdf_input_file);
+ fread (work_buffer, sizeof(char), strlen("startxref"),
+ pdf_input_file);
+ if (debug) {
+ work_buffer[strlen("startxref")] = 0;
+ fprintf (stderr, "[%s]\n", work_buffer);
+ }
+ seek_absolute(pdf_input_file, currentpos);
+ tries--;
+ } while (tries > 0 && strncmp (work_buffer, "startxref", strlen ("startxref")));
+ if (tries <= 0)
+ return 0;
+ /* Skip rest of this line */
+ mfgets (work_buffer, WORK_BUFFER_SIZE, pdf_input_file);
+ /* Next line of input file should contain actual xref location */
+ mfgets (work_buffer, WORK_BUFFER_SIZE, pdf_input_file);
+ if (debug) {
+ fprintf (stderr, "\n->[%s]<-\n", work_buffer);
+ }
+ start = work_buffer;
+ end = start+strlen(work_buffer);
+ skip_white(&start, end);
+ xref_pos = (long) atof (number = parse_number (&start, end));
+ RELEASE (number);
+ if (debug) {
+ fprintf (stderr, ")\n");
+ fprintf (stderr, "xref @ %lu\n", xref_pos);
+ }
+ return xref_pos;
+}
+
+pdf_obj *parse_trailer (void)
+{
+ char *start;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ /* This routine must be called with the file pointer located at
+ the start of the trailer */
+ /* Fill work_buffer and hope trailer fits. This should
+ be made a bit more robust sometime */
+ if (fread (work_buffer, sizeof(char), WORK_BUFFER_SIZE,
+ pdf_input_file) == 0 ||
+ strncmp (work_buffer, "trailer", strlen("trailer"))) {
+ fprintf (stderr, "No trailer. Are you sure this is a PDF file?\n");
+ fprintf (stderr, "\nbuffer:\n->%s<-\n", work_buffer);
+ return NULL;
+ }
+ start = work_buffer + strlen("trailer");
+ skip_white(&start, work_buffer+WORK_BUFFER_SIZE);
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return (parse_pdf_dict (&start, work_buffer+WORK_BUFFER_SIZE));
+}
+
+struct object
+{
+ unsigned long position;
+ unsigned generation;
+ /* Object numbers in original file and new file must have different
+ object numbers.
+ new_ref provides a reference for the object in the new file
+ object space. When it is first set, an object in the old file
+ is copied to the new file with a new number. new_ref remains set
+ until the file is closed so that future references can access the
+ object via new_ref instead of copying the object again */
+ pdf_obj *direct;
+ pdf_obj *indirect;
+ int used;
+} *xref_table = NULL;
+long num_input_objects;
+
+long next_object (unsigned long obj)
+{
+ /* routine tries to estimate an upper bound for character position
+ of the end of the object, so it knows how big the buffer must be.
+ The parsing routines require that the entire object be read into
+ memory. It would be a major pain to rewrite them. The worst case
+ is that an object before an xref table will grab the whole table
+ :-( */
+ unsigned long i;
+ long this_position, result = pdf_file_size; /* Worst case */
+ this_position = xref_table[obj].position;
+ /* Check all other objects to find next one */
+ for (i=0; i<num_input_objects; i++) {
+ if ((xref_table[i].used) &&
+ xref_table[i].position > this_position &&
+ xref_table[i].position < result)
+ result = xref_table[i].position;
+ }
+ return result;
+}
+
+/* The following routine returns a reference to an object existing
+ only in the input file. It does this as follows. If the object
+ has never been referenced before, it reads the object
+ in and creates a reference to it. Then it writes
+ the object out, keeping the existing reference. If the
+ object has been read in (and written out) before, it simply
+ returns the retained existing reference to that object */
+
+pdf_obj *pdf_ref_file_obj (unsigned long obj_no)
+{
+ pdf_obj *direct, *indirect;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if (obj_no >= num_input_objects) {
+ fprintf (stderr, "\n\npdf_ref_file_obj: nonexistent object\n");
+ return NULL;
+ }
+ if (xref_table[obj_no].indirect != NULL) {
+ return pdf_link_obj(xref_table[obj_no].indirect);
+ }
+ if ((direct = pdf_read_object (obj_no)) == NULL) {
+ fprintf (stderr, "\npdf_ref_file_obj: Could not read object\n");
+ return NULL;
+ }
+ indirect = pdf_ref_obj (direct);
+ xref_table[obj_no].indirect = indirect;
+ xref_table[obj_no].direct = direct;
+ /* Make sure the caller can't doesn't free this object */
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return pdf_link_obj(indirect);
+}
+
+
+pdf_obj *pdf_new_ref (unsigned long label, int generation)
+{
+ pdf_obj *result;
+ pdf_indirect *indirect;
+ if (label >= num_input_objects || label < 0) {
+ fprintf (stderr, "pdf_new_ref: Object doesn't exist\n");
+ return NULL;
+ }
+ result = pdf_new_obj (PDF_INDIRECT);
+ indirect = NEW (1, pdf_indirect);
+ result -> data = indirect;
+ indirect -> label = label;
+ indirect -> generation = generation;
+ indirect -> dirty = 1;
+ indirect -> dirty_file = pdf_input_file;
+ return result;
+}
+
+pdf_obj *pdf_read_object (unsigned long obj_no)
+{
+ long start_pos, end_pos;
+ char *buffer, *number, *parse_pointer, *end;
+ pdf_obj *result;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if (debug) {
+ fprintf (stderr, "\nread_object: obj=%lu\n", obj_no);
+ }
+ if (obj_no < 0 || obj_no >= num_input_objects) {
+ fprintf (stderr, "\nTrying to read nonexistent object\n");
+ return NULL;
+ }
+ if (!xref_table[obj_no].used) {
+ fprintf (stderr, "\nTrying to read deleted object\n");
+ return NULL;
+ }
+ if (debug) {
+ fprintf (stderr, "\nobj@%lu\n", xref_table[obj_no].position);
+ }
+ seek_absolute (pdf_input_file, start_pos =
+ xref_table[obj_no].position);
+ end_pos = next_object (obj_no);
+ if (debug) {
+ fprintf (stderr, "\nendobj@%lu\n", end_pos);
+ }
+ buffer = NEW (end_pos - start_pos+1, char);
+ fread (buffer, sizeof(char), end_pos-start_pos, pdf_input_file);
+ buffer[end_pos-start_pos] = 0;
+ if (debug) {
+ fprintf (stderr, "\nobject:\n%s", buffer);
+ }
+ parse_pointer = buffer;
+ end = buffer+(end_pos-start_pos);
+ skip_white (&parse_pointer, end);
+ number = parse_number (&parse_pointer, end);
+ if ((int) atof(number) != obj_no) {
+ fprintf (stderr, "Object number doesn't match\n");
+ RELEASE (buffer);
+ return NULL;
+ }
+ if (number != NULL)
+ RELEASE(number);
+ skip_white (&parse_pointer, end);
+ number = parse_number (&parse_pointer, end);
+ if (number != NULL)
+ RELEASE(number);
+ skip_white(&parse_pointer, end);
+ if (strncmp(parse_pointer, "obj", strlen("obj"))) {
+ fprintf (stderr, "Didn't find \"obj\"\n");
+ RELEASE (buffer);
+ return (NULL);
+ }
+ parse_pointer += strlen("obj");
+ result = parse_pdf_object (&parse_pointer, end);
+ skip_white (&parse_pointer, end);
+ if (strncmp(parse_pointer, "endobj", strlen("endobj"))) {
+ fprintf (stderr, "Didn't find \"endobj\"\n");
+ if (result != NULL)
+ pdf_release_obj (result);
+ result = NULL;
+ }
+ RELEASE (buffer);
+ return (result);
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+}
+/* pdf_deref_obj always returns a link instead of the original */
+pdf_obj *pdf_deref_obj (pdf_obj *obj)
+{
+ pdf_obj *result, *tmp;
+ pdf_indirect *indirect;
+ if (obj == NULL)
+ return NULL;
+ if (obj -> type != PDF_INDIRECT) {
+ return pdf_link_obj (obj);
+ }
+ indirect = obj -> data;
+ if (!(indirect -> dirty)) {
+ ERROR ("Tried to deref a non-file object");
+ }
+ result = pdf_read_object (indirect -> label);
+
+ if (debug){
+ fprintf (stderr, "\npdf_deref_obj: read_object returned\n");
+ pdf_write_obj (stderr, result);
+ }
+
+ while (result && result -> type == PDF_INDIRECT) {
+ tmp = pdf_read_object (result -> label);
+ pdf_release_obj (result);
+ result = tmp;
+ }
+ return result;
+}
+
+/* extends the xref table if we get another segment
+ with higher object numbers than the current object */
+static void extend_xref (long new_size)
+{
+ unsigned long i;
+ xref_table = RENEW (xref_table, new_size,
+ struct object);
+ for (i=num_input_objects; i<new_size; i++) {
+ xref_table[i].direct = NULL;
+ xref_table[i].indirect = NULL;
+ xref_table[i].used = 0;
+ xref_table[i].position = 0;
+ }
+ num_input_objects = new_size;
+}
+
+
+
+static int parse_xref (void)
+{
+ unsigned long first_obj, num_table_objects;
+ unsigned long i;
+ /* This routine reads one xref segment. It must be called
+ positioned at the beginning of an xref table. It may be called
+ multiple times on the same file. xref tables sometimes come in
+ pieces */
+ mfgets (work_buffer, WORK_BUFFER_SIZE, pdf_input_file);
+ if (strncmp (work_buffer, "xref", strlen("xref"))) {
+ fprintf (stderr, "No xref. Are you sure this is a PDF file?\n");
+ return 0;
+ }
+ /* Next line in file has first item and size of table */
+ for (;;) {
+ unsigned long current_pos;
+ current_pos = tell_position (pdf_input_file);
+ if (mfgets (work_buffer, WORK_BUFFER_SIZE, pdf_input_file) ==
+ NULL)
+ ERROR ("parse_xref: premature end of PDF file while parsing xref");
+ if (!strncmp (work_buffer, "trailer", strlen ("trailer"))) {
+ /* Backup... This is ugly, but it seems like the safest thing to
+ do. It is possible the trailer dictionary starts on the same
+ logical line as the word trailer. In that case, the mfgets
+ call might have started to read the trailer dictionary and
+ parse_trailer would fail */
+ seek_absolute (pdf_input_file, current_pos);
+ break;
+ }
+ sscanf (work_buffer, "%lu %lu", &first_obj, &num_table_objects);
+ if (num_input_objects < first_obj+num_table_objects) {
+ extend_xref (first_obj+num_table_objects);
+ }
+ if (debug) {
+ fprintf (stderr, "\nfirstobj=%lu,number=%lu\n",
+ first_obj,num_table_objects);
+ }
+ for (i=first_obj; i<first_obj+num_table_objects; i++) {
+ fread (work_buffer, sizeof(char), 20, pdf_input_file);
+ /* Don't overwrite positions that have already been set by a
+ modified xref table. We are working our way backwards
+ through the reference table, so we only set "position"
+ if it hasn't been set yet. */
+ if (xref_table[i].position == 0) {
+ work_buffer[19] = 0;
+ sscanf (work_buffer, "%lu %u", &(xref_table[i].position),
+ &(xref_table[i].generation));
+ }
+ if (debug) {
+ fprintf (stderr, "pos: %lu gen: %u\n", xref_table[i].position,
+ xref_table[i].generation);
+ }
+ if (work_buffer[17] != 'n' && work_buffer[17] != 'f') {
+ fprintf (stderr, "PDF file is corrupt\n");
+ fprintf (stderr, "[%s]\n", work_buffer);
+ return 0;
+ }
+ if (work_buffer[17] == 'n')
+ xref_table[i].used = 1;
+ else
+ xref_table[i].used = 0;
+ xref_table[i].direct = NULL;
+ xref_table[i].indirect = NULL;
+ }
+ }
+ return 1;
+}
+
+pdf_obj *read_xref (void)
+{
+ pdf_obj *main_trailer, *prev_trailer, *prev_xref, *xref_size;
+ long xref_pos;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if ((xref_pos = find_xref()) == 0) {
+ fprintf (stderr, "Can't find xref table.\n");
+ return NULL;
+ }
+ if (debug) {
+ fprintf(stderr, "xref@%lu\n", xref_pos);
+ }
+ /* Read primary xref table */
+ seek_absolute (pdf_input_file, xref_pos);
+ if (!parse_xref()) {
+ fprintf (stderr,
+ "\nCouldn't read xref table. Is this a correct PDF file?\n");
+ return NULL;
+ }
+ if ((main_trailer = parse_trailer()) == NULL) {
+ fprintf (stderr,
+ "\nCouldn't read xref trailer. Is this a correct PDF file?\n");
+ return NULL;
+ }
+ if (pdf_lookup_dict (main_trailer, "Root") == NULL ||
+ (xref_size = pdf_lookup_dict (main_trailer, "Size")) == NULL) {
+ fprintf (stderr,
+ "\nTrailer doesn't have catalog or a size. Is this a correct PDF file?\n");
+ return NULL;
+ }
+ if (num_input_objects < pdf_number_value (xref_size)) {
+ extend_xref (pdf_number_value (xref_size));
+ }
+ /* Read any additional xref tables */
+ prev_trailer = pdf_link_obj (main_trailer);
+ while ((prev_xref = pdf_lookup_dict (prev_trailer, "Prev")) != NULL) {
+ xref_pos = pdf_number_value (prev_xref);
+ seek_absolute (pdf_input_file, xref_pos);
+ pdf_release_obj (prev_trailer);
+ if (!parse_xref()) {
+ fprintf (stderr,
+ "\nCouldn't read xref table. Is this a correct PDF file?\n");
+ return NULL;
+ }
+ if ((prev_trailer = parse_trailer()) == NULL) {
+ fprintf (stderr,
+ "\nCouldn't read xref trailer. Is this a correct PDF file?\n");
+ return NULL;
+ }
+ if (debug) {
+ fprintf (stderr, "\nprev_trailer:\n");
+ pdf_write_obj (stderr, prev_trailer);
+ }
+ }
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ pdf_release_obj (prev_trailer);
+ return main_trailer;
+}
+
+static char any_open = 0;
+
+pdf_obj *pdf_open (FILE *file)
+{
+ pdf_obj *trailer;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if (any_open) {
+ fprintf (stderr, "\nOnly one PDF file may be open at one time.\n");
+ any_open = 1;
+ exit(1);
+ }
+ pdf_input_file = file;
+ if (!check_for_pdf (pdf_input_file)) {
+ fprintf (stderr, "pdf_open: Not a PDF 1.[1-3] file\n");
+ return NULL;
+ }
+ if ((trailer = read_xref()) == NULL) {
+ fprintf (stderr, "No trailer.\n");
+ pdf_close ();
+ return NULL;
+ }
+ if (debug) {
+ fprintf (stderr, "\nDone with xref:\n");
+ }
+#ifdef MEM_DEBUG
+ MEM_END
+#endif
+ return trailer;
+}
+
+void pdf_close (void)
+{
+ /* Following loop must be iterated because each write could trigger
+ an additional indirect reference of an object with a lower
+ number! */
+ unsigned long i;
+ int done;
+ if (debug) {
+ fprintf (stderr, "\npdf_close:\n");
+ fprintf (stderr, "pdf_input_file=%p\n", pdf_input_file);
+ }
+ do {
+ done = 1;
+ for (i=0; i<num_input_objects; i++) {
+ if (xref_table[i].direct != NULL) {
+ pdf_release_obj (xref_table[i].direct);
+ xref_table[i].direct = NULL;
+ done = 0;
+ }
+ }
+ } while (!done);
+ /* Now take care of the indirect objects
+ They had to be left around until all the direct
+ objects were flushed */
+ for (i=0; i<num_input_objects; i++) {
+ if (xref_table[i].indirect != NULL) {
+ pdf_release_obj (xref_table[i].indirect);
+ }
+ }
+ RELEASE (xref_table);
+ xref_table = NULL;
+ num_input_objects = 0;
+ any_open = 0;
+ pdf_input_file = NULL;
+ if (debug) {
+ fprintf (stderr, "\nexiting pdf_close:\n");
+ }
+}
+
+int check_for_pdf (FILE *file)
+{
+ int result = 0;
+ rewind (file);
+ if (fread (work_buffer, sizeof(char), strlen("%PDF-1.x"), file) ==
+ strlen("%PDF-1.x") &&
+ !strncmp(work_buffer, "%PDF-1.", strlen("%PDF-1."))) {
+ if (work_buffer[7] >= '0' && work_buffer[7] <= '0'+pdf_version)
+ result = 1;
+ else {
+ fprintf (stderr, "\nVersion of PDF file (1.%c) is newer than version limit specification.\n", work_buffer[7]);
+ }
+ }
+ return result;
+}
diff --git a/Build/source/texk/dvipdfm/pdfobj.h b/Build/source/texk/dvipdfm/pdfobj.h
new file mode 100644
index 00000000000..03b1f55a015
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pdfobj.h
@@ -0,0 +1,187 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef PDFOBJ_H
+#define PDFOBJ_H
+#include <stdio.h>
+
+/* Here is the complete list of PDF object types */
+
+#define PDF_BOOLEAN 1u
+#define PDF_NUMBER 2u
+#define PDF_STRING 3u
+#define PDF_NAME 4u
+#define PDF_ARRAY 5u
+#define PDF_DICT 6u
+#define PDF_STREAM 7u
+#define PDF_NULL 8u
+#define PDF_INDIRECT 9u
+
+typedef unsigned char pdf_obj_type;
+
+/* Any of these types can be represented as follows */
+
+struct pdf_obj
+{
+ pdf_obj_type type;
+ void *data;
+ unsigned long label; /* Only used for indirect objects
+ all other "label" to zero */
+ unsigned generation; /* Only used if "label" is used */
+ unsigned refcount; /* Number of links to this object */
+};
+typedef struct pdf_obj pdf_obj;
+
+struct pdf_boolean
+{
+ char value;
+};
+typedef struct pdf_boolean pdf_boolean;
+
+
+struct pdf_number
+{
+ double value;
+};
+typedef struct pdf_number pdf_number;
+
+struct pdf_string
+{
+ unsigned char *string;
+ unsigned length;
+};
+typedef struct pdf_string pdf_string;
+
+
+struct pdf_name
+{
+ char *name;
+};
+typedef struct pdf_name pdf_name;
+
+
+struct pdf_array
+{
+ unsigned long max, size;
+ pdf_obj **values;
+};
+typedef struct pdf_array pdf_array;
+
+struct pdf_dict
+{
+ pdf_obj *key;
+ pdf_obj *value;
+ struct pdf_dict *next;
+};
+typedef struct pdf_dict pdf_dict;
+
+struct pdf_stream
+{
+ struct pdf_obj *dict;
+ char *stream; /* Actual stream contents stored in "stream" */
+ unsigned long stream_length;
+ unsigned long max_length;
+ unsigned char _flags;
+};
+typedef struct pdf_stream pdf_stream;
+
+struct pdf_indirect
+{
+ unsigned label, generation;
+ int dirty; /* Dirty objects came from an input file and were not
+ generated by this program. They have a label in a
+ different numbering sequence. These are translated
+ when the object is written out */
+ FILE *dirty_file;
+};
+typedef struct pdf_indirect pdf_indirect;
+
+/* External interface to pdf routines */
+
+extern void pdf_obj_set_verbose(void);
+struct pdf_obj *pdf_new_obj (pdf_obj_type type);
+extern void pdf_out_init (const char *filename);
+extern void pdf_out_flush (void);
+extern pdf_obj *pdf_new_obj(pdf_obj_type type);
+extern pdf_obj *pdf_link_obj(pdf_obj *object);
+extern pdf_obj *pdf_new_null (void);
+extern pdf_obj *pdf_new_boolean (char value);
+extern void pdf_set_boolean (pdf_obj *object, char value);
+extern void pdf_set_info (pdf_obj *object);
+extern void pdf_set_root (pdf_obj *object);
+extern pdf_obj *pdf_new_number (double value);
+extern void pdf_set_number (pdf_obj *object, double value);
+extern double pdf_number_value (pdf_obj *number);
+extern char *pdf_name_value (pdf_obj *object);
+extern pdf_obj *pdf_new_string (const void *string, unsigned length);
+extern void pdf_set_string (pdf_obj *object, unsigned char *string, unsigned length);
+extern void *pdf_string_value (pdf_obj *object);
+extern unsigned int pdf_string_length (pdf_obj *object);
+#define pdf_obj_string_value(s) ((void *)(((pdf_string *)((s)->data)) -> string))
+#define pdf_obj_string_length(s) (((pdf_string *)((s)->data)) -> length)
+
+extern pdf_obj *pdf_new_name (const char *name); /* Name does not include the / */
+extern int pdf_check_name (const char *name); /* Tell whether name is a
+ valid PDF name */
+
+extern pdf_obj *pdf_new_array (void);
+extern void pdf_add_array (pdf_obj *array, pdf_obj *object); /* Array is ended
+ by a node with NULL
+ this pointer */
+extern pdf_obj *pdf_get_array (pdf_obj *array, unsigned long index);
+extern pdf_obj *pdf_new_dict (void);
+extern void pdf_add_dict (pdf_obj *dict, pdf_obj *key, pdf_obj *value); /* Array is ended
+ by a node with NULL
+ this pointer */
+extern void pdf_merge_dict (pdf_obj *dict1, pdf_obj *dict2);
+extern pdf_obj *pdf_lookup_dict (const pdf_obj *dict, const char *name);
+extern char *pdf_get_dict (const pdf_obj *dict, int index);
+
+extern pdf_obj *pdf_new_stream (int flags);
+#define STREAM_COMPRESS 1
+extern void pdf_obj_set_compression(int level);
+extern void pdf_add_stream (pdf_obj *stream, char *stream_data, unsigned
+ length);
+
+extern pdf_obj *pdf_stream_dict(pdf_obj *stream);
+
+extern void pdf_release_obj (pdf_obj *object);
+extern pdf_obj *pdf_deref_obj (pdf_obj *object);
+extern pdf_obj *pdf_ref_obj (pdf_obj *object);
+extern pdf_obj *pdf_new_ref (unsigned long label, int generation);
+extern pdf_obj *pdf_ref_file_obj (unsigned long obj_no);
+extern void pdf_write_obj (FILE *file, const pdf_obj *object);
+extern pdf_obj *pdf_open (FILE *file);
+extern void pdf_close (void);
+
+extern int pdfobj_escape_str (char *buffer, int size, unsigned char
+ *s, int len, int remap);
+extern int check_for_pdf (FILE *file);
+extern void pdf_set_version (unsigned version);
+extern pdf_obj *pdf_read_object (unsigned long obj_no);
+extern void pdf_error_cleanup(void);
+
+#endif /* PDFOBJ_H */
+
diff --git a/Build/source/texk/dvipdfm/pdfparse.c b/Build/source/texk/dvipdfm/pdfparse.c
new file mode 100644
index 00000000000..94654a39a33
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pdfparse.c
@@ -0,0 +1,692 @@
+/* $Header$
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include "system.h"
+#include "mem.h"
+#include "mfileio.h"
+#include "numbers.h"
+#include "dvi.h"
+#include "pdfparse.h"
+#include "pdfspecial.h"
+#include "pdfobj.h"
+#include "pdfdoc.h"
+#include "pdfdev.h"
+
+#define verbose 0
+#define debug 0
+
+#define DUMP_LIMIT 50
+void dump(char *start, char *end)
+{
+ char *p = start;
+ fprintf (stderr, "\nCurrent input buffer is ");
+ fprintf (stderr, "-->");
+ while (p < end && p < start+DUMP_LIMIT)
+ fprintf (stderr, "%c", *(p++));
+ if (p == start+DUMP_LIMIT)
+ fprintf (stderr, "...\n");
+ fprintf (stderr, "<--\n");
+}
+
+void skip_white (char **start, char *end)
+{
+ while (*start < end && (isspace (**start) || **start == '%')) {
+ if (**start == '%')
+ skip_line (start, end);
+ else /* Skip the white char */
+ (*start)++;
+ }
+ return;
+}
+
+void skip_line (char **start, char *end)
+{
+ /* Note: PDF spec says that all platforms must end line with '\n'
+ after a "stream" keyword */
+ while (*start < end && **start != '\n' && **start != '\r')
+ (*start)++;
+ if (*start < end && **start == '\r')
+ (*start) += 1;
+ if (*start < end && **start == '\n')
+ (*start) += 1;
+ return;
+}
+
+void parse_crap (char **start, char *end)
+{
+ skip_white(start, end);
+ if (*start != end) {
+ fprintf (stderr, "\nCrap left over after object!!\n");
+ dump(*start, end);
+ }
+}
+
+int is_an_int(const char *s)
+{
+ int i;
+ for (i=0; i<strlen(s); i++) {
+ if (i == 0 && s[i] == '-')
+ continue;
+ if (!isdigit (s[i]))
+ return 0;
+ }
+ return 1;
+}
+
+int is_a_number(const char *s)
+{
+ int i, period = 0;
+ for (i=0; i<strlen(s); i++) {
+ if (s[i] == '-' && i == 0)
+ continue;
+ if (s[i] == '.' && !period) {
+ period = 1;
+ continue;
+ }
+ if (!isdigit (s[i]))
+ return 0;
+ }
+ return 1;
+}
+
+
+pdf_obj *parse_pdf_dict (char **start, char *end)
+{
+ pdf_obj *result, *tmp1, *tmp2;
+ char *save = *start;
+ skip_white(start, end);
+ if (*((*start)++) != '<' ||
+ *((*start)++) != '<') {
+ *start = save;
+ dump (*start, end);
+ return NULL;
+ }
+ result = pdf_new_dict ();
+ skip_white(start, end);
+ while (*start < end &&
+ **start != '>') {
+ if ((tmp1 = parse_pdf_name (start, end)) == NULL) {
+ pdf_release_obj (result);
+ {
+ *start = save;
+ dump (*start, end);
+ return NULL;
+ }
+ };
+ if ((tmp2 = parse_pdf_object (start, end)) == NULL) {
+ pdf_release_obj (result);
+ pdf_release_obj (tmp1);
+ {
+ *start = save;
+ dump (*start, end);
+ return NULL;
+ }
+ }
+ pdf_add_dict (result, tmp1, tmp2);
+ skip_white(start, end);
+ }
+ if (*start >= end) {
+ pdf_release_obj (result);
+ *start = save;
+ dump (*start, end);
+ return NULL;
+ }
+ if (*((*start)++) == '>' &&
+ *((*start)++) == '>') {
+ return result;
+ } else {
+ pdf_release_obj (result);
+ fprintf (stderr, "\nDictionary object ended prematurely\n");
+ *start = save;
+ dump (*start, end);
+ return NULL;
+ }
+}
+
+pdf_obj *parse_pdf_array (char **start, char *end)
+{
+ pdf_obj *result, *tmp1;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ skip_white(start, end);
+ if (*((*start)++) != '[')
+ return NULL;
+ result = pdf_new_array ();
+ skip_white(start, end);
+ while (*start < end &&
+ **start != ']') {
+ if ((tmp1 = parse_pdf_object (start, end)) == NULL) {
+ pdf_release_obj (result);
+ return NULL;
+ };
+ pdf_add_array (result, tmp1);
+ skip_white(start, end);
+ }
+ if (*start >= end) {
+ pdf_release_obj (result);
+ fprintf (stderr, "\nArray ended prematurely\n");
+ return NULL;
+ }
+ (*start)++;
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return result;
+}
+
+char *parse_number (char **start, char *end)
+{
+ char *number, *save;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ skip_white(start, end);
+ save = *start;
+ if (*start < end && (**start == '+' || **start == '-')) {
+ *start += 1;
+ }
+ while (*start < end &&
+ isdigit(**start))
+ (*start)++;
+ if (*start < end && **start == '.') {
+ (*start)++;
+ while (*start < end &&
+ isdigit(**start))
+ (*start)++;
+ }
+ if (*start > save) {
+ number = NEW ((*start-save)+1, char);
+ memcpy (number, save, (*start-save));
+ number[*start-save] = 0;
+ return number;
+ }
+ *start = save;
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return NULL;
+}
+
+char *parse_unsigned (char **start, char *end)
+{
+ char *number, *save;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ skip_white(start, end);
+ save = *start;
+ while (*start < end &&
+ isdigit(**start))
+ (*start)++;
+ if (*start > save) {
+ number = NEW ((*start-save)+1, char);
+ memcpy (number, save, (*start-save));
+ number[*start-save] = 0;
+ return number;
+ }
+ *start = save;
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return NULL;
+}
+
+static char *parse_gen_ident (char **start, char *end, char *valid_chars)
+{
+ char *ident, *save;
+ save = *start;
+ skip_white(start, end);
+ while (*start < end && strchr (valid_chars, **start))
+ (*start)++;
+ if (save == *start)
+ return NULL;
+ ident = NEW (*start-save+1, char);
+ memcpy (ident, save, *start-save);
+ ident[*start-save] = 0;
+ return ident;
+}
+
+char *parse_ident (char **start, char *end)
+{
+ static char *valid_chars =
+ "!\"#$&'*+,-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^_`abcdefghijklmnopqrstuvwxyz|~";
+ return parse_gen_ident (start, end, valid_chars);
+}
+
+char *parse_val_ident (char **start, char *end)
+{
+ static char *valid_chars =
+ "!\"#$&'*+,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^_`abcdefghijklmnopqrstuvwxyz|~";
+ return parse_gen_ident (start, end, valid_chars);
+}
+
+char *parse_c_ident (char **start, char *end)
+{
+ static char *valid_chars =
+ "0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
+ return parse_gen_ident (start, end, valid_chars);
+}
+
+char *parse_opt_ident(char **start, char *end)
+{
+ if (*start >= end || (**start) != '@')
+ return NULL;
+ (*start)++;
+ return parse_ident(start, end);
+}
+
+
+pdf_obj *parse_pdf_name (char **start, char *end)
+{
+ pdf_obj *result;
+ char *name;
+ skip_white(start, end);
+ if (**start != '/') {
+ fprintf (stderr, "\nPDF Name expected and not found.\n");
+ dump(*start, end);
+ return NULL;
+ }
+ (*start)++;
+ if ((name = parse_ident(start, end)) != NULL) {
+ result = pdf_new_name (name);
+ RELEASE (name);
+ return result;
+ }
+ return NULL;
+}
+
+char *parse_pdf_reference(char **start, char *end)
+{
+ skip_white (start, end);
+ if (**start != '@') {
+ fprintf (stderr, "\nPDF Name expected and not found.\n");
+ dump(*start, end);
+ return NULL;
+ }
+ (*start)++;
+ return parse_ident(start, end);
+}
+
+pdf_obj *parse_pdf_boolean (char **start, char *end)
+{
+ skip_white (start, end);
+ if (end-*start > strlen ("true") &&
+ !strncmp (*start, "true", strlen("true"))) {
+ *start += strlen("true");
+ return pdf_new_boolean (1);
+ }
+ if (end - *start > strlen ("false") &&
+ !strncmp (*start, "false", strlen("false"))) {
+ *start += strlen("false");
+ return pdf_new_boolean (0);
+ }
+ return NULL;
+}
+
+pdf_obj *parse_pdf_null (char **start, char *end)
+{
+ char *save = *start;
+ char *ident;
+ skip_white (start, end);
+ ident = parse_ident(start, end);
+ if (!strcmp (ident, "null")) {
+ RELEASE(ident);
+ return pdf_new_null();
+ }
+ *start = save;
+ fprintf (stderr, "\nNot a valid object\n");
+ dump(*start, end);
+ return NULL;
+}
+
+static pdf_obj *parse_pdf_number (char **start, char *end)
+{
+ char *number;
+ pdf_obj *result;
+ skip_white(start, end);
+ if ((number = parse_number(start, end)) != NULL) {
+ result = pdf_new_number (atof(number));
+ RELEASE (number);
+ return result;
+ }
+ return NULL;
+}
+
+int xtod (char c)
+{
+ if (c >= '0' && c <= '9')
+ return c-'0';
+ if (c >= 'A' && c <= 'F')
+ return (c-'A')+10;
+ if (c >= 'a' && c <= 'f')
+ return (c-'a')+10;
+ return 0;
+}
+
+pdf_obj *parse_pdf_hex_string (char **start, char *end)
+{
+ pdf_obj *result;
+ char *save;
+ unsigned char *string = NULL;
+ int strlength;
+ skip_white (start, end);
+ if (*start == end || *((*start)++) != '<')
+ return NULL;
+ save = *start;
+ string = NEW ((end - *start)/2+2, unsigned char); /* A little excess here */
+ strlength = 0;
+ while (*start < end && **start != '>') {
+ string[strlength] = xtod(**start) * 16;
+ (*start) += 1;
+ if (*start < end && **start != '>') {
+ string[strlength] += xtod(**start);
+ (*start) += 1;
+ }
+ skip_white (start, end);
+ strlength += 1;
+ }
+ if (*start < end) {
+ *start += 1;
+ result = pdf_new_string (string, strlength);
+ } else {
+ result = NULL;
+ }
+ if (string)
+ RELEASE(string);
+ return result;
+}
+
+pdf_obj *parse_pdf_string (char **start, char *end)
+{
+ pdf_obj *result;
+ int balance = 0;
+ char *save;
+ unsigned char *string;
+ int strlength;
+ skip_white(start, end);
+ save = *start;
+ if (*start == end || **start != '(') {
+ return NULL;
+ }
+ ++(*start);
+ string = NEW (end - *start, unsigned char);
+ strlength = 0;
+ balance = 0;
+ while (*start < end &&
+ (**start != ')' || balance > 0)) {
+ if (**start == '\\')
+ switch (*(++(*start))) {
+ case 'n':
+ string[strlength++] = '\n';
+ (*start)++;
+ break;
+ case 'r':
+ string[strlength++] = '\r';
+ (*start)++;
+ break;
+ case 't':
+ string[strlength++] = '\t';
+ (*start)++;
+ break;
+ case 'b':
+ string[strlength++] = '\b';
+ (*start)++;
+ break;
+ default:
+ if (isdigit(**start)) {
+ int i;
+ string[strlength] = 0;
+ for (i=0; i<3; i++)
+ string[strlength] = string[strlength]*8 + (*((*start)++)-'0');
+ strlength+= 1;
+ } else {
+ string[strlength++] = *((*start)++);
+ }
+ }
+ else {
+ if (**start == '(')
+ balance += 1;
+ if (**start == ')')
+ balance -= 1;
+ string[strlength++] = *((*start)++);
+ }
+ }
+ if (*start >= end) {
+ fprintf (stderr, "\nString object ended prematurely\n");
+ dump (save, *start);
+ return NULL;
+ }
+ (*start)++;
+ result = pdf_new_string (string, strlength);
+ RELEASE (string);
+ return result;
+}
+
+char *parse_c_string (char **start, char *end)
+{
+ char *string, *save;
+ int strlength;
+ skip_white(start, end);
+ save = *start;
+ if (*start == end || **start != '"') {
+ return NULL;
+ }
+ ++(*start);
+ string = NEW (end - *start, char);
+ strlength = 0;
+ while (*start < end && (**start != '"')) {
+ if (**start == '\\')
+ switch (*(++(*start))) {
+ case '"':
+ string[strlength++] = '"';
+ (*start)++;
+ break;
+ case 'n':
+ string[strlength++] = '\n';
+ (*start)++;
+ break;
+ case 'r':
+ string[strlength++] = '\r';
+ (*start)++;
+ break;
+ case 't':
+ string[strlength++] = '\t';
+ (*start)++;
+ break;
+ case 'b':
+ string[strlength++] = '\b';
+ (*start)++;
+ break;
+ default:
+ if (isdigit(**start)) {
+ int i;
+ string[strlength] = 0;
+ for (i=0; i<3; i++)
+ string[strlength] = string[strlength]*8 + (*((*start)++)-'0');
+ strlength+= 1;
+ } else {
+ string[strlength++] = *((*start)++);
+ }
+ }
+ else {
+ string[strlength++] = *((*start)++);
+ }
+ string[strlength]=0;
+ }
+ if (*start >= end) {
+ fprintf (stderr, "\nString ended prematurely\n");
+ dump (save, *start);
+ return NULL;
+ }
+ string[strlength] = 0;
+ (*start)++;
+ return string;
+}
+
+static pdf_obj *parse_pdf_stream (char **start, char *end, pdf_obj
+ *dict)
+{
+ pdf_obj *result, *new_dict, *tmp1, *length_obj;
+ unsigned long length;
+ if (pdf_lookup_dict(dict, "F")) {
+ fprintf (stderr, "File streams not implemented (yet)");
+ return NULL;
+ }
+ if ((tmp1 = pdf_lookup_dict(dict, "Length")) == NULL) {
+ fprintf (stderr, "No length specified");
+ return NULL;
+ }
+ length = pdf_number_value (length_obj = pdf_deref_obj (tmp1));
+ pdf_release_obj (length_obj);
+ skip_white(start, end);
+ skip_line(start, end);
+ result = pdf_new_stream(0);
+ new_dict = pdf_stream_dict(result);
+ pdf_merge_dict (new_dict, dict);
+ pdf_release_obj (dict);
+ pdf_add_stream (result, *start, length);
+ *start += length;
+ skip_white(start, end);
+ if (*start+strlen("endstream") > end ||
+ strncmp(*start, "endstream", strlen("endstream"))) {
+ fprintf (stderr, "\nendstream not found\n");
+ return NULL;
+ }
+ *start += strlen("endstream");
+ return result;
+}
+
+pdf_obj *parse_pdf_object (char **start, char *end)
+{
+ pdf_obj *result, *tmp1=NULL, *tmp2=NULL;
+ char *save = *start;
+ char *position2;
+ skip_white(start, end);
+ if (*start >= end)
+ return NULL;
+ switch (**start) {
+ case '<':
+ /* Check for those troublesome strings starting with '<' */
+ if (*start+1 < end && *(*start+1) != '<') {
+ result = parse_pdf_hex_string (start, end);
+ break;
+ }
+ result = parse_pdf_dict (start, end);
+ skip_white(start, end);
+ if (end - *start > strlen("stream") &&
+ !strncmp(*start, "stream", strlen("stream"))) {
+ result = parse_pdf_stream (start, end, result);
+ }
+ /* Check for stream */
+ break;
+ case '(':
+ result = parse_pdf_string(start, end);
+ break;
+ case '[':
+ result = parse_pdf_array(start, end);
+ break;
+ case '/':
+ result = parse_pdf_name(start, end);
+ break;
+ case '@':
+ result = get_reference(start, end);
+ break;
+ case 't':
+ case 'f':
+ result = parse_pdf_boolean(start, end);
+ break;
+ default:
+ /* This is a bit of a hack, but PDF doesn't easily allow you to
+ tell a number from an indirect object reference with some
+ serious looking ahead */
+
+ if (*start < end &&
+ (isdigit(**start) || **start == '+' || **start == '-' || **start == '.')) {
+ tmp1 = parse_pdf_number(start, end);
+ tmp2 = NULL;
+ /* This could be a # # R type reference. We can't be sure unless
+ we look ahead for the second number and the 'R' */
+ skip_white(start, end);
+ position2 = *start;
+ if (*start < end && isdigit(**start)) {
+ tmp2 = parse_pdf_number(start, end);
+ } else
+ tmp2 = NULL;
+ skip_white(start, end);
+ if (tmp1 != NULL && tmp2 != NULL && *start < end && *((*start)++) == 'R') {
+ result = pdf_new_ref ((unsigned long) pdf_number_value (tmp1),
+ (int) pdf_number_value (tmp2));
+ pdf_release_obj (tmp1);
+ pdf_release_obj (tmp2);
+ break;
+ }
+ /* Following checks if we got two numbers, but not 'r' */
+ if (tmp1 != NULL && tmp2 != NULL) {
+ pdf_release_obj (tmp2);
+ *start = position2;
+ }
+ result = tmp1;
+ break;
+ }
+ if (*start < end && **start == 'n') {
+ result = parse_pdf_null(start, end);
+ break;
+ }
+ result = NULL;
+ break;
+ }
+ if (result == NULL) {
+ fprintf (stderr, "\nExpecting an object, but didn't find one");
+ *start = save;
+ dump(*start, end);
+ }
+ return result;
+}
+
+void parse_key_val (char **start, char *end, char **key, char **val)
+{
+ *key = NULL;
+ *val = NULL;
+ skip_white (start, end);
+ if ((*key = parse_c_ident (start, end))) {
+ skip_white (start, end);
+ if (*start < end && **start == '=')
+ {
+ (*start) += 1;
+ skip_white (start, end);
+ if (*start < end) switch (**start) {
+ case '"':
+ *val = parse_c_string (start, end);
+ break;
+ default:
+ *val = parse_val_ident (start, end);
+ }
+ }
+ }
+}
diff --git a/Build/source/texk/dvipdfm/pdfparse.h b/Build/source/texk/dvipdfm/pdfparse.h
new file mode 100644
index 00000000000..83e8abafc3f
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pdfparse.h
@@ -0,0 +1,81 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+/*
+ This is dvipdf, a DVI to PDF translator.
+ Copyright (C) 1998 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef PDFPARSE_H
+
+#define PDFPARSE_H
+#include "numbers.h"
+#include "pdfobj.h"
+
+extern int is_an_int(const char *s);
+extern int is_a_number(const char *s);
+extern char *parse_ident (char **start, char *end);
+extern char *parse_val_ident (char **start, char *end);
+extern char *parse_c_ident (char **start, char *end);
+extern char *parse_number (char **start, char*end);
+extern char *parse_unsigned (char **start, char*end);
+extern void parse_crap (char **start, char *end);
+extern void skip_white (char **start, char *end);
+extern void skip_line (char **start, char *end);
+
+extern char *parse_c_string (char **start, char*end);
+extern pdf_obj *parse_pdf_string (char **start, char*end);
+extern pdf_obj *parse_pdf_name (char **start, char*end);
+extern pdf_obj *parse_pdf_array (char **start, char*end);
+extern pdf_obj *parse_pdf_object (char **start, char*end);
+extern pdf_obj *parse_pdf_dict (char **start, char*end);
+extern pdf_obj *parse_pdf_boolean (char **start, char*end);
+extern pdf_obj *parse_pdf_null (char **start, char*end);
+extern char *parse_pdf_reference (char **start, char*end);
+extern char *parse_opt_ident (char **start, char*end);
+
+extern void parse_key_val (char **start, char *end, char **key, char **val);
+extern void dump (char *start, char *end);
+
+#endif /* PDFPARSE_H */
diff --git a/Build/source/texk/dvipdfm/pdfspecial.c b/Build/source/texk/dvipdfm/pdfspecial.c
new file mode 100644
index 00000000000..98c9c3a500f
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pdfspecial.c
@@ -0,0 +1,1856 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <math.h>
+#include <string.h>
+#include "system.h"
+#include "mem.h"
+#include "mfileio.h"
+#include "numbers.h"
+#include "dvi.h"
+#include "pdflimits.h"
+#include "pdfspecial.h"
+#include "pdfobj.h"
+#include "pdfdoc.h"
+#include "pdfdev.h"
+#include "pdfparse.h"
+#include "jpeg.h"
+#include "epdf.h"
+#include "mpost.h"
+#include "psimage.h"
+
+#include "config.h"
+
+#ifdef HAVE_LIBPNG
+#include <png.h>
+#include "pngimage.h"
+#endif /* HAVE_LIBPNG */
+
+#define verbose 0
+#define debug 0
+
+static void add_reference (char *name, pdf_obj *object, char *res_name);
+static void release_reference (char *name);
+static pdf_obj *lookup_reference(char *name);
+static char *lookup_ref_res_name (char *name);
+static pdf_obj *lookup_object(char *name);
+static void do_content (char **start, char *end, double x_user, double
+ y_user);
+static void do_image(char **start, char *end, double x_user, double y_user);
+static pdf_obj *jpeg_start_image (FILE *file);
+static void finish_image (pdf_obj *image_res, struct xform_info *p,
+ char *res_name);
+static void do_bxobj (char **start, char *end,
+ double x_user, double y_user);
+static void do_exobj (void);
+static void do_uxobj (char **start, char *end, double x_user, double
+ y_user);
+
+static char ignore_colors = 0;
+static double annot_grow = 0.0;
+
+void pdf_special_set_grow (double g)
+{
+ annot_grow = g;
+}
+double pdf_special_tell_grow (void)
+{
+ return annot_grow;
+}
+
+void pdf_special_ignore_colors(void)
+{
+ ignore_colors = 1;
+}
+
+static void do_bop(char **start, char *end)
+{
+#ifdef MEM_DEBUG
+ MEM_START
+#endif
+ if (*start < end)
+ pdf_doc_bop (*start, end - *start);
+ *start = end;
+#ifdef MEM_DEBUG
+ MEM_END
+#endif
+ return;
+}
+
+static void do_eop(char **start, char *end)
+{
+#ifdef MEM_DEBUG
+ MEM_START
+#endif
+ if (*start < end)
+ pdf_doc_eop (*start, end - *start);
+ *start = end;
+#ifdef MEM_DEBUG
+ MEM_END
+#endif
+}
+
+pdf_obj *get_reference(char **start, char *end)
+{
+ char *name, *save = *start;
+ pdf_obj *result = NULL;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ skip_white (start, end);
+ if ((name = parse_pdf_reference(start, end)) != NULL) {
+ if ((result = lookup_reference (name)) == NULL) {
+ fprintf (stderr, "\nNamed reference (@%s) doesn't exist.\n", name);
+ *start = save;
+ dump(*start, end);
+ }
+ RELEASE (name);
+ }
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return result;
+}
+
+pdf_obj *get_reference_lvalue(char **start, char *end)
+{
+ char *name, *save = *start;
+ pdf_obj *result = NULL;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ skip_white (start, end);
+ if ((name = parse_pdf_reference(start, end)) != NULL) {
+ result = lookup_object (name);
+ if (result == NULL) {
+ fprintf (stderr, "\nNamed object (@%s) doesn't exist.\n", name);
+ *start = save;
+ dump(*start, end);
+ }
+ RELEASE (name);
+ }
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return result;
+}
+
+static void do_put(char **start, char *end)
+{
+ pdf_obj *result = NULL, *data = NULL;
+ char *save = *start;
+ skip_white(start, end);
+ if ((result = get_reference_lvalue(start, end)) != NULL) {
+ skip_white (start, end);
+ save = *start;
+ switch (result -> type) {
+ case PDF_DICT:
+ if ((data = parse_pdf_dict (start, end)) != NULL &&
+ data -> type == PDF_DICT) {
+ pdf_merge_dict (result, data);
+ } else{
+ fprintf (stderr, "\nSpecial put: Expecting a dictionary\n");
+ *start = save;
+ dump(*start, end);
+ }
+ if (data != NULL)
+ pdf_release_obj (data);
+ break;
+ case PDF_ARRAY:
+ while (*start < end &&
+ (data = parse_pdf_object (start, end)) != NULL) {
+ pdf_add_array (result, data);
+ skip_white(start, end);
+ }
+ if (*start < end) {
+ fprintf (stderr, "\nSpecial: put: invalid object. Rest of line ignored.\n");
+ *start = save;
+ dump(*start, end);
+ }
+ break;
+ default:
+ fprintf (stderr, "\nSpecial put: Invalid destination object type\n");
+ break;
+ }
+ }
+ else {
+ fprintf (stderr, "\nSpecial put: Nonexistent object reference\n");
+ }
+ return;
+}
+
+/* The following must be consecutive and
+ starting at 0. Order must match
+ dimensions array below */
+
+#define WIDTH 0
+#define HEIGHT 1
+#define DEPTH 2
+#define SCALE 3
+#define XSCALE 4
+#define YSCALE 5
+#define ROTATE 6
+#define BBOX 7
+
+struct {
+ char *s;
+ int key;
+ int hasunits;
+} dimensions[] = {
+ {"width", WIDTH, 1},
+ {"height", HEIGHT, 1},
+ {"depth", DEPTH, 1},
+ {"scale", SCALE, 0},
+ {"xscale", XSCALE, 0},
+ {"yscale", YSCALE, 0},
+ {"rotate", ROTATE, 0},
+ {"bbox", BBOX, 0}
+};
+
+struct xform_info *new_xform_info (void)
+{
+ struct xform_info *result;
+ result = NEW (1, struct xform_info);
+ result -> width = 0.0;
+ result -> height = 0.0;
+ result -> depth = 0.0;
+ result -> scale = 0.0;
+ result -> xscale = 0.0;
+ result -> yscale = 0.0;
+ result -> rotate = 0.0;
+ result -> user_bbox = 0;
+ result -> clip = 0;
+ /* These next two must be initialized be cause
+ they represent the reference point even
+ if the user doesn't specify one. We must
+ have a reference point */
+ result -> u_llx = 0.0;
+ result -> u_lly = 0.0;
+ return result;
+}
+
+void release_xform_info (struct xform_info *p)
+{
+ RELEASE (p);
+ return;
+}
+
+int validate_image_xform_info (struct xform_info *p)
+{
+ int result = 1;
+ if (p->width != 0.0)
+ if (p->scale !=0.0 || p->xscale != 0.0) {
+ fprintf (stderr, "\nCan't supply both width and scale\n");
+ result = 0;
+ }
+ if (p->height != 0.0)
+ if (p->scale !=0.0 || p->yscale != 0.0) {
+ fprintf (stderr, "\nCan't supply both height and scale\n");
+ result = 0;
+ }
+ if (p->scale != 0.0)
+ if (p->xscale != 0.0 || p->yscale != 0.0) {
+ fprintf (stderr, "\nCan't supply overall scale along with axis scales");
+ result = 0;
+ }
+ return result;
+}
+
+static int parse_one_dim_word (char **start, char *end)
+{
+ int i;
+ char *dimension_string;
+ char *save = *start;
+ int result = -1;
+ skip_white(start, end);
+ if ((dimension_string = parse_ident(start, end)) != NULL) {
+ for (i=0; i<sizeof(dimensions)/sizeof(dimensions[0]); i++) {
+ if (!strcmp (dimensions[i].s, dimension_string))
+ break;
+ }
+ if (i != sizeof(dimensions)/sizeof(dimensions[0])) {
+ result = dimensions[i].key;
+ } else {
+ fprintf (stderr, "\n%s: Invalid keyword\n", dimension_string);
+ }
+ RELEASE (dimension_string);
+ }
+ if (result < 0) {
+ *start = save;
+ fprintf (stderr, "\nExpecting a keyword here, e.g., height, width, etc.\n");
+ dump(*start, end);
+ }
+ return result;
+}
+
+struct {
+ char *s;
+ double units;
+ int is_true_unit;
+} units[] = {
+ {"pt", (72.0/72.27), 0},
+ {"in", (72.0), 0},
+ {"cm", (72.0/2.54), 0},
+ {"mm", (72.0/25.4), 0},
+ {"truept", (72.0/72.27), 1},
+ {"truein", (72.0), 1},
+ {"truecm", (72.0/2.54), 1},
+ {"truemm", (72.0/25.4), 1}
+};
+
+double parse_one_unit (char **start, char *end)
+{
+ int i;
+ char *unit_string = NULL, *save = *start;
+ double result = -1.0;
+ int errors = 0;
+ skip_white(start, end);
+ if ((unit_string = parse_c_ident(start, end)) != NULL) {
+ for (i=0; i<sizeof(units)/sizeof(units[0]); i++) {
+ if (!strcmp (units[i].s, unit_string))
+ break;
+ }
+ if (i == sizeof(units)/sizeof(units[0])) {
+ fprintf (stderr,
+ "\n%s: Invalid unit of measurement (should be in, cm, pt, etc.)\n", unit_string);
+ errors = 1;
+ }
+ if (i != sizeof(units)/sizeof(units[0]) && !units[i].is_true_unit)
+ result = units[i].units;
+ /* If these are "true" units, we must pre-shrink since the entire
+ document is magnified */
+ if (i != sizeof(units)/sizeof(units[0]) && units[i].is_true_unit)
+ result = units[i].units/dvi_tell_mag();
+ RELEASE (unit_string);
+ }
+ if (!unit_string || errors) {
+ fprintf (stderr, "\nExpecting a unit here (e.g., in, cm, pt)\n");
+ *start = save;
+ dump(*start, end);
+ }
+ return result;
+}
+
+static int parse_dimension (char **start, char *end,
+ struct xform_info *p)
+{
+ char *number_string = NULL;
+ char *save = NULL;
+ double units = -1.0;
+ int key, error = 0;
+ skip_white(start, end);
+ while (*start < end && isalpha (**start)) {
+ save = *start;
+ if ((key = parse_one_dim_word(start, end)) >= 0) {
+ skip_white(start, end);
+ } else {
+ fprintf (stderr,
+ "\nExpecting a dimension/transformation keyword (e.g., width, height) here:\n");
+ error = 1;
+ break;
+ }
+ if (key != BBOX) { /* BBOX is handled somewhat differently than
+ all the others */
+ number_string = parse_number(start, end);
+ if (key >= 0 && number_string == NULL) {
+ fprintf (stderr, "Expecting a number following dimension/transformation keyword\n");
+ error = 1;
+ break;
+ }
+ /* If we got a key and a number, see if we need a dimension also */
+ if (key >= 0 && number_string != NULL && dimensions[key].hasunits) {
+ skip_white(start, end);
+ if ((units = parse_one_unit(start, end)) < 0.0) {
+ fprintf (stderr, "\nExpecting a dimension unit\n");
+ error = 1;
+ }
+ }
+ if (!error && key >= 0 && number_string != NULL) {
+ switch (key) {
+ case WIDTH:
+ if (p->width != 0.0)
+ fprintf (stderr, "\nDuplicate width specified: %s\n", number_string);
+ p->width = atof (number_string)*units;
+ break;
+ case HEIGHT:
+ if (p->height != 0.0)
+ fprintf (stderr, "\nDuplicate height specified: %s\n", number_string);
+ p->height = atof (number_string)*units;
+ break;
+ case DEPTH:
+ if (p->depth != 0.0)
+ fprintf (stderr, "\nDuplicate depth specified: %s\n", number_string);
+ p->depth = atof (number_string)*units;
+ break;
+ case SCALE:
+ if (p->scale != 0.0)
+ fprintf (stderr, "\nDuplicate depth specified: %s\n", number_string);
+ p->scale = atof (number_string);
+ break;
+ case XSCALE:
+ if (p->xscale != 0.0)
+ fprintf (stderr, "\nDuplicate xscale specified: %s\n", number_string);
+ p->xscale = atof (number_string);
+ break;
+ case YSCALE:
+ if (p->yscale != 0.0)
+ fprintf (stderr, "\nDuplicate yscale specified: %s\n", number_string);
+ p->yscale = atof (number_string);
+ break;
+ case ROTATE:
+ if (p->rotate != 0)
+ fprintf (stderr, "\nDuplicate rotation specified: %s\n", number_string);
+ p->rotate = atof (number_string) * M_PI / 180.0;
+ break;
+ default:
+ ERROR ("parse_dimension: Invalid key");
+ }
+ if (number_string != NULL) {
+ RELEASE (number_string);
+ number_string = NULL;
+ }
+ }
+ } else { /* BBox case handled here */
+ char *llx = NULL, *lly = NULL, *urx = NULL, *ury = NULL;
+ if ((llx = parse_number (start, end)) &&
+ (lly = parse_number (start, end)) &&
+ (urx = parse_number (start, end)) &&
+ (ury = parse_number (start, end))) {
+ p->u_llx = atof (llx);
+ p->u_lly = atof (lly);
+ p->u_urx = atof (urx);
+ p->u_ury = atof (ury);
+ p->user_bbox = 1; /* Flag to indicate that user specified a bbox */
+ } else {
+ fprintf (stderr, "\nExpecting four numbers following \"bbox\" specification.\n");
+ error = 1; /* Flag error, but don't break until we get a
+ chance to free structures */
+ }
+ if (llx) RELEASE (llx);
+ if (lly) RELEASE (lly);
+ if (urx) RELEASE (urx);
+ if (ury) RELEASE (ury);
+ if (error) break;
+ }
+ skip_white(start, end);
+ }
+ if (error && save)
+ dump (save, end);
+ return !error;
+}
+
+static void do_pagesize(char **start, char *end)
+{
+ struct xform_info *p;
+ int error = 0;
+ p = new_xform_info();
+ skip_white(start, end);
+ if (parse_dimension(start, end, p)) {
+ if (p->scale != 0.0 || p->xscale != 0.0 || p->yscale != 0.0) {
+ fprintf (stderr, "\nScale meaningless for pagesize\n");
+ error = 1;
+ }
+ if (p->width == 0.0 || p->depth + p->height == 0.0) {
+ fprintf (stderr, "\nPage cannot have a zero dimension\n");
+ error = 1;
+ }
+ } else {
+ fprintf (stderr, "\nSpecial: pagesize: Failed to find a valid set of dimensions\n");
+ dump (*start, end);
+ error = 1;
+ }
+ if (!error)
+ /* Since these are physical dimensions, they need to be scaled by
+ mag. "Virtual" dimensions are scaled by a transformation
+ matrix. Physical dimensions (e.g, page size and annotations)
+ cannot */
+ dev_set_page_size (dvi_tell_mag()*p->width, dvi_tell_mag()*(p->depth + p->height));
+ release_xform_info (p);
+ return;
+}
+
+
+static void do_ann(char **start, char *end)
+{
+ pdf_obj *result = NULL, *rectangle = NULL;
+ char *name = NULL;
+ int error = 0;
+ struct xform_info *p;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ p = new_xform_info();
+ skip_white(start, end);
+ name = parse_opt_ident(start, end);
+ skip_white(start, end);
+ if (parse_dimension(start, end, p)) {
+ if (p->scale != 0.0 || p->xscale != 0.0 || p->yscale != 0.0) {
+ fprintf (stderr, "\nScale meaningless for annotations\n");
+ error = 1;
+ }
+ if (p->width == 0.0 || p->depth + p->height == 0.0) {
+ fprintf (stderr, "Special ann: Rectangle has a zero dimension\n");
+ fprintf (stderr, "Special ann: Annotations require both horizontal and vertical dimensions\n");
+ error = 1;
+ }
+ }
+ if (!error && (result = parse_pdf_dict(start, end)) != NULL) {
+ rectangle = pdf_new_array();
+ pdf_add_array (rectangle, pdf_new_number(ROUND(dev_phys_x()-annot_grow,0.01)));
+ pdf_add_array (rectangle, pdf_new_number(ROUND(dev_phys_y()-dvi_tell_mag()*p->depth-annot_grow,0.01)));
+ pdf_add_array (rectangle, pdf_new_number(ROUND(dev_phys_x()+dvi_tell_mag()*p->width+annot_grow,0.01)));
+ pdf_add_array (rectangle, pdf_new_number(ROUND(dev_phys_y()+dvi_tell_mag()*p->height+annot_grow,0.01)));
+ pdf_add_dict (result, pdf_new_name ("Rect"),
+ rectangle);
+ pdf_doc_add_to_page_annots (pdf_ref_obj (result));
+ /* If this object has a named reference, we file it away for
+ later. Otherwise we release it */
+ if (name != NULL) {
+ add_reference (name, result, NULL);
+ /* An annotation is treated differently from a cos object.
+ cos objects are kept open for the user. We forcibly
+ "close" the annotation by calling release_reference */
+ release_reference (name);
+ } else
+ pdf_release_obj (result);
+ } else {
+ fprintf (stderr, "Ignoring annotation with invalid dictionary\n");
+ error = 1;
+ }
+ release_xform_info (p);
+ if (name)
+ RELEASE (name);
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return;
+}
+
+pdf_obj *pending_annot_dict = NULL;
+static void do_bann(char **start, char *end)
+{
+ int error = 0;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if (!pending_annot_dict) {
+ skip_white(start, end);
+ if ((pending_annot_dict = parse_pdf_dict(start, end)) != NULL) {
+ pdf_doc_begin_annot (pending_annot_dict);
+ /* If this object has a named reference, we file it away for
+ later. Otherwise we release it */
+ } else {
+ fprintf (stderr, "Ignoring annotation with invalid dictionary\n");
+ error = 1;
+ }
+ } else {
+ fprintf (stderr, "\nCan't begin an annotation when one is pending.\n");
+ }
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return;
+}
+
+static void do_eann(char **start, char *end)
+{
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ if (pending_annot_dict) {
+ pdf_doc_end_annot ();
+ pdf_release_obj (pending_annot_dict);
+ pending_annot_dict = NULL;
+ } else {
+ fprintf (stderr, "\nTried to end an annotation without starting one!\n");
+ }
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return;
+}
+
+static void do_bgcolor(char **start, char *end)
+{
+ char *save = *start;
+ pdf_obj *color;
+ int error = 0;
+ skip_white(start, end);
+ if ((color = parse_pdf_object(start, end)) != NULL &&
+ (color -> type == PDF_ARRAY ||
+ color -> type == PDF_NUMBER )) {
+ switch (color -> type) {
+ int i;
+ case PDF_ARRAY:
+ for (i=0; i<5; i++) {
+ if (pdf_get_array (color, i) == NULL ||
+ pdf_get_array (color, i) -> type != PDF_NUMBER)
+ break;
+ }
+ switch (i) {
+ case 3:
+ dev_bg_rgb_color (pdf_number_value (pdf_get_array (color,0)),
+ pdf_number_value (pdf_get_array (color,1)),
+ pdf_number_value (pdf_get_array (color,2)));
+ break;
+ case 4:
+ dev_bg_cmyk_color (pdf_number_value (pdf_get_array (color,0)),
+ pdf_number_value (pdf_get_array (color,1)),
+ pdf_number_value (pdf_get_array (color,2)),
+ pdf_number_value (pdf_get_array (color,3)));
+ break;
+ default:
+ fprintf (stderr, "\nSpecial: begincolor: Expecting either RGB or CMYK color array\n");
+ error = 1;
+ }
+ break;
+ case PDF_NUMBER:
+ dev_bg_gray (pdf_number_value (color));
+ }
+ } else {
+ fprintf (stderr, "\nSpecial: background color: Expecting color specified by an array or number\n");
+ error = 1;
+ }
+ if (error) {
+ *start = save;
+ dump (*start, end);
+ }
+ if (color)
+ pdf_release_obj (color);
+ return;
+}
+
+static void do_bcolor(char **start, char *end)
+{
+ char *save = *start;
+ pdf_obj *color;
+ int error = 0;
+#ifdef MEM_DEBUG
+ MEM_START
+#endif /* MEM_DEBUG */
+ skip_white(start, end);
+ if ((color = parse_pdf_object(start, end)) != NULL &&
+ (color -> type == PDF_ARRAY ||
+ color -> type == PDF_NUMBER )) {
+ switch (color -> type) {
+ int i;
+ case PDF_ARRAY:
+ for (i=0; i<5; i++) {
+ if (pdf_get_array (color, i) == NULL ||
+ pdf_get_array (color, i) -> type != PDF_NUMBER)
+ break;
+ }
+ switch (i) {
+ case 3:
+ dev_begin_rgb_color (pdf_number_value (pdf_get_array (color,0)),
+ pdf_number_value (pdf_get_array (color,1)),
+ pdf_number_value (pdf_get_array (color,2)));
+ break;
+ case 4:
+ dev_begin_cmyk_color (pdf_number_value (pdf_get_array (color,0)),
+ pdf_number_value (pdf_get_array (color,1)),
+ pdf_number_value (pdf_get_array (color,2)),
+ pdf_number_value (pdf_get_array (color,3)));
+ break;
+ default:
+ fprintf (stderr, "\nSpecial: begincolor: Expecting either RGB or CMYK color array\n");
+ error = 1;
+ }
+ break;
+ case PDF_NUMBER:
+ dev_begin_gray (pdf_number_value (color));
+ }
+ } else {
+ fprintf (stderr, "\nSpecial: Begincolor: Expecting color specified by an array or number\n");
+ error = 1;
+ }
+ if (error) {
+ *start = save;
+ dump (*start, end);
+ }
+ if (color)
+ pdf_release_obj (color);
+#ifdef MEM_DEBUG
+ MEM_END
+#endif /* MEM_DEBUG */
+ return;
+}
+
+static void do_scolor(char **start, char *end)
+{
+ char *save = *start;
+ pdf_obj *color;
+ int error = 0;
+#ifdef MEM_DEBUG
+ MEM_START
+#endif /* MEM_DEBUG */
+ skip_white(start, end);
+ if ((color = parse_pdf_object(start, end)) != NULL &&
+ (color -> type == PDF_ARRAY ||
+ color -> type == PDF_NUMBER )) {
+ switch (color -> type) {
+ int i;
+ case PDF_ARRAY:
+ for (i=0; i<5; i++) {
+ if (pdf_get_array (color, i) == NULL ||
+ pdf_get_array (color, i) -> type != PDF_NUMBER)
+ break;
+ }
+ switch (i) {
+ case 3:
+ dev_set_def_rgb_color (pdf_number_value (pdf_get_array (color,0)),
+ pdf_number_value (pdf_get_array (color,1)),
+ pdf_number_value (pdf_get_array (color,2)));
+ break;
+ case 4:
+ dev_set_def_cmyk_color (pdf_number_value (pdf_get_array (color,0)),
+ pdf_number_value (pdf_get_array (color,1)),
+ pdf_number_value (pdf_get_array (color,2)),
+ pdf_number_value (pdf_get_array (color,3)));
+ break;
+ default:
+ fprintf (stderr, "\nSpecial: begincolor: Expecting either RGB or CMYK color array\n");
+ error = 1;
+ }
+ break;
+ case PDF_NUMBER:
+ dev_set_def_gray (pdf_number_value (color));
+ }
+ } else {
+ fprintf (stderr, "\nSpecial: Begincolor: Expecting color specified by an array or number\n");
+ error = 1;
+ }
+ if (error) {
+ *start = save;
+ dump (*start, end);
+ }
+ if (color)
+ pdf_release_obj (color);
+#ifdef MEM_DEBUG
+ MEM_END
+#endif /* MEM_DEBUG */
+ return;
+}
+
+static void do_bgray(char **start, char *end)
+{
+ char *number_string;
+ skip_white(start, end);
+ if ((number_string = parse_number (start, end)) != NULL) {
+ dev_begin_gray (atof (number_string));
+ RELEASE (number_string);
+ } else {
+ fprintf (stderr, "\nSpecial: begingray: Expecting a numerical grayscale specification\n");
+ }
+ return;
+}
+
+static void do_ecolor(void)
+{
+ dev_end_color();
+}
+
+static void do_egray(void)
+{
+ dev_end_color();
+}
+
+static void do_bxform (char **start, char *end, double x_user, double y_user)
+{
+ int error = 0;
+ char *save = *start;
+ struct xform_info *p;
+ p = new_xform_info ();
+#ifdef MEM_DEBUG
+ MEM_START
+#endif
+ skip_white (start, end);
+ if (parse_dimension (start, end, p)) {
+ if (!validate_image_xform_info (p)) {
+ fprintf (stderr, "\nSpecified dimensions are inconsistent\n");
+ fprintf (stderr, "\nSpecial will be ignored\n");
+ error = 1;
+ }
+ if (p -> width != 0.0 || p -> height != 0.0 || p -> depth != 0.0) {
+ fprintf (stderr, "Special: bt: width, height, and depth are meaningless\n");
+ fprintf (stderr, "Special: bt: These will be ignored\n");
+ /* This isn't really a fatal error */
+ }
+ if (p -> scale != 0.0) {
+ p->xscale = p->scale;
+ p->yscale = p->scale;
+ }
+ if (p -> xscale == 0.0)
+ p->xscale = 1.0;
+ if (p -> yscale == 0.0)
+ p->yscale = 1.0;
+ } else {
+ fprintf (stderr, "\nError in transformation parameters\n");
+ error = 1;
+ }
+ if (!error) {
+ dev_begin_xform (p->xscale, p->yscale, p->rotate, x_user, y_user);
+ } else {
+ *start = save;
+ dump (*start, end);
+ }
+ release_xform_info (p);
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return;
+}
+
+static void do_exform(void)
+{
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ dev_end_xform();
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+}
+
+static void do_outline(char **start, char *end)
+{
+ pdf_obj *level = NULL, *result;
+ int error = 0;
+ char *save;
+ static int lowest_level = 255;
+ skip_white(start, end);
+ save = *start;
+ if ((level = parse_pdf_object(start, end)) != NULL &&
+ level -> type == PDF_NUMBER) {
+ /* Make sure we know where the starting level is */
+ if ( (int) pdf_number_value (level) < lowest_level)
+ lowest_level = (int) pdf_number_value (level);
+
+ if ((result = parse_pdf_dict(start, end)) != NULL) {
+ pdf_doc_change_outline_depth
+ ((int)pdf_number_value(level)-lowest_level+1);
+ pdf_doc_add_outline (result);
+ } else {
+ fprintf (stderr, "\nIgnoring invalid dictionary\n");
+ error = 1;
+ }
+ } else {
+ fprintf (stderr, "\nSpecial: outline: Expecting number for object level.\n");
+ *start = save;
+ error = 1;
+ }
+ if (error)
+ dump (*start, end);
+ if (level)
+ pdf_release_obj (level);
+ return;
+}
+
+static void do_article(char **start, char *end)
+{
+ char *name = NULL, *save = *start;
+ int error = 0;
+ pdf_obj *info_dict = NULL;
+ skip_white (start, end);
+ if (*((*start)++) != '@' || (name = parse_ident(start, end)) == NULL) {
+ fprintf (stderr, "Article name expected.\n");
+ *start = save;
+ dump (*start, end);
+ error = 1;
+ }
+ if (!error && (info_dict = parse_pdf_dict(start, end)) == NULL) {
+ fprintf (stderr, "Ignoring invalid dictionary\n");
+ error = 1;
+ }
+ if (!error) {
+ pdf_doc_start_article (name, pdf_link_obj(info_dict));
+ add_reference (name, info_dict, NULL);
+ }
+ if (name)
+ RELEASE (name);
+ return;
+}
+
+static void do_bead(char **start, char *end)
+{
+ pdf_obj *bead_dict, *rectangle, *article, *info_dict = NULL;
+ int error = 0;
+ char *name = NULL, *save = *start;
+ struct xform_info *p;
+ p = new_xform_info();
+ skip_white(start, end);
+ if (*((*start)++) != '@' || (name = parse_ident(start, end)) == NULL) {
+ fprintf (stderr, "Article reference expected.\nWhich article does this go with?\n");
+ error = 1;
+ }
+ /* If okay so far, try to get a bounding box */
+ if (!error) {
+ skip_white(start, end);
+ if (!parse_dimension(start, end, p)) {
+ fprintf (stderr, "\nSpecial: thread: Error in bounding box specification for this bead\n");
+ error = 1;
+ }
+ if (p->scale != 0.0 || p->xscale != 0.0 || p->yscale != 0.0) {
+ fprintf (stderr, "\nScale meaningless for annotations\n");
+ error = 1;
+ }
+ if (p->width == 0.0 || p->depth + p->height == 0.0) {
+ fprintf (stderr, "\nSpecial thread: Rectangle has a zero dimension\n");
+ error = 1;
+ }
+ }
+ if (!error) {
+ skip_white (start, end);
+ if (**start == '<') {
+ if ((info_dict = parse_pdf_dict (start, end)) ==
+ NULL) {
+ fprintf (stderr, "\nSpecial: thread: Error in dictionary\n");
+ error = 1;
+ }
+ } else
+ info_dict = pdf_new_dict();
+ }
+ if (!error && name && info_dict) {
+ /* Does this article exist yet */
+ if ((article = lookup_object (name)) == NULL) {
+ pdf_doc_start_article (name, pdf_link_obj (info_dict));
+ add_reference (name, info_dict, NULL);
+ } else {
+ pdf_merge_dict (article, info_dict);
+ pdf_release_obj (info_dict);
+ info_dict = NULL;
+ }
+ bead_dict = pdf_new_dict ();
+ rectangle = pdf_new_array();
+ pdf_add_array (rectangle, pdf_new_number(ROUND(dev_phys_x(),0.01)));
+ pdf_add_array (rectangle, pdf_new_number(ROUND(dev_phys_y()-p->depth,0.01)));
+ pdf_add_array (rectangle, pdf_new_number(ROUND(dev_phys_x()+p->width,0.01)));
+ pdf_add_array (rectangle, pdf_new_number(ROUND(dev_phys_y()+p->height,0.01)));
+ pdf_add_dict (bead_dict, pdf_new_name ("R"),
+ rectangle);
+ pdf_add_dict (bead_dict, pdf_new_name ("P"),
+ pdf_doc_this_page_ref());
+ pdf_doc_add_bead (name, bead_dict);
+ }
+ release_xform_info(p);
+ if (name != NULL) {
+ RELEASE (name);
+ }
+ if (error) {
+ *start = save;
+ dump (*start, end);
+ }
+ return;
+}
+
+pdf_obj *embed_image (char *filename, struct xform_info *p,
+ double x_user, double y_user, char *objname)
+{
+ pdf_obj *result = NULL;
+ char *kpse_file_name;
+ FILE *image_file;
+ static char res_name[16];
+ static long next_image = 1;
+ sprintf (res_name, "Im%ld", next_image);
+ if ((kpse_file_name = kpse_find_pict (filename)) &&
+ (image_file = MFOPEN (kpse_file_name, FOPEN_RBIN_MODE))) {
+ fprintf (stderr, "(%s", kpse_file_name);
+ if (check_for_jpeg(image_file)) {
+ result = jpeg_start_image(image_file);
+ if (result)
+ finish_image (result, p, res_name);
+ }
+#ifdef HAVE_LIBPNG
+ else if (check_for_png(image_file)) {
+ fprintf (stderr, "<PNG>");
+ result = start_png_image (image_file, NULL);
+ if (result)
+ finish_image (result, p, res_name);
+ }
+#endif
+ else if (check_for_pdf (image_file)) {
+ fprintf (stderr, "<PDF>");
+ result = pdf_include_page (image_file, p, res_name);
+ }
+ else if (check_for_mp (image_file)) {
+ fprintf (stderr, "<MPOST>");
+ result = mp_include (image_file, p, res_name, x_user, y_user);
+ }
+ /* Make sure we check for PS *after* checking for MP since
+ MP is a special case of PS */
+ else if (check_for_ps (image_file)) {
+ fprintf (stderr, "<PS>");
+ result = ps_include (kpse_file_name, p,
+ res_name, x_user, y_user);
+ }
+ else{
+ fprintf (stderr, "<?>");
+ result = ps_include (kpse_file_name, p,
+ res_name, x_user, y_user);
+ }
+ MFCLOSE (image_file);
+ fprintf (stderr, ")");
+ } else {
+ fprintf (stderr, "\nError locating or opening file (%s)\n", filename);
+ }
+ if (result) { /* Put reference to object on page */
+ next_image += 1;
+ pdf_doc_add_to_page_xobjects (res_name, pdf_ref_obj(result));
+ pdf_doc_add_to_page (" q", 2);
+ /* Handle the conversion to PDF stream units here */
+ add_xform_matrix (x_user, y_user,
+ p->xscale/pdf_dev_scale(), p->yscale/pdf_dev_scale(), p->rotate);
+ if (p->depth != 0.0)
+ add_xform_matrix (0.0, -p->depth, 1.0, 1.0, 0.0);
+ sprintf (work_buffer, " /%s Do Q", res_name);
+ pdf_doc_add_to_page (work_buffer, strlen(work_buffer));
+ } else {
+ fprintf (stderr, "\npdf: image inclusion failed for (%s).\n", filename);
+ }
+ if (objname != NULL && result != NULL) {
+ add_reference (objname, pdf_link_obj (result), res_name);
+ /* Read the explanation for the next line in do_ann() */
+ release_reference (objname);
+ }
+ return result;
+}
+
+static void do_image (char **start, char *end, double x_user, double y_user)
+{
+ char *filename = NULL, *objname = NULL, *save;
+ pdf_obj *filestring = NULL, *result = NULL;
+ int error = 0;
+ struct xform_info *p;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ skip_white(start, end);
+ objname = parse_opt_ident(start, end);
+ p = new_xform_info();
+ skip_white(start, end);
+ save = *start;
+ if (!parse_dimension(start, end, p)) {
+ fprintf (stderr, "\nError in dimensions of encapsulated image\n");
+ error = 1;
+ }
+ skip_white(start, end);
+ if (!error && (filestring = parse_pdf_string(start, end)) == NULL) {
+ fprintf (stderr, "\nMissing filename\n");
+ error = 1;
+ }
+ if (!error) {
+ filename = pdf_string_value(filestring);
+ }
+ if (!error && !validate_image_xform_info (p)) {
+ fprintf (stderr, "\nSpecified dimensions are inconsistent\n");
+ dump (save, end);
+ error = 1;
+ }
+ if (!error)
+ result = embed_image (filename, p, x_user, y_user, objname);
+ else
+ dump (save, end);
+ if (p)
+ release_xform_info (p);
+ if (objname)
+ RELEASE (objname);
+ if (filestring)
+ pdf_release_obj (filestring);
+ if (error || !result)
+ fprintf (stderr, "Image special ignored.\n");
+ if (result)
+ pdf_release_obj (result);
+ return;
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+}
+
+static void do_dest(char **start, char *end)
+{
+ pdf_obj *name;
+ pdf_obj *array;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ skip_white(start, end);
+ if ((name = parse_pdf_string(start, end)) == NULL) {
+ fprintf (stderr, "\nPDF string expected and not found.\n");
+ fprintf (stderr, "Special dest: ignored\n");
+ dump(*start, end);
+ return;
+ }
+ if ((array = parse_pdf_array(start, end)) == NULL) {
+ pdf_release_obj (name);
+ return;
+ }
+ pdf_doc_add_dest (pdf_obj_string_value(name),
+ pdf_obj_string_length(name),
+ pdf_ref_obj (array));
+ pdf_release_obj (name);
+ pdf_release_obj (array);
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+}
+
+static void do_docinfo(char **start, char *end)
+{
+ pdf_obj *result;
+ if ((result = parse_pdf_dict(start, end)) != NULL) {
+ pdf_doc_merge_with_docinfo (result);
+ } else {
+ fprintf (stderr, "\nSpecial: docinfo: Dictionary expected and not found\n");
+ dump (*start, end);
+ }
+ pdf_release_obj (result);
+ return;
+}
+
+static void do_docview(char **start, char *end)
+{
+ pdf_obj *result;
+ if ((result = parse_pdf_dict(start, end)) != NULL) {
+ pdf_doc_merge_with_catalog (result);
+ } else {
+ fprintf (stderr, "\nSpecial: docview: Dictionary expected and not found\n");
+ dump (*start, end);
+ }
+ pdf_release_obj (result);
+ return;
+}
+
+
+static void do_close(char **start, char *end)
+{
+ char *name;
+ skip_white(start, end);
+ if ((name = parse_pdf_reference(start, end)) != NULL) {
+ release_reference (name);
+ RELEASE (name);
+ }
+ return;
+}
+
+static void do_obj(char **start, char *end)
+{
+ pdf_obj *result;
+ char *name;
+ skip_white(start, end);
+ name = parse_opt_ident(start, end);
+ if ((result = parse_pdf_object(start, end)) == NULL) {
+ fprintf (stderr, "Special object: Ignored.\n");
+ return;
+ };
+ if (name != NULL) {
+ add_reference (name, result, NULL);
+ RELEASE (name);
+ }
+ return;
+}
+
+static void do_content(char **start, char *end, double x_user, double y_user)
+{
+ int len;
+ if (*start < end) {
+ sprintf (work_buffer, " q 1 0 0 1 %.2f %.2f cm ", x_user, y_user);
+ len = strlen(work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ pdf_doc_add_to_page (*start, end-*start);
+ pdf_doc_add_to_page (" Q", 2);
+ }
+ *start = end;
+ return;
+}
+
+
+static int is_pdf_special (char **start, char *end)
+{
+ skip_white(start, end);
+ if (end-*start >= strlen ("pdf:") &&
+ !strncmp (*start, "pdf:", strlen("pdf:"))) {
+ *start += strlen("pdf:");
+ return 1;
+ }
+ return 0;
+}
+
+#define ANN 1
+#define OUTLINE 2
+#define ARTICLE 3
+#define DEST 4
+#define DOCINFO 7
+#define DOCVIEW 8
+#define OBJ 9
+#define CONTENT 10
+#define PUT 11
+#define CLOSE 12
+#define BOP 13
+#define EOP 14
+#define BEAD 15
+#define EPDF 16
+#define IMAGE 17
+#define BCOLOR 18
+#define ECOLOR 19
+#define BGRAY 20
+#define EGRAY 21
+#define BGCOLOR 22
+#define BXFORM 23
+#define EXFORM 24
+#define DVIPDFM_PAGE_SIZE 25
+#define BXOBJ 26
+#define EXOBJ 27
+#define UXOBJ 28
+#define SCOLOR 29
+#define BANN 30
+#define EANN 31
+#define LINK_ANNOT 32
+#define NOLINK_ANNOT 33
+
+struct pdfmark
+{
+ char *string;
+ int value;
+} pdfmarks[] = {
+ {"ann", ANN},
+ {"annot", ANN},
+ {"annotate", ANN},
+ {"annotation", ANN},
+ {"out", OUTLINE},
+ {"outline", OUTLINE},
+ {"art", ARTICLE},
+ {"article", ARTICLE},
+ {"bead", BEAD},
+ {"thread", BEAD},
+ {"dest", DEST},
+ {"docinfo", DOCINFO},
+ {"docview", DOCVIEW},
+ {"obj", OBJ},
+ {"object", OBJ},
+ {"content", CONTENT},
+ {"put", PUT},
+ {"close", CLOSE},
+ {"bop", BOP},
+ {"eop", EOP},
+ {"epdf", EPDF},
+ {"image", IMAGE},
+ {"img", IMAGE},
+ {"bc", BCOLOR},
+ {"bcolor", BCOLOR},
+ {"begincolor", BCOLOR},
+ {"link", LINK_ANNOT},
+ {"nolink", NOLINK_ANNOT},
+ {"sc", SCOLOR},
+ {"scolor", SCOLOR},
+ {"setcolor", SCOLOR},
+ {"ec", ECOLOR},
+ {"ecolor", ECOLOR},
+ {"endcolor", ECOLOR},
+ {"bg", BGRAY},
+ {"bgray", BGRAY},
+ {"begingray", BGRAY},
+ {"eg", EGRAY},
+ {"egray", EGRAY},
+ {"endgray", EGRAY},
+ {"bgcolor", BGCOLOR},
+ {"bgc", BGCOLOR},
+ {"bbc", BGCOLOR},
+ {"bbg", BGCOLOR},
+ {"pagesize", DVIPDFM_PAGE_SIZE},
+ {"beginann", BANN},
+ {"bann", BANN},
+ {"bannot", BANN},
+ {"eann", EANN},
+ {"endann", EANN},
+ {"eannot", EANN},
+ {"begintransform", BXFORM},
+ {"begintrans", BXFORM},
+ {"btrans", BXFORM},
+ {"bt", BXFORM},
+ {"endtransform", EXFORM},
+ {"endtrans", EXFORM},
+ {"etrans", EXFORM},
+ {"et", EXFORM},
+ {"beginxobj", BXOBJ},
+ {"bxobj", BXOBJ},
+ {"endxobj", EXOBJ},
+ {"exobj", EXOBJ},
+ {"usexobj", UXOBJ},
+ {"uxobj", UXOBJ}
+};
+
+static int parse_pdfmark (char **start, char *end)
+{
+ char *save;
+ int i;
+ if (verbose) {
+ fprintf (stderr, "\nparse_pdfmark:");
+ dump (*start, end);
+ }
+ skip_white(start, end);
+ if (*start >= end) {
+ fprintf (stderr, "Special ignored...no pdfmark found\n");
+ return -1;
+ }
+
+ save = *start;
+ while (*start < end && isalpha (**start))
+ (*start)++;
+ for (i=0; i<sizeof(pdfmarks)/sizeof(struct pdfmark); i++) {
+ if (*start-save == strlen (pdfmarks[i].string) &&
+ !strncmp (save, pdfmarks[i].string,
+ strlen(pdfmarks[i].string)))
+ return pdfmarks[i].value;
+ }
+ *start = save;
+ fprintf (stderr, "\nExpecting pdfmark (and didn't find one)\n");
+ dump(*start, end);
+ return -1;
+}
+
+struct named_reference
+{
+ char *name;
+ char *res_name;
+ pdf_obj *object_ref;
+ pdf_obj *object;
+} *named_references = NULL;
+static unsigned long number_named_references = 0, max_named_objects = 0;
+
+static void add_reference (char *name, pdf_obj *object, char *res_name)
+{
+ int i;
+ if (number_named_references >= max_named_objects) {
+ max_named_objects += NAMED_OBJ_ALLOC_SIZE;
+ named_references = RENEW (named_references, max_named_objects,
+ struct named_reference);
+ }
+ for (i=0; i<number_named_references; i++) {
+ if (!strcmp (named_references[i].name, name)) {
+ break;
+ }
+ }
+ if (i != number_named_references) {
+ fprintf (stderr, "\nWarning: @%s: Duplicate named reference ignored\n", name);
+ }
+ named_references[number_named_references].name = NEW (strlen
+ (name)+1,
+ char);
+ strcpy (named_references[number_named_references].name, name);
+ if (res_name != NULL && strlen(res_name) != 0) {
+ named_references[number_named_references].res_name=NEW(strlen(name)+1, char);
+ strcpy (named_references[number_named_references].res_name,
+ res_name);
+ } else {
+ named_references[number_named_references].res_name = NULL;
+ }
+ named_references[number_named_references].object_ref = pdf_ref_obj(object);
+ named_references[number_named_references].object = object;
+ number_named_references+=1;
+}
+/* The following routine returns copies, not the original object */
+static pdf_obj *lookup_reference(char *name)
+{
+ int i;
+ /* First check for builtins first */
+ if (!strcmp (name, "ypos")) {
+ return pdf_new_number(ROUND(dev_phys_y(),0.01));
+ }
+ if (!strcmp (name, "xpos")) {
+ return pdf_new_number(ROUND(dev_phys_x(),0.01));
+ }
+ if (!strcmp (name, "thispage")) {
+ return pdf_doc_this_page_ref();
+ }
+ if (!strcmp (name, "prevpage")) {
+ return pdf_doc_prev_page_ref();
+ }
+ if (!strcmp (name, "nextpage")) {
+ return pdf_doc_next_page_ref();
+ }
+ if (!strcmp (name, "pages")) {
+ return pdf_ref_obj (pdf_doc_page_tree());
+ }
+ if (!strcmp (name, "names")) {
+ return pdf_ref_obj (pdf_doc_names());
+ }
+ if (!strcmp (name, "resources")) {
+ return pdf_ref_obj (pdf_doc_current_page_resources());
+ }
+ if (!strcmp (name, "catalog")) {
+ return pdf_ref_obj (pdf_doc_catalog());
+ }
+
+ if (strlen (name) > 4 &&
+ !strncmp (name, "page", 4) &&
+ is_an_int (name+4)) {
+ return pdf_doc_ref_page(atoi (name+4));
+ }
+ for (i=0; i<number_named_references; i++) {
+ if (!strcmp (named_references[i].name, name)) {
+ break;
+ }
+ }
+ if (i == number_named_references)
+ return NULL;
+ return (pdf_link_obj (named_references[i].object_ref));
+}
+
+static pdf_obj *lookup_object(char *name)
+{
+ int i;
+ if (!strcmp (name, "thispage")) {
+ return pdf_doc_this_page();
+ }
+ if (!strcmp (name, "pages")) {
+ return pdf_doc_page_tree();
+ }
+ if (!strcmp (name, "names")) {
+ return pdf_doc_names();
+ }
+ if (!strcmp (name, "resources")) {
+ return pdf_doc_current_page_resources();
+ }
+ if (!strcmp (name, "catalog")) {
+ return pdf_doc_catalog();
+ }
+
+ for (i=0; i<number_named_references; i++) {
+ if (!strcmp (named_references[i].name, name)) {
+ break;
+ }
+ }
+ if (i == number_named_references)
+ return NULL;
+ if (named_references[i].object == NULL)
+ fprintf (stderr, "lookup_object: Referenced object not defined or already closed\n");
+ return (named_references[i].object);
+}
+
+char *lookup_ref_res_name(char *name)
+{
+ int i;
+ for (i=0; i<number_named_references; i++) {
+ if (named_references[i].name != NULL)
+ if (named_references[i].name != NULL &&
+ !strcmp (named_references[i].name, name)) {
+ break;
+ }
+ }
+ if (i == number_named_references)
+ return NULL;
+ if (named_references[i].res_name == NULL)
+ fprintf (stderr, "lookup_object: Referenced object not useable as a form!\n");
+ return (named_references[i].res_name);
+}
+
+static void release_reference (char *name)
+{
+ int i;
+ for (i=0; i<number_named_references; i++) {
+ if (!strcmp (named_references[i].name, name)) {
+ break;
+ }
+ }
+ if (i == number_named_references) {
+ fprintf (stderr, "\nrelease_reference: tried to release nonexistent reference\n");
+ return;
+ }
+ if (named_references[i].object != NULL) {
+ pdf_release_obj (named_references[i].object);
+ named_references[i].object = NULL;
+ }
+ else
+ fprintf (stderr, "\nrelease_reference: @%s: trying to close an object twice?\n", name);
+}
+
+
+void pdf_finish_specials (void)
+{
+ int i;
+ /* Flush out any pending objects that weren't properly closeed.
+ Threads never get closed. Is this a bug? */
+ for (i=0; i<number_named_references; i++) {
+ pdf_release_obj (named_references[i].object_ref);
+ if (named_references[i].object != NULL) {
+ pdf_release_obj (named_references[i].object);
+ named_references[i].object = NULL;
+ }
+ if (named_references[i].res_name != NULL) {
+ RELEASE (named_references[i].res_name);
+ named_references[i].res_name = NULL;
+ }
+ RELEASE (named_references[i].name);
+ }
+ if (number_named_references > 0)
+ RELEASE (named_references);
+}
+
+int pdf_parse_special(char *buffer, UNSIGNED_QUAD size, double
+ x_user, double y_user)
+{
+ int pdfmark, result=0;
+ char *start = buffer, *end;
+ end = buffer + size;
+
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+
+ if (is_pdf_special(&start, end)) {
+ result = 1; /* This means it really was a pdf special. It doesn't
+ mean it succeeded */
+ /* Must have a pdf special */
+ pdfmark = parse_pdfmark(&start, end);
+ switch (pdfmark) {
+ case ANN:
+ do_ann(&start, end);
+ break;
+ case BANN:
+ do_bann(&start, end);
+ break;
+ case LINK_ANNOT:
+ dev_link_annot(1);
+ break;
+ case NOLINK_ANNOT:
+ dev_link_annot(0);
+ break;
+ case EANN:
+ do_eann(&start, end);
+ break;
+ case OUTLINE:
+ do_outline(&start, end);
+ break;
+ case ARTICLE:
+ do_article(&start, end);
+ break;
+ case BEAD:
+ do_bead(&start, end);
+ break;
+ case DEST:
+ do_dest(&start, end);
+ break;
+ case DOCINFO:
+ do_docinfo(&start, end);
+ break;
+ case DOCVIEW:
+ do_docview(&start, end);
+ break;
+ case OBJ:
+ do_obj(&start, end);
+ break;
+ case CONTENT:
+ do_content(&start, end, x_user, y_user);
+ break;
+ case PUT:
+ do_put(&start, end);
+ break;
+ case CLOSE:
+ do_close(&start, end);
+ break;
+ case BOP:
+ do_bop(&start, end);
+ break;
+ case EOP:
+ do_eop(&start, end);
+ break;
+ case EPDF:
+ do_image(&start, end, x_user, y_user);
+ break;
+ case IMAGE:
+ do_image(&start, end, x_user, y_user);
+ break;
+ case BGCOLOR:
+ if (!ignore_colors)
+ do_bgcolor (&start, end);
+ break;
+ case SCOLOR:
+ if (!ignore_colors)
+ do_scolor (&start, end);
+ break;
+ case BCOLOR:
+ if (!ignore_colors)
+ do_bcolor (&start, end);
+ break;
+ case ECOLOR:
+ if (!ignore_colors)
+ do_ecolor ();
+ break;
+ case BGRAY:
+ do_bgray (&start, end);
+ break;
+ case EGRAY:
+ do_egray ();
+ break;
+ case BXFORM:
+ do_bxform (&start, end, x_user, y_user);
+ break;
+ case EXFORM:
+ do_exform ();
+ break;
+ case DVIPDFM_PAGE_SIZE:
+ do_pagesize(&start, end);
+ break;
+ case BXOBJ:
+ do_bxobj (&start, end, x_user, y_user);
+ break;
+ case EXOBJ:
+ do_exobj ();
+ break;
+ case UXOBJ:
+ do_uxobj (&start, end, x_user, y_user);
+ break;
+ default:
+ dump (start, end);
+ fprintf (stderr, "Invalid pdf special ignored\n");
+ break;
+ }
+ skip_white (&start, end);
+ if (start < end) {
+ fprintf (stderr, "\nUnparsed material at end of special ignored...");
+ dump (start, end);
+ }
+ } else {
+ result = 0;
+ }
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return result;
+}
+
+/* Compute a transformation matrix
+ transformations are applied in the following
+ order: scaling, rotate, displacement. */
+void add_xform_matrix (double xoff, double yoff,
+ double xscale, double yscale,
+ double rotate)
+{
+ double c, s;
+ c = ROUND(cos(rotate),1e-5);
+ s = ROUND(sin(rotate),1e-5);
+ sprintf (work_buffer, " %g %g %g %g %.2f %.2f cm",
+ c*xscale, s*xscale, -s*yscale, c*yscale, xoff, yoff);
+ pdf_doc_add_to_page (work_buffer, strlen(work_buffer));
+}
+
+
+pdf_obj *jpeg_start_image(FILE *file)
+{
+ pdf_obj *xobject, *xobj_dict;
+ struct jpeg *jpeg;
+ jpeg = jpeg_open (file);
+ xobject = pdf_new_stream(0);
+ xobj_dict = pdf_stream_dict (xobject);
+ pdf_add_dict (xobj_dict, pdf_new_name ("Width"),
+ pdf_new_number (jpeg -> width));
+ pdf_add_dict (xobj_dict, pdf_new_name ("Height"),
+ pdf_new_number (jpeg -> height));
+ pdf_add_dict (xobj_dict, pdf_new_name ("BitsPerComponent"),
+ pdf_new_number (jpeg -> bits_per_color));
+ if (jpeg->colors == 1)
+ pdf_add_dict (xobj_dict, pdf_new_name ("ColorSpace"),
+ pdf_new_name ("DeviceGray"));
+ if (jpeg->colors > 1)
+ pdf_add_dict (xobj_dict, pdf_new_name ("ColorSpace"),
+ pdf_new_name ("DeviceRGB"));
+ pdf_add_dict (xobj_dict, pdf_new_name ("Filter"),
+ pdf_new_name ("DCTDecode"));
+ {
+ int length;
+ rewind (jpeg -> file);
+ while ((length = fread (work_buffer, sizeof (char),
+ WORK_BUFFER_SIZE, jpeg -> file)) > 0) {
+ pdf_add_stream (xobject, work_buffer, length);
+ }
+ }
+ jpeg_close (jpeg);
+ return (xobject);
+}
+
+void pdf_scale_image (struct xform_info *p)
+{
+ double xscale = 1.0, yscale = 1.0, nat_width, nat_height;
+ if (p->user_bbox) { /* Did user override natural bounding box */
+ nat_width = p->u_urx - p->u_llx;
+ nat_height = p->u_ury - p->u_lly;
+ } else { /* If not, use media width and height */
+ nat_width = p->c_urx - p->c_llx;
+ nat_height = p->c_ury - p->c_lly;
+ p->u_llx = 0.0; /* Initialize u_llx and u_lly because they
+ p->u_lly = 0.0; are used to set the origin within the crop
+ area */
+ }
+ if (p->clip && p->user_bbox) { /* Clip to user specified bbox? */
+ p->c_urx = p->u_urx;
+ p->c_ury = p->u_ury;
+ p->c_llx = p->u_llx;
+ p->c_lly = p->u_lly;
+ }
+ if (p->scale != 0) {
+ xscale = p->scale;
+ yscale = p->scale;
+ }
+ if (p->xscale != 0) {
+ xscale = p->xscale;
+ }
+ if (p->yscale != 0) {
+ yscale = p->yscale;
+ }
+ if (p->width != 0.0 && nat_width != 0.0) {
+ xscale = p->width/nat_width;
+ if (p->height == 0.0)
+ yscale = xscale;
+ }
+ if (p->height != 0.0 && nat_height != 0.0) {
+ yscale = p->height/nat_height;
+ if (p->width == 0.0)
+ xscale = yscale;
+ }
+ /* We overwrite p->xscale and p->yscale to pass values back to
+ caller to user */
+ p->xscale = xscale;
+ p->yscale = yscale;
+ return;
+}
+
+static void finish_image (pdf_obj *image_res, struct xform_info *p,
+ char *res_name)
+{
+ pdf_obj *image_dict;
+ image_dict = pdf_stream_dict (image_res);
+ pdf_add_dict (image_dict, pdf_new_name ("Name"),
+ pdf_new_name (res_name));
+ pdf_add_dict (image_dict, pdf_new_name ("Type"),
+ pdf_new_name ("XObject"));
+ pdf_add_dict (image_dict, pdf_new_name ("Subtype"),
+ pdf_new_name ("Image"));
+ { /* Compute new xscale and yscale based on user specified values
+ and image dimensions (recall that PDF changes dimensions of all
+ images to 1x1 :-( */
+ int width, height;
+ width = pdf_number_value(pdf_lookup_dict (image_dict, "Width"));
+ height = pdf_number_value(pdf_lookup_dict (image_dict, "Height"));
+ /* Following routine sets xscale and yscale to a fraction of
+ their natural values */
+ p->c_llx = 0;
+ p->c_lly = 0;
+ p->c_urx = width*(72.0/100.0);
+ p->c_ury = height*(72.0/100.0);
+ if (p->user_bbox) {
+ fprintf (stderr,
+ "\nWarning: Ignoring user specified bounding box for raster image.\n");
+ p->user_bbox = 0;
+ }
+ pdf_scale_image (p);
+ /* Since bitmapped images are always 1x1 in PDF, we must rescale
+ again */
+ p->xscale *= width*(72.0/100.0);
+ p->yscale *= height*(72.0/100.0);
+ }
+ return;
+}
+
+static void do_bxobj (char **start, char *end, double x_user, double y_user)
+{
+ char *objname = NULL;
+ static unsigned long num_forms = 0;
+ pdf_obj *xobject = NULL;
+ struct xform_info *p = NULL;
+ int errors = 0;
+ skip_white(start, end);
+ /* If there's an object name, check dimensions */
+ if ((objname = parse_opt_ident(start, end)) != NULL) {
+ p = new_xform_info ();
+ skip_white(start, end);
+ if (!parse_dimension(start, end, p)) {
+ fprintf (stderr, "\nFailed to find a valid dimension.\n");
+ errors = 1;
+ }
+ if (p->scale != 0.0 || p->xscale != 0.0 || p->yscale != 0.0) {
+ fprintf (stderr, "\nScale information is meaningless for form xobjects\n");
+ errors = 1;
+ }
+ if (p->width == 0.0 || p->depth+p->height == 0.0) {
+ fprintf (stderr, "\nSpecial: bxobj: Bounding box has a zero dimension\n");
+ fprintf (stderr, "width:%g, height:%g, depth:%g\n", p->width,
+ p->height, p->depth);
+ errors = 1;
+ }
+ /* If there's an object name and valid dimension, add it to the
+ tables */
+ if (!errors) {
+ char *res_name;
+ sprintf (work_buffer, "Fm%ld", ++num_forms);
+ res_name = NEW (strlen(work_buffer)+1, char);
+ strcpy (res_name, work_buffer);
+ xobject = begin_form_xobj (x_user, y_user,
+ x_user, y_user-p->depth,
+ x_user+p->width, y_user+p->height,
+ res_name);
+ add_reference (objname, xobject, res_name);
+ RELEASE (res_name);
+ /* Next line has Same explanation as for do_ann. */
+ release_reference (objname);
+ }
+ release_xform_info (p);
+ RELEASE (objname);
+ }
+ else {
+ fprintf (stderr, "\nSpecial: beginxobj: A form XObject must be named\n");
+ }
+ return;
+}
+
+
+static void do_exobj (void)
+{
+ end_form_xobj();
+}
+
+static void do_uxobj (char **start, char *end, double x_user, double y_user)
+{
+ char *objname, *res_name = NULL;
+ pdf_obj *xobj_res = NULL;
+ skip_white (start, end);
+ if (((objname = parse_opt_ident(start, end)) != NULL) &&
+ ((res_name = lookup_ref_res_name (objname)) != NULL) &&
+ ((xobj_res = lookup_reference (objname)) != NULL)) {
+ sprintf (work_buffer, " q 1 0 0 1 %.2f %.2f cm /%s Do Q", x_user, y_user, res_name);
+ pdf_doc_add_to_page (work_buffer, strlen(work_buffer));
+ pdf_doc_add_to_page_xobjects (res_name, xobj_res);
+ }
+ if (objname != NULL && (res_name == NULL || xobj_res == NULL)) {
+ fprintf (stderr, "\nSpecial: usexobj: Specified XObject doesn't exist: %s\n",
+ objname);
+ }
+ if (objname != NULL)
+ RELEASE (objname);
+ return;
+}
+
diff --git a/Build/source/texk/dvipdfm/pdfspecial.h b/Build/source/texk/dvipdfm/pdfspecial.h
new file mode 100644
index 00000000000..1d8fd7aa9f1
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pdfspecial.h
@@ -0,0 +1,102 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef PDFSPECIAL_H
+
+#define PDFSPECIAL_H
+#include "numbers.h"
+#include "pdfobj.h"
+
+struct xform_info
+{
+ double width;
+ double height;
+ double depth;
+ double scale;
+ double xscale;
+ double yscale;
+ double rotate;
+ /* If the user enters a "bounding box", user_bbox is nonzero */
+ unsigned char user_bbox;
+ /* If the user enters a "bounding box", the use specified
+ coordinates follow */
+ double u_llx, u_lly, u_urx, u_ury;
+ /* The following lines are for compatibility with dvips specials.
+ The method is a bit clumsy, and requires a lengthy explanation,
+ because dvipdfm uses form xobjects to embed all image types.
+
+ Because the image is a form xobject, the image must be clipped
+ somewhere. Form xobjects always crop to their bounding box.
+ However, this is not the dvips behavior. If the user specifies
+ "clip", PS and PDF images will be clipped to the user specified
+ bounding box; in other words, the user specified bounding box and
+ the clipping bounding box are one and the same. Otherwise,
+ dvipdfm will clip the image at the bounding box contained in the
+ image file. (The eps header in the case of Metapost images or
+ the media box or crop box in the case of PDF images.) In the
+ case that the user bounding box and clip bounding box are
+ different, the image is scaled to match any user specified
+ dimensions.
+
+ Processing of all image inclusion specials are handled by common
+ code which fills in the user bounding box, if any, as well as the
+ width, height, depth, xscale, yscale, scale, and rotate fields.
+ That common routine calls a routine specific to each image type.
+ The routines specific to each file type MUST fill in the c_llx
+ through c_ury fields, because the source of this information is
+ image type dependent. They are also responsible for calling
+ pdf_scale_image(), which checks the information for consistency
+ and recalculates ` the scaling required to achieve the desired
+ effect. */
+ unsigned char clip;
+ double c_llx, c_lly, c_urx, c_ury;
+};
+
+extern int pdf_parse_special(char *buffer, UNSIGNED_QUAD size, double
+ x_user, double y_user);
+extern void pdf_finish_specials(void);
+extern pdf_obj *get_reference(char **start, char *end);
+extern struct xform_info *new_xform_info (void);
+extern void release_xform_info (struct xform_info *p);
+extern int validate_image_xform_info (struct xform_info *p);
+extern void add_xform_matrix (double xoff, double yoff, double xscale, double
+ yscale, double rotate);
+
+extern void pdf_special_ignore_colors(void);
+
+extern double parse_one_unit (char **start, char *end);
+extern void pdf_scale_image (struct xform_info *p);
+extern pdf_obj *embed_image (char *filename, struct xform_info *p,
+ double x_user, double y_user, char
+ *objname);
+extern void pdf_finish_specials(void);
+extern void pdf_special_set_grow (double g);
+extern double pdf_special_tell_grow (void);
+
+#ifndef M_PI
+ #define M_PI (4.0*atan(1.0))
+#endif /* M_PI */
+
+#endif /* PDFSPECIAL_H */
diff --git a/Build/source/texk/dvipdfm/pkfont.c b/Build/source/texk/dvipdfm/pkfont.c
new file mode 100644
index 00000000000..b0fd8b94583
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pkfont.c
@@ -0,0 +1,620 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <stdio.h>
+#include "system.h"
+#include "mem.h"
+#include "error.h"
+#include "mfileio.h"
+#include "numbers.h"
+#include "pkfont.h"
+#include "pdfobj.h"
+#include "pdflimits.h"
+#include "tfm.h"
+#include "ctype.h"
+
+pdf_obj *pk_encoding_ref = NULL;
+static unsigned char verbose = 0, debug = 0;
+static unsigned font_dpi = 600;
+
+void pk_set_verbose(void)
+{
+ if (verbose < 255) {
+ verbose += 1;
+ }
+}
+
+void pk_set_dpi (int dpi)
+{
+ font_dpi = dpi;
+}
+
+
+static void make_pk_encoding_ref (void)
+{
+ static char first = 1;
+ if (first) {
+ int i;
+ pdf_obj *encoding, *differences;
+ encoding = pdf_new_dict();
+ pdf_add_dict (encoding,
+ pdf_new_name ("Type"),
+ pdf_new_name ("Encoding"));
+ differences = pdf_new_array();
+ pdf_add_dict (encoding,
+ pdf_new_name ("Differences"),
+ differences);
+ pdf_add_array (differences, pdf_new_number (0.0));
+ for (i=0; i<256; i++) {
+ sprintf (work_buffer, "x%x", i);
+ pdf_add_array (differences, pdf_new_name(work_buffer));
+ }
+ pk_encoding_ref = pdf_ref_obj (encoding);
+ pdf_release_obj (encoding);
+ }
+ first = 0;
+ return;
+}
+
+static void release_pk_encoding_ref (void)
+{
+ pdf_release_obj (pk_encoding_ref);
+}
+
+struct a_pk_font
+{
+ pdf_obj *direct, *indirect;
+ char *tex_name, *pk_file_name;
+ double ptsize;
+ char *used_chars;
+} *pk_fonts;
+
+void init_pk_record (struct a_pk_font *p)
+{
+ int i;
+ p->used_chars = NEW (256, char);
+ for (i=0; i<256; i++) {
+ (p->used_chars)[i] = 0;
+ }
+ p->tex_name = NULL;
+ p->pk_file_name = NULL;
+}
+
+
+int num_pk_fonts = 0, max_pk_fonts = 0;
+
+int pk_font (const char *tex_name, double ptsize, int tfm_font_id, char
+ *res_name)
+{
+ int i, j;
+ int firstchar, lastchar;
+ pdf_obj *tmp1;
+ for (i=0; i<num_pk_fonts; i++) {
+ if (!strcmp (tex_name, pk_fonts[i].tex_name) &&
+ (ptsize == pk_fonts[i].ptsize))
+ break;
+ }
+ if (i == num_pk_fonts) {
+ char *pk_file_name;
+ kpse_glyph_file_type kpse_file_info;
+ if ((pk_file_name = kpse_find_glyph(tex_name,
+ font_dpi*ptsize/tfm_get_design_size(tfm_font_id)+0.5,
+ kpse_pk_format,
+ &kpse_file_info))) {
+ /* Make sure there is enough room in pk_fonts for this entry */
+ if (num_pk_fonts >= max_pk_fonts) {
+ max_pk_fonts += MAX_FONTS;
+ pk_fonts = RENEW (pk_fonts, max_pk_fonts, struct a_pk_font);
+ }
+ init_pk_record (pk_fonts+i);
+ pk_fonts[i].pk_file_name = NEW (strlen(pk_file_name)+1, char);
+ strcpy (pk_fonts[i].pk_file_name, pk_file_name);
+ pk_fonts[i].tex_name = NEW (strlen (tex_name)+1, char);
+ strcpy (pk_fonts[i].tex_name, tex_name);
+ pk_fonts[i].ptsize = ptsize;
+ pk_fonts[i].direct = pdf_new_dict ();
+ pdf_add_dict (pk_fonts[i].direct,
+ pdf_new_name ("Type"),
+ pdf_new_name ("Font"));
+ pdf_add_dict (pk_fonts[i].direct,
+ pdf_new_name ("Name"),
+ pdf_new_name (res_name));
+ pdf_add_dict (pk_fonts[i].direct,
+ pdf_new_name ("Subtype"),
+ pdf_new_name ("Type3"));
+ firstchar = tfm_get_firstchar(tfm_font_id);
+ pdf_add_dict (pk_fonts[i].direct,
+ pdf_new_name ("FirstChar"),
+ pdf_new_number (firstchar));
+ lastchar = tfm_get_lastchar(tfm_font_id);
+ pdf_add_dict (pk_fonts[i].direct,
+ pdf_new_name ("LastChar"),
+ pdf_new_number (lastchar));
+ tmp1 = pdf_new_array ();
+ for (j=firstchar; j<=lastchar; j++) {
+ pdf_add_array (tmp1,
+ pdf_new_number(ROUND(tfm_get_width (tfm_font_id, j)*1000.0,0.01)));
+ }
+ pdf_add_dict (pk_fonts[i].direct,
+ pdf_new_name ("Widths"),
+ tmp1);
+ {
+ double max_height, max_depth, max_width;
+ max_height = tfm_get_max_height (tfm_font_id)*1000.0;
+ max_depth = tfm_get_max_depth (tfm_font_id)*1000.0;
+ max_width = tfm_get_max_width (tfm_font_id)*1000.0;
+ max_height = ROUND(max_height, 1.0);
+ max_depth = ROUND(max_depth, 1.0);
+ max_width = ROUND(max_width, 1.0);
+ tmp1 = pdf_new_array();
+ pdf_add_array (tmp1, pdf_new_number(-0.10*max_width));
+ pdf_add_array (tmp1,
+ pdf_new_number(-max_depth-0.20*(max_height+max_depth)));
+ pdf_add_array (tmp1, pdf_new_number(1.10*max_width));
+ pdf_add_array (tmp1, pdf_new_number(max_height+0.10*(max_height+max_depth)));
+ pdf_add_dict (pk_fonts[i].direct,
+ pdf_new_name ("FontBBox"), tmp1);
+ }
+ {
+ tmp1 = pdf_new_array();
+ pdf_add_array (tmp1, pdf_new_number (0.001));
+ pdf_add_array (tmp1, pdf_new_number (0.0));
+ pdf_add_array (tmp1, pdf_new_number (0.0));
+ pdf_add_array (tmp1, pdf_new_number (0.001));
+ pdf_add_array (tmp1, pdf_new_number (0.0));
+ pdf_add_array (tmp1, pdf_new_number (0.0));
+ pdf_add_dict (pk_fonts[i].direct, pdf_new_name ("FontMatrix"),
+ tmp1);
+ }
+ if (pk_encoding_ref == NULL) {
+ make_pk_encoding_ref();
+ }
+ pdf_add_dict (pk_fonts[i].direct,
+ pdf_new_name ("Encoding"),
+ pdf_link_obj (pk_encoding_ref));
+ pk_fonts[i].indirect = pdf_ref_obj (pk_fonts[i].direct);
+ num_pk_fonts += 1;
+ } else { /* Found no glyph file */
+ i = -1;
+ }
+ }
+ return i;
+}
+
+pdf_obj *pk_font_resource (int pk_id)
+{
+ if (pk_id <0 || pk_id >= num_pk_fonts) {
+ fprintf (stderr, "pk_id = %d\n", pk_id);
+ ERROR ("pk_font_resource: Invalid pk_id\n");
+ }
+ return pdf_link_obj (pk_fonts[pk_id].indirect);
+}
+
+char *pk_font_used (int pk_id)
+{
+ if (pk_id < 0 || pk_id >= num_pk_fonts) {
+ fprintf (stderr, "pk_id = %d\n", pk_id);
+ ERROR ("pk_font_used: Invalid pk_id\n");
+ }
+ return pk_fonts[pk_id].used_chars;
+}
+
+
+static FILE *pk_file;
+
+static void do_skip(unsigned long length)
+{
+ unsigned long i;
+ for (i=0; i<length; i++)
+ fgetc (pk_file);
+ return;
+}
+
+static void add_raster_data (pdf_obj *glyph, long w, long h,
+ int dyn_f, int run_color,
+ unsigned char *pk_data,
+ unsigned char *eod)
+
+ /* First define some macros to be used as "in-line" functions */
+#define advance_nybble() \
+{ \
+ if (partial_byte) { \
+ partial_byte=0; \
+ pk_data++; \
+ } else \
+ partial_byte=1; \
+}
+
+#define current_nybble() (partial_byte? (*pk_data%16): (*pk_data/16))
+#define set_bits(n) {\
+ int i; \
+ for (i=0; i<(n); i++) { \
+ row[next_col] |= (128u>>next_bit++); \
+ if (next_bit > 7) { \
+ next_bit = 0; \
+ next_col += 1; \
+ } \
+ } \
+}
+
+#define skip_bits(n) {\
+ next_col += (n)/8; \
+ next_bit += (n)%8; \
+ if (next_bit > 7) { \
+ next_bit -= 8; \
+ next_col += 1; \
+ } \
+}
+
+#define get_bit(p,n) (p[(n)/8] & (128u>>((n)%8)))
+
+{
+ long i, w_bytes, repeat_count, run_count = 0;
+ int partial_byte = 0;
+ unsigned char *row;
+ w_bytes = (w%8 == 0)? w/8: (w/8+1);
+ row = NEW (w_bytes, unsigned char);
+ /* Make sure we output "h" rows of data */
+ if (dyn_f == 14) {
+ for (i=0; i<h; i++) {
+ int next_col = 0, next_bit = 0;
+ int j;
+ for (j=0; j<w_bytes; j++) row[j] = 0;
+ for (j=0; j<w; j++) {
+ if (get_bit(pk_data,i*w+j)) {
+ skip_bits(1);
+ }
+ else {
+ set_bits(1);
+ }
+ }
+ pdf_add_stream (glyph, (char *) row, w_bytes);
+ }
+ } else
+ for (i=0; i<h; i++) {
+ int next_col = 0, next_bit = 0;
+ int j, row_bits_left = w;
+ /* Initialize row to all zeros */
+ for (j=0; j<w_bytes; j++) row[j] = 0;
+ repeat_count = 0;
+ /* Fill any run left over from previous rows */
+ if (run_count != 0) {
+ int nbits;
+ nbits = MIN (w, run_count);
+ run_count -= nbits;
+ switch (run_color) {
+ case 1: /* This is actually white ! */
+ set_bits(nbits);
+ break;
+ case 0:
+ skip_bits(nbits);
+ break;
+ }
+ row_bits_left -= nbits;
+ }
+ /* Read nybbles until we have a full row */
+ while (pk_data < eod && row_bits_left>0) {
+ int com_nyb;
+ long packed = 0;
+ com_nyb = current_nybble();
+ if (com_nyb == 15) {
+ repeat_count = 1;
+ advance_nybble();
+ continue;
+ }
+ if (com_nyb == 14) {
+ advance_nybble();
+ }
+ /* Get a packed number */
+ {
+ int nyb;
+ nyb = current_nybble();
+ /* Test for single nybble case */
+ if (nyb > 0 && nyb <= dyn_f) {
+ packed = nyb;
+ advance_nybble();
+ }
+ if (nyb > dyn_f) {
+ advance_nybble();
+ packed = (nyb-dyn_f-1)*16+current_nybble()+dyn_f+1;
+ advance_nybble();
+ }
+ if (nyb == 0) {
+ int nnybs = 1;
+ while (current_nybble() == 0) {
+ advance_nybble();
+ nnybs += 1;
+ }
+ packed = 0;
+ while (nnybs) {
+ packed = packed*16 + current_nybble();
+ advance_nybble();
+ nnybs -= 1;
+ }
+ packed += (13-dyn_f)*16-15+dyn_f;
+ }
+ }
+ if (com_nyb == 14) {
+ repeat_count = packed;
+ continue;
+ }
+ {
+ int nbits;
+ run_count = packed;
+ run_color = !run_color;
+ nbits = MIN (row_bits_left, run_count);
+ run_count -= nbits;
+ row_bits_left -= nbits;
+ switch (run_color) {
+ case 1:
+ set_bits(nbits);
+ break;
+ case 0:
+ skip_bits(nbits);
+ break;
+ }
+ }
+ continue;
+ }
+ pdf_add_stream (glyph, (char *) row, w_bytes);
+ /* Duplicate the row "repeat_count" times */
+ for (j=0; j<repeat_count; j++) {
+ pdf_add_stream (glyph, (char *) row, w_bytes);
+ }
+ /* Skip repeat_count interations */
+ i += repeat_count;
+ }
+ RELEASE (row);
+}
+
+static void do_preamble(void)
+{
+ /* Check for id byte */
+ if (fgetc (pk_file) == 89) {
+ /* Skip comment */
+ do_skip (get_unsigned_byte (pk_file));
+ /* Skip other header info. It's normally used for verifying this
+ is the file wethink it is */
+ do_skip (16);
+ } else {
+ ERROR ("embed_pk_font: PK ID byte is incorrect. Are you sure this is a PK file?");
+ }
+ return;
+}
+
+#define SHORT_FORM 1
+#define MED_FORM 2
+#define LONG_FORM 3
+static void do_character (unsigned char flag, int pk_id, pdf_obj *char_procs)
+{
+ int format;
+ unsigned long packet_length = 0, code = 0;
+ /* Last three bits of flag determine packet size in a complex way */
+ if ((flag & 4) == 0) {
+ format = SHORT_FORM;
+ } else if ((flag & 7) == 7) {
+ format = LONG_FORM;
+ } else {
+ format = MED_FORM;
+ }
+ if (debug) {
+ fprintf (stderr, "packet format: %d\n", format);
+ }
+ switch (format) {
+ case SHORT_FORM:
+ packet_length = (flag & 3) * 256u + get_unsigned_byte (pk_file);
+ code = get_unsigned_byte (pk_file);
+ break;
+ case MED_FORM:
+ packet_length = (flag & 3) * 65536ul + get_unsigned_pair(pk_file);
+ code = get_unsigned_byte (pk_file);
+ break;
+ case LONG_FORM:
+ packet_length = get_unsigned_quad (pk_file);
+ code = get_unsigned_quad (pk_file);
+ if (code > 255)
+ ERROR ("Unable to handle long characters in PK files");
+ break;
+ }
+ if (debug) {
+ fprintf (stderr, "\npk_do_character: code=%lu, packet_length=%lu\n",
+ code, packet_length);
+ }
+ if ((pk_fonts[pk_id].used_chars)[code%256]) {
+ int dyn_f;
+ unsigned long tfm_width = 0;
+ long dm=0, dx=0, dy=0, w=0, h=0;
+ int hoff=0, voff=0;
+ dyn_f = flag/16;
+ switch (format) {
+ case SHORT_FORM:
+ tfm_width = get_unsigned_triple (pk_file);
+ dm = get_unsigned_byte (pk_file);
+ w = get_unsigned_byte (pk_file);
+ h = get_unsigned_byte (pk_file);
+ hoff = get_signed_byte (pk_file);
+ voff = get_signed_byte (pk_file);
+ packet_length -= 8;
+ break;
+ case MED_FORM:
+ tfm_width = get_unsigned_triple (pk_file);
+ dm = get_unsigned_pair (pk_file);
+ w = get_unsigned_pair (pk_file);
+ h = get_unsigned_pair (pk_file);
+ hoff = get_signed_pair (pk_file);
+ voff = get_signed_pair (pk_file);
+ packet_length -= 13;
+ break;
+ case LONG_FORM:
+ tfm_width = get_signed_quad (pk_file);
+ dx = get_signed_quad (pk_file);
+ dy = get_signed_quad (pk_file);
+ w = get_signed_quad (pk_file);
+ h = get_signed_quad (pk_file);
+ hoff = get_signed_quad (pk_file);
+ voff = get_signed_quad (pk_file);
+ packet_length -= 28;
+ break;
+ }
+ {
+ pdf_obj *glyph;
+ double char_width, llx, lly, urx, ury;
+ double pix2charu;
+ int len;
+ pix2charu = 72000.0/((double) font_dpi)/pk_fonts[pk_id].ptsize;
+ char_width = tfm_width / (double) (1<<20) * 1000.0;
+ char_width = ROUND (char_width, 0.01);
+ llx = -hoff*pix2charu;
+ lly = (voff-h)*pix2charu;
+ urx = (w-hoff)*pix2charu;
+ ury = voff*pix2charu;
+ glyph = pdf_new_stream(STREAM_COMPRESS);
+ /* The following line is a "metric" for the PDF reader */
+ sprintf (work_buffer, "%.2f %.2f %.2f %.2f %.2f %.2f d1",
+ char_width, 0.0,
+ llx, lly, urx, ury);
+ len = strlen (work_buffer);
+ pdf_add_stream (glyph, work_buffer, len);
+ /* For now add an outline box for debugging purposes */
+ /* len = sprintf (work_buffer, " %.2f %.2f m %.2f %.2f l %.2f %.2f l %.2f %.2f l s",
+ llx, lly, urx, lly, urx, ury, llx, ury);
+ pdf_add_stream (glyph, work_buffer, len); */
+ /* Scale and translate origin to lower left corner for raster data */
+ sprintf (work_buffer, " q %.2f 0 0 %.2f %.2f %.2f cm",
+ w*pix2charu, h*pix2charu, llx, lly);
+ len = strlen (work_buffer);
+ pdf_add_stream (glyph, work_buffer, len);
+ if (w != 0 && h != 0 && packet_length != 0) {
+ unsigned char *pk_data;
+ long read_len;
+ sprintf (work_buffer, "\nBI\n/W %ld\n/H %ld\n/IM true\n/BPC 1\n/I true\n", w, h);
+ len = strlen (work_buffer);
+ pdf_add_stream (glyph, work_buffer, len);
+ sprintf (work_buffer, "ID ");
+ len = strlen (work_buffer);
+ pdf_add_stream (glyph, work_buffer, len);
+ pk_data = NEW (packet_length, unsigned char);
+ if ((read_len=fread (pk_data, 1, packet_length, pk_file))!=
+ packet_length) {
+ fprintf (stderr, "packet length should be %ld, but only %ld bytes were read\n",
+ packet_length, read_len);
+ ERROR ("Error reading character packet from PK file\n");
+ }
+ add_raster_data (glyph, w, h, dyn_f, (flag&8)>>3, pk_data, pk_data+packet_length);
+ RELEASE (pk_data);
+ sprintf (work_buffer, "\nEI");
+ len = strlen (work_buffer);
+ pdf_add_stream (glyph, work_buffer, len);
+ } /* Otherwise we embed an empty stream :-( */
+ sprintf (work_buffer, "\nQ");
+ len = strlen (work_buffer);
+ pdf_add_stream (glyph, work_buffer, len);
+ sprintf (work_buffer, "x%x", (int)code%256);
+ pdf_add_dict (char_procs, pdf_new_name (work_buffer),
+ pdf_ref_obj (glyph));
+ pdf_release_obj (glyph);
+ }
+ } else {
+ if (debug)
+ fprintf (stderr, "\npk_do_character: Skipping code=%ld, length=%ld\n", code,
+ packet_length);
+ do_skip (packet_length);
+ }
+}
+
+#define PK_XXX1 240
+#define PK_XXX2 241
+#define PK_XXX3 242
+#define PK_XXX4 243
+#define PK_YYY 244
+#define PK_POST 245
+#define PK_NO_OP 246
+#define PK_PRE 247
+
+static void embed_pk_font (int pk_id)
+{
+ if (verbose)
+ fprintf (stderr, "(%s", pk_fonts[pk_id].pk_file_name);
+ if ((pk_file = MFOPEN (pk_fonts[pk_id].pk_file_name,
+ FOPEN_RBIN_MODE))) {
+ int pk_command_byte;
+ pdf_obj *char_procs;
+ char_procs = pdf_new_dict();
+ while ((pk_command_byte = fgetc(pk_file)) >= 0 &&
+ pk_command_byte != PK_POST) {
+ if (pk_command_byte < 240) {
+ do_character (pk_command_byte, pk_id, char_procs);
+ } else /* A command byte */
+ switch (pk_command_byte) {
+ case PK_NO_OP:
+ break;
+ case PK_XXX1:
+ do_skip(get_unsigned_byte(pk_file));
+ break;
+ case PK_XXX2:
+ do_skip(get_unsigned_pair(pk_file));
+ break;
+ case PK_XXX3:
+ do_skip(get_unsigned_triple(pk_file));
+ break;
+ case PK_XXX4:
+ do_skip(get_unsigned_quad(pk_file));
+ break;
+ case PK_YYY:
+ do_skip(4);
+ break;
+ case PK_PRE:
+ do_preamble();
+ break;
+ }
+ }
+ MFCLOSE (pk_file);
+ if (verbose)
+ fprintf (stderr, ")\n");
+ pdf_add_dict (pk_fonts[pk_id].direct,
+ pdf_new_name ("CharProcs"),
+ pdf_ref_obj(char_procs));
+ pdf_release_obj (char_procs);
+ } else {
+ ERROR ("embed_pk_font: Failed to open PK file");
+ }
+}
+
+void pk_close_all (void)
+{
+ int i;
+ if (pk_encoding_ref)
+ pdf_release_obj (pk_encoding_ref);
+ for (i=0; i<num_pk_fonts; i++) {
+ embed_pk_font (i);
+ pdf_release_obj (pk_fonts[i].direct);
+ pdf_release_obj (pk_fonts[i].indirect);
+ RELEASE (pk_fonts[i].tex_name);
+ RELEASE (pk_fonts[i].pk_file_name);
+ RELEASE (pk_fonts[i].used_chars);
+ }
+ if (pk_fonts)
+ RELEASE (pk_fonts);
+}
+
diff --git a/Build/source/texk/dvipdfm/pkfont.h b/Build/source/texk/dvipdfm/pkfont.h
new file mode 100644
index 00000000000..9d3afac34ba
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pkfont.h
@@ -0,0 +1,38 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#ifndef _PK_FONT_H
+#define _PK_FONT_H
+
+#include "pdfobj.h"
+
+extern void pk_set_verbose(void);
+extern int pk_font (const char *tex_name, double ptsize, int tfm_id, char
+ *res_name);
+extern pdf_obj *pk_font_resource (int pk_id);
+extern char *pk_font_used (int pk_id);
+extern void pk_close_all (void);
+extern void pk_set_dpi (int dpi);
+
+#endif /* _PK_FONT_H */
diff --git a/Build/source/texk/dvipdfm/pngimage.c b/Build/source/texk/dvipdfm/pngimage.c
new file mode 100644
index 00000000000..b16ef3ed360
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pngimage.c
@@ -0,0 +1,146 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <kpathsea/config.h>
+#include <kpathsea/c-ctype.h>
+#include "system.h"
+#include "config.h"
+#include "mem.h"
+#include "pdfobj.h"
+
+#ifdef HAVE_LIBPNG
+#include <png.h>
+
+#define TMP "/tmp"
+
+static unsigned char sigbytes[4];
+int check_for_png (FILE *png_file)
+{
+ rewind (png_file);
+ if (fread (sigbytes, 1, sizeof(sigbytes), png_file) !=
+ sizeof(sigbytes) ||
+ (!png_check_sig (sigbytes, sizeof(sigbytes))))
+ return 0;
+ else
+ return 1;
+}
+
+pdf_obj *start_png_image (FILE *file, char *res_name)
+{
+ pdf_obj *result = NULL, *dict = NULL;
+ png_structp png_ptr;
+ png_infop info_ptr;
+ unsigned long width, height;
+ unsigned bit_depth, color_type;
+ rewind (file);
+ if (!(png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
+ NULL, NULL, NULL)) ||
+ !(info_ptr = png_create_info_struct (png_ptr))) {
+ fprintf (stderr, "\n\nLibpng failed to initialize\n");
+ if (png_ptr)
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
+ return NULL;
+ }
+ png_init_io (png_ptr, file);
+ /* png_set_sig_bytes (png_ptr, 0); */
+ /* Read PNG header */
+ png_read_info (png_ptr, info_ptr);
+ {
+ png_color_16 default_background;
+ png_color_16p file_background;
+
+ default_background.red=255; default_background.green=255;
+ default_background.blue=255; default_background.gray=0;
+ default_background.index = 0;
+
+ width = png_get_image_width(png_ptr, info_ptr);
+ height = png_get_image_height(png_ptr, info_ptr);
+ color_type = png_get_color_type(png_ptr, info_ptr);
+ bit_depth = png_get_bit_depth(png_ptr, info_ptr);
+ /* Convert paletted images to true color */
+ if (color_type == PNG_COLOR_TYPE_PALETTE) {
+ png_set_expand(png_ptr);
+ }
+ /* Limit image component depth to 8 bits */
+ if (bit_depth == 16) {
+ png_set_strip_16 (png_ptr);
+ }
+ if (png_get_bKGD(png_ptr, info_ptr, &file_background)) {
+ png_set_background(png_ptr, file_background,
+ PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
+ } else {
+ png_set_background(png_ptr, &default_background,
+ PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
+ }
+ }
+ { /* Read the image in raw RGB format */
+ int i, rowbytes, pdf_bit_depth;
+ png_bytep *rows;
+ png_read_update_info(png_ptr, info_ptr);
+ rows = NEW (height, png_bytep);
+ rowbytes = png_get_rowbytes(png_ptr, info_ptr);
+ for (i=0; i<height; i++) {
+ rows[i] = NEW (rowbytes, png_byte);
+ }
+ png_read_image(png_ptr, rows);
+ result = pdf_new_stream(STREAM_COMPRESS);
+ dict = pdf_stream_dict(result);
+ pdf_add_dict (dict, pdf_new_name ("Width"),
+ pdf_new_number(width));
+ pdf_add_dict (dict, pdf_new_name ("Height"),
+ pdf_new_number(height));
+ if (color_type == PNG_COLOR_TYPE_GRAY) {
+ pdf_bit_depth = bit_depth;
+ } else {
+ pdf_bit_depth = 8;
+ }
+ pdf_add_dict (dict, pdf_new_name ("BitsPerComponent"),
+ pdf_new_number(pdf_bit_depth));
+ if (color_type == PNG_COLOR_TYPE_GRAY ||
+ color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
+ pdf_add_dict (dict, pdf_new_name ("ColorSpace"),
+ pdf_new_name ("DeviceGray"));
+ } else{
+ pdf_add_dict (dict, pdf_new_name ("ColorSpace"),
+ pdf_new_name ("DeviceRGB"));
+ }
+ for (i=0; i<height; i++) {
+ pdf_add_stream (result, (char *) rows[i], rowbytes);
+ RELEASE (rows[i]);
+ }
+ RELEASE (rows);
+ }
+ { /* Cleanup */
+ if (info_ptr)
+ png_destroy_info_struct(png_ptr, &info_ptr);
+ if (png_ptr)
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
+ }
+ return result;
+}
+
+#endif /* HAVE_LIBPNG */
+
diff --git a/Build/source/texk/dvipdfm/pngimage.h b/Build/source/texk/dvipdfm/pngimage.h
new file mode 100644
index 00000000000..8d7f28591fb
--- /dev/null
+++ b/Build/source/texk/dvipdfm/pngimage.h
@@ -0,0 +1,40 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef PNGIMAGE_H
+
+#define PNGIMAGE_H
+
+#include <stdio.h>
+#include "pdfobj.h"
+
+#include "config.h"
+#ifdef HAVE_LIBPNG
+extern pdf_obj *start_png_image (FILE *file, char *res_name);
+extern int check_for_png (FILE *file);
+#endif
+
+#endif /* PNGIMAGE_H */
+
diff --git a/Build/source/texk/dvipdfm/psimage.c b/Build/source/texk/dvipdfm/psimage.c
new file mode 100644
index 00000000000..4d6497d1d93
--- /dev/null
+++ b/Build/source/texk/dvipdfm/psimage.c
@@ -0,0 +1,152 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <stdio.h>
+#include "system.h"
+#include "config.h"
+#include "mem.h"
+#include "mfileio.h"
+#include "pdfobj.h"
+#include "psimage.h"
+#include "epdf.h"
+
+static char * distiller_template = NULL;
+
+void set_distiller_template (char *s)
+{
+ distiller_template = NEW (strlen(s)+1, char);
+ strcpy (distiller_template, s);
+ return;
+}
+
+#define need(n) { unsigned k=(n); \
+ if (size+k>max_size) { \
+ max_size += k+128; \
+ result=RENEW(result,max_size,char); \
+ }}
+
+static char *last_dot (char *s)
+{
+ char *end;
+ end = s+strlen(s);
+ while (--end > s) {
+ if (*end == '.')
+ return end;
+ }
+ return NULL;
+}
+
+#ifdef HAVE_SYSTEM /* No need to build a command line if we don't
+ have system() */
+static char *build_command_line (char *psname, char *pdfname)
+{
+ char *result = NULL, *current;
+ int size = 0, max_size = 0;
+ if (distiller_template) {
+ need(strlen(distiller_template)+1);
+ for (current =distiller_template; *current != 0; current ++) {
+ if (*current == '%') {
+ switch (*(++current)) {
+ case 'o': /* Output file name */
+ need(strlen(pdfname));
+ strcpy (result+size, pdfname);
+ size+=strlen(pdfname);
+ break;
+ case 'i': /* Input filename */
+ need(strlen(psname));
+ strcpy (result+size, psname);
+ size+=strlen(psname);
+ break;
+ case 'b':
+ {
+ char *last;
+ need(strlen(psname));
+ if ((last = last_dot (psname))) {
+ strncpy (result+size, psname, last-psname);
+ size += last-psname;
+ } else {
+ strcpy (result+size, psname);
+ size += strlen(psname);
+ }
+ }
+ case 0:
+ break;
+ case '%':
+ result[size++] = '%';
+ }
+ } else {
+ result[size++] = *current;
+ }
+ result[size] = 0;
+ }
+ } else {
+ fprintf (stderr, "\nConfig file contains no template to perform PS -> PDF conversion\n");
+ }
+ return result;
+}
+#endif
+
+pdf_obj *ps_include (char *file_name,
+ struct xform_info *p,
+ char *res_name, double x_user, double y_user)
+{
+#ifdef HAVE_SYSTEM
+ pdf_obj *result = NULL;
+ char *tmp, *cmd;
+ FILE *pdf_file = NULL;
+ /* Get a full qualified tmp name */
+ tmp = tmpnam (NULL);
+ if ((cmd = build_command_line (file_name, tmp))) {
+ if (!system (cmd) && (pdf_file = MFOPEN (tmp, FOPEN_RBIN_MODE))) {
+ result = pdf_include_page (pdf_file, p, res_name);
+ } else {
+ fprintf (stderr, "\nConversion via ->%s<- failed\n", cmd);
+ }
+ if (pdf_file) {
+ MFCLOSE (pdf_file);
+ remove (tmp);
+ }
+ RELEASE (cmd);
+ }
+ return result;
+#else
+ fprintf (stderr, "\n\nCannot include PS/EPS files unless you have and enable system() command.\n");
+ return NULL;
+#endif
+}
+
+int check_for_ps (FILE *image_file)
+{
+ rewind (image_file);
+ mfgets (work_buffer, WORK_BUFFER_SIZE, image_file);
+ if (!strncmp (work_buffer, "%!", 2))
+ return 1;
+ return 0;
+}
+
+void psimage_close(void)
+{
+ if (distiller_template)
+ RELEASE (distiller_template);
+}
diff --git a/Build/source/texk/dvipdfm/psimage.h b/Build/source/texk/dvipdfm/psimage.h
new file mode 100644
index 00000000000..b01f85b2946
--- /dev/null
+++ b/Build/source/texk/dvipdfm/psimage.h
@@ -0,0 +1,39 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#ifndef PSIMAGE_H
+#define PSIMAGE_H
+
+#include "pdfobj.h"
+#include "pdfspecial.h"
+
+extern void set_distiller_template (char *s);
+extern pdf_obj *ps_include (char *file_name,
+ struct xform_info *p,
+ char *res_name,
+ double x_user, double y_user);
+
+extern int check_for_ps (FILE *image_file);
+extern void psimage_close (void);
+#endif
diff --git a/Build/source/texk/dvipdfm/psspecial.c b/Build/source/texk/dvipdfm/psspecial.c
new file mode 100644
index 00000000000..4b9329c8b69
--- /dev/null
+++ b/Build/source/texk/dvipdfm/psspecial.c
@@ -0,0 +1,265 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <stdlib.h>
+#include "system.h"
+#include "mem.h"
+#include "mfileio.h"
+#include "psspecial.h"
+#include "pdfparse.h"
+#include "pdfspecial.h"
+#include "psimage.h"
+#include "mpost.h"
+#include "pdfdoc.h"
+
+#define HOFFSET 1
+#define VOFFSET 2
+#define HSIZE 3
+#define VSIZE 4
+#define HSCALE 5
+#define VSCALE 6
+#define ANGLE 7
+#define CLIP 8
+#define LLX 9
+#define LLY 10
+#define URX 11
+#define URY 12
+#define RWI 13
+#define RHI 14
+
+struct keys
+{
+ char *key;
+ int id;
+} keys[] = {
+ {"hoffset", HOFFSET},
+ {"voffset", VOFFSET},
+ {"hsize", HSIZE},
+ {"vsize", VSIZE},
+ {"hscale", HSCALE},
+ {"vscale", VSCALE},
+ {"angle", ANGLE},
+ {"clip", CLIP},
+ {"llx", LLX},
+ {"lly", LLY},
+ {"urx", URX},
+ {"ury", URY},
+ {"rwi", RWI},
+ {"rhi", RHI},
+};
+
+static int parse_psfile (char **start, char *end, double x_user, double y_user)
+{
+ char *key, *val, *filename = NULL;
+ double hoffset = 0.0, voffset = 0.0;
+ double hsize = 0.0, vsize = 0.0;
+ int error = 0;
+ struct xform_info *p = new_xform_info();
+ skip_white(start, end);
+ parse_key_val (start, end, &key, &val);
+ if (key && val) {
+ filename = val;
+ RELEASE (key);
+ skip_white (start, end);
+ while (*start < end) {
+ parse_key_val (start, end, &key, &val);
+ if (key) {
+ int i;
+ for (i=0; i<sizeof(keys)/sizeof(keys[0]); i++) {
+ if (!strcmp (key, keys[i].key))
+ break;
+ }
+ if (i == sizeof(keys)/sizeof(keys[0])) {
+ fprintf (stderr, "\nUnknown key in special: %s\n", key);
+ break;
+ }
+ if (val) {
+ if (is_a_number(val)) {
+ switch (keys[i].id) {
+ case HOFFSET:
+ hoffset = atof (val);
+ break;
+ case VOFFSET:
+ voffset = atof (val);
+ break;
+ case HSIZE:
+ hsize = atof (val);
+ break;
+ case VSIZE:
+ vsize = atof (val);
+ break;
+ case HSCALE:
+ p -> xscale = atof(val)/100.0;
+ break;
+ case VSCALE:
+ p -> yscale = atof(val)/100.0;
+ break;
+ case ANGLE:
+ p -> rotate = atof(val)*M_PI/180.0;
+ break;
+ case LLX:
+ p -> user_bbox = 1;
+ p -> u_llx = atof(val);
+ break;
+ case LLY:
+ p -> user_bbox = 1;
+ p -> u_lly = atof(val);
+ break;
+ case URX:
+ p -> user_bbox = 1;
+ p -> u_urx = atof(val);
+ break;
+ case URY:
+ p -> user_bbox = 1;
+ p -> u_ury = atof(val);
+ break;
+ case RWI:
+ p -> width = atof(val)/10.0;
+ break;
+ case RHI:
+ p -> height = atof(val)/10.0;
+ break;
+ default:
+ if (keys[i].id == CLIP) {
+ fprintf (stderr, "\nPSfile key \"clip\" takes no value\n");
+ } else
+ fprintf (stderr, "\nPSfile key \"%s=%s\" not recognized\n",
+ key, val);
+ error = 1;
+ }
+ } else {
+ fprintf (stderr, "\nPSfile key \"%s\" assigned nonnumeric value\n", key);
+ error = 1;
+ }
+ RELEASE (val);
+ } else { /* Keywords without values */
+ switch (keys[i].id) {
+ case CLIP:
+ p -> clip = 1;
+ break;
+ default:
+ fprintf (stderr, "\nPSfile key \"%s\" needs a value\n",
+ key);
+ error = 1;
+ }
+ }
+ RELEASE (key);
+ } else {
+ fprintf (stderr, "\nInvalid keyword in PSfile special\n");
+ dump (*start, end);
+ break;
+ }
+ skip_white (start, end);
+ } /* If here and *start == end we got something */
+ if (*start == end && validate_image_xform_info (p)) {
+ pdf_obj *result;
+ result = embed_image (filename, p, x_user, y_user, NULL);
+ if (result)
+ pdf_release_obj (result);
+ }
+ } else {
+ fprintf (stderr, "\nPSfile special has no filename\n");
+ error = 1;
+ }
+ if (filename)
+ RELEASE (filename);
+ release_xform_info (p);
+ return !error;
+}
+
+static void do_texfig (char **start, char *end)
+{
+ char *filename;
+ struct xform_info *p;
+ skip_white (start, end);
+ if (*start < end && (filename = parse_val_ident (start, end))) {
+ p = new_xform_info (); /* Leave this empty */
+ p-> yscale = -1;
+ if (validate_image_xform_info (p)) {
+ pdf_obj *result;
+ result = embed_image (filename, p, 0.0, 0.0, NULL);
+ if (result)
+ pdf_release_obj (result);
+ }
+ release_xform_info (p);
+ RELEASE (filename);
+ } else {
+ fprintf (stderr, "Expecting filename here:\n");
+ dump (*start, end);
+ }
+}
+
+
+int ps_parse_special (char *buffer, UNSIGNED_QUAD size, double x_user,
+ double y_user)
+{
+ char *start = buffer, *end;
+ static int block_pending = 0;
+ static double pending_x=0.0, pending_y=0.0;
+ int result = 0;
+ end = buffer + size;
+ skip_white (&start, end);
+ if (!strncmp (start, "PSfile", strlen("PSfile")) ||
+ !strncmp (start, "psfile", strlen("PSfile"))) {
+ result = 1; /* This means it is a PSfile special, not that it was
+ successful */
+ parse_psfile(&start, end, x_user, y_user);
+ } else if (!strncmp (start, "ps::[begin]", strlen("ps::[begin]"))) {
+ start += strlen("ps::[begin]");
+ block_pending = 1;
+ pending_x = x_user;
+ pending_y = y_user;
+ result = 1; /* Likewise */
+ do_raw_ps_special (&start, end, 1, x_user, y_user);
+ } else if (!strncmp (start, "ps::[end]", strlen("ps::[end]"))) {
+ if (block_pending) {
+ start += strlen("ps::[end]");
+ do_raw_ps_special (&start, end, 1, pending_x, pending_y);
+ block_pending = 0;
+ } else {
+ fprintf (stderr, "\nps::[end] without ps::[begin] ignored.\n");
+ }
+ result = 1; /* Likewise */
+ } else if (!strncmp (start, "ps: plotfile", strlen("ps: plotfile"))) {
+ /* This is a bizarre, ugly special case.. Not really postscript
+ code */
+ start += strlen ("ps: plotfile");
+ result = 1;
+ do_texfig (&start, end);
+ } else if (!strncmp (start, "ps::", strlen("ps::")) ||
+ !strncmp (start, "PS::", strlen("PS::"))) {
+ /* dvipdfm doesn't distinguish between ps:: and ps: */
+ start += 4;
+ result = 1; /* Likewise */
+ do_raw_ps_special (&start, end, 1,
+ block_pending?pending_x:x_user, block_pending?pending_y:y_user);
+ } else if (!strncmp (start, "ps:", strlen("ps:")) ||
+ !strncmp (start, "PS:", strlen("PS:"))) {
+ start += 3;
+ result = 1; /* Likewise */
+ do_raw_ps_special (&start, end, 1,
+ block_pending?pending_x:x_user, block_pending?pending_y:y_user);
+ }
+ return result;
+}
diff --git a/Build/source/texk/dvipdfm/psspecial.h b/Build/source/texk/dvipdfm/psspecial.h
new file mode 100644
index 00000000000..fc71a07d9b2
--- /dev/null
+++ b/Build/source/texk/dvipdfm/psspecial.h
@@ -0,0 +1,35 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#ifndef PSSPECIAL_H
+# define PSSPECIAL_H
+
+#include "numbers.h"
+
+extern int ps_parse_special (char *buffer, UNSIGNED_QUAD size, double
+ x_user, double y_user);
+
+#endif /* PSSPECIAL_H */
+
+
diff --git a/Build/source/texk/dvipdfm/stamp-auto.in b/Build/source/texk/dvipdfm/stamp-auto.in
new file mode 100644
index 00000000000..26524463450
--- /dev/null
+++ b/Build/source/texk/dvipdfm/stamp-auto.in
@@ -0,0 +1 @@
+Mo Aug 22 08:29:58 CEST 2005
diff --git a/Build/source/texk/dvipdfm/standardenc.h b/Build/source/texk/dvipdfm/standardenc.h
new file mode 100644
index 00000000000..603f67c3d04
--- /dev/null
+++ b/Build/source/texk/dvipdfm/standardenc.h
@@ -0,0 +1,112 @@
+static char *standardencoding[256] = {
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", "space", "exclam", "quotedbl",
+ "numbersign", "dollar", "percent", "ampersand", "quoteright",
+ "parenleft", "parenright", "asterisk", "plus", "comma",
+ "hyphen", "period", "slash", "zero", "one",
+ "two", "three", "four", "five", "six",
+ "seven", "eight", "nine", "colon", "semicolon",
+ "less", "equal", "greater", "question", "at",
+ "A", "B", "C", "D", "E",
+ "F", "G", "H", "I", "J",
+ "K", "L", "M", "N", "O",
+ "P", "Q", "R", "S", "T",
+ "U", "V", "W", "X", "Y",
+ "Z", "bracketleft", "backslash", "bracketright", "asciicircum",
+ "underscore", "quoteleft", "a", "b", "c",
+ "d", "e", "f", "g", "h",
+ "i", "j", "k", "l", "m",
+ "n", "o", "p", "q", "r",
+ "s", "t", "u", "v", "w",
+ "x", "y", "z", "braceleft", "bar",
+ "braceright", "asciitilde", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", "exclamdown", "cent", "sterling", "fraction",
+ "yen", "florin", "section", "currency", "quotesingle",
+ "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi",
+ "fl", ".notdef", "endash", "dagger", "daggerdbl",
+ "periodcentered", ".notdef", "paragraph", "bullet", "quotesinglbase",
+ "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand",
+ ".notdef", "questiondown", ".notdef", "grave", "acute",
+ "circumflex", "tilde", "macron", "breve", "dotaccent",
+ "dieresis", ".notdef", "ring", "cedilla", ".notdef",
+ "hungarumlaut", "ogonek", "caron", "emdash", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ "AE", ".notdef", "ordfeminine", ".notdef", ".notdef",
+ ".notdef", ".notdef", "Lslash", "Oslash", "OE",
+ "ordmasculine", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", "ae", ".notdef", ".notdef", ".notdef",
+ "dotlessi", ".notdef", ".notdef", "lslash", "oslash",
+ "oe", "germandbls", ".notdef", ".notdef", ".notdef",
+ ".notdef"
+};
+
+static char *isoencoding[256] = {
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", "space", "exclam", "quotedbl",
+ "numbersign", "dollar", "percent", "ampersand", "quotesingle",
+ "parenleft", "parenright", "asterisk", "plus", "comma",
+ "hyphen", "period", "slash", "zero", "one",
+ "two", "three", "four", "five", "six",
+ "seven", "eight", "nine", "colon", "semicolon",
+ "less", "equal", "greater", "question", "at",
+ "A", "B", "C", "D", "E",
+ "F", "G", "H", "I", "J",
+ "K", "L", "M", "N", "O",
+ "P", "Q", "R", "S", "T",
+ "U", "V", "W", "X", "Y",
+ "Z", "bracketleft", "backslash", "bracketright", "asciicircum",
+ "underscore", "grave", "a", "b", "c",
+ "d", "e", "f", "g", "h",
+ "i", "j", "k", "l", "m",
+ "n", "o", "p", "q", "r",
+ "s", "t", "u", "v", "w",
+ "x", "y", "z", "braceleft", "bar",
+ "braceright", "asciitilde", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", "dotlessi",
+ "quoteleft", "quoteright", "circumflex", "tilde", "macron",
+ "breve", "dotaccent", "dieresis", ".notdef", "ring",
+ "cedilla", ".notdef", "hungarumlaut", "ogonek", "caron",
+ "space", "exclamdown", "cent", "sterling", "currency",
+ "yen", "brokenbar", "section", "dieresis", "copyright",
+ "ordfeminine", "guillemotleft", "logicalnot", "hyphen",
+ "registered",
+ "macron", "degree", "plusminus", "twosuperior", "threesuperior",
+ "acute", "mu", "paragraph", "periodcentered", "cedilla",
+ "onesuperior", "ordmasculine", "guillemotright", "onequarter",
+ "onehalf",
+ "threequarters", "questiondown", "Agrave", "Aacute", "Acircumflex",
+ "Atilde", "Adieresis", "Aring", "AE", "Ccedilla",
+ "Egrave", "Eacute", "Ecircumflex", "Edieresis", "Igrave",
+ "Iacute", "Icircumflex", "Idieresis", "Eth", "Ntilde",
+ "Ograve", "Oacute", "Ocircumflex", "Otilde", "Odieresis",
+ "multiply", "Oslash", "Ugrave", "Uacute", "Ucircumflex",
+ "Udieresis", "Yacute", "Thorn", "germandbls", "agrave",
+ "aacute", "acircumflex", "atilde", "adieresis", "aring",
+ "ae", "ccedilla", "egrave", "eacute", "ecircumflex",
+ "edieresis", "igrave", "iacute", "icircumflex", "idieresis",
+ "eth", "ntilde", "ograve", "oacute", "ocircumflex",
+ "otilde", "odieresis", "divide", "oslash", "ugrave",
+ "uacute", "ucircumflex", "udieresis", "yacute", "thorn",
+ "ydieresis"
+};
+
diff --git a/Build/source/texk/dvipdfm/system.h b/Build/source/texk/dvipdfm/system.h
new file mode 100644
index 00000000000..7eafe555533
--- /dev/null
+++ b/Build/source/texk/dvipdfm/system.h
@@ -0,0 +1,25 @@
+#ifndef _SYSTEM_H_
+
+#define _SYSTEM_H_
+
+#include <kpathsea/c-auto.h>
+#include <kpathsea/kpathsea.h>
+
+#ifdef WIN32
+# undef ERROR
+# undef NO_ERROR
+# undef RGB
+# undef CMYK
+# undef SETLINEJOIN
+# undef SETMITERLIMIT
+# undef SETLINECAP
+# pragma warning(disable : 4101 4018)
+#else
+# define __cdecl
+# define CDECL
+#endif /* WIN32 */
+
+#endif /* _SYSTEM_H_ */
+
+
+
diff --git a/Build/source/texk/dvipdfm/t1crypt.c b/Build/source/texk/dvipdfm/t1crypt.c
new file mode 100644
index 00000000000..59229382fd4
--- /dev/null
+++ b/Build/source/texk/dvipdfm/t1crypt.c
@@ -0,0 +1,26 @@
+unsigned short int r;
+unsigned short int c1 = 52845;
+unsigned short int c2 = 22719;
+
+#include "t1crypt.h"
+
+unsigned char t1_encrypt(unsigned char plain)
+{
+ unsigned char cipher;
+ cipher = (plain ^ (r >> 8));
+ r = (cipher+r)*c1 + c2;
+ return cipher;
+}
+
+void t1_crypt_init (unsigned short int key)
+{
+ r = key;
+}
+
+unsigned char t1_decrypt(unsigned char cipher)
+{
+ unsigned char plain;
+ plain = (cipher ^ (r>>8));
+ r = (cipher+r)*c1 + c2;
+ return plain;
+}
diff --git a/Build/source/texk/dvipdfm/t1crypt.h b/Build/source/texk/dvipdfm/t1crypt.h
new file mode 100644
index 00000000000..7f8a35ed905
--- /dev/null
+++ b/Build/source/texk/dvipdfm/t1crypt.h
@@ -0,0 +1,11 @@
+#ifndef T1CRYPT_H
+#define T1CRYPT_H
+
+#define EEKEY 55665u
+#define CHARKEY 4330u
+
+unsigned char t1_encrypt(unsigned char plain);
+void t1_crypt_init (unsigned short int key);
+unsigned char t1_decrypt(unsigned char cipher);
+
+#endif
diff --git a/Build/source/texk/dvipdfm/t1fonts.map b/Build/source/texk/dvipdfm/t1fonts.map
new file mode 100644
index 00000000000..7638e13f3f4
--- /dev/null
+++ b/Build/source/texk/dvipdfm/t1fonts.map
@@ -0,0 +1,240 @@
+% original t1fonts.map -- Constructed by M. Wicks, 8/17/99
+%
+% Format is as follows:
+% TeX-name encoding AFM-name PFB-name
+% The default behavior is to use the font's built-in
+% encoding, to use the TeX-name as the AFM-name, and
+% to use the AFM-name as the PFB-name.
+% The word "default" may be used in any field to
+% specify the default behavior. You can
+% also say "none", in the PFB field, for example
+% to say that no PFB should be loaded
+%
+% The following entries are used to force an encoding to work around several
+% bugs in Acrobat reader. The ot1 encoding is used to supply an encoding
+% external to that the the type 1 font definition. The seems to be necessary
+% to be able to search ligatures, for example. The "-r" option
+% is used to remap the character positions that Adobe normally does
+% not use to higher positions. This seems to fix a variety of problems
+%
+cmr10 ot1 -r
+cmr12 ot1 -r
+cmr17 ot1 -r
+cmr6 ot1 -r
+cmr7 ot1 -r
+cmr8 ot1 -r
+cmr9 ot1 -r
+% cmr5 is encoded somewhat differently
+cmr5 -r
+% Bold
+cmbx10 ot1 -r
+cmbx12 ot1 -r
+cmbx6 ot1 -r
+cmbx7 ot1 -r
+cmbx8 ot1 -r
+cmbx9 ot1 -r
+% Symbol fonts are remapped, but not reencoded
+cmex10 -r
+cmbsy10 -r
+cmsy10 -r
+cmsy9 -r
+cmsy8 -r
+cmsy7 -r
+cmsy6 -r
+cmsy5 -r
+lasy10 -r
+lasy9 -r
+lasy8 -r
+lasy7 -r
+lasy6 -r
+lasy5 -r
+cmbsy7 -r
+cmbsy5 -r
+euex10 -r
+eufm10 -r
+eufm7 -r
+eufm5 -r
+eufb10 -r
+eufb7 -r
+eufb5 -r
+eurb10 -r
+eurm10 -r
+eurb7 -r
+eurm7 -r
+eurb5 -r
+eurm5 -r
+msam10 -r
+xycmat10 -r
+xycmbt10 -r
+xtdash10 -r
+xycirc10 -r
+xyatip10 -r
+xybtip10 -r
+% Likewise for math italic
+cmmi12 -r
+cmmi10 -r
+cmmib10 -r
+cmmi9 -r
+cmmi8 -r
+cmmi7 -r
+cmmi6 -r
+cmmi5 -r
+% Misc
+cmb10 ot1 -r
+cmbxsl10 ot1 -r
+cmbxti10 ot1alt -r
+cmdunh10 ot1 -r
+cmff10 ot1alt -r
+cmfi10 ot1alt -r
+cmfib8 ot1alt -r
+cmssbx10 ot1 -r
+cmssdc10 ot1 -r
+cmssq8 ot1 -r
+cmssqi8 ot1 -r
+cmu10 ot1alt -r
+cmvtt10 ot1 -r
+lcmss8 ot1 -r
+lcmssb8 ot1 -r
+lcmssi8 ot1 -r
+% tt fonts
+cmtt10 -r
+cmtt12 -r
+cmtt8 -r
+cmtt9 -r
+% Italic
+cmti10 ot1alt -r
+cmti12 ot1alt -r
+cmti7 ot1alt -r
+cmti8 ot1alt -r
+cmti9 ot1alt -r
+% Slanted
+cmsl10 ot1 -r
+cmsl12 ot1 -r
+cmsl8 ot1 -r
+cmsl9 ot1 -r
+% Roman sanserif
+cmss10 ot1 -r
+cmss12 ot1 -r
+cmss17 ot1 -r
+cmss8 ot1 -r
+cmss9 ot1 -r
+% Sans Serif
+cmssi10 ot1 -r
+cmssi12 ot1 -r
+cmssi17 ot1 -r
+cmssi8 ot1 -r
+cmssi9 ot1 -r
+%
+
+% CharterBT-Bold
+bchb8r 8r bchb8a
+% CharterBT-BoldItalic
+bchbi8r 8r bchbi8a
+% CharterBT-Roman
+bchr8r 8r bchr8a
+% CharterBT-Italic
+bchri8r 8r bchri8a
+% AvantGarde-Demi
+pagd8r 8r pagd8a
+% AvantGarde-DemiOblique
+pagdo8r 8r pagdo8a
+% AvantGarde-Book
+pagk8r 8r pagk8a
+% AvantGarde-BookOblique
+pagko8r 8r pagko8a
+% Bookman-Demi
+pbkd8r 8r pbkd8a
+% Bookman-DemiItalic
+pbkdi8r 8r pbkdi8a
+% Bookman-Light
+pbkl8r 8r pbkl8a
+% Bookman-LightItalic
+pbkli8r 8r pbkli8a
+% Courier-Bold
+pcrb8r 8r Courier-Bold
+% Courier-BoldOblique
+pcrbo8r 8r Courier-BoldOblique
+% Courier
+pcrr8r 8r Courier
+% Narrow Courier
+pcrr8rn 8r Courier -e 0.85
+% Courier-Oblique
+pcrro8r 8r Courier-Oblique
+% Helvetica-Bold
+phvb8r 8r Helvetica-Bold
+% Helvetica-Narrow-Bold
+phvb8rn 8r Helvetica-Narrow-Bold
+% Helvetica-BoldOblique
+phvbo8r 8r phvbo8a
+% Helvetica-Narrow-BoldOblique
+phvbo8rn 8r Helvetica-Narrow-BoldOblique
+%
+phvbon8r 8r Helvetica-BoldOblique -e 0.82
+phvbrn8r 8r Helvetica-Bold -e 0.82
+% Helvetica
+phvr8r 8r phvr8a
+% Helvetica-Narrow
+phvr8rn 8r Helvetica-Narrow
+% Helvetica-Oblique
+phvro8r 8r Helvetica-Oblique
+% Helvetica-Narrow-Oblique
+phvro8rn 8r Helvetica-Narrow-Oblique
+phvron8r 8r Helvetica-Oblique -e 0.82
+phvrrn8r Helvetica -e 0.82
+% NewCenturySchlbk-Bold
+pncb8r 8r pncb8a
+% NewCenturySchlbk-BoldItalic
+pncbi8r 8r pncbi8a
+pncbo8r 8r pncb8a -s 0.167
+% NewCenturySchlbk-Roman
+pncr8r 8r pncr8a
+% NewCenturySchlbk-Italic
+pncri8r 8r pncri8a
+pncro8r 8r pncri8a -s 0.167
+% Palatino-Bold
+pplb8r 8r pplb8a
+% Palatino-BoldItalic
+pplbi8r 8r pplbi8a
+pplbo8r 8r pplb8a -s 0.167
+pplbu8r 8r pplbi8a -s -0.1763
+% Palatino-Roman
+pplr8r 8r pplr8a
+% Palatino-Italic
+pplri8r 8r pplri8a
+pplro8r 8r pplr8a -s 0.167
+pplrre8r 8r pplr8a -e 1.2
+pplrrn8r 8r pplr8a -e 0.82
+pplru8r 8r pplri8a -s -0.1763
+% Symbol
+psyr none Symbol
+psyro none Symbol -s 0.167
+% Times-Bold
+ptmb8r 8r Times-Bold
+% Times-BoldItalic
+ptmbi8r 8r Times-Italic
+% Times-Roman
+ptmr8r 8r Times-Roman
+% Times-Italic
+ptmri8r 8r Times-Italic
+ptmbo8r 8r Times-Bold -s 0.167
+ptmro8r 8r Times-Roman -s 0.167
+ptmrre8r 8r Times-Roman -e 1.2
+ptmrrn8r 8r Times-Roman -e 0.82
+% Utopia-Bold
+putb8r 8r putb8a
+% Utopia-BoldItalic
+putbi8r 8r putbi8a
+% Utopia-Regular
+putr8r 8r putr8a
+% Utopia-Italic
+putri8r 8r putri8a
+putbo8r 8r putb8a -s 0.167
+putro8r 8r putr8a -s 0.167
+% ZapfChancery-MediumItalic
+pzcmi8r 8r pzcmi8a
+% ZapfDingbats
+pzdr none ZapfDingbats
+% LaTeX Fonts having short file names
+lcirclew10 none lcirclew -r
+lcircle10 none lcircle1 -r
+line10 -r
diff --git a/Build/source/texk/dvipdfm/tfm.c b/Build/source/texk/dvipdfm/tfm.c
new file mode 100644
index 00000000000..d325f405e0e
--- /dev/null
+++ b/Build/source/texk/dvipdfm/tfm.c
@@ -0,0 +1,714 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <stdio.h>
+#include "system.h"
+#include "mem.h"
+#include "error.h"
+#include "mfileio.h"
+#include "pdflimits.h"
+#include "numbers.h"
+#include "tfm.h"
+#include "config.h"
+
+#define FWBASE ((double) (1<<20))
+
+static char tfm_verbose = 0;
+static char tfm_debug = 0;
+
+/* TFM Record structure
+ Multiple TFM's may be read in at once */
+
+struct a_tfm
+{
+ UNSIGNED_QUAD wlenfile, wlenheader;
+ UNSIGNED_QUAD bc, ec;
+ UNSIGNED_QUAD nwidths, nheights, ndepths;
+ UNSIGNED_QUAD nitcor, nlig, nkern, nextens;
+ UNSIGNED_QUAD nfonparm;
+ UNSIGNED_QUAD font_direction; /* Used only in OFMs. TFMs don't have
+ this field*/
+ UNSIGNED_QUAD nco, ncw, npc;
+ SIGNED_QUAD *header;
+ UNSIGNED_QUAD *char_info;
+ UNSIGNED_PAIR *width_index;
+ UNSIGNED_BYTE *height_index;
+ UNSIGNED_BYTE *depth_index;
+ SIGNED_QUAD *width;
+ SIGNED_QUAD *height;
+ SIGNED_QUAD *depth;
+ char *tex_name;
+ fixword *unpacked_widths;
+ fixword *unpacked_heights;
+ fixword *unpacked_depths;
+};
+
+void a_tfm_init (struct a_tfm *a_tfm)
+{
+ a_tfm->header = NULL;
+ a_tfm->char_info = NULL;
+ a_tfm->width_index = NULL;
+ a_tfm->height_index = NULL;
+ a_tfm->depth_index = NULL;
+ a_tfm->width = NULL;
+ a_tfm->height = NULL;
+ a_tfm->depth = NULL;
+ a_tfm->unpacked_widths = NULL;
+ a_tfm->unpacked_heights = NULL;
+ a_tfm->unpacked_depths = NULL;
+}
+
+
+struct a_tfm *tfm = NULL;
+static unsigned numtfms = 0, max_tfms = 0; /* numtfms should equal
+ numfonts in dvi.c */
+static void tfms_need (unsigned n)
+{
+ if (n > max_tfms) {
+ max_tfms = MAX (max_tfms+MAX_FONTS, n);
+ tfm = RENEW (tfm, max_tfms, struct a_tfm);
+ }
+}
+
+/* External Routine */
+
+void tfm_set_verbose (void)
+{
+ tfm_verbose += 1;
+}
+
+void tfm_set_debug (void)
+{
+ tfm_verbose = 1;
+ tfm_debug = 1;
+}
+
+static UNSIGNED_PAIR sum_of_tfm_sizes (struct a_tfm *a_tfm)
+{
+ unsigned long result = 6;
+ result += (a_tfm -> ec - a_tfm -> bc + 1);
+ result += a_tfm -> wlenheader;
+ result += a_tfm -> nwidths;
+ result += a_tfm -> nheights;
+ result += a_tfm -> ndepths;
+ result += a_tfm -> nitcor;
+ result += a_tfm -> nlig;
+ result += a_tfm -> nkern;
+ result += a_tfm -> nextens;
+ result += a_tfm -> nfonparm;
+ return result;
+}
+
+static SIGNED_QUAD sum_of_ofm_sizes (struct a_tfm *a_tfm)
+{
+ unsigned long result = 14;
+ result += 2*(a_tfm -> ec - a_tfm -> bc + 1);
+ result += a_tfm -> wlenheader;
+ result += a_tfm -> nwidths;
+ result += a_tfm -> nheights;
+ result += a_tfm -> ndepths;
+ result += a_tfm -> nitcor;
+ result += 2*(a_tfm -> nlig);
+ result += a_tfm -> nkern;
+ result += 2*(a_tfm -> nextens);
+ result += a_tfm -> nfonparm;
+ return result;
+}
+
+
+static void get_sizes (FILE *tfm_file, SIGNED_QUAD tfm_file_size,
+ struct a_tfm *a_tfm)
+{
+ a_tfm -> wlenfile = get_unsigned_pair (tfm_file);
+ a_tfm -> wlenheader = get_unsigned_pair (tfm_file);
+ a_tfm -> bc = get_unsigned_pair (tfm_file);
+ a_tfm -> ec = get_unsigned_pair (tfm_file);
+ if (a_tfm -> ec < a_tfm -> bc) {
+ ERROR ("TFM file error (ec < bc)\n");
+ }
+ a_tfm -> nwidths = get_unsigned_pair (tfm_file);
+ a_tfm -> nheights = get_unsigned_pair (tfm_file);
+ a_tfm -> ndepths = get_unsigned_pair (tfm_file);
+ a_tfm -> nitcor = get_unsigned_pair (tfm_file);
+ a_tfm -> nlig = get_unsigned_pair (tfm_file);
+ a_tfm -> nkern = get_unsigned_pair (tfm_file);
+ a_tfm -> nextens = get_unsigned_pair (tfm_file);
+ a_tfm -> nfonparm = get_unsigned_pair (tfm_file);
+ if (tfm_debug) {
+ fprintf (stderr, "\nComputed size (words)%d\n", sum_of_tfm_sizes (a_tfm));
+ fprintf (stderr, "Stated size (words)%ld\n", a_tfm -> wlenfile);
+ fprintf (stderr, "Actual size (bytes)%ld\n", tfm_file_size);
+ }
+ if ( a_tfm -> wlenfile != tfm_file_size/4 ||
+ sum_of_tfm_sizes (a_tfm) != a_tfm -> wlenfile) {
+ if (tfm_file_size/4 > a_tfm -> wlenfile) {
+ fprintf (stderr, "\nHmm. A TFM file is larger than it says it is!");
+ fprintf (stderr, "\nProceeding nervously...\n");
+ } else {
+ ERROR ("TFM file problem. Table sizes don't agree.\n");
+ }
+ }
+ return;
+}
+
+static int ofm_get_sizes (FILE *ofm_file, UNSIGNED_QUAD ofm_file_size,
+ struct a_tfm *a_tfm)
+{
+ SIGNED_QUAD level;
+ level = get_signed_quad (ofm_file);
+ a_tfm -> wlenfile = get_signed_quad (ofm_file);
+ a_tfm -> wlenheader = get_signed_quad (ofm_file);
+ a_tfm -> bc = get_signed_quad (ofm_file);
+ a_tfm -> ec = get_signed_quad (ofm_file);
+ if (a_tfm -> ec < a_tfm -> bc) {
+ ERROR ("OFM file error (ec < bc)\n");
+ }
+ a_tfm -> nwidths = get_signed_quad (ofm_file);
+ a_tfm -> nheights = get_signed_quad (ofm_file);
+ a_tfm -> ndepths = get_signed_quad (ofm_file);
+ a_tfm -> nitcor = get_signed_quad (ofm_file);
+ a_tfm -> nlig = get_signed_quad (ofm_file);
+ a_tfm -> nkern = get_signed_quad (ofm_file);
+ a_tfm -> nextens = get_signed_quad (ofm_file);
+ a_tfm -> nfonparm = get_signed_quad (ofm_file);
+ a_tfm -> font_direction = get_signed_quad (ofm_file);
+ if (a_tfm->font_direction) {
+ fprintf (stderr, "Warning: I may be interpreting a font direction incorrectly.\n");
+ }
+ if (level == 0) {
+ if (a_tfm -> wlenfile != ofm_file_size/4 ||
+ sum_of_ofm_sizes (a_tfm) != a_tfm -> wlenfile) {
+ ERROR ("OFM file problem. Table sizes don't agree.\n");
+ }
+ if (level == 0 && tfm_debug) {
+ fprintf (stderr, "Computed size (words)%ld\n", sum_of_ofm_sizes (a_tfm));
+ fprintf (stderr, "Stated size (words)%ld\n", a_tfm -> wlenfile);
+ fprintf (stderr, "Actual size (bytes)%ld\n", ofm_file_size);
+ }
+ } else if (level == 1) {
+ a_tfm -> nco = get_signed_quad (ofm_file);
+ a_tfm -> ncw = get_signed_quad (ofm_file);
+ a_tfm -> npc = get_signed_quad (ofm_file);
+ seek_absolute (ofm_file, 4*(a_tfm -> nco));
+ } else {
+ ERROR ("Can't handle OFM files with level > 1");
+ }
+ return (int) (level);
+}
+
+static void dump_sizes (struct a_tfm *a_tfm)
+{
+ fprintf (stderr, "\nwlenfile: %ld, ", a_tfm -> wlenfile);
+ fprintf (stderr, "wlenheader: %ld\n", a_tfm -> wlenheader);
+ fprintf (stderr, "bc: %ld, ", a_tfm -> bc);
+ fprintf (stderr, "ec: %ld, ", a_tfm -> ec);
+ fprintf (stderr, "nwidths: %ld, ", a_tfm -> nwidths);
+ fprintf (stderr, "nheights: %ld, ", a_tfm -> nheights);
+ fprintf (stderr, "ndepths: %ld\n", a_tfm -> ndepths);
+ fprintf (stderr, "nitcor: %ld, ", a_tfm -> nitcor);
+ fprintf (stderr, "nlig: %ld, ", a_tfm -> nlig);
+ fprintf (stderr, "nkern: %ld, ", a_tfm -> nkern);
+ fprintf (stderr, "nextens: %ld, ", a_tfm -> nextens);
+ fprintf (stderr, "nfonparm: %ld\n", a_tfm -> nfonparm);
+ return;
+}
+
+
+static void get_fix_word_array (FILE *tfm_file, SIGNED_QUAD *a_word,
+ SIGNED_QUAD length)
+{
+ unsigned i;
+ for (i=0; i< length; i++) {
+ a_word[i] = get_signed_quad (tfm_file);
+ }
+ return;
+}
+
+static void get_unsigned_quad_array (FILE *tfm_file, UNSIGNED_QUAD *a_word,
+ SIGNED_QUAD length)
+{
+ unsigned i;
+ for (i=0; i< length; i++) {
+ a_word[i] = get_unsigned_quad (tfm_file);
+ }
+ return;
+}
+
+static void do_fix_word_array (FILE *tfm_file, SIGNED_QUAD **a, SIGNED_QUAD len)
+{
+ if (len != 0) {
+ *a = NEW (len, SIGNED_QUAD);
+ get_fix_word_array (tfm_file, *a, len);
+ } else
+ *a = NULL;
+ return;
+}
+
+static void do_unsigned_quad_array (FILE *tfm_file, UNSIGNED_QUAD **a, UNSIGNED_PAIR len)
+{
+ if (len != 0) {
+ *a = NEW (len, UNSIGNED_QUAD);
+ get_unsigned_quad_array (tfm_file, *a, len);
+ } else
+ *a = NULL;
+ return;
+}
+static void unpack_widths(struct a_tfm *a_tfm)
+{
+ int i;
+ UNSIGNED_QUAD charinfo;
+ UNSIGNED_PAIR width_index;
+ a_tfm -> unpacked_widths = NEW (256, fixword);
+ for (i=0; i<256; i++) {
+ (a_tfm ->unpacked_widths)[i] = 0;
+ }
+ for (i=(a_tfm->bc); i<=(a_tfm->ec); i++ ) {
+ charinfo = (a_tfm->char_info)[i-(a_tfm->bc)];
+ width_index = (charinfo / 16777216ul);
+ (a_tfm->unpacked_widths)[i] = (a_tfm->width)[width_index];
+ }
+ return;
+}
+
+static void unpack_heights(struct a_tfm *a_tfm)
+{
+ int i;
+ UNSIGNED_QUAD charinfo;
+ UNSIGNED_PAIR height_index;
+ a_tfm -> unpacked_heights = NEW (256, fixword);
+ for (i=0; i<256; i++) {
+ (a_tfm ->unpacked_heights)[i] = 0;
+ }
+ for (i=(a_tfm->bc); i<=(a_tfm->ec); i++ ) {
+ charinfo = (a_tfm->char_info)[i-(a_tfm->bc)];
+ height_index = (charinfo / 0x100000ul) & 0xf;
+ (a_tfm->unpacked_heights)[i] = (a_tfm->height)[height_index];
+ }
+ return;
+}
+
+static void unpack_depths(struct a_tfm *a_tfm)
+{
+ int i;
+ UNSIGNED_QUAD charinfo;
+ UNSIGNED_PAIR depth_index;
+ a_tfm -> unpacked_depths = NEW (256, fixword);
+ for (i=0; i<256; i++) {
+ (a_tfm ->unpacked_depths)[i] = 0;
+ }
+ for (i=(a_tfm->bc); i<=(a_tfm->ec); i++ ) {
+ charinfo = (a_tfm->char_info)[i-(a_tfm->bc)];
+ depth_index = (charinfo / 0x10000ul) & 0xf;
+ (a_tfm->unpacked_depths)[i] = (a_tfm->depth)[depth_index];
+ }
+ return;
+}
+
+static void get_arrays (FILE *tfm_file, struct a_tfm *a_tfm)
+{
+ if (tfm_debug) fprintf (stderr, "Reading %ld word header\n",
+ a_tfm->wlenheader);
+ do_fix_word_array (tfm_file, &(a_tfm -> header), a_tfm -> wlenheader);
+ if (tfm_debug) fprintf (stderr, "Reading %ld char_infos\n",
+ (a_tfm->ec)-(a_tfm->bc)+1);
+ do_unsigned_quad_array (tfm_file, &(a_tfm -> char_info), (a_tfm->ec)-(a_tfm->bc)+1);
+ if (tfm_debug) fprintf (stderr, "Reading %ld widths\n",
+ a_tfm -> nwidths);
+ do_fix_word_array (tfm_file, &(a_tfm -> width), a_tfm -> nwidths);
+ if (tfm_debug) fprintf (stderr, "Reading %ld heights\n",
+ a_tfm -> nheights);
+ do_fix_word_array (tfm_file, &(a_tfm -> height), a_tfm -> nheights);
+ if (tfm_debug) fprintf (stderr, "Reading %ld depths\n",
+ a_tfm -> ndepths);
+ do_fix_word_array (tfm_file, &(a_tfm -> depth), a_tfm -> ndepths);
+ unpack_widths (a_tfm);
+ unpack_heights (a_tfm);
+ unpack_depths (a_tfm);
+ return;
+}
+
+static void do_ofm_zero_char_info (FILE *tfm_file, struct a_tfm *a_tfm)
+{
+ unsigned i;
+ UNSIGNED_QUAD num_chars;
+ num_chars = a_tfm->ec - a_tfm->bc + 1;
+ if (num_chars != 0) {
+ a_tfm -> width_index = NEW (num_chars, UNSIGNED_PAIR);
+ a_tfm -> height_index = NEW (num_chars, UNSIGNED_BYTE);
+ a_tfm -> depth_index = NEW (num_chars, UNSIGNED_BYTE);
+ a_tfm -> unpacked_widths = NEW (a_tfm->bc+num_chars, fixword);
+ a_tfm -> unpacked_heights = NEW (a_tfm->bc+num_chars, fixword);
+ a_tfm -> unpacked_depths = NEW (a_tfm->bc+num_chars, fixword);
+ }
+ for (i=0; i<num_chars; i++) {
+ (a_tfm->width_index)[i] = get_unsigned_pair (tfm_file);
+ (a_tfm->height_index)[i] = get_unsigned_byte (tfm_file);
+ (a_tfm->depth_index)[i] = get_unsigned_byte (tfm_file);
+ /* Ignore remaining quad */
+ get_unsigned_quad (tfm_file);
+ }
+}
+
+static void do_ofm_one_char_info (FILE *tfm_file, struct a_tfm *a_tfm)
+{
+ UNSIGNED_QUAD i;
+ UNSIGNED_QUAD num_char_infos, char_infos_read;
+ UNSIGNED_QUAD num_chars;
+ UNSIGNED_QUAD char_info_size;
+ char_info_size = 3 + (a_tfm->npc/2);
+ num_char_infos = (a_tfm -> ncw) / char_info_size;
+ num_chars = (a_tfm->ec - a_tfm ->bc) + 1;
+ if (tfm_debug)
+ fprintf (stderr, "\nReading %ld level 1 chars\n", num_chars);
+ if (num_chars != 0) {
+ a_tfm -> width_index = NEW (num_chars, UNSIGNED_PAIR);
+ a_tfm -> height_index = NEW (num_chars, UNSIGNED_BYTE);
+ a_tfm -> depth_index = NEW (num_chars, UNSIGNED_BYTE);
+ a_tfm -> unpacked_widths = NEW (a_tfm->bc+num_chars, fixword);
+ a_tfm -> unpacked_heights = NEW (a_tfm->bc+num_chars, fixword);
+ a_tfm -> unpacked_depths = NEW (a_tfm->bc+num_chars, fixword);
+ }
+ for (i=0, char_infos_read = 0; i<num_chars && char_infos_read < num_char_infos; i++) {
+ int repeats, j;
+ (a_tfm->width_index)[i] = get_unsigned_pair (tfm_file);
+ (a_tfm->height_index)[i] = get_unsigned_byte (tfm_file);
+ (a_tfm->depth_index)[i] = get_unsigned_byte (tfm_file);
+ /* Ignore next quad */
+ get_unsigned_quad (tfm_file);
+ repeats = get_unsigned_pair (tfm_file);
+ /* Skip params */
+ for (j=0; j<a_tfm->npc; j++) {
+ get_unsigned_pair (tfm_file);
+ }
+ /* Remove word padding if necessary */
+ if (ISEVEN (a_tfm->npc)){
+ get_unsigned_pair (tfm_file);
+ }
+ char_infos_read += 1;
+ if (i+repeats > num_chars)
+ ERROR ("repeats causes number of characters to be exceeded");
+ for (j=0; j<repeats; j++) {
+ a_tfm->width_index[i+j+1] = a_tfm->width_index[i];
+ a_tfm->height_index[i+j+1] = a_tfm->height_index[i];
+ a_tfm->depth_index[i+j+1] = a_tfm->depth_index[i];
+ }
+ /* Skip ahead because we have already handled repeats */
+ i += repeats;
+ }
+ if (tfm_debug) {
+ fprintf (stderr, "\npackets read = %ld/%ld\n", char_infos_read,
+ num_char_infos);
+ fprintf (stderr, "\ncharacters defined = %ld/%ld\n", i, num_chars);
+ }
+}
+
+static void ofm_unpack_arrays (struct a_tfm *a_tfm, UNSIGNED_QUAD num_chars)
+{
+ unsigned i;
+ for (i=0; i<num_chars; i++) {
+ (a_tfm->unpacked_widths)[a_tfm->bc+i] = (a_tfm->width)[(a_tfm->width_index)[i]];
+ (a_tfm->unpacked_heights)[a_tfm->bc+i] = (a_tfm->height)[(a_tfm->height_index)[i]];
+ (a_tfm->unpacked_depths)[a_tfm->bc+i] = (a_tfm->depth)[(a_tfm->depth_index)[i]];
+ }
+}
+
+static void ofm_get_arrays (FILE *tfm_file, struct a_tfm *a_tfm, int level)
+{
+ switch (level) {
+ case 0:
+ if (tfm_debug) fprintf (stderr, "Reading %ld word header\n",
+ a_tfm->wlenheader);
+ do_fix_word_array (tfm_file, &(a_tfm -> header), a_tfm ->
+ wlenheader);
+ if (tfm_debug) fprintf (stderr, "Reading %ld char_infos\n",
+ (a_tfm->ec)-(a_tfm->bc)+1);
+ do_ofm_zero_char_info (tfm_file, a_tfm);
+ break;
+ case 1:
+ if (tfm_debug) fprintf (stderr, "Reading %ld char_infos words\n",
+ a_tfm->ncw);
+ do_ofm_one_char_info (tfm_file, a_tfm);
+ break;
+ default:
+ ERROR ("level != 0 or 1 in ofm_get_arrays()");
+ }
+ if (tfm_debug) fprintf (stderr, "Reading %ld widths\n",
+ a_tfm -> nwidths);
+ do_fix_word_array (tfm_file, &(a_tfm -> width), a_tfm -> nwidths);
+ if (tfm_debug) fprintf (stderr, "Reading %ld heights\n",
+ a_tfm -> nheights);
+ do_fix_word_array (tfm_file, &(a_tfm -> height), a_tfm -> nheights);
+ if (tfm_debug) fprintf (stderr, "Reading %ld depths\n",
+ a_tfm -> ndepths);
+ do_fix_word_array (tfm_file, &(a_tfm -> depth), a_tfm -> ndepths);
+ ofm_unpack_arrays (a_tfm, (a_tfm->ec)-(a_tfm->bc)+1);
+ return;
+}
+
+static void get_ofm (FILE *ofm_file, UNSIGNED_QUAD ofm_file_size,
+ struct a_tfm *a_tfm)
+{
+ int level;
+ level = ofm_get_sizes (ofm_file, ofm_file_size, a_tfm);
+ ofm_get_arrays (ofm_file, a_tfm, level);
+ return;
+}
+
+static void get_tfm (FILE *tfm_file, UNSIGNED_QUAD tfm_file_size,
+ struct a_tfm *a_tfm)
+{
+ get_sizes (tfm_file, tfm_file_size, a_tfm);
+ get_arrays (tfm_file, a_tfm);
+ return;
+}
+
+/* External Routine */
+
+int tfm_open (const char *tfm_name)
+{
+ FILE *tfm_file;
+ int i;
+ UNSIGNED_QUAD tfm_file_size;
+ char *full_tfm_file_name;
+ for (i=0; i<numtfms; i++) {
+ if (!strcmp (tfm_name, tfm[i].tex_name))
+ break;
+ }
+ if (i == numtfms) { /* Name hasn't already been loaded */
+ if ((full_tfm_file_name = kpse_find_tfm (tfm_name))) {
+ tfms_need (numtfms+1);
+ a_tfm_init (tfm+numtfms);
+ if (!(tfm_file = MFOPEN (full_tfm_file_name, FOPEN_RBIN_MODE))) {
+ fprintf (stderr, "\n%s: ", tfm_name);
+ ERROR ("Specified TFM file cannot be opened");
+ }
+ if (tfm_verbose == 1)
+ fprintf (stderr, "(TFM:%s", tfm_name);
+ if (tfm_verbose > 1)
+ fprintf (stderr, "(TFM:%s", full_tfm_file_name);
+ if ((tfm_file_size = file_size(tfm_file)) < 24) {
+ ERROR ("TFM file too small to be a valid file\n");
+ }
+ get_tfm (tfm_file, tfm_file_size, &tfm[numtfms]);
+#ifdef HAVE_OMEGA_FORMATS
+ } else if ((full_tfm_file_name = kpse_find_ofm (tfm_name))) {
+ tfms_need (numtfms+1);
+ a_tfm_init (tfm+numtfms);
+ if (!(tfm_file = MFOPEN (full_tfm_file_name, FOPEN_RBIN_MODE))) {
+ fprintf (stderr, "\n%s: ", tfm_name);
+ ERROR ("OFM file cannot be opened");
+ }
+ if (tfm_verbose == 1)
+ fprintf (stderr, "(OFM:%s", tfm_name);
+ if (tfm_verbose > 1)
+ fprintf (stderr, "(OFM:%s", full_tfm_file_name);
+ if ((tfm_file_size = file_size(tfm_file)) < 24) {
+ ERROR ("OFM file too small to be a valid file\n");
+ }
+ get_ofm (tfm_file, tfm_file_size, &tfm[numtfms]);
+#endif
+ } else {
+ fprintf (stderr, "\n%s: ", tfm_name);
+ ERROR ("Unable to find a TFM or OFM file");
+ }
+ tfm[numtfms].tex_name = NEW (strlen(tfm_name)+1, char);
+ strcpy (tfm[numtfms].tex_name, tfm_name);
+ MFCLOSE (tfm_file);
+ if (tfm_verbose)
+ fprintf (stderr, ")");
+ if (tfm_verbose>3) {
+ dump_sizes (&tfm[numtfms]);
+ }
+ return numtfms++;
+ } else { /* Name has been loaded before */
+ return i;
+ }
+}
+
+void tfm_close_all(void)
+{
+ int i;
+ for (i=0; i<numtfms; i++) {
+ if (tfm[i].header)
+ RELEASE (tfm[i].header);
+ if (tfm[i].char_info)
+ RELEASE (tfm[i].char_info);
+ if (tfm[i].width)
+ RELEASE (tfm[i].width);
+ if (tfm[i].height)
+ RELEASE (tfm[i].height);
+ if (tfm[i].depth)
+ RELEASE (tfm[i].depth);
+ RELEASE (tfm[i].tex_name);
+ RELEASE (tfm[i].unpacked_widths);
+ RELEASE (tfm[i].unpacked_heights);
+ RELEASE (tfm[i].unpacked_depths);
+ if (tfm[i].width_index)
+ RELEASE (tfm[i].width_index);
+ if (tfm[i].height_index)
+ RELEASE (tfm[i].height_index);
+ if (tfm[i].depth_index)
+ RELEASE (tfm[i].depth_index);
+ }
+ if (tfm)
+ RELEASE (tfm);
+}
+
+/* tfm_get_width returns the width of the font
+ as a (double) fraction of the design size */
+double tfm_get_width (int font_id, UNSIGNED_QUAD ch)
+{
+ if (tfm[font_id].unpacked_widths && ch <= tfm[font_id].ec)
+ return (double) (tfm[font_id].unpacked_widths)[ch] / FWBASE;
+ else return 0.0;
+}
+
+double tfm_get_height (int font_id, UNSIGNED_QUAD ch)
+{
+ if (tfm[font_id].unpacked_heights && ch <= tfm[font_id].ec)
+ return (double) (tfm[font_id].unpacked_heights)[ch] / FWBASE;
+ else return 0.0;
+}
+
+double tfm_get_depth (int font_id, UNSIGNED_QUAD ch)
+{
+ if (tfm[font_id].unpacked_depths && ch <= tfm[font_id].ec)
+ return (tfm[font_id].unpacked_depths)[ch]/FWBASE;
+ else return 0.0;
+}
+
+fixword tfm_get_fw_width (int font_id, UNSIGNED_QUAD ch)
+{
+ if (tfm[font_id].unpacked_widths && ch <= tfm[font_id].ec) {
+ return (tfm[font_id].unpacked_widths)[ch];
+ }
+ return 0;
+}
+
+fixword tfm_get_fw_height (int font_id, UNSIGNED_QUAD ch)
+{
+ if (tfm[font_id].unpacked_heights && ch <= tfm[font_id].ec)
+ return (tfm[font_id].unpacked_heights)[ch];
+ return 0;
+}
+
+fixword tfm_get_fw_depth (int font_id, UNSIGNED_QUAD ch)
+{
+ if (tfm[font_id].unpacked_depths && ch <= tfm[font_id].ec)
+ return (tfm[font_id].unpacked_depths)[ch];
+ return 0;
+}
+
+fixword tfm_string_width (int font_id, unsigned char *s, unsigned len)
+{
+ fixword result = 0;
+ unsigned i;
+ if (tfm[font_id].unpacked_widths)
+ for (i=0; i<len; i++) {
+ if (s[i] <= tfm[font_id].ec)
+ result += tfm[font_id].unpacked_widths[s[i]];
+ }
+ return result;
+}
+
+fixword tfm_string_depth (int font_id, unsigned char *s, unsigned len)
+{
+ fixword result = 0;
+ unsigned i;
+ if (tfm[font_id].unpacked_depths)
+ for (i=0; i<len; i++) {
+ if (s[i] <= tfm[font_id].ec)
+ result = MAX(result, tfm[font_id].unpacked_depths[s[i]]);
+ }
+ return result;
+}
+
+fixword tfm_string_height (int font_id, unsigned char *s, unsigned len)
+{
+ fixword result = 0;
+ unsigned i;
+ if (tfm[font_id].unpacked_heights)
+ for (i=0; i<len; i++) {
+ if (s[i] <= tfm[font_id].ec)
+ result = MAX(result, tfm[font_id].unpacked_heights[s[i]-tfm[font_id].bc]);
+ }
+ return result;
+}
+
+UNSIGNED_PAIR tfm_get_firstchar (int font_id)
+{
+ return tfm[font_id].bc;
+}
+
+UNSIGNED_PAIR tfm_get_lastchar (int font_id)
+{
+ return tfm[font_id].ec;
+}
+
+double tfm_get_design_size (int font_id)
+{
+ return ((tfm[font_id].header))[1]/FWBASE*(72.0/72.27);
+}
+
+
+double tfm_get_max_width (int font_id)
+{
+ SIGNED_QUAD max = 0;
+ int i;
+ for (i=0; i<tfm[font_id].nwidths; i++) {
+ if ((tfm[font_id].width)[i] > max)
+ max = (tfm[font_id].width)[i];
+ }
+ return (max/FWBASE);
+}
+
+int tfm_is_fixed_width (int font_id)
+{
+ /* We always have two widths since width[0] = 0.
+ A fixed width font will have width[1] = something
+ and not have any other widths */
+ return (tfm[font_id].nwidths == 2);
+}
+
+double tfm_get_max_height (int font_id)
+{
+ SIGNED_QUAD max = 0;
+ int i;
+ for (i=0; i<tfm[font_id].nheights; i++) {
+ if ((tfm[font_id].height)[i] > max)
+ max = (tfm[font_id].height)[i];
+ }
+ return (max/FWBASE);
+}
+
+double tfm_get_max_depth (int font_id)
+{
+ SIGNED_QUAD max = 0;
+ int i;
+ for (i=0; i<tfm[font_id].ndepths; i++) {
+ if ((tfm[font_id].depth)[i] > max)
+ max = (tfm[font_id].depth)[i];
+ }
+ return (max/FWBASE);
+}
diff --git a/Build/source/texk/dvipdfm/tfm.h b/Build/source/texk/dvipdfm/tfm.h
new file mode 100644
index 00000000000..9a717dcf266
--- /dev/null
+++ b/Build/source/texk/dvipdfm/tfm.h
@@ -0,0 +1,63 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef TFM_H
+
+#define TFM_H
+
+#include "numbers.h"
+
+extern void tfm_set_verbose(void);
+extern void tfm_set_debug(void);
+
+extern int tfm_open(const char * tex_font_name);
+extern void tfm_close_all (void);
+
+extern double tfm_get_width (int font_id, UNSIGNED_QUAD ch);
+extern double tfm_get_height (int font_id, UNSIGNED_QUAD ch);
+extern double tfm_get_depth (int font_id, UNSIGNED_QUAD ch);
+extern fixword tfm_get_fw_width (int font_id, UNSIGNED_QUAD ch);
+extern fixword tfm_get_fw_height (int font_id, UNSIGNED_QUAD ch);
+extern fixword tfm_get_fw_depth (int font_id, UNSIGNED_QUAD ch);
+extern fixword tfm_string_width (int font_id, unsigned char *s,
+ unsigned len);
+extern fixword tfm_string_depth (int font_id, unsigned char *s,
+ unsigned len);
+extern fixword tfm_string_height (int font_id, unsigned char *s,
+ unsigned len);
+extern double tfm_get_space (int font_id);
+extern double tfm_get_it_slant (int font_id);
+extern double tfm_get_x_height (int font_id);
+
+extern UNSIGNED_PAIR tfm_get_firstchar (int font_id);
+extern UNSIGNED_PAIR tfm_get_lastchar (int font_id);
+
+extern double tfm_get_design_size (int font_id);
+extern double tfm_get_max_height (int font_id);
+extern double tfm_get_max_width (int font_id);
+extern int tfm_is_fixed_width (int font_id);
+extern double tfm_get_max_depth (int font_id);
+
+#endif /* TFM_H */
diff --git a/Build/source/texk/dvipdfm/thumbnail.c b/Build/source/texk/dvipdfm/thumbnail.c
new file mode 100644
index 00000000000..003822745fc
--- /dev/null
+++ b/Build/source/texk/dvipdfm/thumbnail.c
@@ -0,0 +1,108 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <kpathsea/config.h>
+#include <kpathsea/c-ctype.h>
+#include "system.h"
+#include "config.h"
+#include "mfileio.h"
+#include "mem.h"
+#include "pdfobj.h"
+#include "thumbnail.h"
+
+#ifdef HAVE_LIBPNG
+#include <png.h>
+#include "pngimage.h"
+
+#define TMP "/tmp"
+
+static char *guess_name (const char *thumb_filename)
+{
+ /* Build path name for anticipated thumbnail image */
+ char *tmpdir, *tmpname;
+ if (!(tmpdir = getenv ("TMPDIR")) &&
+ !(tmpdir = getenv ("TEMP")) &&
+ !(tmpdir = getenv ("TMP")))
+ tmpdir = TMP;
+ tmpname = NEW (strlen(tmpdir)+strlen(thumb_filename)+strlen(DIR_SEP_STRING)+1,
+ char);
+ strcpy (tmpname, tmpdir);
+ if (!IS_DIR_SEP (tmpname[strlen(tmpname)-1])) {
+ strcat (tmpname, DIR_SEP_STRING);
+ }
+ strcat (tmpname, thumb_filename);
+ return tmpname;
+}
+
+static char thumbnail_remove_opt = 0;
+void thumb_remove(void)
+{
+ thumbnail_remove_opt = 1;
+}
+
+static unsigned char sigbytes[4];
+
+pdf_obj *do_thumbnail (const char *thumb_filename)
+{
+ pdf_obj *image_stream = NULL, *image_ref = NULL;
+ int found_in_cwd = 0;
+ FILE *thumb_file;
+ char *guess_filename = NULL;
+ guess_filename = guess_name (thumb_filename);
+ if ((thumb_file = MFOPEN (thumb_filename, FOPEN_RBIN_MODE))) {
+ found_in_cwd = 1;
+ } else if (!(thumb_file = MFOPEN (guess_filename, FOPEN_RBIN_MODE))) {
+ fprintf (stderr, "\nNo thumbnail file\n");
+ return NULL;
+ }
+ if (fread (sigbytes, 1, sizeof(sigbytes), thumb_file) !=
+ sizeof(sigbytes) ||
+ (!png_check_sig (sigbytes, sizeof(sigbytes)))) {
+ fprintf (stderr, "\nThumbnail not a png file! Skipping\n");
+ return NULL;
+ }
+ rewind (thumb_file);
+
+ if ((image_stream = start_png_image (thumb_file, NULL))) {
+ image_ref = pdf_ref_obj (image_stream);
+ pdf_release_obj (image_stream);
+ } else {
+ image_ref = NULL;
+ }
+ if (thumbnail_remove_opt && found_in_cwd)
+ remove (thumb_filename);
+ else if (thumbnail_remove_opt)
+ remove (guess_filename);
+ if (guess_filename)
+ RELEASE (guess_filename);
+ MFCLOSE (thumb_file);
+ return image_ref;
+}
+
+#endif /* HAVE_LIBPNG */
+
+
+
diff --git a/Build/source/texk/dvipdfm/thumbnail.h b/Build/source/texk/dvipdfm/thumbnail.h
new file mode 100644
index 00000000000..c8d2e401f57
--- /dev/null
+++ b/Build/source/texk/dvipdfm/thumbnail.h
@@ -0,0 +1,40 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef THUMBNAIL_H
+
+#define THUMBNAIL_H
+
+#include <stdio.h>
+#include "pdfobj.h"
+
+#include "config.h"
+#ifdef HAVE_LIBPNG
+extern pdf_obj *do_thumbnail (const char *thumb_filename);
+extern void thumb_remove (void);
+#endif
+
+#endif /* THUMBNAIL_H */
+
diff --git a/Build/source/texk/dvipdfm/tpic.c b/Build/source/texk/dvipdfm/tpic.c
new file mode 100644
index 00000000000..639ba4af854
--- /dev/null
+++ b/Build/source/texk/dvipdfm/tpic.c
@@ -0,0 +1,498 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <string.h>
+#include <stdlib.h>
+#include "system.h"
+#include "mem.h"
+#include "mfileio.h"
+#include "tpic.h"
+#include "pdfparse.h"
+#include "pdfdoc.h"
+#include "pdfdev.h"
+#include "dvi.h"
+
+/* Following "constant" converts milli-inches to
+ device (in this case PDF stream) coordinates */
+
+#define MI2DEV (0.072/pdf_dev_scale())
+
+double pen_size = 1.0;
+int fill_shape = 0;
+double fill_color = 0.0; double default_fill_color = 0.5;
+static struct path
+{
+ double x, y;
+} *path = NULL;
+unsigned long path_length = 0, max_path_length = 0;
+
+static void tpic_clear_state (void)
+{
+ if ((path))
+ RELEASE(path);
+ path = NULL;
+ path_length = 0;
+ max_path_length = 0;
+ fill_shape = 0;
+ fill_color = 0.0;
+ return;
+}
+
+static void set_pen_size (char **buffer, char *end)
+{
+ char *number;
+ skip_white (buffer, end);
+ if ((number = parse_number(buffer, end))) {
+ pen_size = atof (number) * MI2DEV;
+ RELEASE (number);
+ } else {
+ dump (*buffer, end);
+ fprintf (stderr, "tpic special: pn: Invalid pen size\n");
+ }
+}
+
+static void set_fill_color (char **buffer, char *end)
+{
+ char *number;
+MEM_START
+ fill_shape = 1;
+ fill_color = default_fill_color;
+ skip_white (buffer, end);
+ if ((number = parse_number(buffer, end))) {
+ fill_color = 1.0 - atof (number);
+ if (fill_color > 1.0)
+ fill_color = 1.0;
+ if (fill_color < 0.0)
+ fill_color = 0.0;
+ RELEASE (number);
+ }
+MEM_END
+}
+
+static void add_point (char **buffer, char *end)
+{
+ char *x= NULL, *y= NULL;
+MEM_START
+ skip_white (buffer, end);
+ if (*buffer < end)
+ x = parse_number (buffer, end);
+ skip_white (buffer, end);
+ if (*buffer < end)
+ y = parse_number (buffer, end);
+ if ((x) && (y)) {
+ if (path_length >= max_path_length) {
+ max_path_length += 256;
+ path = RENEW (path, max_path_length, struct path);
+ }
+ path[path_length].x = atof(x)*MI2DEV;
+ path[path_length].y = atof(y)*MI2DEV;
+ path_length += 1;
+ } else {
+ dump (*buffer, end);
+ fprintf (stderr, "tpic special: pa: Missing coordinate\n");
+ }
+ if (x) RELEASE(x);
+ if (y) RELEASE(y);
+MEM_END
+ return;
+}
+
+static void show_path (int hidden)
+{
+ int len;
+ /* The semantics of a fill_color of 0.0 or 0.5 will be to use current
+ painting color known to dvipdfm */
+ if (fill_shape && fill_color != 0.0) {
+ sprintf (work_buffer, " %.2f g", fill_color);
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ }
+ if (!hidden && fill_shape) {
+ pdf_doc_add_to_page (" b", 2);
+ }
+ if (hidden && fill_shape) {
+ pdf_doc_add_to_page (" f", 2);
+ }
+ if (!hidden && !fill_shape)
+ pdf_doc_add_to_page (" S", 2);
+ if (fill_shape)
+ fill_shape = 0;
+ fill_color = 0.0;
+ fill_shape = 0.0;
+}
+
+
+static void flush_path (double x_user, double y_user, int hidden,
+ double dash_dot)
+{
+ int len;
+MEM_START
+ /* Make pen_size == 0 equivalent to hidden */
+ if (pen_size == 0)
+ hidden = 1;
+ if (path_length > 1) {
+ int i;
+ sprintf (work_buffer, " q");
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ if (pen_size != 0.0) {
+ sprintf (work_buffer, " %.2f w", pen_size);
+ len = strlen (work_buffer);
+ }
+ pdf_doc_add_to_page (work_buffer, len);
+ sprintf (work_buffer, " 1 J 1 j");
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ if (dash_dot != 0.0) {
+ if (dash_dot > 0.0) {
+ sprintf (work_buffer, " [%.1f %.1f] 0 d",
+ dash_dot*72.0, dash_dot*36.0);
+ len = strlen (work_buffer);
+ } else {
+ sprintf (work_buffer, " [%.1f %.1f] 0 d", pen_size,
+ -dash_dot*72.0);
+ len = strlen (work_buffer);
+ }
+ pdf_doc_add_to_page (work_buffer, len);
+ }
+ sprintf (work_buffer, " %.2f %.2f m",
+ x_user+path[0].x, y_user-path[0].y);
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ for (i=0; i<path_length; i++) {
+ sprintf (work_buffer, " %.2f %.2f l", x_user+path[i].x, y_user-path[i].y);
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ }
+ show_path (hidden);
+ pdf_doc_add_to_page (" Q", 2);
+ } else {
+ fprintf (stderr, "tpic special: fp: Not enough points!\n");
+ }
+ tpic_clear_state();
+MEM_END
+ return;
+}
+static void spline_path (double x_user, double y_user, double dash_dot)
+{
+ int len;
+MEM_START
+ /* Spline is meaningless for path length of less than 3 */
+ if (path_length > 2) {
+ int i;
+ sprintf (work_buffer, " q 1.4 M %.2f w", pen_size);
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ if (dash_dot != 0.0) {
+ if (dash_dot > 0.0) {
+ sprintf (work_buffer, " [%.1f %.1f] 0 d",
+ dash_dot*72.0, dash_dot*36.0);
+ len = strlen (work_buffer);
+ } else if (dash_dot < 0.0) {
+ sprintf (work_buffer, " [%.1f %.1f] 0 d 1 J", pen_size,
+ -dash_dot*72.0);
+ len = strlen (work_buffer);
+ }
+ pdf_doc_add_to_page (work_buffer, len);
+ }
+ sprintf (work_buffer, " %.2f %.2f m",
+ x_user+path[0].x, y_user-path[0].y);
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ sprintf (work_buffer, " %.2f %.2f l",
+ x_user+0.5*(path[0].x+path[1].x),
+ y_user-0.5*(path[0].y+path[1].y));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ for (i=1; i<path_length-1; i++) {
+ sprintf (work_buffer, " %.2f %.2f %.2f %.2f y",
+ x_user+path[i].x, y_user-path[i].y,
+ x_user+0.5*(path[i].x+path[i+1].x),
+ y_user-0.5*(path[i].y+path[i+1].y));
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ }
+ sprintf (work_buffer, " %.2f %.2f l",
+ x_user+path[path_length-1].x,
+ y_user-path[path_length-1].y);
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ show_path (0);
+ pdf_doc_add_to_page (" Q", 2);
+ } else {
+ fprintf (stderr, "tpic special: sp: Not enough points!\n");
+ }
+ tpic_clear_state();
+MEM_END
+ return;
+}
+
+static void arc (char **buffer, char *end, double x_user, double
+ y_user, int hidden)
+{
+ char *xcs= NULL, *ycs= NULL,
+ *xrs=NULL, *yrs=NULL, *sas=NULL, *eas=NULL;
+ char *save;
+ double xc, yc, xr, yr, sa, ea;
+MEM_START
+ save = *buffer;
+/* pen_size == 0 is equivalent to hidden */
+ if (pen_size == 0)
+ hidden = 1;
+ if ((xcs=parse_number(buffer, end)) &&
+ (ycs=parse_number(buffer, end)) &&
+ (xrs=parse_number(buffer, end)) &&
+ (yrs=parse_number(buffer, end)) &&
+ (sas=parse_number(buffer, end)) &&
+ (eas=parse_number(buffer, end))) {
+ double c, s, cur_x, cur_y, inc_ang;
+ double cp1_x, cp1_y, cp2_x, cp2_y;
+ double new_x, new_y;
+ int len, i, nsteps;
+ xc=atof (xcs)*MI2DEV; yc=atof (ycs)*MI2DEV;
+ xr=atof (xrs)*MI2DEV; yr=atof (yrs)*MI2DEV;
+ sa=atof (sas); ea=atof (eas);
+#define ROTATE(x,y,c,s) {new_x=(c)*(x)-(s)*(y);new_y=(s)*(x)+(c)*(y);x=new_x,y=new_y;}
+ #define MAX_ANG_STEP 1.0
+ nsteps = (int) ((ea-sa)/MAX_ANG_STEP) + 1;
+ inc_ang = (ea-sa)/nsteps;
+ c = cos(inc_ang); s = sin(inc_ang);
+ cur_x=cos(sa); cur_y=sin(sa);
+ cp1_x = cur_x - inc_ang/3.0*cur_y;
+ cp1_y = cur_y + inc_ang/3.0*cur_x;
+ cp2_x = cur_x + inc_ang/3.0*cur_y;
+ cp2_y = cur_y - inc_ang/3.0*cur_x;
+ sprintf (work_buffer, " q");
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ if (pen_size != 0.0) {
+ sprintf (work_buffer, " %.2f w", pen_size);
+ len = strlen (work_buffer);
+ }
+ pdf_doc_add_to_page (work_buffer, len);
+ sprintf (work_buffer, " 1 J");
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ sprintf (work_buffer, " %.2f %.2f m", x_user+xr*cur_x+xc, y_user-yr*cur_y-yc);
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ ROTATE (cp2_x, cp2_y, c, s);
+ ROTATE (cur_x, cur_y, c, s);
+ for (i=0; i<nsteps; i++) {
+ sprintf (work_buffer, " %.2f %.2f %.2f %.2f %.2f %.2f c",
+ x_user+xr*cp1_x+xc, y_user-yr*cp1_y-yc,
+ x_user+xr*cp2_x+xc, y_user-yr*cp2_y-yc,
+ x_user+xr*cur_x+xc, y_user-yr*cur_y-yc);
+ len = strlen (work_buffer);
+ pdf_doc_add_to_page (work_buffer, len);
+ ROTATE (cur_x, cur_y, c, s);
+ ROTATE (cp1_x, cp1_y, c, s);
+ ROTATE (cp2_x, cp2_y, c, s);
+ }
+ show_path (hidden);
+ pdf_doc_add_to_page (" Q", 2);
+ } else {
+ dump (save, end);
+ fprintf (stderr, "tpic special: ar/ir: Error in parameters\n");
+ }
+ if (xcs) RELEASE(xcs);
+ if (ycs) RELEASE(ycs);
+ if (xrs) RELEASE(xrs);
+ if (yrs) RELEASE(yrs);
+ if (sas) RELEASE(sas);
+ if (eas) RELEASE(eas);
+MEM_END
+ tpic_clear_state();
+ return;
+}
+
+#define TPIC_PN 1
+#define TPIC_PA 2
+#define TPIC_FP 3
+#define TPIC_IP 4
+#define TPIC_DA 5
+#define TPIC_DT 6
+#define TPIC_SP 7
+#define TPIC_AR 8
+#define TPIC_IA 9
+#define TPIC_SH 10
+#define TPIC_WH 11
+#define TPIC_BK 12
+#define TPIC_TX 13
+
+struct {
+ char *s;
+ int tpic_command;
+} tpic_specials[] = {
+ {"pn", TPIC_PN},
+ {"pa", TPIC_PA},
+ {"fp", TPIC_FP},
+ {"ip", TPIC_IP},
+ {"da", TPIC_DA},
+ {"dt", TPIC_DT},
+ {"sp", TPIC_SP},
+ {"ar", TPIC_AR},
+ {"ia", TPIC_IA},
+ {"sh", TPIC_SH},
+ {"wh", TPIC_WH},
+ {"bk", TPIC_BK},
+ {"tx", TPIC_TX}
+};
+
+int tpic_parse_special(char *buffer, UNSIGNED_QUAD size, double
+ x_user, double y_user)
+{
+ int i, tpic_command, result = 0;
+ char *end = buffer + size;
+ char *token;
+ skip_white (&buffer, end);
+ if ((token = parse_ident (&buffer, end))) {
+ for (i=0; i<(sizeof(tpic_specials)/sizeof(tpic_specials[0])); i++) {
+ if (!strcmp (tpic_specials[i].s, token))
+ break;
+ }
+ RELEASE (token);
+ } else
+ return 0;
+ if (i < sizeof(tpic_specials)/sizeof(tpic_specials[0])) {
+ tpic_command = tpic_specials[i].tpic_command;
+ skip_white (&buffer, end);
+ result = 1;
+ switch (tpic_command) {
+ case TPIC_PN:
+ set_pen_size (&buffer, end);
+ break;
+ case TPIC_PA:
+ add_point (&buffer, end);
+ break;
+ case TPIC_FP:
+ flush_path(x_user, y_user, 0, 0.0);
+ break;
+ case TPIC_IP:
+ flush_path(x_user, y_user, 1, 0.0);
+ break;
+ case TPIC_DA:
+ {
+ char *s;
+ if ((s=parse_number(&buffer, end))) {
+ flush_path(x_user, y_user, 0, atof (s));
+ RELEASE (s);
+ }
+ }
+ break;
+ case TPIC_DT:
+ {
+ char *s;
+ if ((s=parse_number(&buffer, end))) {
+ flush_path(x_user, y_user, 0, -atof (s));
+ RELEASE (s);
+ }
+ }
+ break;
+ case TPIC_SP:
+ {
+ char *s;
+ if ((s=parse_number(&buffer, end)))
+ spline_path (x_user, y_user, atof (s));
+ else
+ spline_path(x_user, y_user, 0.0);
+ break;
+ }
+ case TPIC_AR:
+ arc (&buffer, end, x_user, y_user, 0);
+ break;
+ case TPIC_IA:
+ arc (&buffer, end, x_user, y_user, 1);
+ break;
+ case TPIC_SH:
+ set_fill_color (&buffer, end);
+ break;
+ case TPIC_WH:
+ fill_shape = 1;
+ fill_color = 1.0;
+ break;
+ case TPIC_BK:
+ fill_shape = 1;
+ fill_color = 0.0;
+ break;
+ case TPIC_TX:
+ fill_shape = 1;
+ {
+ long num = 0, den = 0;
+ while (buffer++ < end) {
+ switch (*(buffer++)) {
+ case '0':
+ num += 0;
+ case '1':
+ case '2':
+ case '4':
+ case '8':
+ num += 1;
+ break;
+ case '3':
+ case '5':
+ case '6':
+ case '9':
+ case 'a':
+ case 'A':
+ case 'c':
+ case 'C':
+ num += 2;
+ break;
+ case '7':
+ case 'b':
+ case 'B':
+ case 'd':
+ case 'D':
+ num += 3;
+ break;
+ case 'f':
+ case 'F':
+ num += 4;
+ break;
+ default:
+ break;
+ }
+ den += 16;
+ }
+ if (den != 0) {
+ default_fill_color = 1.0 - (float) (num)/(den);
+ }
+ else {
+ default_fill_color = 0.5;
+ }
+ }
+ break;
+ default:
+ fprintf (stderr, "Fix me, I'm broke. This should never happen");
+ exit(1);
+ }
+ } else {
+ result = 0;
+ }
+ return result;
+}
+
+
+
diff --git a/Build/source/texk/dvipdfm/tpic.h b/Build/source/texk/dvipdfm/tpic.h
new file mode 100644
index 00000000000..0a8cddc3919
--- /dev/null
+++ b/Build/source/texk/dvipdfm/tpic.h
@@ -0,0 +1,41 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef _TPIC_H_
+
+#define _TPIC_H_
+
+#include "numbers.h"
+
+extern int tpic_parse_special(char *buffer, UNSIGNED_QUAD size, double
+ x_user, double y_user);
+#ifndef M_PI
+ #define M_PI (4.0*atan(1.0))
+#endif /* M_PI */
+
+#endif /* _TPIC_H */
+
+
+
diff --git a/Build/source/texk/dvipdfm/ttf.c b/Build/source/texk/dvipdfm/ttf.c
new file mode 100755
index 00000000000..45b6111ddb4
--- /dev/null
+++ b/Build/source/texk/dvipdfm/ttf.c
@@ -0,0 +1,1031 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+/* This is tailored for PDF */
+
+#include "config.h"
+
+#ifdef HAVE_TTF_FORMATS
+#include "ttf.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include "system.h"
+#include "mem.h"
+#include "error.h"
+#include "mfileio.h"
+#include "pdfobj.h"
+#include "numbers.h"
+#include "tfm.h"
+#include "pdflimits.h"
+#include "twiddle.h"
+#include "encodings.h"
+
+static unsigned char verbose = 0;
+
+void ttf_set_verbose(void)
+{
+ if (verbose < 255) {
+ verbose += 1;
+ }
+}
+
+static char partial_enabled = 0;
+
+void ttf_disable_partial (void)
+{
+ partial_enabled = 0;
+}
+
+
+/* Convert ttf "fixed" type to double */
+
+#define fixed(a) ((double)((a)%0x10000L)/(double)(0x10000L)+ \
+ (((a)/0x10000L) > 0x8000L? 0x10000L - ((a)/0x10000L): ((a)/0x10000L)))
+
+/* Convert four-byte number to big endianess in a machine independent
+ way */
+static void convert_tag (char *tag, unsigned long u_tag)
+{
+ int i;
+ for (i=3; i>= 0; i--) {
+ tag[i] = u_tag % 256;
+ u_tag /= 256;
+ }
+ tag[4] = 0;
+}
+
+struct table_header
+{
+ char tag[5];
+ UNSIGNED_QUAD check_sum, offset, length;
+ int omit; /* If an application call sets omit=1, this table will
+ not be written to the output by ttf_build_font() */
+ void *table_data;
+};
+
+struct table_directory
+{
+ SIGNED_QUAD version;
+ UNSIGNED_PAIR num_tables, search_range,
+ entry_selector, range_shift;
+ struct table_header *tables;
+};
+
+static void release_directory (struct table_directory *r)
+{
+ if (r && r->tables) {
+ RELEASE (r->tables);
+ }
+ if (r)
+ RELEASE (r);
+}
+
+static int put_big_endian (char *s, UNSIGNED_QUAD q, int n)
+{
+ int i;
+ for (i=n-1; i>=0; i--) {
+ s[i] = (char) q%256;
+ q/=256L;
+ }
+ return n;
+}
+
+static unsigned max2floor(unsigned n)
+/* Computes the max power of 2 <= n */
+{
+ int i = 1;
+ while (n > 1) {
+ n /= 2;
+ i *= 2;
+ }
+ return i;
+}
+
+static unsigned log2floor(unsigned n)
+/* Computes the log2 of the max power of 2 <= n */
+{
+ unsigned i = 0;
+ while (n > 1) {
+ n /= 2;
+ i += 1;
+ }
+ return i;
+}
+
+
+static char *ttf_build_font (FILE *ttf_file, struct table_directory
+ *td, long *size)
+{
+ char *result, *p;
+ long font_size = 0, offset = 0;
+ int i, num_kept_tables = 0, new_search_range;
+ for (i=0; i<(td->num_tables); i++) {
+ if (!(td->tables)[i].omit) {
+ font_size += (td->tables[i].length);
+ num_kept_tables += 1;
+ }
+ }
+ font_size += (td->num_tables)*16; /* 16 bytes per table entry */
+ font_size += 12; /* 12 bytes for the directory */
+ *size = font_size;
+ result = NEW (font_size, char);
+ p = result;
+ { /* Header */
+ p += put_big_endian (p, td->version, 4);
+ p += put_big_endian (p, num_kept_tables, 2);
+ new_search_range = max2floor(num_kept_tables) * 16;
+ p += put_big_endian (p, new_search_range, 2);
+ p += put_big_endian (p, log2floor(num_kept_tables), 2);
+ p += put_big_endian (p, num_kept_tables*16-new_search_range, 2);
+ }
+ /* Computer start of actual tables (after headers) */
+ offset = 12 + 16 * num_kept_tables;
+ for (i=0; i<(td->num_tables); i++) {
+ if (!(td->tables)[i].omit) {
+ sprintf (p, "%4s", (td->tables)[i].tag);
+ p += strlen (p);
+ p += put_big_endian (p, (td->tables)[i].check_sum, 4);
+ p += put_big_endian (p, offset, 4);
+ p += put_big_endian (p, (td->tables)[i].length, 4);
+ /* Be careful here. Offset to the right place in the file
+ using the old offset and read the data into the right
+ place in the buffer using the new offset */
+ seek_absolute (ttf_file, (td->tables)[i].offset);
+ fread (result+offset, (td->tables)[i].length, sizeof(char), ttf_file);
+ /* Set offset for next table */
+ offset += (td->tables)[i].length;
+ if (offset > font_size )
+ ERROR ("Uh oh");
+ }
+ }
+ return result;
+}
+
+
+static struct table_directory *read_directory(FILE *ttf_file)
+{
+ unsigned long i;
+ struct table_directory *td = NEW (1, struct table_directory);
+ rewind (ttf_file);
+ td -> version = get_unsigned_quad(ttf_file);
+ td -> num_tables = get_unsigned_pair (ttf_file);
+ td -> search_range = get_unsigned_pair (ttf_file);
+ td -> entry_selector = get_unsigned_pair (ttf_file);
+ td -> range_shift = get_unsigned_pair (ttf_file);
+ if (verbose > 3) {
+ fprintf (stdout, "File Header\n");
+ fprintf (stdout, "\tVersion: %.5f\n", fixed(td -> version));
+ fprintf (stdout, "\tNumber of tables: %d\n",
+ td -> num_tables);
+ fprintf (stdout, "\tSearch Range: %d\n", td -> search_range);
+ fprintf (stdout, "\tEntry Selector: %d\n",
+ td -> entry_selector);
+ fprintf (stdout, "\tRange Shift: %d\n",
+ td -> range_shift);
+ }
+ td->tables = NEW (td -> num_tables, struct table_header);
+ for (i=0; i < td->num_tables; i++) {
+ unsigned long u_tag;
+ if (verbose > 3) {
+ fprintf (stdout, "New Table\n");
+ }
+ u_tag = get_unsigned_quad (ttf_file);
+ convert_tag ((td->tables)[i].tag, u_tag);
+ (td->tables)[i].check_sum = get_unsigned_quad (ttf_file);
+ (td->tables)[i].offset = get_unsigned_quad (ttf_file);
+ (td->tables)[i].length = get_unsigned_quad (ttf_file);
+ if (verbose) {
+ fprintf (stdout, "\tTag: %4s\n", (td->tables)[i].tag);
+ fprintf (stdout, "\tChecksum: %lx\n", (td->tables)[i].check_sum);
+ fprintf (stdout, "\tOffset: %lx\n", (td->tables)[i].offset);
+ fprintf (stdout, "\tLength: %lx\n", (td->tables)[i].length);
+ }
+ (td->tables)[i].omit = 0;
+ (td->tables)[i].table_data = NULL;
+ }
+ return td;
+}
+
+static int find_table_index (struct table_directory *td, char *tag)
+{
+ int result, i;
+ for (i=0; i < td->num_tables; i++) {
+ if (!strncmp ((td->tables)[i].tag, tag, 4)) {
+ break;
+ }
+ }
+ if (i < td-> num_tables)
+ result = i;
+ else
+ result = -1;
+ return result;
+}
+
+
+static long find_table_pos (FILE *ttf_file, struct table_directory *td, char *tag)
+{
+ int i;
+ long result = -1;
+ if ((i=find_table_index (td, tag)) >= 0) {
+ result = (td->tables)[i].offset;
+ }
+ return result;
+}
+
+static struct post_header
+{
+ UNSIGNED_QUAD format;
+ UNSIGNED_QUAD italicAngle;
+ SIGNED_PAIR underlinePosition;
+ SIGNED_PAIR underlineThickness;
+ UNSIGNED_QUAD isFixedPitch;
+} post_header;
+
+void read_post_table(FILE *ttf_file, struct table_directory *td)
+{
+ long post_offset = find_table_pos (ttf_file, td, "post");
+ seek_absolute (ttf_file, post_offset);
+ if (verbose > 3) {
+ fprintf (stdout, "Table type: post\n");
+ fprintf (stderr, "post table @ %ld\n", post_offset);
+ }
+ post_header.format = get_unsigned_quad(ttf_file);
+ post_header.italicAngle = get_unsigned_quad (ttf_file);
+ post_header.underlinePosition = get_signed_pair (ttf_file);
+ post_header.underlineThickness = get_signed_pair (ttf_file);
+ post_header.isFixedPitch = get_unsigned_quad (ttf_file);
+ if (verbose > 3) {
+ fprintf (stdout, "\tVersion: %f(%lx)\n",
+ fixed(post_header.format),
+ post_header.format);
+ fprintf (stdout, "\tItalic Angle: %f\n",
+ fixed(post_header.italicAngle));
+ fprintf (stdout, "\tUnderline Position: %d\n",
+ post_header.underlinePosition);
+ fprintf (stdout, "\tUnderline Thickness: %d\n",
+ post_header.underlineThickness);
+ fprintf (stdout, "\tIs Fixed Pitch?: %ld\n",
+ post_header.isFixedPitch);
+ }
+ return;
+}
+
+struct horz_header
+{
+ UNSIGNED_QUAD version;
+ SIGNED_PAIR ascender, descender, line_gap;
+ UNSIGNED_PAIR advanceWidthMax;
+ SIGNED_PAIR minLeftSideBearing, minRightSideBearing, xMaxExtent;
+ SIGNED_PAIR caretSlopeRise, caretSlopeRun;
+ UNSIGNED_PAIR numberOfHMetrics;
+} horz_header;
+
+void read_hhea_table (FILE *ttf_file)
+{
+ horz_header.version = get_unsigned_quad(ttf_file);
+ horz_header.ascender = get_signed_pair (ttf_file);
+ horz_header.descender = get_signed_pair (ttf_file);
+ horz_header.line_gap = get_signed_pair (ttf_file);
+ if (verbose > 3) {
+ fprintf (stdout, "Table type: hhea\n");
+ fprintf (stdout, "\tVersion: %f\n", fixed(horz_header.version));
+ fprintf (stdout, "\tAscender: %d\n", horz_header.ascender);
+ fprintf (stdout, "\tDescender: %d\n", horz_header.descender);
+ fprintf (stdout, "\tLine Gap: %d\n", horz_header.line_gap);
+ }
+}
+
+
+struct font_header
+{
+ double version, revision;
+ UNSIGNED_QUAD check_sum;
+ UNSIGNED_QUAD magic;
+ UNSIGNED_PAIR flags, units_per_em;
+ SIGNED_PAIR xMin, yMin, xMax, yMax;
+ UNSIGNED_PAIR style, minsize;
+ SIGNED_PAIR fontDirectionHint, indexToLocFormat;
+ SIGNED_PAIR glyphDataFormat;
+};
+
+struct font_header *read_head_table(FILE *ttf_file, struct table_directory *td)
+{
+ struct font_header *r;
+ int i;
+ unsigned long fw;
+ long head_offset = find_table_pos (ttf_file, td, "head");
+ seek_absolute (ttf_file, head_offset);
+ r = NEW (1, struct font_header);
+ fw = get_unsigned_quad(ttf_file);
+ (r->version) = fixed(fw);
+ fw = get_unsigned_quad(ttf_file);
+ (r->revision) = fixed(fw);
+ r->check_sum = get_unsigned_quad(ttf_file);
+ r->magic = get_unsigned_quad(ttf_file);
+ r->flags = get_unsigned_pair(ttf_file);
+ r->units_per_em = get_unsigned_pair(ttf_file);
+ if (verbose > 3) {
+ fprintf (stdout, "Table type: head\n");
+ fprintf (stdout, "\tVersion: %f\n", r->version);
+ fprintf (stdout, "\tRevision: %f\n", r->revision);
+ fprintf (stdout, "\tChecksum: %lx\n", r->check_sum);
+ fprintf (stdout, "\tMagic: %lx\n", r->magic);
+ fprintf (stdout, "\tFlags: %x\n", r->flags);
+ fprintf (stdout, "\tunits_per_em: %d\n", r->units_per_em);
+ }
+ /* Skip Dates */
+ for (i=0; i<4; i++) {
+ get_unsigned_quad (ttf_file);
+ }
+ r->xMin = get_signed_pair(ttf_file);
+ r->yMin = get_signed_pair(ttf_file);
+ r->xMax = get_signed_pair(ttf_file);
+ r->yMax = get_signed_pair(ttf_file);
+ r->style = get_unsigned_pair(ttf_file);
+ r->minsize = get_unsigned_pair(ttf_file);
+ r->fontDirectionHint = get_signed_pair(ttf_file);
+ r->indexToLocFormat = get_signed_pair(ttf_file);
+ r->glyphDataFormat = get_signed_pair(ttf_file);
+ if (verbose > 3) {
+ fprintf (stdout, "\txMin: %d\n", r->xMin);
+ fprintf (stdout, "\tyMin: %d\n", r->yMin);
+ fprintf (stdout, "\txMax: %d\n", r->xMax);
+ fprintf (stdout, "\tyMax: %d\n", r->yMax);
+ fprintf (stdout, "\tyStyle: %d\n", r->style);
+ fprintf (stdout, "\tyMin readable size (pixels): %d\n", r->minsize);
+ fprintf (stdout, "\tDirection Hint: %d\n", r->fontDirectionHint);
+ fprintf (stdout, "\tIndex Format: %d\n",
+ r->indexToLocFormat);
+ fprintf (stdout, "\tData Format: %d\n",
+ r->glyphDataFormat);
+ }
+ return r;
+}
+
+
+static unsigned num_ttfs = 0;
+static unsigned max_ttfs = 0;
+struct a_ttf
+{
+ char *ttf_name;
+ char *fontname;
+ struct table_directory *directory;
+ pdf_obj *direct, *indirect, *descriptor;
+ char **used_glyphs;
+ char **int_encoding;
+ char *used_def_enc_chars; /* The positions used from the default
+ encoding. When a default encoding
+ is used, the glyph names will not
+ be known until the font is actually
+ read. Since the glyph names are
+ unknown, only the positions of the
+ used chars are stored when the
+ default encoding is used */
+ unsigned n_used_glyphs, max_used_glyphs;
+} *ttfs = NULL;
+
+static void init_a_ttf (struct a_ttf *ttf)
+{
+ int i;
+ ttf -> n_used_glyphs = 0;
+ ttf -> max_used_glyphs = 0;
+ ttf -> used_glyphs = NULL;
+ ttf->ttf_name = NULL;
+ ttf->fontname = NULL;
+ ttf->direct = NULL;
+ ttf->indirect = NULL;
+ ttf->descriptor = NULL;
+ ttf -> used_def_enc_chars = NULL;
+ if (partial_enabled) {
+ ttf -> int_encoding = NEW (256, char *);
+ for (i=0; i<256; i++) {
+ (ttf -> int_encoding)[i] = NULL;
+ }
+ } else {
+ ttf -> int_encoding = NULL;
+ }
+}
+
+#include "macglyphs.h"
+
+
+#define FIXED_WIDTH 1
+#define SERIF 2
+#define STANDARD 32
+#define ITALIC 64
+#define SYMBOLIC 4 /* Fonts that don't have Adobe encodings (e.g.,
+ cmr, should be set to be symbolic */
+#define STEMV 80
+
+
+extern int CDECL glyph_cmp(const void *v1, const void *v2);
+extern int CDECL glyph_match(const void *key, const void *v);
+
+
+static void dump_glyphs( char **glyphs, int n, int show_index)
+{
+ int i;
+ for (i=0; i<n; i++) {
+ if (show_index)
+ fprintf (stderr, "(%d", i);
+ if (glyphs[i])
+ fprintf (stderr, "/%s", glyphs[i]);
+ else
+ fprintf (stderr, "(null)");
+ if (show_index)
+ fprintf (stderr, ")");
+ }
+ return;
+}
+
+static void dump_used( char *used_chars)
+{
+ int i;
+ for (i=0; i<256; i++)
+ fprintf (stderr, "(%d/%d)", i, used_chars[i]);
+ return;
+}
+
+static unsigned int glyph_length (char **glyphs)
+{
+ int i;
+ unsigned result = 0;
+ for (i=0; i<256; i++) {
+ result += strlen (glyphs[i]);
+ }
+ return result;
+}
+
+static char *ttf_find_name (FILE *ttf_file, struct table_directory *td)
+{
+ char *result = NULL;
+ unsigned num_names, string_offset;
+ long name_offset;
+ int i;
+ name_offset = find_table_pos (ttf_file, td, "name");
+ if (name_offset >= 0) {
+ seek_absolute (ttf_file, name_offset);
+ if (get_unsigned_pair (ttf_file))
+ ERROR ("Expecting zero in ttf_find_name()");
+ num_names = get_unsigned_pair (ttf_file);
+ string_offset = get_unsigned_pair (ttf_file);
+ for (i=0; i<num_names; i++) {
+ unsigned platform_id, plat_encoding_id;
+ unsigned language_id, name_id;
+ unsigned length, offset;
+ platform_id = get_unsigned_pair (ttf_file);
+ plat_encoding_id = get_unsigned_pair (ttf_file);
+ language_id = get_unsigned_pair (ttf_file);
+ name_id = get_unsigned_pair (ttf_file);
+ length = get_unsigned_pair (ttf_file);
+ offset = get_unsigned_pair (ttf_file);
+ if (platform_id == 1 &&
+ name_id == 6) { /* For now, return the PS font name */
+ seek_absolute (ttf_file, name_offset+string_offset+offset);
+ result = NEW (length+1, char);
+ fread (result, length, sizeof(char), ttf_file);
+ result[length] = 0;
+ if (verbose > 3) {
+ fprintf (stdout, "TTF internal name is %s\n", result);
+ }
+ break;
+ }
+ }
+ if (i == num_names) {
+ ERROR ("Couldn't find ttf font name in a platform/encoding I could understand");
+ }
+ } else {
+ fprintf (stdout, "Name table not found!\n");
+ }
+ return result;
+}
+
+static pdf_obj *ttf_fontfile (int ttf_id)
+{
+ if (ttf_id >= 0 && ttf_id < num_ttfs)
+ return pdf_link_obj (ttfs[ttf_id].indirect);
+ else
+ return NULL;
+}
+
+static char *ttf_fontname (int ttf_id)
+{
+ if (ttf_id >= 0 && ttf_id < num_ttfs)
+ return ttfs[ttf_id].fontname;
+ else
+ return NULL;
+}
+
+
+static void ttf_add_to_used_glyphs (int ttf_id, char *glyph)
+{
+ if (ttf_id >= 0 && ttf_id < num_ttfs && glyph) {
+ if (ttfs[ttf_id].n_used_glyphs == 0 ||
+ !bsearch (glyph, ttfs[ttf_id].used_glyphs,
+ ttfs[ttf_id].n_used_glyphs,
+ sizeof (char *), glyph_match)) {
+ if (ttfs[ttf_id].n_used_glyphs+1 >=
+ ttfs[ttf_id].max_used_glyphs) {
+ ttfs[ttf_id].max_used_glyphs += 16;
+ ttfs[ttf_id].used_glyphs = RENEW (ttfs[ttf_id].used_glyphs,
+ ttfs[ttf_id].max_used_glyphs,
+ char *);
+ }
+ (ttfs[ttf_id].used_glyphs)[ttfs[ttf_id].n_used_glyphs] =
+ NEW (strlen(glyph)+1, char);
+ strcpy((ttfs[ttf_id].used_glyphs)[ttfs[ttf_id].n_used_glyphs],
+ glyph);
+ ttfs[ttf_id].n_used_glyphs += 1;
+ qsort (ttfs[ttf_id].used_glyphs, ttfs[ttf_id].n_used_glyphs,
+ sizeof (char *), glyph_cmp);
+ }
+ }
+}
+
+static char *new_used_chars (void)
+{
+ char *result;
+ int i;
+ result = NEW (256, char);
+ for (i=0; i<256; i++) {
+ result[i] = 0;
+ }
+ return result;
+}
+
+/* Mark the character at position "code" as used in the ttf font
+ corresponding to "ttf_id" */
+static void ttf_add_to_used_chars (int ttf_id, unsigned code)
+{
+ if (ttf_id >= 0 && ttf_id < num_ttfs && code < 256) {
+ if (!ttfs[ttf_id].used_def_enc_chars) {
+ ttfs[ttf_id].used_def_enc_chars = new_used_chars();
+ }
+ (ttfs[ttf_id].used_def_enc_chars)[code] = 1;
+ }
+ if (code >= 256)
+ ERROR ("ttf_add_to_used_chars(): code >= 256");
+ return;
+}
+
+/* Mangle_fontname mangles the name in place. fontname
+ must be big enough to add seven characters */
+
+static void mangle_fontname(char *fontname)
+{
+ int i;
+ char ch;
+ static char first = 1;
+ memmove (fontname+7, fontname, strlen(fontname)+1);
+ /* The following procedure isn't very random, but it
+ doesn't need to be for this application. */
+ if (first) {
+ srand (time(NULL));
+ first = 0;
+ }
+ for (i=0; i<6; i++) {
+ ch = rand() % 26;
+ fontname[i] = ch+'A';
+ }
+ fontname[6] = '+';
+}
+
+
+/* This routine builds a default font descriptor with dummy values
+ filled in for the required keys. As the ttf file is parsed,
+ any values that are found are rewritten. By doing this,
+ all the required fields are found in the font descriptor
+ even if the ttf is somewhat defective. This approach is
+ conservative, with the cost of keeping the names around in memory
+ for a while.
+*/
+
+static void ttf_start_font_descriptor (FILE *ttf_file, int ttf_id)
+{
+ pdf_obj *tmp1;
+ struct font_header *r;
+ ttfs[ttf_id].descriptor = pdf_new_dict ();
+
+ pdf_add_dict (ttfs[ttf_id].descriptor,
+ pdf_new_name ("Type"),
+ pdf_new_name ("FontDescriptor"));
+ /* For now, insert dummy values */
+ pdf_add_dict (ttfs[ttf_id].descriptor,
+ pdf_new_name ("CapHeight"),
+ pdf_new_number (850.0)); /* This number is arbitrary */
+ pdf_add_dict (ttfs[ttf_id].descriptor,
+ pdf_new_name ("Ascent"),
+ pdf_new_number (850.0)); /* This number is arbitrary */
+ pdf_add_dict (ttfs[ttf_id].descriptor,
+ pdf_new_name ("Descent"),
+ pdf_new_number (-200.0));
+ r = read_head_table(ttf_file, ttfs[ttf_id].directory);
+ tmp1 = pdf_new_array ();
+ pdf_add_array (tmp1, pdf_new_number ((double) r->xMin));
+ pdf_add_array (tmp1, pdf_new_number ((double) r->yMin));
+ pdf_add_array (tmp1, pdf_new_number ((double) r->xMax));
+ pdf_add_array (tmp1, pdf_new_number ((double) r->yMax));
+ RELEASE (r);
+ pdf_add_dict (ttfs[ttf_id].descriptor, pdf_new_name ("FontBBox"), tmp1);
+ pdf_add_dict (ttfs[ttf_id].descriptor,
+ pdf_new_name ("FontName"),
+ pdf_new_name (ttf_fontname(ttf_id)));
+
+ pdf_add_dict (ttfs[ttf_id].descriptor,
+ pdf_new_name ("ItalicAngle"),
+ pdf_new_number(0.0));
+ pdf_add_dict (ttfs[ttf_id].descriptor,
+ pdf_new_name ("StemV"), /* StemV is required, StemH
+ is not */
+ pdf_new_number (STEMV)); /* Use a default value */
+ /* You don't need a fontfile for the standard fonts */
+ if (ttf_id >= 0)
+ pdf_add_dict (ttfs[ttf_id].descriptor,
+ pdf_new_name ("FontFile2"),
+ ttf_fontfile (ttf_id));
+
+ pdf_add_dict (ttfs[ttf_id].descriptor,
+ pdf_new_name ("Flags"),
+ pdf_new_number (SYMBOLIC)); /* Treat all fonts as symbolic */
+ return;
+}
+
+static int ttf_get_id (const char *ttf_name)
+{
+ int i;
+ for (i=0; i<num_ttfs; i++) {
+ if (ttfs[i].ttf_name && !strcmp (ttfs[i].ttf_name, ttf_name))
+ break;
+ }
+ if (i == num_ttfs) { /* This font not previously called for */
+ FILE *ttf_file;
+ char *full_ttf_name, *short_fontname;
+ if (!(full_ttf_name = kpse_find_file (ttf_name, kpse_truetype_format,
+ 1)) ||
+ !(ttf_file = MFOPEN (full_ttf_name, FOPEN_RBIN_MODE))) {
+ return -1;
+ }
+ if (num_ttfs >= max_ttfs) {
+ max_ttfs += MAX_FONTS;
+ ttfs = RENEW (ttfs, max_ttfs, struct a_ttf);
+ }
+ num_ttfs += 1;
+ init_a_ttf (ttfs+i);
+ ttfs[i].directory = read_directory (ttf_file);
+ short_fontname = ttf_find_name (ttf_file, ttfs[i].directory);
+ ttfs[i].ttf_name = NEW (strlen(ttf_name)+1, char);
+ strcpy (ttfs[i].ttf_name, ttf_name);
+ ttfs[i].direct = pdf_new_stream(STREAM_COMPRESS);
+ ttfs[i].indirect = pdf_ref_obj (ttfs[i].direct);
+ if (partial_enabled) {
+ ttfs[i].fontname = NEW (strlen(short_fontname)+8, char);
+ strcpy (ttfs[i].fontname, short_fontname);
+ mangle_fontname(ttfs[i].fontname);
+ }
+ else {
+ ttfs[i].fontname = NEW (strlen(short_fontname)+1, char);
+ strcpy (ttfs[i].fontname, short_fontname);
+ }
+ ttf_start_font_descriptor(ttf_file, i);
+ if (short_fontname)
+ RELEASE (short_fontname);
+ MFCLOSE (ttf_file);
+ }
+ return i;
+}
+
+static void ttf_release (int id)
+{
+ if (id >= 0 && id < num_ttfs) {
+ RELEASE (ttfs[id].ttf_name);
+ pdf_release_obj (ttfs[id].indirect);
+ release_directory (ttfs[id].directory);
+ RELEASE (ttfs[id].fontname);
+
+ if (ttfs[id].used_def_enc_chars)
+ RELEASE (ttfs[id].used_def_enc_chars);
+ if (ttfs[id].int_encoding){
+ int i;
+ for (i=0; i<256; i++) {
+ if ((ttfs[id].int_encoding)[i])
+ RELEASE ((ttfs[id].int_encoding)[i]);
+ }
+ RELEASE (ttfs[id].int_encoding);
+ }
+ if (ttfs[id].used_glyphs) {
+ unsigned i;
+ for (i=0; i<ttfs[id].n_used_glyphs; i++) {
+ RELEASE ((ttfs[id].used_glyphs)[i]);
+ }
+ RELEASE (ttfs[id].used_glyphs);
+ }
+ }
+}
+
+static void release_glyphs (char **glyphs)
+{
+ int i;
+ for (i=0; i<256; i++) {
+ RELEASE (glyphs[i]);
+ }
+}
+
+static void omit_unecessary (struct table_directory *td)
+{
+ int omitindex;
+ if ((omitindex = find_table_index (td, "kern")) >= 0)
+ (td->tables)[omitindex].omit = 1;
+}
+
+static void do_ttf (int ttf_id)
+{
+ char *full_ttf_name;
+ FILE *ttf_file;
+ pdf_obj *stream_dict;
+ full_ttf_name = kpse_find_file (ttfs[ttf_id].ttf_name, kpse_truetype_format,
+ 1);
+ if (verbose == 1)
+ fprintf (stderr, "(TTF:%s", ttfs[ttf_id].ttf_name);
+ if (verbose > 1)
+ fprintf (stderr, "(TTF:%s", full_ttf_name);
+ if (full_ttf_name == NULL ||
+ (ttf_file = MFOPEN (full_ttf_name, FOPEN_RBIN_MODE)) == NULL) {
+ fprintf (stderr, "Unable to find or open binary font file (%s)",
+ ttfs[ttf_id].ttf_name);
+ ERROR ("This existed when I checked it earlier!");
+ return;
+ }
+ /* Following section doesn't hide PDF stream structure very well */
+
+ /* The following section seems determines which, if any,
+ glyphs were used via the internal encoding, which hasn't
+ been known until now.*/
+ if (partial_enabled) {
+ int j;
+ if (verbose > 2) {
+ fprintf (stderr, "Default encoding:\n");
+ dump_glyphs (ttfs[ttf_id].int_encoding, 256, 1);
+ }
+ if (ttfs[ttf_id].used_def_enc_chars) {
+ if (verbose > 2)
+ fprintf (stderr, "\nRetaining portion of default encoding:\n");
+ for (j=0; j<256; j++) {
+ if ((ttfs[ttf_id].used_def_enc_chars)[j]) {
+ if (verbose > 2)
+ fprintf (stderr, "(%d/%s)", j, (ttfs[ttf_id].int_encoding)[j]);
+ ttf_add_to_used_glyphs (ttf_id, (ttfs[ttf_id].int_encoding)[j]);
+ }
+ }
+ }
+ }
+ {
+ char *buffer;
+ long size;
+ omit_unecessary (ttfs[ttf_id].directory);
+ buffer = ttf_build_font (ttf_file, ttfs[ttf_id].directory, &size);
+ MFCLOSE (ttf_file);
+ stream_dict = pdf_stream_dict (ttfs[ttf_id].direct);
+ pdf_add_stream(ttfs[ttf_id].direct, buffer, size);
+ RELEASE (buffer);
+ pdf_add_dict (stream_dict, pdf_new_name ("Length1"),
+ pdf_new_number (size));
+ pdf_release_obj (ttfs[ttf_id].direct);
+ /* Finally, flush the descriptor */
+ pdf_release_obj (ttfs[ttf_id].descriptor);
+ }
+ return;
+}
+
+void ttf_flush_all (void)
+{
+ int i;
+ for (i=0; i<num_ttfs; i++) {
+ do_ttf(i);
+ ttf_release (i);
+ }
+ if (ttfs)
+ RELEASE (ttfs);
+}
+
+struct a_ttf_font
+{
+ pdf_obj *indirect, *encoding;
+ long ttf_id;
+ int encoding_id;
+ char *used_chars;
+} *ttf_fonts = NULL;
+int num_ttf_fonts = 0, max_ttf_fonts = 0;
+
+
+static void init_a_ttf_font (struct a_ttf_font *this_ttf_font)
+{
+ if (partial_enabled) {
+ this_ttf_font -> used_chars = new_used_chars ();
+ } else {
+ this_ttf_font -> used_chars = NULL;
+ }
+}
+
+pdf_obj *ttf_font_resource (int ttf_id)
+{
+ if (ttf_id>=0 && ttf_id<max_ttf_fonts)
+ return pdf_link_obj(ttf_fonts[ttf_id].indirect);
+ else {
+ ERROR ("Invalid font id in ttf_font_resource");
+ return NULL;
+ }
+}
+
+char *ttf_font_used (int ttf_id)
+{
+ char *result;
+ if (ttf_id>=0 && ttf_id<max_ttf_fonts) {
+ result = ttf_fonts[ttf_id].used_chars;
+ } else {
+ fprintf (stderr, "ttf_font_used: ttf_id=%d\n", ttf_id);
+ ERROR ("Invalid font id in ttf_font_used");
+ }
+ return result;
+}
+
+
+
+int ttf_font (const char *map_name, int tfm_font_id, char
+ *resource_name, int encoding_id, int remap)
+{
+ int i, result = -1;
+ int tfm_firstchar, tfm_lastchar;
+ int pdf_firstchar, pdf_lastchar;
+ int ttf_id = -1;
+ pdf_obj *font_resource=NULL, *tmp1, *font_encoding_ref;
+
+ if (num_ttf_fonts >= max_ttf_fonts) {
+ max_ttf_fonts = MAX (max_ttf_fonts+MAX_FONTS, num_ttf_fonts+1);
+ ttf_fonts = RENEW (ttf_fonts, max_ttf_fonts, struct
+ a_ttf_font);
+ }
+
+ if ((ttf_id = ttf_get_id(map_name)) >= 0) {
+ /* Looks like we have a physical font (either a reader font or a
+ Type 1 font binary file). */
+ init_a_ttf_font (ttf_fonts+num_ttf_fonts);
+ ttf_fonts[num_ttf_fonts].ttf_id = ttf_id;
+ ttf_fonts[num_ttf_fonts].encoding_id = encoding_id;
+ /* Allocate a dictionary for the physical font */
+ font_resource = pdf_new_dict ();
+ if (ttf_fonts[num_ttf_fonts].encoding_id >= 0) {
+ font_encoding_ref = encoding_ref (encoding_id);
+ pdf_add_dict (font_resource,
+ pdf_new_name ("Encoding"),
+ font_encoding_ref);
+ }
+ pdf_add_dict (font_resource,
+ pdf_new_name ("Type"),
+ pdf_new_name ("Font"));
+ pdf_add_dict (font_resource,
+ pdf_new_name ("Subtype"),
+ pdf_new_name ("TrueType"));
+ pdf_add_dict (font_resource,
+ pdf_new_name ("Name"),
+ pdf_new_name (resource_name));
+ if (ttf_fonts[num_ttf_fonts].ttf_id >= 0) {
+ pdf_add_dict (font_resource,
+ pdf_new_name ("FontDescriptor"),
+ pdf_ref_obj(ttfs[ttf_fonts[num_ttf_fonts].ttf_id].descriptor));
+ }
+ /* If we are embedding this font, it may have been used by another virtual
+ font and we need to use the same mangled name. Mangled
+ names are known only to the ttf module, so we call it to get
+ the name */
+ if (ttf_fonts[num_ttf_fonts].ttf_id >= 0) {
+ pdf_add_dict (font_resource,
+ pdf_new_name ("BaseFont"),
+ pdf_new_name
+ (ttf_fontname(ttf_fonts[num_ttf_fonts].ttf_id)));
+ /* Otherwise we use the base name */
+ } else {
+ pdf_add_dict (font_resource,
+ pdf_new_name ("BaseFont"),
+ pdf_new_name (map_name));
+ }
+ tfm_firstchar = tfm_get_firstchar(tfm_font_id);
+ tfm_lastchar = tfm_get_lastchar(tfm_font_id);
+ if (partial_enabled && remap) {
+ unsigned char t;
+ pdf_firstchar=255; pdf_lastchar=0;
+ for (i=tfm_firstchar; i<=tfm_lastchar; i++) {
+ if ((t=twiddle(i)) < pdf_firstchar)
+ pdf_firstchar = t;
+ if (t > pdf_lastchar)
+ pdf_lastchar = t;
+ }
+ } else {
+ pdf_firstchar = tfm_firstchar;
+ pdf_lastchar = tfm_lastchar;
+ }
+ pdf_add_dict (font_resource,
+ pdf_new_name ("FirstChar"),
+ pdf_new_number (pdf_firstchar));
+ pdf_add_dict (font_resource,
+ pdf_new_name ("LastChar"),
+ pdf_new_number (pdf_lastchar));
+ tmp1 = pdf_new_array ();
+ for (i=pdf_firstchar; i<=pdf_lastchar; i++) {
+ if (partial_enabled && remap) {
+ int t;
+ if ((t=untwiddle(i)) <= tfm_lastchar && t>=tfm_firstchar)
+ pdf_add_array (tmp1,
+ pdf_new_number(ROUND(tfm_get_width
+ (tfm_font_id,t)*1000.0,0.1)));
+ else
+ pdf_add_array (tmp1,
+ pdf_new_number(0.0));
+ } else
+ pdf_add_array (tmp1,
+ pdf_new_number(ROUND(tfm_get_width
+ (tfm_font_id, i)*1000.0,0.1)));
+ }
+ pdf_add_dict (font_resource,
+ pdf_new_name ("Widths"),
+ tmp1);
+ ttf_fonts[num_ttf_fonts].indirect = pdf_ref_obj(font_resource);
+ pdf_release_obj (font_resource);
+ result = num_ttf_fonts;
+ num_ttf_fonts += 1;
+ }
+ return result;
+}
+
+
+void ttf_close_all (void)
+{
+ int i, j;
+ /* Three arrays are created by this module and need to be released */
+ /* First, each TeX font name that ends up as a postscript font gets
+ added to ttf_fonts (yes, even Times-Roman, etc.) */
+ /* The first thing to do is to resolve all character references to
+ actual glyph references. If an external encoding is specified,
+ we simply look up the glyph name in the encoding. If the internal
+ encoding is being used, we add it to the used_chars array of
+ the internal encoding */
+ for (i=0; i<num_ttf_fonts; i++) {
+ /* If font subsetting is enabled, each used character needs
+ to be added to the used_glyphs array in the corresponding ttf
+ */
+ if (partial_enabled) {
+ /* We always consider .notdef to be used */
+ ttf_add_to_used_glyphs (ttf_fonts[i].ttf_id, ".notdef");
+ for (j=0; j<256; j++) {
+ char *glyph;
+ if (ttf_fonts[i].ttf_id >= 0 &&
+ ttf_fonts[i].encoding_id >= 0 &&
+ (ttf_fonts[i].used_chars)[j]) {
+ glyph = encoding_glyph (ttf_fonts[i].encoding_id,
+ j);
+ ttf_add_to_used_glyphs (ttf_fonts[i].ttf_id, glyph);
+ }
+ if (ttf_fonts[i].ttf_id >= 0 &&
+ ttf_fonts[i].encoding_id < 0 &&
+ (ttf_fonts[i].used_chars)[j])
+ ttf_add_to_used_chars (ttf_fonts[i].ttf_id, j);
+ }
+ }
+ if (ttf_fonts[i].used_chars)
+ RELEASE (ttf_fonts[i].used_chars);
+ pdf_release_obj (ttf_fonts[i].indirect);
+ }
+ if (ttf_fonts)
+ RELEASE (ttf_fonts);
+ /* Second every distinct ttf name ends up in ttfs. It is possible
+ that two distinct tex names map to the same ttf name. That's why
+ there is a separate array for ttfs */
+ /* Read any necessary font files and flush them */
+ ttf_flush_all();
+}
+
+
+#endif /* HAVE_TTF_FORMATS */
+
diff --git a/Build/source/texk/dvipdfm/ttf.h b/Build/source/texk/dvipdfm/ttf.h
new file mode 100755
index 00000000000..cefceaeeb0b
--- /dev/null
+++ b/Build/source/texk/dvipdfm/ttf.h
@@ -0,0 +1,39 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef TTF_H
+#define TTF_H
+
+#include "pdfobj.h"
+
+extern void ttf_set_verbose(void);
+extern pdf_obj *ttf_font_resource (int ttf_id);
+extern char *ttf_font_used (int ttf_id);
+extern void ttf_disable_partial (void);
+extern int ttf_font (const char *tex_name, int tfm_font_id, char
+ *resource_name, int encoding_id, int remap);
+extern void ttf_set_mapfile (const char *name);
+extern void ttf_close_all (void);
+#endif /* TTF_H */
diff --git a/Build/source/texk/dvipdfm/twiddle.h b/Build/source/texk/dvipdfm/twiddle.h
new file mode 100644
index 00000000000..066637bcca6
--- /dev/null
+++ b/Build/source/texk/dvipdfm/twiddle.h
@@ -0,0 +1,11 @@
+#define U(a) ((unsigned char)(a))
+#define twiddle(n) (( \
+ (U(n)<=9)? ((n)+161): \
+ (U(n)<=32? ((n)+163): \
+ (U(n) == 127? 196: (n)))))
+
+#define untwiddle(n) (( \
+ ((U(n)>=161 && (U(n))<=170)? ((n)-161): \
+ ((U(n)>=173 && (U(n))<=195)? ((n)-163): \
+ (U(n) == 196? 127: (n))))))
+
diff --git a/Build/source/texk/dvipdfm/type1.c b/Build/source/texk/dvipdfm/type1.c
new file mode 100644
index 00000000000..77eb1e46e2d
--- /dev/null
+++ b/Build/source/texk/dvipdfm/type1.c
@@ -0,0 +1,1372 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+/* This is tailored for PDF */
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <time.h>
+#include <ctype.h>
+#include "system.h"
+#include "mem.h"
+#include "error.h"
+#include "mfileio.h"
+#include "pdfobj.h"
+#include "numbers.h"
+#include "type1.h"
+#include "tfm.h"
+#include "pdfparse.h"
+#include "pdflimits.h"
+#include "t1crypt.h"
+#include "twiddle.h"
+#include "encodings.h"
+
+static unsigned char verbose = 0;
+
+void type1_set_verbose(void)
+{
+ if (verbose < 255) {
+ verbose += 1;
+ }
+}
+
+
+static unsigned long get_low_endian_quad (FILE *file)
+{
+ unsigned long result;
+ static unsigned bytes[4];
+ int ch, i;
+ for (i=0; i<4; i++) {
+ if ((ch = fgetc (file)) < 0) {
+ ERROR ("get_low_endian_quad: Error reading file");
+ }
+ bytes[i] = ch;
+ }
+ result = bytes[3];
+ for (i=2; i>=0; i--) {
+ result = result*256u + bytes[i];
+ }
+ return result;
+}
+
+/* PFB section */
+
+static char partial_enabled = 1;
+
+void type1_disable_partial (void)
+{
+ partial_enabled = 0;
+}
+
+static unsigned num_pfbs = 0;
+static unsigned max_pfbs = 0;
+struct a_pfb
+{
+ char *pfb_name;
+ char *fontname;
+ pdf_obj *direct, *indirect, *descriptor;
+ char **used_glyphs;
+ char **int_encoding;
+ char *used_def_enc_chars; /* The positions used from the default
+ encoding. When a default encoding
+ is used, the glyph names will not
+ be known until the font is actually
+ read. Since the glyph names are
+ unknown, only the positions of the
+ used chars are stored when the
+ default encoding is used */
+ unsigned n_used_glyphs, max_used_glyphs;
+} *pfbs = NULL;
+
+static void init_a_pfb (struct a_pfb *pfb)
+{
+ int i;
+ pfb -> n_used_glyphs = 0;
+ pfb -> max_used_glyphs = 0;
+ pfb -> used_glyphs = NULL;
+ pfb->pfb_name = NULL;
+ pfb->fontname = NULL;
+ pfb->direct = NULL;
+ pfb->indirect = NULL;
+ pfb->descriptor = NULL;
+ pfb -> used_def_enc_chars = NULL;
+ if (partial_enabled) {
+ pfb -> int_encoding = NEW (256, char *);
+ for (i=0; i<256; i++) {
+ (pfb -> int_encoding)[i] = NULL;
+ }
+ } else {
+ pfb -> int_encoding = NULL;
+ }
+}
+
+#include "standardenc.h"
+
+static void do_a_standard_enc(char **glyphs, char **encoding)
+{
+ int i;
+ for (i=0; i<256; i++) {
+ RELEASE (glyphs[i]);
+ glyphs[i] = NEW (strlen(encoding[i])+1, char);
+ strcpy (glyphs[i], encoding[i]);
+ }
+}
+#define FIXED_WIDTH 1
+#define SERIF 2
+#define STANDARD 32
+#define ITALIC 64
+#define SYMBOLIC 4 /* Fonts that don't have Adobe encodings (e.g.,
+ cmr, should be set to be symbolic */
+#define STEMV 80
+
+
+int CDECL glyph_cmp (const void *v1, const void *v2)
+{
+ char *s1, *s2;
+ s1 = *((char **) v1);
+ s2 = *((char **) v2);
+ return (strcmp (s1, s2));
+}
+
+int CDECL glyph_match (const void *key, const void *v)
+{
+ char *s;
+ s = *((char **) v);
+ return (strcmp (key, s));
+}
+
+static unsigned long parse_header (unsigned char *filtered, unsigned char *buffer,
+ unsigned long length, int pfb_id)
+{
+ /* If the encoding has been overridden, this routine should eliminate any
+ built-in encoding (other than things like StandardEncoding) in
+ the header to save space */
+
+ /* On second thought, that's the way it _should_ work, but the
+ reader doesn't seem to agree. The reader is happy if you don't
+ specify an encoding as long as you actually change the locations
+ in the overriding encoding. The reader is unhappy if you don't
+ specify an encoding and don't change the location of the
+ characters in the overriding encoding. Ghostscript doesn't
+ have a problem with it. */
+
+ unsigned char *filtered_pointer;
+ int state = 0;
+ char *start, *end, *lead;
+ int copy = 1;
+ int last_number = 0;
+ char *glyph = NULL;
+#ifdef MEM_DEBUG
+ MEM_START
+#endif
+ /* This routine uses a state machine parser rather than trying to
+ interpret Postcript the way mpost.c does. There are only
+ a few key parameters it is trying to find */
+
+ /* State definitions
+ state 0: Initial state
+ state 1: Saw /FontName
+ state 2: Saw /Encoding
+ state 3: Saw "dup" in state 2
+ state 4: Saw a number in state 3
+ state 5: Saw /glyphname in state 4
+ state 6: Saw /FontBBox in state 0
+ state 7: Saw a '{' or a '[' in state 6
+ state 8: Saw /ItalicAngle in state 0 */
+ /* As the parser operates, start always points to the next point in
+ the buffer */
+ start = (char *) buffer;
+ end = start+length;
+ filtered_pointer = filtered;
+ /* When the parser decides to keep text, the text
+ between lead and start is copied to the output buffer. To
+ keep a block of text from being copied, the parser simply
+ sets copy = 0 */
+ lead = start;
+ skip_white (&start, end);
+ if (filtered && lead != start) {
+ memcpy (filtered_pointer, lead, start-lead);
+ filtered_pointer += start-lead;
+ lead = start;
+ }
+ while (start < end) {
+ char *ident;
+ pdf_obj *pdfobj;
+ copy = 1; /* By default, we copy most things */
+ switch (state) {
+ /* First three states are very similar. In most cases we just
+ ignore other postscript junk and don't change state */
+ case 0:
+ case 1:
+ case 2:
+ switch (*start) {
+ /* Ignore arrays and procedures */
+ case '[':
+ case ']':
+ case '{':
+ case '}':
+ start += 1;
+ if (state >= 2)
+ state = 2;
+ break;
+ case '(':
+ pdfobj = parse_pdf_string (&start, end);
+ if (pdfobj == NULL) {
+ ERROR ("parse_header: Error parsing a string in pfb header");
+ }
+ pdf_release_obj (pdfobj);
+ if (state == 1) {
+ if (filtered)
+ sprintf ((char *)filtered_pointer, "/%s ", pfbs[pfb_id].fontname);
+ filtered_pointer += strlen ((char *)filtered_pointer);
+ copy = 0; /* Don't copy old string to output */
+ lead = start; /* Forget what we've seen */
+ state = 0;
+ }
+ if (state >= 2)
+ state = 2;
+ break;
+ case '/':
+ start += 1;
+ ident = parse_ident (&start, end);
+ if (state == 0 && !strcmp (ident, "FontName")) {
+ state = 1;
+ } else if (state == 0 && !strcmp (ident, "Encoding")) {
+ state = 2;
+ if (filtered && !pfbs[pfb_id].used_def_enc_chars) {
+ sprintf ((char *)filtered_pointer, "/Encoding StandardEncoding readonly ");
+ filtered_pointer += strlen ((char *)filtered_pointer);
+ }
+ } else if (state == 0 && !strcmp (ident, "FontBBox")) {
+ state = 6;
+ } else if (state == 0 && !strcmp (ident, "ItalicAngle")) {
+ state = 8;
+ } else if (state == 1) {
+ if (filtered) {
+ sprintf ((char *)filtered_pointer, "/%s ", pfbs[pfb_id].fontname);
+ filtered_pointer += strlen ((char *)filtered_pointer);
+ }
+ copy = 0; /* Don't copy old string to putput */
+ lead = start; /* Forget the name we've seen */
+ state = 0;
+ }
+ RELEASE (ident);
+ break;
+ default:
+ ident = parse_ident (&start, end);
+ if (state == 2 && !strcmp (ident, "def")) {
+ /* Assume this is the end of the encoding */
+ state = 0;
+ } else if (state == 2 &&
+ !strcmp (ident, "dup")) {
+ copy = 0; /* Don't copy this to output buffer until we
+ know if we want to keep it */
+ state = 3;
+ } else if (state == 2 &&
+ !strcmp (ident, "StandardEncoding") &&
+ pfbs[pfb_id].int_encoding) {
+ do_a_standard_enc(pfbs[pfb_id].int_encoding, standardencoding);
+ } else if (state == 2 &&
+ !strcmp (ident, "ISOLatin1Encoding") &&
+ pfbs[pfb_id].int_encoding) {
+ do_a_standard_enc(pfbs[pfb_id].int_encoding, isoencoding);
+ }
+ RELEASE (ident);
+ break;
+ }
+ break;
+ case 3:
+ ident = parse_ident (&start, end);
+ if (is_an_int (ident)) {
+ last_number = (int) atof (ident);
+ copy = 0; /* We still don't know if we want to keep it */
+ state = 4;
+ } else {
+ state = 2; /* Contents back to "lead" will be flushed */
+ }
+ RELEASE (ident);
+ break;
+ case 4:
+ if (*start == '/') {
+ start += 1;
+ glyph = parse_ident (&start, end);
+ copy = 0; /* We still don't know if we want to keep it.
+ Wait for a complete sequence before making
+ that decision */
+ state = 5;
+ } else {
+ state = 2;
+ }
+ break;
+ case 5:
+ ident = parse_ident (&start, end);
+ /* Here we either decide to keep or remove the encoding entry */
+ if (ident != NULL && !strcmp (ident, "put") &&
+ (int) last_number < 256 && (int) last_number >= 0) {
+ skip_white(&start, end); /* Remove white space */
+ lead = start; /* Remove this entry (it may or may not be
+ replaced with a rewritten entry) */
+ copy = 0;
+ if (filtered &&
+ pfbs[pfb_id].used_def_enc_chars &&
+ (pfbs[pfb_id].used_def_enc_chars)[last_number]) {
+ sprintf((char *) filtered_pointer, "dup %d /%s put\n",
+ last_number,
+ glyph);
+ filtered_pointer += strlen ((char *) filtered_pointer);
+ }
+ /* Add this glyph to the internal encoding table for the pfb
+ */
+ if (pfbs[pfb_id].int_encoding &&
+ (!(pfbs[pfb_id].int_encoding)[last_number])) {
+ if ((pfbs[pfb_id].int_encoding)[last_number]) {
+ RELEASE ((pfbs[pfb_id].int_encoding)[last_number]);
+ }
+ (pfbs[pfb_id].int_encoding)[last_number] = glyph;
+ glyph = NULL; /* Prevent glyph from being released */
+ }
+ }
+ if (glyph)
+ RELEASE (glyph);
+ if (ident != NULL)
+ RELEASE (ident);
+ state = 2;
+ break;
+ case 6:
+ switch (*start) {
+ case '[':
+ case '{':
+ start += 1 ;
+ state = 7;
+ break;
+ default:
+ state = 0; /* Something's probably wrong */
+ fprintf (stderr, "\nUnexpected token after FontBBox. Struggling along\n");
+ dump (start, end);
+ }
+ break;
+ case 7:
+ switch (*start) {
+ case ']':
+ case '}':
+ start += 1 ;
+ state = 0;
+ break;
+ case '{':
+ case '[':
+ case '(':
+ case '/':
+ state = 0; /* Something's probably wrong */
+ fprintf (stderr, "\nUnexpected token in FontBBox array. Struggling along\n");
+ dump (start, end);
+ break;
+ default:
+ ident = parse_ident (&start, end);
+ if ((ident) && is_a_number (ident)) {
+ pdf_obj *tmp = pdf_lookup_dict (pfbs[pfb_id].descriptor,
+ "FontBBox");
+ pdf_add_array (tmp, pdf_new_number (atof (ident)));
+ }
+ if (ident)
+ RELEASE (ident);
+ }
+ break;
+ case 8:
+ switch (*start) {
+ case '{': case '}': case '[': case ']': case '/':
+ state = 0;
+ break;
+ default:
+ ident = parse_ident (&start, end);
+ if ((ident) && is_a_number (ident)) {
+ double italic = atof(ident);
+ if (italic != 0.0) {
+ int flags = (int) pdf_number_value(pdf_lookup_dict (pfbs[pfb_id].descriptor,
+ "Flags"));
+ pdf_add_dict (pfbs[pfb_id].descriptor,
+ pdf_new_name ("ItalicAngle"),
+ pdf_new_number (italic));
+ pdf_add_dict (pfbs[pfb_id].descriptor,
+ pdf_new_name ("Flags"),
+ pdf_new_number (flags+ITALIC));
+ }
+ }
+ if (ident)
+ RELEASE (ident);
+ state = 0;
+ }
+ }
+ skip_white (&start, end);
+ if (state >=2 && state <= 5 && !pfbs[pfb_id].used_def_enc_chars) {
+ lead = start;
+ }
+ if (copy && start != lead) { /* Flush everything back to "lead" */
+ if (filtered) {
+ memcpy (filtered_pointer, lead, start-lead);
+ filtered_pointer += start-lead;
+ }
+ lead = start;
+ }
+ }
+#ifdef MEM_DEBUG
+ MEM_END
+#endif /* MEM_DEBUG */
+ return filtered? filtered_pointer-filtered: length;
+}
+
+static void dump_glyphs( char **glyphs, int n, int show_index)
+{
+ int i;
+ for (i=0; i<n; i++) {
+ if (show_index)
+ fprintf (stderr, "(%d", i);
+ if (glyphs[i])
+ fprintf (stderr, "/%s", glyphs[i]);
+ else
+ fprintf (stderr, "(null)");
+ if (show_index)
+ fprintf (stderr, ")");
+ }
+ return;
+}
+static void dump_used( char *used_chars)
+{
+ int i;
+ for (i=0; i<256; i++)
+ fprintf (stderr, "(%d/%d)", i, used_chars[i]);
+ return;
+}
+
+
+#define ASCII 1
+#define BINARY 2
+
+static int is_a_pfb (FILE *file)
+{
+ int result, ch;
+ if ((ch = fgetc (file)) == 128 &&
+ ((ch = fgetc (file)) == ASCII ||
+ (ch == BINARY))) {
+ result = 1;
+ } else
+ result = 0;
+ rewind (file);
+ return result;
+}
+
+static unsigned char *get_pfb_segment (unsigned long *length,
+ FILE *file, int expected_type)
+{
+ unsigned char *buffer = NULL;
+ unsigned long nread;
+ unsigned long new_length;
+ int stream_type, ch;
+
+ *length = 0;
+ /* Unfortunately, there can be several segments that need to be
+ concatenated, so we loop through all of them */
+ for (;;) {
+ if ((ch = fgetc (file)) < 0) /* Some files don't terminate
+ properly */
+ break;
+ if (ch != 128){
+ sprintf (work_buffer, "get_pfb_segment: Not a pfb file.\n");
+ sprintf (work_buffer, "get_pfb_segment: pfb header has %d, expecting 128\n", ch);
+ ERROR (work_buffer);
+ }
+ if ((stream_type = fgetc (file)) < 0 || stream_type != expected_type) {
+ seek_relative (file, -2); /* Backup up two (yuck!) */
+ break;
+ }
+ new_length = get_low_endian_quad (file);
+ if (verbose > 4) {
+ fprintf (stderr, "Length of next PFB segment: %ld\n",
+ new_length);
+ }
+ buffer = RENEW (buffer, (*length)+new_length, unsigned char);
+ if ((nread = fread(buffer+(*length), sizeof(unsigned char), new_length, file)) !=
+ new_length) {
+ fprintf (stderr, "Found only %ld/%ld bytes\n", nread, new_length);
+ ERROR ("type1_do_pfb_segment: Are you sure this is a pfb?");
+ }
+ *length += new_length;
+ }
+ if (*length == 0) {
+ ERROR ("type1_get_pfb_segment: Segment length is zero");
+ }
+ if (expected_type == ASCII) {
+ int i;
+ for (i=0; i<(*length); i++) {
+ if (buffer[i] == '\r')
+ buffer[i] = '\n'; /* Show my Unix prejudice */
+ }
+ }
+ return buffer;
+}
+
+static unsigned int glyph_length (char **glyphs)
+{
+ int i;
+ unsigned result = 0;
+ for (i=0; i<256; i++) {
+ result += strlen (glyphs[i]);
+ }
+ return result;
+}
+
+static char *pfb_find_name (FILE *pfb_file)
+{
+ unsigned char *buffer;
+ unsigned long length = 0;
+ char *start, *end, *fontname;
+ int state = 0;
+#ifdef MEM_DEBUG
+ MEM_START
+#endif
+ rewind (pfb_file);
+ buffer = get_pfb_segment (&length, pfb_file, ASCII);
+ /* State definitions
+ state 0: Initial state
+ state 1: Saw /FontName */
+ start = (char *) buffer;
+ end = start+length;
+ skip_white (&start, end);
+ fontname = NULL;
+ while (start < end && fontname == NULL) {
+ char *ident;
+ pdf_obj *pdfobj;
+ switch (*start) {
+ /* Ignore arrays and procedures */
+ case '[':
+ case ']':
+ case '{':
+ case '}':
+ start += 1;
+ if (state == 1) {
+ ERROR ("Garbage following /FontName");
+ }
+ break;
+ case '(':
+ pdfobj = parse_pdf_string (&start, end);
+ if (pdfobj == NULL) {
+ ERROR ("parse_header: Error parsing a string in pfb header");
+ }
+ if (state == 1) { /* This string must be the font name */
+ char *tmp = pdf_string_value (pdfobj);
+ fontname = NEW (strlen(tmp)+1, char);
+ memcpy (fontname, tmp, strlen(tmp)+1);
+ }
+ pdf_release_obj (pdfobj);
+ break;
+ case '/':
+ start += 1;
+ ident = parse_ident (&start, end);
+ if (state == 0 && !strcmp (ident, "FontName")) {
+ state = 1;
+ } else if (state == 1) {
+ fontname = NEW (strlen(ident)+1, char);
+ memcpy (fontname, ident, strlen(ident)+1);
+ }
+ RELEASE (ident);
+ break;
+ default:
+ ident = parse_ident (&start, end);
+ RELEASE (ident);
+ break;
+ }
+ skip_white (&start, end);
+ }
+ RELEASE (buffer);
+#ifdef MEM_DEBUG
+ MEM_END
+#endif /* MEM_DEBUG */
+ return fontname;
+}
+
+static void pfb_add_to_used_glyphs (int pfb_id, char *glyph)
+{
+ if (pfb_id >= 0 && pfb_id < num_pfbs && glyph) {
+ if (pfbs[pfb_id].n_used_glyphs == 0 ||
+ !bsearch (glyph, pfbs[pfb_id].used_glyphs,
+ pfbs[pfb_id].n_used_glyphs,
+ sizeof (char *), glyph_match)) {
+ if (pfbs[pfb_id].n_used_glyphs+1 >=
+ pfbs[pfb_id].max_used_glyphs) {
+ pfbs[pfb_id].max_used_glyphs += 16;
+ pfbs[pfb_id].used_glyphs = RENEW (pfbs[pfb_id].used_glyphs,
+ pfbs[pfb_id].max_used_glyphs,
+ char *);
+ }
+ (pfbs[pfb_id].used_glyphs)[pfbs[pfb_id].n_used_glyphs] =
+ NEW (strlen(glyph)+1, char);
+ strcpy((pfbs[pfb_id].used_glyphs)[pfbs[pfb_id].n_used_glyphs],
+ glyph);
+ pfbs[pfb_id].n_used_glyphs += 1;
+ qsort (pfbs[pfb_id].used_glyphs, pfbs[pfb_id].n_used_glyphs,
+ sizeof (char *), glyph_cmp);
+ }
+ }
+}
+
+static char *new_used_chars (void)
+{
+ char *result;
+ int i;
+ result = NEW (256, char);
+ for (i=0; i<256; i++) {
+ result[i] = 0;
+ }
+ return result;
+}
+
+/* Mark the character at position "code" as used in the pfb font
+ corresponding to "pfb_id" */
+static void pfb_add_to_used_chars (int pfb_id, unsigned code)
+{
+ if (pfb_id >= 0 && pfb_id < num_pfbs && code < 256) {
+ if (!pfbs[pfb_id].used_def_enc_chars) {
+ pfbs[pfb_id].used_def_enc_chars = new_used_chars();
+ }
+ (pfbs[pfb_id].used_def_enc_chars)[code] = 1;
+ }
+ if (code >= 256)
+ ERROR ("pfb_add_to_used_chars(): code >= 256");
+ return;
+}
+
+static unsigned long do_pfb_header (FILE *file, int pfb_id)
+{
+ unsigned char *buffer, *filtered = NULL;
+ unsigned long length = 0;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ buffer = get_pfb_segment (&length, file, ASCII);
+ if (partial_enabled) {
+ filtered = NEW (length+strlen(pfbs[pfb_id].fontname)+1+1024, unsigned
+ char);
+ }
+ /* We must parse the header even if not doing font subsetting so
+ that we can determine the parameters for the font descriptor.
+ parse_head() won't write to a null pointer */
+ length = parse_header (filtered, buffer, length, pfb_id);
+ if (filtered) {
+ pdf_add_stream (pfbs[pfb_id].direct, (char *) filtered, length);
+ RELEASE (filtered);
+ } else {
+ pdf_add_stream (pfbs[pfb_id].direct, (char *) buffer, length);
+ }
+ RELEASE (buffer);
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return length;
+}
+
+
+static unsigned long parse_body (unsigned char *filtered, unsigned char
+ *unfiltered, unsigned long length,
+ char **used_glyphs, unsigned *n_used,
+ pdf_obj *descriptor)
+{
+ char *start, *end, *tail, *ident;
+ unsigned char *filtered_pointer;
+ double last_number = 0.0;
+ int state = 0;
+ if (verbose > 2) {
+ fprintf (stderr, "\nSearching for following glyphs in font:\n");
+ dump_glyphs (used_glyphs, *n_used, 0);
+ }
+ start = (char *) unfiltered, end = (char *) unfiltered+length;
+ /* Skip first four bytes */
+ tail = start; filtered_pointer = filtered;
+ start += 4;
+ /* Skip everything up to the charstrings section */
+ while (start < end) {
+ pdf_obj *pdfobj;
+ skip_white (&start, end);
+ /* Very simple state machine
+ state = 0: nothing special
+ state = 1: Saw StdVW, but waiting for number after it */
+ switch (*start) {
+ case '[':
+ case ']':
+ case '{':
+ case '}':
+ start += 1;
+ continue;
+ case '(':
+ pdfobj = parse_pdf_string (&start, end);
+ if (pdfobj == NULL) {
+ ERROR ("Error processing a string in a PFB file.");
+ }
+ pdf_release_obj (pdfobj);
+ continue;
+ case '/':
+ start += 1;
+ if ((ident = parse_ident (&start, end)) &&
+ !strcmp ((char *) ident, "CharStrings")) {
+ RELEASE (ident);
+ break;
+ } else if (ident && !strcmp ((char *) ident, "StdVW")) {
+ state = 1; /* Saw StdVW */
+ }
+ if (ident) {
+ RELEASE (ident);
+ } else {
+ fprintf (stderr, "\nError processing identifier in PFB file.\n");
+ dump (start, end);
+ }
+ continue;
+ default:
+ ident = parse_ident (&start, end);
+ if (ident == NULL)
+ ERROR ("Error processing a symbol in the PFB file.");
+ if (is_an_int(ident))
+ if (state == 1) {
+ pdf_add_dict (descriptor, pdf_new_name ("StemV"),
+ pdf_new_number (atof (ident)));
+ state = 0; /* Return to normal processing */
+ } else
+ last_number = atof (ident); /* Might be start of RD */
+ else {
+ if (!strcmp (ident, "RD") ||
+ !strcmp (ident, "-|")) {
+ start += ((unsigned long) last_number) + 1;
+ }
+ }
+ RELEASE (ident);
+ continue;
+ }
+ break;
+ }
+ if (start >= end)
+ ERROR ("Unexpected end of binary portion of PFB file");
+ /* Copy what we have so far over to the new buffer */
+ if (filtered) {
+ memcpy (filtered_pointer, tail, start-tail);
+ /* Advance pointer into new buffer */
+ filtered_pointer += (start-tail);
+ }
+ /* At this point, start is positioned just before the beginning of the glyphs, just after
+ the word /CharStrings. The earlier portion of the input buffer has
+ been copied to the output. The remainder of the routine need not
+ be executed if not doing font subsetting */
+ if (filtered) {
+ char **this_glyph;
+ sprintf ((char *) filtered_pointer, " %d", *n_used);
+ filtered_pointer += strlen ((char *) filtered_pointer);
+ skip_white(&start, end);
+ /* The following ident *should* be the number of glyphs in this
+ file */
+ ident = parse_ident (&start, end);
+ if (verbose>1) {
+ fprintf (stderr, "\n Embedding %d of %s glyphs\n", *n_used, ident);
+ }
+ if (ident == NULL || !is_an_int (ident) || *n_used > atof (ident))
+ ERROR ("More glyphs needed than present in file");
+ RELEASE (ident);
+ tail = start;
+ while (start < end && *start != '/') start++;
+ if (filtered) {
+ memcpy (filtered_pointer, tail, start-tail);
+ filtered_pointer += (start-tail);
+ }
+ /* Now we are exactly at the beginning of the glyphs */
+ while (start < end && *start == '/') {
+ char *glyph;
+ tail = start;
+ start += 1;
+ glyph = parse_ident (&start, end);
+ /* Get the number that should follow the glyph name */
+ skip_white(&start, end);
+ ident = parse_ident (&start, end);
+ if (!is_an_int (ident))
+ ERROR ("Expecting an integer after glyph name");
+ last_number = atof (ident);
+ RELEASE (ident);
+ /* The next identifier should be a "RD" or a "-|". We don't
+ really care what it is */
+ skip_white(&start, end);
+ ident = parse_ident (&start, end);
+ RELEASE (ident);
+ /* Skip a blank */
+ start += 1;
+ /* Skip the binary stream */
+ start += (unsigned long) last_number;
+ /* Skip the "ND" or "|-" terminator */
+ skip_white(&start, end);
+ ident = parse_ident (&start, end);
+ RELEASE (ident);
+ skip_white (&start, end);
+ if (*n_used != 0 && (this_glyph = bsearch (glyph, used_glyphs, *n_used, sizeof (char *),
+ glyph_match))) {
+ memcpy (filtered_pointer, tail, start-tail);
+ filtered_pointer += start-tail;
+ (*n_used)--;
+ /* Remove glyph and rearrange used_glyphs array */
+ {
+ RELEASE (*this_glyph);
+ (*this_glyph) = used_glyphs[*n_used];
+ qsort (used_glyphs, *n_used, sizeof (char *), glyph_cmp);
+ }
+ }
+ RELEASE (glyph);
+ }
+ if (*n_used != 0) {
+ fprintf (stderr, "Didn't find following required glyphs in the font:\n");
+ dump_glyphs (used_glyphs, *n_used, 0);
+ ERROR ("Possibly the encoding is incorrect.");
+ }
+ /* Include the rest of the file verbatim */
+ if (start < end){
+ memcpy (filtered_pointer, start, end-start);
+ filtered_pointer += end-start;
+ }
+ if (verbose>1) {
+ fprintf (stderr, " (subsetting eliminated %ld bytes)", length-(filtered_pointer-filtered));
+ }
+ }
+ return (filtered? filtered_pointer-filtered: length);
+}
+
+static unsigned long do_pfb_body (FILE *file, int pfb_id)
+{
+ int i;
+ unsigned char *buffer=NULL, *filtered=NULL;
+ unsigned long length=0;
+#ifdef MEM_DEBUG
+ MEM_START
+#endif
+ buffer = get_pfb_segment (&length, file, BINARY);
+ /* We need to decrypt the binary
+ portion of the pfb */
+ t1_crypt_init(EEKEY);
+ for (i=0; i<length; i++) {
+ buffer[i] = t1_decrypt(buffer[i]);
+ }
+ if (partial_enabled) {
+ filtered = NEW (length, unsigned char);
+ }
+ length = parse_body (filtered, buffer, length,
+ pfbs[pfb_id].used_glyphs,
+ &pfbs[pfb_id].n_used_glyphs,
+ pfbs[pfb_id].descriptor);
+ /* And reencrypt the whole thing */
+ t1_crypt_init (EEKEY);
+ for (i=0; i<length; i++) {
+ buffer[i] = t1_encrypt(partial_enabled? filtered[i]: buffer[i]);
+ }
+ if (filtered)
+ RELEASE (filtered);
+ pdf_add_stream (pfbs[pfb_id].direct, (char *) buffer, length);
+ RELEASE (buffer);
+#ifdef MEM_DEBUG
+ MEM_START
+#endif
+ return length;
+}
+
+static unsigned long do_pfb_trailer (FILE *file, pdf_obj *stream)
+{
+ unsigned char *buffer;
+ unsigned long length;
+ buffer = get_pfb_segment (&length, file, ASCII);
+ pdf_add_stream (stream, (char *) buffer, length);
+ RELEASE (buffer);
+ return length;
+}
+
+
+static pdf_obj *type1_fontfile (int pfb_id)
+{
+ if (pfb_id >= 0 && pfb_id < num_pfbs)
+ return pdf_link_obj(pfbs[pfb_id].indirect);
+ else
+ return NULL;
+}
+
+static char *type1_fontname (int pfb_id)
+{
+ if (pfb_id >= 0 && pfb_id < num_pfbs)
+ return pfbs[pfb_id].fontname;
+ else
+ return NULL;
+}
+
+/* Mangle_fontname mangles the name in place. fontname
+ must be big enough to add seven characters */
+
+static void mangle_fontname(char *fontname)
+{
+ int i;
+ char ch;
+ static char first = 1;
+ memmove (fontname+7, fontname, strlen(fontname)+1);
+ /* The following procedure isn't very random, but it
+ doesn't need to be for this application. */
+ if (first) {
+ srand (time(NULL));
+ first = 0;
+ }
+ for (i=0; i<6; i++) {
+ ch = rand() % 26;
+ fontname[i] = ch+'A';
+ }
+ fontname[6] = '+';
+}
+
+
+/* This routine builds a default font descriptor with dummy values
+ filled in for the required keys. As the pfb file is parsed,
+ any values that are found are rewritten. By doing this,
+ all the required fields are found in the font descriptor
+ even if the pfb is somewhat defective. This approach is
+ conservative, with the cost of keeping the names around in memory
+ for a while.
+*/
+
+static void type1_start_font_descriptor (int pfb_id)
+{
+ pdf_obj *tmp1;
+ pfbs[pfb_id].descriptor = pdf_new_dict ();
+ pdf_add_dict (pfbs[pfb_id].descriptor,
+ pdf_new_name ("Type"),
+ pdf_new_name ("FontDescriptor"));
+ /* For now, insert dummy values */
+ pdf_add_dict (pfbs[pfb_id].descriptor,
+ pdf_new_name ("CapHeight"),
+ pdf_new_number (850.0)); /* This number is arbitrary */
+ pdf_add_dict (pfbs[pfb_id].descriptor,
+ pdf_new_name ("Ascent"),
+ pdf_new_number (850.0)); /* This number is arbitrary */
+ pdf_add_dict (pfbs[pfb_id].descriptor,
+ pdf_new_name ("Descent"),
+ pdf_new_number (-200.0));
+ tmp1 = pdf_new_array ();
+ pdf_add_dict (pfbs[pfb_id].descriptor, pdf_new_name ("FontBBox"), tmp1);
+ pdf_add_dict (pfbs[pfb_id].descriptor,
+ pdf_new_name ("FontName"),
+ pdf_new_name (type1_fontname(pfb_id)));
+
+ pdf_add_dict (pfbs[pfb_id].descriptor,
+ pdf_new_name ("ItalicAngle"),
+ pdf_new_number(0.0));
+ pdf_add_dict (pfbs[pfb_id].descriptor,
+ pdf_new_name ("StemV"), /* StemV is required, StemH
+ is not */
+ pdf_new_number (STEMV)); /* Use a default value */
+ /* You don't need a fontfile for the standard fonts */
+ if (pfb_id >= 0)
+ pdf_add_dict (pfbs[pfb_id].descriptor,
+ pdf_new_name ("FontFile"),
+ type1_fontfile (pfb_id));
+
+ pdf_add_dict (pfbs[pfb_id].descriptor,
+ pdf_new_name ("Flags"),
+ pdf_new_number (SYMBOLIC)); /* Treat all fonts as symbolic */
+ return;
+}
+
+static int pfb_get_id (const char *pfb_name)
+{
+ int i;
+ for (i=0; i<num_pfbs; i++) {
+ if (pfbs[i].pfb_name && !strcmp (pfbs[i].pfb_name, pfb_name))
+ break;
+ }
+ if (i == num_pfbs) { /* This font not previously called for */
+ FILE *pfb_file = NULL;
+ char *full_pfb_name, *short_fontname;
+ if (!(full_pfb_name = kpse_find_file (pfb_name, kpse_type1_format,
+ 1)) ||
+ !(pfb_file = MFOPEN (full_pfb_name, FOPEN_RBIN_MODE)) ||
+ !(is_a_pfb (pfb_file))) {
+ if (pfb_file)
+ MFCLOSE (pfb_file);
+ i = -1;
+ } else {
+ short_fontname = pfb_find_name (pfb_file);
+ MFCLOSE (pfb_file);
+ if (num_pfbs >= max_pfbs) {
+ max_pfbs += MAX_FONTS;
+ pfbs = RENEW (pfbs, max_pfbs, struct a_pfb);
+ }
+ num_pfbs += 1;
+ init_a_pfb (pfbs+i);
+ pfbs[i].pfb_name = NEW (strlen(pfb_name)+1, char);
+ strcpy (pfbs[i].pfb_name, pfb_name);
+ pfbs[i].direct = pdf_new_stream(STREAM_COMPRESS);
+ pfbs[i].indirect = pdf_ref_obj (pfbs[i].direct);
+ if (partial_enabled) {
+ pfbs[i].fontname = NEW (strlen(short_fontname)+8, char);
+ strcpy (pfbs[i].fontname, short_fontname);
+ mangle_fontname(pfbs[i].fontname);
+ }
+ else {
+ pfbs[i].fontname = NEW (strlen(short_fontname)+1, char);
+ strcpy (pfbs[i].fontname, short_fontname);
+ }
+ type1_start_font_descriptor(i);
+ if (short_fontname)
+ RELEASE (short_fontname);
+ }
+ }
+ return i;
+}
+
+static void pfb_release (int id)
+{
+ if (id >= 0 && id < num_pfbs) {
+ pdf_release_obj (pfbs[id].direct);
+ RELEASE (pfbs[id].pfb_name);
+ pdf_release_obj (pfbs[id].indirect);
+ RELEASE (pfbs[id].fontname);
+ if (pfbs[id].used_def_enc_chars)
+ RELEASE (pfbs[id].used_def_enc_chars);
+ if (pfbs[id].int_encoding){
+ int i;
+ for (i=0; i<256; i++) {
+ if ((pfbs[id].int_encoding)[i])
+ RELEASE ((pfbs[id].int_encoding)[i]);
+ }
+ RELEASE (pfbs[id].int_encoding);
+ }
+ if (pfbs[id].used_glyphs) {
+ unsigned i;
+ for (i=0; i<pfbs[id].n_used_glyphs; i++) {
+ RELEASE ((pfbs[id].used_glyphs)[i]);
+ }
+ RELEASE (pfbs[id].used_glyphs);
+ }
+ }
+}
+
+static void release_glyphs (char **glyphs)
+{
+ int i;
+ for (i=0; i<256; i++) {
+ RELEASE (glyphs[i]);
+ }
+}
+
+static void do_pfb (int pfb_id)
+{
+ char *full_pfb_name;
+ FILE *type1_binary_file;
+ pdf_obj *stream_dict;
+ unsigned long length1, length2, length3;
+ int ch;
+ full_pfb_name = kpse_find_file (pfbs[pfb_id].pfb_name, kpse_type1_format,
+ 1);
+ if (verbose == 1)
+ fprintf (stderr, "(PFB:%s", pfbs[pfb_id].pfb_name);
+ if (verbose > 1)
+ fprintf (stderr, "(PFB:%s", full_pfb_name);
+ if (full_pfb_name == NULL ||
+ (type1_binary_file = MFOPEN (full_pfb_name, FOPEN_RBIN_MODE)) == NULL) {
+ fprintf (stderr, "type1_fontfile: Unable to find or open binary font file (%s)",
+ pfbs[pfb_id].pfb_name);
+ ERROR ("This existed when I checked it earlier!");
+ return;
+ }
+ /* Following section doesn't hide PDF stream structure very well */
+ length1 = do_pfb_header (type1_binary_file, pfb_id);
+ /* The following section seems determines which, if any,
+ glyphs were used via the internal encoding, which hasn't
+ been known until now.*/
+ if (partial_enabled) {
+ int j;
+ if (verbose > 2) {
+ fprintf (stderr, "Default encoding:\n");
+ dump_glyphs (pfbs[pfb_id].int_encoding, 256, 1);
+ }
+ if (pfbs[pfb_id].used_def_enc_chars) {
+ if (verbose > 2)
+ fprintf (stderr, "\nRetaining portion of default encoding:\n");
+ for (j=0; j<256; j++) {
+ if ((pfbs[pfb_id].used_def_enc_chars)[j]) {
+ if (verbose > 2)
+ fprintf (stderr, "(%d/%s)", j, (pfbs[pfb_id].int_encoding)[j]);
+ pfb_add_to_used_glyphs (pfb_id, (pfbs[pfb_id].int_encoding)[j]);
+ }
+ }
+ }
+ }
+ length2 = do_pfb_body (type1_binary_file, pfb_id);
+ length3 = do_pfb_trailer (type1_binary_file, pfbs[pfb_id].direct);
+ if ((ch = fgetc (type1_binary_file)) != 128 ||
+ (ch = fgetc (type1_binary_file)) != 3) {
+ fprintf (stderr, "\n\nWarning: PFB file may be improperly terminated\n");
+ }
+ /* Got entire file! */
+ if (verbose > 1)
+ fprintf (stderr, "\n Embedded size: %ld bytes\n", length1+length2+length3);
+ if (verbose) {
+ fprintf (stderr, ")");
+ }
+ MFCLOSE (type1_binary_file);
+ stream_dict = pdf_stream_dict (pfbs[pfb_id].direct);
+ pdf_add_dict (stream_dict, pdf_new_name("Length1"),
+ pdf_new_number (length1));
+ pdf_add_dict (stream_dict, pdf_new_name("Length2"),
+ pdf_new_number (length2));
+ pdf_add_dict (stream_dict, pdf_new_name("Length3"),
+ pdf_new_number (length3));
+ /* Finally, flush the descriptor */
+ pdf_release_obj (pfbs[pfb_id].descriptor);
+ return;
+}
+
+void pfb_flush_all (void)
+{
+ int i;
+ for (i=0; i<num_pfbs; i++) {
+ do_pfb(i);
+ pfb_release (i);
+ }
+ if (pfbs)
+ RELEASE (pfbs);
+}
+
+struct a_type1_font
+{
+ pdf_obj *indirect, *encoding;
+ long pfb_id;
+ int encoding_id;
+ char *used_chars;
+} *type1_fonts = NULL;
+int num_type1_fonts = 0, max_type1_fonts = 0;
+
+
+static void init_a_type1_font (struct a_type1_font *this_type1_font)
+{
+ if (partial_enabled) {
+ this_type1_font -> used_chars = new_used_chars ();
+ } else {
+ this_type1_font -> used_chars = NULL;
+ }
+}
+
+pdf_obj *type1_font_resource (int type1_id)
+{
+ if (type1_id>=0 && type1_id<max_type1_fonts)
+ return pdf_link_obj(type1_fonts[type1_id].indirect);
+ else {
+ ERROR ("Invalid font id in type1_font_resource");
+ return NULL;
+ }
+}
+
+char *type1_font_used (int type1_id)
+{
+ char *result;
+ if (type1_id>=0 && type1_id<max_type1_fonts) {
+ result = type1_fonts[type1_id].used_chars;
+ } else {
+ fprintf (stderr, "type1_font_used: type1_id=%d\n", type1_id);
+ ERROR ("Invalid font id in type1_font_used");
+ }
+ return result;
+}
+
+
+static int is_a_base_font (const char *name)
+{
+ static char *basefonts[] = {
+ "Courier", "Courier-Bold", "Courier-Oblique",
+ "Courier-BoldOblique", "Helvetica", "Helvetica-Bold",
+ "Helvetica-Oblique", "Helvetica-BoldOblique", "Symbol",
+ "Times-Roman", "Times-Bold", "Times-Italic",
+ "Times-BoldItalic", "ZapfDingbats"
+ };
+ int i;
+ for (i=0; i<14; i++) {
+ if (!strcmp (name, basefonts[i]))
+ return 1;
+ }
+ return 0;
+}
+
+int type1_font (const char *map_name, int tfm_font_id, char
+ *resource_name, int encoding_id, int remap)
+{
+ int i, result = -1;
+ int tfm_firstchar, tfm_lastchar;
+ int pdf_firstchar, pdf_lastchar;
+ int pfb_id = -1;
+ pdf_obj *font_resource, *tmp1, *font_encoding_ref;
+
+ if (num_type1_fonts >= max_type1_fonts) {
+ max_type1_fonts = MAX (max_type1_fonts+MAX_FONTS, num_type1_fonts+1);
+ type1_fonts = RENEW (type1_fonts, max_type1_fonts, struct
+ a_type1_font);
+ }
+
+ if ((map_name && is_a_base_font(map_name)) ||
+ (pfb_id = pfb_get_id(map_name)) >= 0) {
+ /* Looks like we have a physical font (either a reader font or a
+ Type 1 font binary file). */
+ init_a_type1_font (type1_fonts+num_type1_fonts);
+ type1_fonts[num_type1_fonts].pfb_id = pfb_id;
+ type1_fonts[num_type1_fonts].encoding_id = encoding_id;
+ /* Allocate a dictionary for the physical font */
+ font_resource = pdf_new_dict ();
+ if (type1_fonts[num_type1_fonts].encoding_id >= 0) {
+ font_encoding_ref = encoding_ref (encoding_id);
+ pdf_add_dict (font_resource,
+ pdf_new_name ("Encoding"),
+ font_encoding_ref);
+ }
+ pdf_add_dict (font_resource,
+ pdf_new_name ("Type"),
+ pdf_new_name ("Font"));
+ pdf_add_dict (font_resource,
+ pdf_new_name ("Subtype"),
+ pdf_new_name ("Type1"));
+ pdf_add_dict (font_resource,
+ pdf_new_name ("Name"),
+ pdf_new_name (resource_name));
+ if (type1_fonts[num_type1_fonts].pfb_id >= 0) {
+ pdf_add_dict (font_resource,
+ pdf_new_name ("FontDescriptor"),
+ pdf_ref_obj(pfbs[type1_fonts[num_type1_fonts].pfb_id].descriptor));
+ }
+ /* If we are embedding this font, it may have been used by another virtual
+ font and we need to use the same mangled name. Mangled
+ names are known only to the pfb module, so we call it to get
+ the name */
+ if (type1_fonts[num_type1_fonts].pfb_id >= 0) {
+ pdf_add_dict (font_resource,
+ pdf_new_name ("BaseFont"),
+ pdf_new_name
+ (type1_fontname(type1_fonts[num_type1_fonts].pfb_id)));
+ /* Otherwise we use the base name */
+ } else {
+ pdf_add_dict (font_resource,
+ pdf_new_name ("BaseFont"),
+ pdf_new_name (map_name));
+ }
+ if (!(map_name && is_a_base_font (map_name))) {
+ tfm_firstchar = tfm_get_firstchar(tfm_font_id);
+ tfm_lastchar = tfm_get_lastchar(tfm_font_id);
+ if (remap) {
+ unsigned char t;
+ pdf_firstchar=255; pdf_lastchar=0;
+ for (i=tfm_firstchar; i<=tfm_lastchar; i++) {
+ if ((t=twiddle(i)) < pdf_firstchar)
+ pdf_firstchar = t;
+ if (t > pdf_lastchar)
+ pdf_lastchar = t;
+ }
+ } else {
+ pdf_firstchar = tfm_firstchar;
+ pdf_lastchar = tfm_lastchar;
+ }
+ pdf_add_dict (font_resource,
+ pdf_new_name ("FirstChar"),
+ pdf_new_number (pdf_firstchar));
+ pdf_add_dict (font_resource,
+ pdf_new_name ("LastChar"),
+ pdf_new_number (pdf_lastchar));
+ tmp1 = pdf_new_array ();
+ for (i=pdf_firstchar; i<=pdf_lastchar; i++) {
+ if (remap) {
+ int t;
+ if ((t=untwiddle(i)) <= tfm_lastchar && t>=tfm_firstchar)
+ pdf_add_array (tmp1,
+ pdf_new_number(ROUND(tfm_get_width
+ (tfm_font_id,t)*1000.0,0.1)));
+ else
+ pdf_add_array (tmp1,
+ pdf_new_number(0.0));
+ } else
+ pdf_add_array (tmp1,
+ pdf_new_number(ROUND(tfm_get_width
+ (tfm_font_id, i)*1000.0,0.1)));
+ }
+ pdf_add_dict (font_resource,
+ pdf_new_name ("Widths"),
+ tmp1);
+ }
+ type1_fonts[num_type1_fonts].indirect = pdf_ref_obj(font_resource);
+ pdf_release_obj (font_resource);
+ result = num_type1_fonts;
+ num_type1_fonts += 1;
+ } else { /* Don't have a physical font */
+ result = -1;
+ }
+ return result;
+}
+
+
+void type1_close_all (void)
+{
+ int i, j;
+ /* Three arrays are created by this module and need to be released */
+ /* First, each TeX font name that ends up as a postscript font gets
+ added to type1_fonts (yes, even Times-Roman, etc.) */
+ /* The first thing to do is to resolve all character references to
+ actual glyph references. If an external encoding is specified,
+ we simply look up the glyph name in the encoding. If the internal
+ encoding is being used, we add it to the used_chars array of
+ the internal encoding */
+ for (i=0; i<num_type1_fonts; i++) {
+ /* If font subsetting is enabled, each used character needs
+ to be added to the used_glyphs array in the corresponding pfb
+ */
+ if (partial_enabled) {
+ /* We always consider .notdef to be used */
+ pfb_add_to_used_glyphs (type1_fonts[i].pfb_id, ".notdef");
+ for (j=0; j<256; j++) {
+ char *glyph;
+ if (type1_fonts[i].pfb_id >= 0 &&
+ type1_fonts[i].encoding_id >= 0 &&
+ (type1_fonts[i].used_chars)[j]) {
+ glyph = encoding_glyph (type1_fonts[i].encoding_id,
+ j);
+ pfb_add_to_used_glyphs (type1_fonts[i].pfb_id, glyph);
+ }
+ if (type1_fonts[i].pfb_id >= 0 &&
+ type1_fonts[i].encoding_id < 0 &&
+ (type1_fonts[i].used_chars)[j])
+ pfb_add_to_used_chars (type1_fonts[i].pfb_id, j);
+ }
+ }
+ if (type1_fonts[i].used_chars)
+ RELEASE (type1_fonts[i].used_chars);
+ pdf_release_obj (type1_fonts[i].indirect);
+ }
+ RELEASE (type1_fonts);
+ /* Second every distinct pfb name ends up in pfbs. It is possible
+ that two distinct tex names map to the same pfb name. That's why
+ there is a separate array for pfbs */
+
+ /* Read any necessary font files and flush them */
+ pfb_flush_all();
+
+}
+
diff --git a/Build/source/texk/dvipdfm/type1.h b/Build/source/texk/dvipdfm/type1.h
new file mode 100644
index 00000000000..3c5a93cabd0
--- /dev/null
+++ b/Build/source/texk/dvipdfm/type1.h
@@ -0,0 +1,39 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+
+#ifndef TYPE1_H
+#define TYPE1_H
+
+#include "pdfobj.h"
+
+extern void type1_set_verbose(void);
+extern pdf_obj *type1_font_resource (int type1_id);
+extern char *type1_font_used (int type1_id);
+extern void type1_disable_partial (void);
+extern int type1_font (const char *tex_name, int tfm_font_id, char
+ *resource_name, int encoding_id, int remap);
+extern void type1_set_mapfile (const char *name);
+extern void type1_close_all (void);
+#endif /* TYPE1_H */
diff --git a/Build/source/texk/dvipdfm/version b/Build/source/texk/dvipdfm/version
new file mode 100644
index 00000000000..cad203ec44b
--- /dev/null
+++ b/Build/source/texk/dvipdfm/version
@@ -0,0 +1 @@
+0.13.2c
diff --git a/Build/source/texk/dvipdfm/vf.c b/Build/source/texk/dvipdfm/vf.c
new file mode 100644
index 00000000000..cfde19f14b4
--- /dev/null
+++ b/Build/source/texk/dvipdfm/vf.c
@@ -0,0 +1,1018 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#include <stdio.h>
+#include <ctype.h>
+#include "system.h"
+#include "mfileio.h"
+#include "pdflimits.h"
+#include "numbers.h"
+#include "mem.h"
+#include "error.h"
+#include "tfm.h"
+#include "pdfdev.h"
+#include "dvi.h"
+#include "vf.h"
+#include "config.h"
+
+#include "dvicodes.h"
+
+#define VF_ID 202
+#define FIX_WORD_BASE 1048576.0
+#define TEXPT2PT (72.0/72.27)
+#define FW2PT (TEXPT2PT/((double)(FIX_WORD_BASE)))
+
+static unsigned char verbose = 0, debug = 0;
+
+void vf_set_verbose(void)
+{
+ if (verbose < 255) {
+ verbose += 1;
+ }
+}
+
+
+struct font_def {
+ signed long font_id /* id used internally in vf file */;
+ unsigned long checksum, size, design_size;
+ char *directory, *name;
+ int tfm_id; /* id returned by TFM module */
+ int dev_id; /* id returned by DEV module */
+};
+
+
+typedef struct font_def dev_font;
+
+struct vf
+{
+ char *tex_name;
+ spt_t ptsize;
+ unsigned long design_size; /* A fixword-pts quantity */
+ int num_dev_fonts, max_dev_fonts;
+ dev_font *dev_fonts;
+ unsigned char **ch_pkt;
+ unsigned long *pkt_len;
+ unsigned num_chars;
+};
+
+struct vf *vf_fonts = NULL;
+int num_vf_fonts = 0, max_vf_fonts = 0;
+
+static int read_header(FILE *vf_file, int thisfont)
+{
+ int i, result = 1, ch;
+
+ /* Check for usual signature */
+ if ((ch = get_unsigned_byte (vf_file)) == PRE &&
+ (ch = get_unsigned_byte (vf_file)) == VF_ID) {
+
+ /* If here, assume it's a legitimate vf file */
+ ch = get_unsigned_byte (vf_file);
+
+ /* skip comment */
+ for (i=0; i<ch; i++)
+ get_unsigned_byte (vf_file);
+
+ /* Skip checksum */
+ get_unsigned_quad(vf_file);
+
+ vf_fonts[thisfont].design_size =
+ get_unsigned_quad(vf_file);
+ } else { /* Try to fail gracefully and return an error to caller */
+ fprintf (stderr, "VF file may be corrupt\n");
+ result = 0;
+ }
+ return result;
+}
+
+
+static void resize_vf_fonts(int size)
+{
+ int i;
+ if (size > max_vf_fonts) {
+ vf_fonts = RENEW (vf_fonts, size, struct vf);
+ for (i=max_vf_fonts; i<size; i++) {
+ vf_fonts[i].num_dev_fonts = 0;
+ vf_fonts[i].max_dev_fonts = 0;
+ vf_fonts[i].dev_fonts = NULL;
+ }
+ max_vf_fonts = size;
+ }
+ return;
+}
+
+static void resize_one_vf_font (struct vf *a_vf, unsigned size)
+{
+ unsigned i;
+ if (size > (a_vf->num_chars)) {
+ size = MAX (size, a_vf->num_chars+256);
+ a_vf->ch_pkt = RENEW (a_vf->ch_pkt, size, unsigned char *);
+ a_vf->pkt_len = RENEW (a_vf->pkt_len, size, unsigned long);
+ for (i=a_vf->num_chars; i<size; i++) {
+ (a_vf->ch_pkt)[i] = NULL;
+ (a_vf->pkt_len)[i] = 0;
+ }
+ a_vf->num_chars = size;
+ }
+}
+
+static void read_a_char_def(FILE *vf_file, int thisfont, unsigned long pkt_len,
+ unsigned ch)
+{
+ unsigned char *pkt;
+ if (debug)
+ fprintf (stderr, "read_a_char_def: len=%ld, ch=%d\n", pkt_len, ch);
+ /* Resize and initialize character arrays if necessary */
+ if (ch >= vf_fonts[thisfont].num_chars) {
+ resize_one_vf_font (vf_fonts+thisfont, ch+1);
+ }
+ if (pkt_len > 0) {
+ pkt = NEW (pkt_len, unsigned char);
+ if (fread (pkt, 1, pkt_len, vf_file) != pkt_len)
+ ERROR ("VF file ended prematurely.");
+ (vf_fonts[thisfont].ch_pkt)[ch] = pkt;
+ }
+ (vf_fonts[thisfont].pkt_len)[ch] = pkt_len;
+ return;
+}
+
+static void read_a_font_def(FILE *vf_file, signed long font_id, int thisfont)
+{
+ dev_font *dev_font;
+ int dir_length, name_length;
+ if (debug) {
+ fprintf (stderr, "read_a_font_def: font_id = %ld\n", font_id);
+ }
+ if (vf_fonts[thisfont].num_dev_fonts >=
+ vf_fonts[thisfont].max_dev_fonts) {
+ vf_fonts[thisfont].max_dev_fonts += VF_ALLOC_SIZE;
+ vf_fonts[thisfont].dev_fonts = RENEW
+ (vf_fonts[thisfont].dev_fonts,
+ vf_fonts[thisfont].max_dev_fonts,
+ struct font_def);
+ }
+ dev_font = vf_fonts[thisfont].dev_fonts+
+ vf_fonts[thisfont].num_dev_fonts;
+ dev_font -> font_id = font_id;
+ dev_font -> checksum = get_unsigned_quad (vf_file);
+ dev_font -> size = get_unsigned_quad (vf_file);
+ dev_font -> design_size = get_unsigned_quad (vf_file);
+ dir_length = get_unsigned_byte (vf_file);
+ name_length = get_unsigned_byte (vf_file);
+ dev_font -> directory = NEW (dir_length+1, char);
+ dev_font -> name = NEW (name_length+1, char);
+ fread (dev_font -> directory, 1, dir_length, vf_file);
+ fread (dev_font -> name, 1, name_length, vf_file);
+ (dev_font -> directory)[dir_length] = 0;
+ (dev_font -> name)[name_length] = 0;
+ vf_fonts[thisfont].num_dev_fonts += 1;
+ dev_font->tfm_id = tfm_open (dev_font -> name);
+ dev_font->dev_id =
+ dvi_locate_font (dev_font->name,
+ sqxfw (vf_fonts[thisfont].ptsize,
+ dev_font->size));
+ if (debug) {
+ fprintf (stderr, "[%s/%s]\n", dev_font -> directory, dev_font -> name);
+ }
+ return;
+}
+
+
+void process_vf_file (FILE *vf_file, int thisfont)
+{
+ int eof = 0, code;
+ unsigned long font_id;
+ while (!eof) {
+ code = get_unsigned_byte (vf_file);
+ switch (code) {
+ case FNT_DEF1:
+ font_id = get_unsigned_byte (vf_file);
+ read_a_font_def (vf_file, font_id, thisfont);
+ break;
+ case FNT_DEF2:
+ font_id = get_unsigned_pair (vf_file);
+ read_a_font_def (vf_file, font_id, thisfont);
+ break;
+ case FNT_DEF3:
+ font_id = get_unsigned_triple(vf_file);
+ read_a_font_def (vf_file, font_id, thisfont);
+ break;
+ case FNT_DEF4:
+ font_id = get_signed_quad(vf_file);
+ read_a_font_def (vf_file, font_id, thisfont);
+ break;
+ default:
+ if (code < 242) {
+ long ch;
+ /* For a short packet, code is the pkt_len */
+ ch = get_unsigned_byte (vf_file);
+ /* Skip over TFM width since we already know it */
+ get_unsigned_triple (vf_file);
+ read_a_char_def (vf_file, thisfont, code, ch);
+ break;
+ }
+ if (code == 242) {
+ unsigned long pkt_len, ch;
+ pkt_len = get_unsigned_quad(vf_file);
+ ch = get_unsigned_quad (vf_file);
+ /* Skip over TFM width since we already know it */
+ get_unsigned_quad (vf_file);
+ if (ch < 65536L)
+ read_a_char_def (vf_file, thisfont, pkt_len, ch);
+ else {
+ fprintf (stderr, "char=%ld\n", ch);
+ ERROR ("Long character (>16 bits) in VF file.\nI can't handle long characters!\n");
+ }
+ break;
+ }
+ if (code == POST) {
+ eof = 1;
+ break;
+ }
+ fprintf (stderr, "Quitting on code=%d\n", code);
+ eof = 1;
+ break;
+ }
+ }
+ return;
+}
+
+/* Unfortunately, the following code isn't smart enough
+ to load the vf only once for multiple point sizes.
+ You will get a separate copy of each VF in memory (and a separate
+ opening and reading of the file) for
+ each point size. Since VFs are pretty small, I guess
+ this is tolerable for now. In any case,
+ the PDF file will never repeat a physical font name */
+/* Note: This code needs to be able to recurse */
+/* Global variables such as num_vf_fonts require careful attention */
+int vf_locate_font (char *tex_name, spt_t ptsize)
+{
+ int thisfont = -1, i;
+ char *full_vf_file_name;
+ FILE *vf_file;
+ /* Has this name and ptsize already been loaded as a VF? */
+ for (i=0; i<num_vf_fonts; i++) {
+ if (!strcmp (vf_fonts[i].tex_name, tex_name) &&
+ vf_fonts[i].ptsize == ptsize)
+ break;
+ }
+ if (i != num_vf_fonts) {
+ thisfont = i;
+ } else {
+ /* It's hasn't already been loaded as a VF, so try to load it */
+ full_vf_file_name = kpse_find_file (tex_name,
+ kpse_vf_format,
+ 1);
+#ifdef HAVE_OMEGA_FORMATS
+ if (!full_vf_file_name) {
+ full_vf_file_name = kpse_find_file (tex_name,
+ kpse_ovf_format,
+ 1);
+ }
+#endif
+ if (full_vf_file_name &&
+ (vf_file = MFOPEN (full_vf_file_name, FOPEN_RBIN_MODE)) != NULL) {
+ if (verbose == 1)
+ fprintf (stderr, "(VF:%s", tex_name);
+ if (verbose > 1)
+ fprintf (stderr, "(VF:%s", full_vf_file_name);
+ if (num_vf_fonts >= max_vf_fonts) {
+ resize_vf_fonts (max_vf_fonts + VF_ALLOC_SIZE);
+ }
+ thisfont = num_vf_fonts++;
+ { /* Initialize some pointers and such */
+ vf_fonts[thisfont].tex_name = NEW (strlen(tex_name)+1, char);
+ strcpy (vf_fonts[thisfont].tex_name, tex_name);
+ vf_fonts[thisfont].ptsize = ptsize;
+ vf_fonts[thisfont].num_chars = 0;
+ vf_fonts[thisfont].ch_pkt = NULL;
+ vf_fonts[thisfont].pkt_len = NULL;
+ }
+ read_header(vf_file, thisfont);
+ process_vf_file (vf_file, thisfont);
+ if (verbose)
+ fprintf (stderr, ")");
+ MFCLOSE (vf_file);
+ }
+ }
+ return thisfont;
+}
+
+#define next_byte() (*((*start)++))
+static UNSIGNED_BYTE unsigned_byte (unsigned char **start, unsigned char *end)
+{
+ UNSIGNED_BYTE byte = 0;
+ if (*start < end)
+ byte = next_byte();
+ else
+ ERROR ("Premature end of DVI byte stream in VF font\n");
+ return byte;
+}
+
+static SIGNED_BYTE signed_byte (unsigned char **start, unsigned char *end)
+{
+ int byte = 0;
+ if (*start < end) {
+ byte = next_byte();
+ if (byte >= 0x80)
+ byte -= 0x100;
+ }
+ else
+ ERROR ("Premature end of DVI byte stream in VF font\n");
+ return (SIGNED_BYTE) byte;
+}
+
+static UNSIGNED_PAIR unsigned_pair (unsigned char **start, unsigned char *end)
+{
+ int i;
+ UNSIGNED_BYTE byte;
+ UNSIGNED_PAIR pair = 0;
+ if (end-*start > 1) {
+ for (i=0; i<2; i++) {
+ byte = next_byte();
+ pair = pair*0x100u + byte;
+ }
+ }
+ else
+ ERROR ("Premature end of DVI byte stream in VF font\n");
+ return pair;
+}
+
+static SIGNED_PAIR signed_pair (unsigned char **start, unsigned char *end)
+{
+ int i;
+ long pair = 0;
+ if (end - *start > 1) {
+ for (i=0; i<2; i++) {
+ pair = pair*0x100 + next_byte();
+ }
+ if (pair >= 0x8000) {
+ pair -= 0x10000l;
+ }
+ } else
+ ERROR ("Premature end of DVI byte stream in VF font\n");
+ return (SIGNED_PAIR) pair;
+}
+
+static UNSIGNED_TRIPLE unsigned_triple(unsigned char **start, unsigned
+ char *end)
+{
+ int i;
+ long triple = 0;
+ if (end-*start > 2) {
+ for (i=0; i<3; i++) {
+ triple = triple*0x100u + next_byte();
+ }
+ } else
+ ERROR ("Premature end of DVI byte stream in VF font\n");
+ return (UNSIGNED_TRIPLE) triple;
+}
+
+static SIGNED_TRIPLE signed_triple(unsigned char **start, unsigned char *end)
+{
+ int i;
+ long triple = 0;
+ if (end-*start > 2) {
+ for (i=0; i<3; i++) {
+ triple = triple*0x100 + next_byte();
+ }
+ if (triple >= 0x800000l)
+ triple -= 0x1000000l;
+ } else
+ ERROR ("Premature end of DVI byte stream in VF font\n");
+ return (SIGNED_TRIPLE) triple;
+}
+
+static SIGNED_QUAD signed_quad(unsigned char **start, unsigned char *end)
+{
+ int byte, i;
+ long quad = 0;
+ /* Check sign on first byte before reading others */
+ if (end-*start > 3) {
+ byte = next_byte();
+ quad = byte;
+ if (quad >= 0x80)
+ quad = byte - 0x100;
+ for (i=0; i<3; i++) {
+ quad = quad*0x100 + next_byte();
+ }
+ } else
+ ERROR ("Premature end of DVI byte stream in VF font\n");
+ return (SIGNED_QUAD) quad;
+}
+
+static UNSIGNED_QUAD unsigned_quad(unsigned char **start, unsigned char *end)
+{
+ int i;
+ unsigned long quad = 0;
+ if (end-*start > 3) {
+ for (i=0; i<4; i++) {
+ quad = quad*0x100u + next_byte();
+ }
+ } else
+ ERROR ("Premature end of DVI byte stream in VF font\n");
+ return (UNSIGNED_QUAD) quad;
+}
+
+static void vf_set (SIGNED_QUAD ch)
+{
+ /* Defer to the dvi_set() defined in dvi.c */
+ dvi_set (ch);
+ return;
+}
+
+static void vf_set1(unsigned char **start, unsigned char *end)
+{
+ vf_set (unsigned_byte(start, end));
+ return;
+}
+
+static void vf_set2(unsigned char **start, unsigned char *end)
+{
+ vf_set (unsigned_pair(start, end));
+ return;
+}
+
+static void vf_putrule(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ SIGNED_QUAD width, height;
+ height = signed_quad (start, end);
+ width = signed_quad (start, end);
+ if (width > 0 && height > 0) {
+ dvi_rule (sqxfw(ptsize,width), sqxfw(ptsize, height));
+ }
+ return;
+}
+
+static void vf_setrule(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ SIGNED_QUAD width, height, s_width;
+ height = signed_quad (start, end);
+ width = signed_quad (start, end);
+ s_width = sqxfw(ptsize, width);
+ if (width > 0 && height > 0) {
+ dvi_rule (s_width, sqxfw(ptsize, height));
+ }
+ dvi_right (s_width);
+ return;
+}
+
+static void vf_put1(unsigned char **start, unsigned char *end)
+{
+ dvi_put (unsigned_byte(start, end));
+ return;
+}
+
+static void vf_put2(unsigned char **start, unsigned char *end)
+{
+ dvi_put (unsigned_pair(start, end));
+ return;
+}
+
+static void vf_push(void)
+{
+ dvi_push();
+ return;
+}
+
+static void vf_pop(void)
+{
+ dvi_pop();
+ return;
+}
+
+static void vf_right (SIGNED_QUAD x, spt_t ptsize)
+{
+ dvi_right ((SIGNED_QUAD) (sqxfw(ptsize, x)));
+ return;
+}
+
+
+static void vf_right1(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_right (signed_byte (start, end), ptsize);
+ return;
+}
+
+static void vf_right2(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_right (signed_pair (start, end), ptsize);
+ return;
+}
+
+static void vf_right3(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_right (signed_triple (start, end), ptsize);
+ return;
+}
+
+static void vf_right4(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_right (signed_quad (start, end), ptsize);
+ return;
+}
+
+static void vf_w0(void)
+{
+ dvi_w0();
+ return;
+}
+
+static void vf_w (SIGNED_QUAD w, spt_t ptsize)
+{
+ dvi_w ((SIGNED_QUAD) (sqxfw(ptsize, w)));
+ return;
+}
+
+static void vf_w1(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_w (signed_byte(start, end), ptsize);
+ return;
+}
+
+static void vf_w2(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_w (signed_pair(start, end), ptsize);
+ return;
+}
+
+static void vf_w3(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_w (signed_triple(start, end), ptsize);
+ return;
+}
+
+static void vf_w4(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_w (signed_quad(start, end), ptsize);
+ return;
+}
+
+static void vf_x0(void)
+{
+ dvi_x0();
+ return;
+}
+
+static void vf_x (SIGNED_QUAD x, spt_t ptsize)
+{
+ dvi_x ((SIGNED_QUAD) (sqxfw(ptsize, x)));
+ return;
+}
+
+static void vf_x1(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_x (signed_byte(start, end), ptsize);
+ return;
+}
+
+static void vf_x2(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_x (signed_pair(start, end), ptsize);
+ return;
+}
+
+static void vf_x3(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_x (signed_triple(start, end), ptsize);
+ return;
+}
+
+static void vf_x4(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_x (signed_quad(start, end), ptsize);
+ return;
+}
+
+static void vf_down (SIGNED_QUAD y, spt_t ptsize)
+{
+ dvi_down ((SIGNED_QUAD) (sqxfw(ptsize, y)));
+ return;
+}
+
+static void vf_down1(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_down (signed_byte(start, end), ptsize);
+ return;
+}
+
+static void vf_down2(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_down (signed_pair(start, end), ptsize);
+ return;
+}
+
+static void vf_down3(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_down (signed_triple(start, end), ptsize);
+ return;
+}
+
+static void vf_down4(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_down (signed_quad(start, end), ptsize);
+ return;
+}
+
+static void vf_y0(void)
+{
+ dvi_y0();
+ return;
+}
+
+static void vf_y (SIGNED_QUAD y, spt_t ptsize)
+{
+ dvi_y ((SIGNED_QUAD) (sqxfw(ptsize, y)));
+ return;
+}
+
+
+static void vf_y1(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_y (signed_byte(start, end), ptsize);
+ return;
+}
+
+static void vf_y2(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_y (signed_pair(start, end), ptsize);
+ return;
+}
+
+static void vf_y3(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_y (signed_triple(start, end), ptsize);
+ return;
+}
+
+static void vf_y4(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_y (signed_quad(start, end), ptsize);
+ return;
+}
+
+static void vf_z0(void)
+{
+ dvi_z0();
+ return;
+}
+
+static void vf_z (SIGNED_QUAD z, spt_t ptsize)
+{
+ dvi_z ((SIGNED_QUAD) (sqxfw(ptsize, z)));
+ return;
+}
+
+static void vf_z1(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_z (signed_byte(start, end), ptsize);
+ return;
+}
+
+static void vf_z2(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_z (signed_pair(start, end), ptsize);
+ return;
+}
+
+static void vf_z3(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_z (signed_triple(start, end), ptsize);
+ return;
+}
+
+static void vf_z4(unsigned char **start, unsigned char *end, spt_t ptsize)
+{
+ vf_z (signed_quad(start, end), ptsize);
+ return;
+}
+
+static void vf_fnt (SIGNED_QUAD font_id, unsigned long vf_font)
+{
+ int i;
+ for (i=0; i<vf_fonts[vf_font].num_dev_fonts; i++) {
+ if (font_id == ((vf_fonts[vf_font].dev_fonts)[i]).font_id) {
+ break;
+ }
+ }
+ if (i < vf_fonts[vf_font].num_dev_fonts) { /* Font was found */
+ dvi_set_font ((vf_fonts[vf_font].dev_fonts[i]).dev_id);
+ } else {
+ fprintf (stderr, "Font_id: %ld not found in VF\n", font_id);
+ }
+ return;
+}
+
+static void vf_fnt1(unsigned char **start, unsigned char *end,
+ unsigned long vf_font)
+{
+ vf_fnt (unsigned_byte(start, end), vf_font);
+ return;
+}
+
+static void vf_fnt2(unsigned char **start, unsigned char *end,
+ unsigned long vf_font)
+{
+ vf_fnt (unsigned_pair(start, end), vf_font);
+ return;
+}
+
+static void vf_fnt3(unsigned char **start, unsigned char *end,
+ unsigned long vf_font)
+{
+ vf_fnt (unsigned_triple(start, end), vf_font);
+ return;
+}
+
+static void vf_fnt4(unsigned char **start, unsigned char *end,
+ unsigned long vf_font)
+{
+ vf_fnt (signed_quad(start, end), vf_font);
+ return;
+}
+
+static void vf_xxx (SIGNED_QUAD len, unsigned char **start, unsigned
+ char *end)
+{
+ /* For now, skip specials */
+ if (end-*start >= len)
+ *start += len;
+ else
+ ERROR ("Premature end of DVI byte stream in VF font\n");
+ return;
+}
+
+static void vf_xxx1(unsigned char **start, unsigned char *end)
+{
+ vf_xxx (unsigned_byte(start, end), start, end);
+ return;
+}
+
+static void vf_xxx2(unsigned char **start, unsigned char *end)
+{
+ vf_xxx (unsigned_pair(start, end), start, end);
+ return;
+}
+
+static void vf_xxx3(unsigned char **start, unsigned char *end)
+{
+ vf_xxx (unsigned_triple(start, end), start, end);
+ return;
+}
+
+static void vf_xxx4(unsigned char **start, unsigned char *end)
+{
+ vf_xxx (unsigned_quad(start, end), start, end);
+ return;
+}
+
+void vf_set_char(SIGNED_QUAD ch, int vf_font)
+{
+ unsigned char opcode;
+ unsigned char *start, *end;
+ spt_t ptsize;
+ int default_font = -1;
+ if (vf_font < num_vf_fonts) {
+ /* Initialize to the first font or -1 if undefined */
+ ptsize = vf_fonts[vf_font].ptsize;
+ if (vf_fonts[vf_font].num_dev_fonts > 0)
+ default_font = ((vf_fonts[vf_font].dev_fonts)[0]).dev_id;
+ dvi_vf_init (default_font);
+ if (ch >= vf_fonts[vf_font].num_chars ||
+ !(start = (vf_fonts[vf_font].ch_pkt)[ch])) {
+ fprintf (stderr, "\nchar=0x%lx(%ld)\n", ch, ch);
+ fprintf (stderr, "Tried to set a nonexistent character in a virtual font");
+ start = end = NULL;
+ } else {
+ end = start + (vf_fonts[vf_font].pkt_len)[ch];
+ }
+ while (start && start < end) {
+ opcode = *(start++);
+ if (debug) {
+ fprintf (stderr, "VF opcode: %d", opcode);
+ if (isprint (opcode)) fprintf (stderr, " (\'%c\')\n", opcode);
+ else fprintf (stderr, "\n");
+ }
+ switch (opcode)
+ {
+ case SET1:
+ vf_set1(&start, end);
+ break;
+ case SET2:
+ vf_set2(&start, end);
+ break;
+ case SET3:
+ case SET4:
+ ERROR ("Multibyte (>16 bits) character in VF packet.\nI can't handle this!");
+ break;
+ case SET_RULE:
+ vf_setrule(&start, end, ptsize);
+ break;
+ case PUT1:
+ vf_put1(&start, end);
+ break;
+ case PUT2:
+ vf_put2(&start, end);
+ break;
+ case PUT3:
+ case PUT4:
+ ERROR ("Multibyte (>16 bits) character in VF packet.\nI can't handle this!");
+ break;
+ case PUT_RULE:
+ vf_putrule(&start, end, ptsize);
+ break;
+ case NOP:
+ break;
+ case PUSH:
+ vf_push();
+ break;
+ case POP:
+ vf_pop();
+ break;
+ case RIGHT1:
+ vf_right1(&start, end, ptsize);
+ break;
+ case RIGHT2:
+ vf_right2(&start, end, ptsize);
+ break;
+ case RIGHT3:
+ vf_right3(&start, end, ptsize);
+ break;
+ case RIGHT4:
+ vf_right4(&start, end, ptsize);
+ break;
+ case W0:
+ vf_w0();
+ break;
+ case W1:
+ vf_w1(&start, end, ptsize);
+ break;
+ case W2:
+ vf_w2(&start, end, ptsize);
+ break;
+ case W3:
+ vf_w3(&start, end, ptsize);
+ break;
+ case W4:
+ vf_w4(&start, end, ptsize);
+ break;
+ case X0:
+ vf_x0();
+ break;
+ case X1:
+ vf_x1(&start, end, ptsize);
+ break;
+ case X2:
+ vf_x2(&start, end, ptsize);
+ break;
+ case X3:
+ vf_x3(&start, end, ptsize);
+ break;
+ case X4:
+ vf_x4(&start, end, ptsize);
+ break;
+ case DOWN1:
+ vf_down1(&start, end, ptsize);
+ break;
+ case DOWN2:
+ vf_down2(&start, end, ptsize);
+ break;
+ case DOWN3:
+ vf_down3(&start, end, ptsize);
+ break;
+ case DOWN4:
+ vf_down4(&start, end, ptsize);
+ break;
+ case Y0:
+ vf_y0();
+ break;
+ case Y1:
+ vf_y1(&start, end, ptsize);
+ break;
+ case Y2:
+ vf_y2(&start, end, ptsize);
+ break;
+ case Y3:
+ vf_y3(&start, end, ptsize);
+ break;
+ case Y4:
+ vf_y4(&start, end, ptsize);
+ break;
+ case Z0:
+ vf_z0();
+ break;
+ case Z1:
+ vf_z1(&start, end, ptsize);
+ break;
+ case Z2:
+ vf_z2(&start, end, ptsize);
+ break;
+ case Z3:
+ vf_z3(&start, end, ptsize);
+ break;
+ case Z4:
+ vf_z4(&start, end, ptsize);
+ break;
+ case FNT1:
+ vf_fnt1(&start, end, vf_font);
+ break;
+ case FNT2:
+ vf_fnt2(&start, end, vf_font);
+ break;
+ case FNT3:
+ vf_fnt3(&start, end, vf_font);
+ break;
+ case FNT4:
+ vf_fnt4(&start, end, vf_font);
+ break;
+ case XXX1:
+ vf_xxx1(&start, end);
+ break;
+ case XXX2:
+ vf_xxx2(&start, end);
+ break;
+ case XXX3:
+ vf_xxx3(&start, end);
+ break;
+ case XXX4:
+ vf_xxx4(&start, end);
+ break;
+ default:
+ if (opcode <= SET_CHAR_127) {
+ vf_set (opcode);
+ } else if (opcode >= FNT_NUM_0 && opcode <= FNT_NUM_63) {
+ vf_fnt (opcode - FNT_NUM_0, vf_font);
+ } else {
+ fprintf (stderr, "Unexpected opcode: %d\n", opcode);
+ ERROR ("Unexpected opcode in vf file\n");
+ }
+ }
+ }
+ dvi_vf_finish();
+ } else {
+ fprintf (stderr, "vf_set_char: font: %d", vf_font);
+ ERROR ("Font not loaded\n");
+ }
+ return;
+}
+
+
+void vf_close_all_fonts(void)
+{
+ unsigned long i;
+ int j;
+ dev_font *one_font;
+#ifdef MEM_DEBUG
+MEM_START
+#endif
+ for (i=0; i<num_vf_fonts; i++) {
+ /* Release the packet for each character */
+ if (vf_fonts[i].ch_pkt) {
+ for (j=0; j<vf_fonts[i].num_chars; j++) {
+ if ((vf_fonts[i].ch_pkt)[j] != NULL)
+ RELEASE ((vf_fonts[i].ch_pkt)[j]);
+ }
+ RELEASE (vf_fonts[i].ch_pkt);
+ }
+ if (vf_fonts[i].pkt_len)
+ RELEASE (vf_fonts[i].pkt_len);
+ if (vf_fonts[i].tex_name)
+ RELEASE (vf_fonts[i].tex_name);
+ /* Release each font record */
+ for (j=0; j<vf_fonts[i].num_dev_fonts; j++) {
+ one_font = &(vf_fonts[i].dev_fonts)[j];
+ RELEASE (one_font -> directory);
+ RELEASE (one_font -> name);
+ }
+ if (vf_fonts[i].dev_fonts != NULL)
+ RELEASE (vf_fonts[i].dev_fonts);
+ }
+ if (vf_fonts != NULL)
+ RELEASE (vf_fonts);
+#ifdef MEM_DEBUG
+MEM_END
+#endif
+ return;
+}
diff --git a/Build/source/texk/dvipdfm/vf.h b/Build/source/texk/dvipdfm/vf.h
new file mode 100644
index 00000000000..746f165b795
--- /dev/null
+++ b/Build/source/texk/dvipdfm/vf.h
@@ -0,0 +1,35 @@
+/* $Header$
+
+ This is dvipdfm, a DVI to PDF translator.
+ Copyright (C) 1998, 1999 by Mark A. Wicks
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ The author may be contacted via the e-mail address
+
+ mwicks@kettering.edu
+*/
+
+#ifndef _VH_H_
+#define _VH_H_
+
+#include "pdfdev.h"
+
+extern void vf_set_verbose(void);
+extern int vf_locate_font (char *tex_name, spt_t ptsize);
+extern void vf_set_char(SIGNED_QUAD ch, int vf_font);
+extern void vf_close_all_fonts(void);
+
+#endif
diff --git a/Build/source/texk/dvipdfm/win32.mak b/Build/source/texk/dvipdfm/win32.mak
new file mode 100644
index 00000000000..77c01a9b36a
--- /dev/null
+++ b/Build/source/texk/dvipdfm/win32.mak
@@ -0,0 +1,116 @@
+################################################################################
+#
+# Makefile : Dvipdfm
+# Author : Fabrice Popineau <Fabrice.Popineau@supelec.fr>
+# Platform : Win32, Microsoft VC++ 6.0, depends upon fpTeX 0.5 sources
+# Time-stamp: <04/02/16 17:48:30 popineau>
+#
+################################################################################
+root_srcdir = ..\..
+!ifdef DEVELOPMENT
+INCLUDE=$(INCLUDE);$(root_srcdir)\texk.development
+!else
+INCLUDE=$(INCLUDE);$(root_srcdir)\texk
+!endif
+
+version = 0.13.2c
+
+USE_GNUW32 = 1
+USE_KPATHSEA = 1
+USE_PNG = 1
+USE_ZLIB = 1
+
+!include <msvc/common.mak>
+
+DEFS = $(DEFS) -DHAVE_CONFIG_H
+
+dvipdfmdir=$(texmf)\dvipdfm
+
+programs=$(objdir)\dvipdfm.exe $(objdir)\ebb.exe
+
+headers = dvi.h pdflimits.h error.h mfileio.h jpeg.h mem.h numbers.h \
+ pdfdev.h pdfdoc.h pdfparse.h pdfspecial.h tfm.h type1.h epdf.h \
+ vf.h dvicodes.h t1crypt.h pkfont.h tpic.h thumbnail.h htex.h \
+ twiddle.h mpost.h psimage.h psspecial.h colors.h colorsp.h \
+ dvipdfm.h encodings.h ttf.h $(TTF_OPT) macglyphs.h
+
+src = pdfdev.c pdfdoc.c dvi.c mfileio.c mem.c jpeg.c numbers.c pdfobj.c \
+ pdfparse.c pdfspecial.c tfm.c type1.c dvipdfm.c epdf.c vf.c \
+ t1crypt.c pkfont.c tpic.c thumbnail.c pngimage.c ebb.c htex.c \
+ mpost.c psimage.c psspecial.c colorsp.c encodings.c $(TTF_OPT) ttf.c
+
+objects = $(objdir)\pdfdev.obj $(objdir)\pdfdoc.obj $(objdir)\dvi.obj \
+ $(objdir)\mfileio.obj $(objdir)\mem.obj $(objdir)\jpeg.obj \
+ $(objdir)\numbers.obj $(objdir)\pdfobj.obj $(objdir)\pdfparse.obj \
+ $(objdir)\pdfspecial.obj $(objdir)\tfm.obj $(objdir)\type1.obj \
+ $(objdir)\dvipdfm.obj $(objdir)\epdf.obj $(objdir)\vf.obj \
+ $(objdir)\t1crypt.obj $(objdir)\pkfont.obj $(objdir)\tpic.obj \
+ $(objdir)\thumbnail.obj $(objdir)\pngimage.obj $(objdir)\htex.obj \
+ $(objdir)\mpost.obj $(objdir)\psimage.obj $(objdir)\psspecial.obj \
+ $(objdir)\colorsp.obj $(objdir)\encodings.obj $(TTF_OPT) \
+ $(objdir)\ttf.obj
+manfiles = dvipdfm.1
+eobjects=$(objdir)\ebb.obj $(objdir)\jpeg.obj $(objdir)\pdfobj.obj \
+ $(objdir)\mem.obj $(objdir)\mfileio.obj $(objdir)\numbers.obj \
+ $(objdir)\pdfparse.obj $(objdir)\pngimage.obj
+encodings=ot1.enc ot1alt.enc ot1r.enc
+mapfiles=cmr.map psbase14.map lw35urw.map lw35urwa.map
+
+default: all
+
+all: $(objdir) $(programs)
+
+$(objdir)\dvipdfm.exe: $(objects) $(kpathsealib) $(zliblib) $(pnglib)
+ $(link) $(**) $(conlibs)
+
+$(objdir)\ebb.exe: $(eobjects) $(kpathsealib) $(zliblib) $(pnglib)
+ $(link) $(**) $(conlibs)
+
+!include <msvc/config.mak>
+
+acconfig.h: acconfig.h.in
+ $(perl) -I$(win32perldir) $(win32perldir)/conf-cauto.pl acconfig.h.in
+
+installdirs = $(dvipdfmdir)\base $(dvipdfmdir)\config $(docdir)\dvipdfm $(prefix)\setupw32
+
+!include <msvc/install.mak>
+
+install:: install-exec install-data install-doc
+
+install-data::
+# -@echo $(verbose) & ( \
+# $(copy) .\t1fonts.map $(dvipdfmdir)\config\t1fonts.map $(redir_stdout) \
+# & $(copy) .\config.dvipdfm $(dvipdfmdir)\config\config $(redir_stdout) \
+# & $(copy) .\config.dvipdfm $(prefix)\setupw32 $(redir_stdout) \
+# & ( for %%f in ($(encodings)) do $(copy) %%f $(dvipdfmdir)\base $(redir_stdout) ) \
+# & ( for %%f in ($(mapfiles)) do $(copy) %%f $(dvipdfmdir)\config $(redir_stdout) ) \
+# )
+
+install-doc:: $(programs)
+ -@echo $(verbose) & ( \
+ pushd doc \
+ & tex dvipdfm $(redir_stdout) \
+ & tex dvipdfm $(redir_stdout) \
+ & ..\$(objdir)\dvipdfm dvipdfm $(redir_stdout) \
+ & $(copydir) /d * $(docdir)\dvipdfm $(redir_stdout) \
+ & $(del) *.log dvipdfm.dvi dvipdfm.pdf *.aux $(redir_stderr) \
+ & popd \
+ )
+
+distclean::
+# @$(copy) config.dvipdfm config-dvipdfm $(redir_stdout)
+
+!include <msvc/clean.mak>
+
+distclean::
+# @$(copy) config-dvipdfm config.dvipdfm $(redir_stdout)
+ -@$(del) config-dvipdfm $(redir_stderr)
+
+!include <msvc/rdepend.mak>
+!include "./depend.mak"
+
+#
+# Local variables:
+# page-delimiter: "^# \f"
+# mode: Makefile
+# End:
diff --git a/Build/source/texk/dvipdfm/winansi.h b/Build/source/texk/dvipdfm/winansi.h
new file mode 100644
index 00000000000..87443d527d6
--- /dev/null
+++ b/Build/source/texk/dvipdfm/winansi.h
@@ -0,0 +1,53 @@
+static char *winansi_encoding[256] = {
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
+ ".notdef", ".notdef",
+ "space", "exclam", "quotedbl", "numbersign", "dollar",
+ "percent", "ampersand", "quotesingle", "parenleft", "parenright",
+ "asterisk", "plus", "comma", "hyphen", "period",
+ "slash", "zero", "one", "two", "three", "four",
+ "five", "six", "seven", "eight", "nine", "colon",
+ "semicolon", "less", "equal", "greater", "question",
+ "at", "A", "B", "C", "D",
+ "E", "F", "G", "H", "I",
+ "J", "K", "L", "M", "N",
+ "O", "P", "Q", "R", "S",
+ "T", "U", "V", "W", "X",
+ "Y", "Z", "bracketleft", "backslash", "bracketright",
+ "asciicircum", "underscore", "grave", "a", "b",
+ "c", "d", "e", "f", "g",
+ "h", "i", "j", "k", "l",
+ "m", "n", "o", "p", "q",
+ "r", "s", "t", "u", "v",
+ "w", "x", "y", "z", "braceleft",
+ "bar", "braceright", "asciitilde", "bullet", "bullet",
+ "bullet", "quotesinglbase", "florin", "quotedblbase", "ellipsis",
+ "dagger", "daggerdbl", "circumflex", "perthousand", "Scaron",
+ "guilsinglleft", "OE", "bullet", "bullet", "bullet",
+ "bullet", "quoteleft", "quoteright", "quotedblleft",
+ "quotedblright",
+ "bullet", "endash", "emdash", "tilde", "trademark",
+ "scaron", "guilsinglright", "oe", "bullet", "bullet",
+ "Ydieresis", "space", "exclamdown", "cent", "sterling",
+ "currency", "yen", "brokenbar", "section", "dieresis",
+ "copyright", "ordfeminine", "guillemotleft", "logicalnot", "hyphen", "registered",
+ "macron", "degree", "plusminus", "twosuperior", "threesuperior",
+ "acute", "mu", "paragraph", "periodcentered", "cedilla",
+ "onesuperior", "ordmasculine", "guillemotright", "onequarter", "onehalf",
+ "threequarters", "questiondown", "Agrave", "Aacute", "Acircumflex",
+ "Atilde", "Adieresis", "Aring", "AE", "Ccedilla", "Egrave",
+ "Eacute", "Ecircumflex", "Edieresis", "Igrave", "Iacute",
+ "Icircumflex", "Idieresis", "Eth", "Ntilde", "Ograve", "Oacute",
+ "Ocircumflex", "Otilde", "Odieresis", "multiply", "Oslash",
+ "Ugrave", "Uacute", "Ucircumflex", "Udieresis", "Yacute", "Thorn",
+ "germandbls", "agrave", "aacute", "acircumflex", "atilde",
+ "adieresis", "aring", "ae", "ccedilla", "egrave", "eacute",
+ "ecircumflex", "edieresis", "igrave", "iacute", "icircumflex",
+ "idieresis", "eth", "ntilde", "ograve", "oacute", "ocircumflex",
+ "otilde", "odieresis", "divide", "oslash", "ugrave", "uacute",
+ "ucircumflex", "udieresis", "yacute", "thorn", "ydieresis"
+};