FAQ |
PDF manual "fig2vect.pdf" available german version "f2vde.pdf" available too |
General FAQ
What is the purpose of the program?
The fig2vect program converts Fig drawings to MetaPost, EPS, PDF, TeX and SVG
files.
It is intended for LaTeX users which want to use their Fig
drawings with both LaTeX and pdfLaTeX.
How does fig2vect compare against other Fig to xxx conversion software?
Here is a list of differences between fig2vect and transfig:
- fig2vect is specialized for use with LaTeX/pdfLaTeX.
The transfig package provides a large number of output drivers for general purpose usage. The fig2vect program is intended for those who want to use Fig drawings with LaTeX/pdfLaTeX. At this time there are only five output drivers (MetaPost, EPS, PDF, TeX and SVG). - X-Spline to Bezier spline conversion in fig2vect.
In fig2dev X-splines are converted to a polyline when reading the Fig file. The fig2vect program calculates Bezier splines. Each X-spline segment can be drawn by using a number of Bezier spline segments. - Fill patterns are implemented as vector graphics.
Fig2vect uses vector drawing operations to fill objects, not bitmap images. - Support for UTF-8 encoded text.
As more and more Linux/Unix installations use a ``lang.UTF-8'' languages setting, support for UTF-8 encoded text becomes more and more important.
Fig2vect can handle Fig files containing UTF-8 encoded texts.
See the UTF-8 support FAQ section for details - Both fig2vect and transfig are designed to be extensible.
Both fig2vect and transfig allow programmers to add new output drivers. In transfig an output driver is a set of functions obtaining a pointer to a drawing primitive. For each drawing primitive one function from the set is invoked, the function has only access to the drawing primitive's data.
In fig2vect an output driver is one function obtaining a pointer to the entire drawing and the conversion options. The driver function can traverse the list of drawing primitives as often as necessary. This can be used to collect style information in a first pass and to write output using the style information in a second pass.
- Different configuration mechanisms.
The fig2dev program is configured via command line options only.
The fig2vect program uses a configuration file (${prefix}/etc/fig2vect/fig2vect.cfg or a users own copy) to define different output configurations for different purposes. Command line options are used to choose an output configuration and/or to overwrite settings from the output configuration. - No rotation of embedded images
XFig and jFig behave differently if the first point of an image polygon is not the upper left point. XFig rotates the image by multiples of 90 degree depending on which point was specified first. jFig shows the image without any rotation.
The fig2vect program does not rotate the image. If you really want a rotated image, use a graphics program to do the rotation and embed the rotated image specifying the upper left point first. This allows correct processing by XFig, jFig, transfig and fig2vect.
What about the license conditions?
The software is licensed to you under the terms of a BSD-style license.
Installation FAQ
Installation on UNIX
Should I install from source?
Yes, you should. There are no binary installation packages out there.
Which libraries do I need to install before building fig2vect?
The following libraries are needed/recommended to install fig2vect:
- zlib (recommended)
http://www.gzip.org/zlib - libbzip2 (recommended)
http://sources.redhat.com/bzip2/ - dklibs (required)
http://dklibs.sourceforge.net - libpng (recommended)
http://www.libpng.org/pub/png/libpng.html - jpeglib (recommended)
ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz - NetPBM (recommended)
ftp://ftp.metalab.unc.edu/pub/Linux/apps/graphics/convert/netpbm-10.11.10.tgz
Where can I get the sources?
The fig2vect project is hosted on SourceForge, you can get the sources from the project's download area via http://sourceforge.net/projects/fig2vect.
How do I build and install the software?
-
Unpack the archive fig2vect-*.tar.gz, i.e.
gzip -dc fig2vect-0.9.8.tar.gz | tar xf -
- Change into the fig2vect directory
cd fig2vect
- Run the configure script
./configure
- Build the software
make
- Install the software
make install
Installation on Windows
Should I use the setup executable or install from source?
For the wide majority of users I recommend to obtain the
setup executable from
http://sourceforge.net/projects/dklibs.
The dklibs-win32 package contains executable setup to install the dklibs
library set and some of the applications using it (fig2vect is one of them).
There are two files for each version: The dklibs-win32-*-user.exe installs
binaries, libraries, header files and documentation.
The dklibs-win32-*-dev.exe installs all that, the sources for the projects and
the sources for the libraries needed for the projects. The *dev.exe
is significantly larger than the *user.exe.
Installing from source is recommended for experienced programmers only. You need
a good working knowledge of your development system, your C compiler and linker's
options and makefiles.
You should also read
http://dklibs.sourceforge.net/inst_w32.pdf. This document gives some
hints about installing the dklibs library set and applications using it from
source.
Configuration file
What is the fig2vect.cfg.sample file?
A file ${prefix}/etc/fig2vect/fig2vect.cfg is created when the fig2vect
package is installed the first time. Additionally a file
fig2vect.cfg.sample is installed.
During update installation the fig2vect.cfg file is not changed as it
might be modified. The current version of the fig2vect.cfg file from
the distribution is installed as fig2vect.cfg.sample.
How do I manage configurations after a fig2vect update
The configuration file is prepared to have three section:
- Section 1: the pre-defined configurations from the fig2vect distribution.
- Section 2: planned for site-wide configurations.
- Section 3: planned for user-specific configurations in the users private copy of the configuration file.
After an update of the fig2vect software the administrator should:
- Replace section 1 of the existing configuration file ${prefix}/etc/fig2vect/fig2vect.cfg by the section 1 of ${prefix}/etc/fig2vect/fig2vect.cfg.sample. This guarantees that all predefined configurations are up to date.
- Inform all users that ${prefix}/etc/fig2vect/fig2vect.cfg was updated. Users can now update their private copies and replace the sections 1 and 2 of ${HOME}/.defaults/fig2vect.cfg by the contents of the ${prefix}/etc/fig2vect/fig2vect.cfg file.
Usage FAQ
General Usage
How do I start the program
Use
fig2vect options input-file output-file
fig2vect options directory
to run the program. When using the MetaPost driver you can also use
fig2vect options input-file
fig2vect options
If there is no file name for the output file specified output goes to standard
input. If the file name for the input file is omitted the program
processes standard input.
Can I process compressed files directly?
Yes, it's possible if support for zlib and/or the bzip2 library was
enabled during build. Simply specify a file name "*.fig.gz" or "*.fig.bz2"
for input files or "*.mp.gz"..."*.eps.bz2" for output files.
To find out whether or not zlib/bzip2 support is enabled run
fig2vect --versionIf the output contains the lines
zlib General compression library libbz2 Library for compressing/decompressing data in the bzip2 formatin the "Libraries used:" section support for zlib/bzip2 is enabled.
How do I provide configuration options to the program
The fig2vect program uses a configuration file fig2vect.cfg. This file consists of serveral sections, each section describes one configuration. A section consists of a configuration name and several key/value pairs. Keys can consist of multi-part strings. The keys are also referred to as options.
How do I choose a name for a configuration?
The name for a configuration consists of the base driver name ("mp", "eps",
"tex" or "svg"),
a dot (".") and a unique name of your choice containing numbers, digits,
underscore and minus.
In the configuration file the name is surrounded by "[" and "]".
How does option inheritance work?
If a user chooses a configuration "mp.my-conf" by specifying
fig2vect -l mp.my-conf ...on the command line the program searches for a configuration section "[*]" first and processes this section. The "[mp]" section is processed next, settings in this section overwrite settings from the "[*]" section. The "[mp.my-conf]" section is processed at the end, overwriting all earlier settings.
Note: only the first dot separating the base driver from the remainder of the name is of importance. Naming a section "[mp.users.me.docs]" will result in processing "[*]", "[mp]" and "[mp.users.me.docs]", not "[*]", "[mp]", "[mp.users]", "[mp.users.me]" and "[mp.users.me.docs]".
What is the name of user-specific the configuration file?
By default the configuration file "${prefix}/etc/fig2vect/fig2vect.cfg" is used. If a file "$HOME/.defaults/fig2vect.cfg" is found, this file is used instead of the default configuration file.
How does fig2vect calculate the image dimensions?
The fig2vect program inspects all drawing elements except the
texts and calculates the elements dimensions. The element dimensions
of all elements are combined to calculate the dimensions for the entire
drawing. The output file dimensions are choosen to match the borders
of the outermost elements.
Texts are skipped for two reasons:
- Width and height of a text depend on the output driver used to print that text. Image dimension calucalation is done before the output driver is run.
- The methods for calculating text width and height would be driver-specific. I.e. for the SVG output driver we would need to be able to read and process SVG fonts, for the EPS output driver we would need to read *.pfb and *.afm files, for the MetaPost driver we would need to read *.dvi and *.tfm files...
For the MetaPost driver this is not a problem as there is no bounding box information in the *.mp file.
How do I handle a text on the outermost left/right/top/bottom position?
If your Fig file contains text on the outermost left/right/top/bottom position you can use either
- a white filled rectangle or
- a background rectangle (see below)
How can I add some border space
Use either
- a white filled rectangle or
- a background rectangle (see below)
What is a background rectangle, how do I use it?
A background rectangle is an additional rectangle you add to the Fig file. This rectangle is not drawn to the output file, it is only used to calculate the output file dimensions. A background rectangle must have the following features assigned:
- object type 2 (polygon), subtype 2 (rectangle/box),
- layer (depth) 999,
- stroke color -1 (default),
- line width 0,
- area fill -1 (no fill), fill color does not matter.
remove background rectangle = yesmust be used to prevent drawing of the background rectangle.
How can I produce bitmap images?
Produce a PNG image first (see below) and convert the PNG image to the bitmap type you need, i.e. using NetPBM, ImageMagick, Xnview (the nconvert program) or Gimp.
How can I produce a PNG image?
There are four choices:
- Convert the image to SVG and convert the SVG file to PNG using
either the Squiggle (the Batik SVG viewer) or the Batik rasterizer.
Using the Batik rasterizer is the recommended method if your *.fig file does not contain special text.
All ranges of the output file not covered by graphics elements will be transparent, so this method is well-suited to create graphics for web sites...
This method will only work if the Fig file does not contain special text.fig2vect -lsvg image.fig image.svg java -jar /.../batik-rasterizer.jar image.svg
The Batik software is available from xml.apache.org. A java program is available in the Java Runtime Environment (JRE) from java.sun.com. - Convert the image into a standalone PDF and convert the
PDF file to PNG using
pdftoppm (form the xpdf package) and pnmtopng (from the NetPBM package).
This is the recommended method if your *.fig file contains special text.
fig2vect -l pdf.tex image.fig imagei.pdf fig2vect -l tex.full -i imagei image.fig image.tex pdflatex image && pdflatex image pdftoppm -t1lib yes -freetype yes -aa yes -aaVector yes image.pdf image pnmtopng < image-000001.ppm > image.png
- Convert the image into a standalone PDF file and use
Ghostscript to convert the PDF to PNG.
fig2vect -lpdf.tex image.fig imagei.pdf fig2vect -ltex.full -iimagei image.fig image.tex pdflatex image && pdflatex image && pdflatex image gs ... -sOutputFile=image.png image.pdf
Use the following options for Ghostscript:
You might want to try different combinations of graphics alpha bits and text alpha bits.-dBATCH run in batch mode -dNOPAUSE do not pause after each page -dNOCACHE do not cache rendered characters -sDEVICE=png16m choose output file type PNG -dGraphicsAlphaBits=4 Anti-Aliasing for graphics uses 4 bits (1, 2 or 4 bits, or omit this option) -dTextAlphaBits=4 Anti-Aliasing for text uses 4 bits (1, 2 or 4 bits, or omit this option) -dNOCACHE do not cache rendered characters -r300 use 300 dpi (you may choose another resolution) - Convert the image into a standalone EPS file and use
Ghostscript to convert the EPS to PNG.
fig2vect -leps image.fig image.eps gs ... -sOutputFile=image.png image.eps
Use the following options for Ghostscript:
You might want to try different combinations of graphics alpha bits and text alpha bits.-dBATCH run in batch mode -dNOPAUSE do not pause after each page -dEPSCrop choose output image size to fit EPS BoundingBox -dNOCACHE do not cache rendered characters -sDEVICE=png16m choose output file type PNG -dGraphicsAlphaBits=4 Anti-Aliasing for graphics uses 4 bits (1, 2 or 4 bits, or omit this option) -dTextAlphaBits=4 Anti-Aliasing for text uses 4 bits (1, 2 or 4 bits, or omit this option) -dNOCACHE do not cache rendered characters -r300 use 300 dpi (you may choose another resolution)
Once I have produced a PNG, how can I compress it?
Use the optipng program, this program can be found on SourceForge at
http://sourceforge.net/projects/optipng.
For normal compression run:
optipng image.png
To suppress the messages add the -q option:
optipng -q image.png
To create an image for use on web servers, use -i1 to make the image interlaced:
optipng -i1 image.png
For better compression use -o7:
optipng -o7 image.png
To attempt a large amount of combinations for compression options (this will not necessarily result in smaller files but will result in larger computation time) use:
optipng -zc1-9 -zm1-9 -zs0-3 -f0-5 image.png
The options -i1, -q and the compression options can be combined.
Driver specific FAQ
MetaPost driver
What about the pros and cons of this driver?
The MetaPost program can handle LaTeX special text, so you can use special
text in your Fig files when using this driver. The output created
by MetaPost can be used with both LaTeX and pdfLateX. As I nearly always
use the MetaPost driver, this driver is better tested than the other
drivers.
The MetaPost language does not provide a possibility to include any
images, so you can not use included images when using this driver.
Which settings are recommended for images to be included in LaTeX documents?
- Choose the correct TeX command
If your document is processed by LaTeX or pdfLaTeX the configuration file should containtex command = latex
Only if the document is processed by plain TeX or pdfTeX you should usetex command = tex
Remember to either set the TEX environment output variable to "latex" before running mpost or to invoke mpost usingmpost -tex=latex
ormpost --tex=latex
to process the *.mp file. The number of minuses may differ depending on your LaTeX distribution. - Use the same fonts in the image as in the document text
Using the same fonts in images and in the document text looks more professional than using different fonts. Create a minimal preamble for font setup (strip down the document preamble) and usepreamble file = ...
to refer to this minimal preamble.
If -- for example -- your document has a preamble like\documentclass[12pt]{book} \usepackage{ifpdf} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} \usepackage{textcomp} \usepackage[intlimits]{amsmath} \usepackage{amssymb} \usepackage{mathptmx} \usepackage[scaled=.92]{helvet} \usepackage{courier} \usepackage{array} \usepackage{enumerate} \usepackage{longtable} \usepackage{latexsym} \usepackage{varioref} \usepackage{makeidx} \usepackage{listings} \lstset{numbers=left, numberstyle=\tiny, numbersep=5pt, basicstyle=\small} \usepackage{color} \ifpdf \usepackage[activate=normal]{pdfcprot} \usepackage[pdftex]{graphicx} \usepackage{epstopdf} \pdfcompresslevel=9 \usepackage[ pdftex, a4paper=true, pdftitle={The fig2vect manual}, pdfsubject={fig2vect}, pdfauthor={Dipl.-Ing. D. Krause}, colorlinks=true, bookmarks, bookmarksnumbered, linkcolor=linkgreen, pdfpagemode=None, pdfstartview=FitH ]{hyperref} \else \usepackage[dvips]{graphicx} \DeclareGraphicsRule{.png}{eps}{.bb}{`bmeps #1} \usepackage[dvips]{hyperref} \fi \definecolor{linkgreen}{rgb}{0,0.5,0} \def\theyear{2002} \author{Dipl.-Ing.~D.~Krause} \title{The fig2vect manual} \include{cover} \DeclareMathOperator{\element}{\in} \DeclareMathOperator{\notelement}{!\in} \newcommand{\ora}[1]{\overrightarrow{#1}} \DeclareMathOperator{\grad}{grad} \DeclareMathOperator{\divergence}{div} \DeclareMathOperator{\rot}{rot} \newcommand{\atpos}[2]{{\left.#1\right|}_{#2}} \newcommand{\inrange}[3]{{\left.#1\right|}_{#2}^{#3}} \newcommand{\intd}[0]{\mathrm{d}} \DeclareMathOperator{\arcsinh}{arcsinh} \DeclareMathOperator{\card}{card} \DeclareMathOperator{\Res}{Res} \newcommand{\imagelw}[2]{ \begin{figure}[ht] {\centering \includegraphics[width=\linewidth]{#1.mps} \caption{#2} \label{fig:#1} } \end{figure} } \newcommand{\ximagelw}[3]{ \begin{figure}[ht] {\centering \includegraphics[width=#1\linewidth]{#2.mps} \caption{#3} \label{fig:#2} } \end{figure} } \DeclareMathOperator{\oplaplace}{\triangle} \DeclareMathOperator{\opLaplace}{{\mathfrak L}} \DeclareMathOperator{\iopLaplace}{{\opLaplace}^{-1}} \DeclareMathOperator{\definedas}{\overset{=}{\text{\tiny{Def}}}} \DeclareMathOperator{\lcorrelates}{\laplace} \DeclareMathOperator{\ilcorrelates}{\Laplace} \DeclareMathOperator{\mustbe}{\overset{\text{\tiny !}}{=}} \makeindexcreate a stripped down file\documentclass[12pt]{book} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} \usepackage{textcomp} \usepackage[intlimits]{amsmath} \usepackage{amssymb} \usepackage{mathptmx} \usepackage[scaled=.92]{helvet} \usepackage{courier}and save it as "/home/jim/mypreamble.tex".
In the configuration file usepreamble file = /home/jim/mypreamble.tex
- Change fonts automatically if necessary
Usenormal text = handling:tex,font:similar,size:fig special text = handling:tex,font:tex,size:tex,mbox
to allow automatic font changing for normal text. If -- for example -- a Fig file uses "Palatino-Bold" for a text and fig2vect was configured to use the preamble file "/home/jim/mypreamble.tex" the text is written in roman font configured by that preamble, fontweight bold, upright style (not italic). - No embedded fonts in the *.mps image
When translating the LaTeX source to PS/PDF the document fonts are embedded into the output file by dvips or pdflatex once for the document. Our images should not attempt to embed the same fonts again, they should re-use the fonts already embedded.
Useembed fonts = no
- Use MetaPost arrowheads
Useuse metapost arrowheads = yes
to allow usage of MetaPost arrowheads. MetaPost produces curved arrowheads at the end of curved lines.
Which settings are recommended to produce standalone images?
- Avoid text handling by TeX/LaTeX
When creating the Fig file avoid use of special text.
In the configuration file usenormal text = handling:none,font:fig,size:fig
to make sure that only the 35 well-known PostScript fonts are used. - Embed the fonts
Useembed fonts = yes
to make sure the mpost output file contains all the fonts needed to show the texts.
EPS driver
What about the pros and cons of this driver?
When using this driver you can use included images (PNG, JPEG, NetPBM and EPS)
in the Fig file.
You can not use LaTeX special text in conjunction with this driver. In theory we
could do the same things as MetaPost: write special text to a LaTeX file, process
the file using LaTeX, read the DVI file and convert to EPS. Practically this is
a lot of work, requiring a good knowledge of DVI file structure, PS font encodings,
font metrics... and a team of volunteers contributing code.
How do I configure the PS level?
Use
ps level = 1to produce PostScript level 1 output. Alternatively use "2" or "3".
Use DSC comments
Use
dsc comments = yesto write DSC comments or
dsc comments = noto suppress writing of DSC comments. Alternatively you can use "1", "2" or "3" to get DSC comments matching a certain PS level.
Use showpage operator?
This operator is only allowed in PS files, not in EPS files. PS images included into documents should not contain the showpage operator, use
ps showpage = nofor these images.
Standalone image to be viewed using i.e. GhostView should contain this operator, use
ps showpage = yesto use the operator.
Use setpagedevice operator?
This operator is only allowed in PS files, not in EPS files. It can be used to restrict media size to match the graphics size. Turn it of for EPS files and for those PS files embedded into documents using
ps setpagedevice = noIf you produce PS files you want to convert into other graphics formats using GhostScript you can enable use of the setpagedevice operator using
ps setpagedevice = yes
Which options are related to included images?
- remove bitmap border
The image box for an inluced image is specified as a polygon in the Fig file. There is no GUI-based mechanism to change the line width of this polygon. To draw the included image without stroking the image border useremove bitmap border = yes
To draw the image box border useremove bitmap border = no
- keep bitmap aspect ratio
In many cases the width/height relation of the image will differ from the relation of the image box.
Usekeep bitmap aspect ratio = yes
to keep the original ratio leaving some parts of the image box unused.
Usingkeep bitmap aspect ratio = no
you can fill the entire polygon using different scale factors for width and height. - fill bitmap background
There is no GUI-based way to change the background color / fill pattern of a polygon used for image inclusion.
Usefill bitmap background = no
to ignore any background filling information from the Fig file orfill bitmap background = yes
to fill the polygon before adding the bitmap. - ps run-length encoding
allows or denies usage of run-length compression. - separated rgb channels
PS level 2 and above provides two choices for structuring color image data:- Combined data source
For each pixel the data stream contains the red-, green- and blue value.separated rgb channels = no
- Separated data sources
The data stream first contains the red-values for all the pixels followed by all the green-values, followed again by all the blue-values.separated rgb channels = yes
Unfortunately the PostScript code must use 3 strings of width*height bytes to uncompress image data from separated sources while only one string of 3*width bytes is necessary to uncompress data from a combined data source. Separated data sources are not recommended to produce print jobs for printers with minimal memory equipment. - Combined data source
Which options are related to the PostScript virtual memory?
- bitmap image dictionary
Usebitmap image dictionary = yes
to encapsulate the drawing code in a... dict begin % drawing code here end
structure. All the strings required to uncompress bitmap image data are now defined in this new dictionary. After finishing all drawing operations the dictionary is removed from the dict stack. As there is no reference to the dictionary it is unusable now, the garbage collection is allowed to remove the dictionary. The only references to the strings are contained in the dictionary, as no access to the dictionary is possible there is also no access to the strings possible. So the strings can be removed by the garbage collection too.
Note: Do not use this option if the Fig file includes EPS images! The dictionary size is calculated to match the number of strings needed for PNG/JPEG/NetPBM images. There is no place in the dictionary for additional definitions from included EPS files. - force garbage collection
Useforce garbage collection = yes
to add a line1 vmreclaim
to the end of EPS output. This tells the PostScript interpreter to attempt to run the garbage collection after finishing the drawing operations.
PDF driver
What about the pros and cons of this driver?
This driver produces PDF images which can be included in a LaTeX source processed
with pdflatex.
If there are alpha channels in embedded PNG images, the
alpha channel is converted into PDF transparency data.
This allows to place partially transparent images over other content.
The PDF driver has only minimal text processing capabilities (only
non-special left-aligned text, all fonts are converted into the
14 PDF base fonts). It is recommended to use the PDF driver in conjunction
with the TeX driver, the TeX driver should be used for both special
and non-special text.
How can I inspect the graphics instructions in the PDF file?
Use the configuration entry
plain text streams = yesor the command line option
-o plain.text.streams=yesto produce uncompressed plain text streams, you can open the resulting PDF file in a text editor.
How can I improve the on-screen rendering of fill patterns?
Use the configuration entry
large pattern cell = yesor the command line option
-o large.pattern.cell=yesto make pattern cells as large as the entire PDF image. This avoids irritations on pattern cell borders.
How can I improve the rendering of embedded images?
Use the configuration entry
interpolate images = yesor the command line option
-o interpolate.images=yesto activate image interpolation.
Should I embed images containing transparency (alpha channel in PNGs)?
Yes, you can. But if you use PDFs containing alpha channels with pdfLaTeX you need a special line
\pdfpageattr {/Group << /S /Transparency /I true /CS /DeviceRGB>>}
in the document preamble (suggested by J. Quirk in the pdftex mailing list).The purpose of this line is to prevent PDF viewers from using CMYK as color space for temporary calculations.
How can I get rid of the "At least one alpha channel..." message?
The message
At least one alpha channel was converted to PDF.
When referencing PDFs containing alpha data from your *.tex sources, you should use
\ifpdf\pdfpageattr{/Group <</S /Transparency /I true /CS /DeviceRGB>>}\fi
in the preamble.
or the german version
Ein Alpha-Kanal wurde in eine PDF-Ausgabe übertragen.
Um PDFs mit Alpha-Kanal mit pdfLaTeX zu verwenden, sollten Sie
\ifpdf\pdfpageattr{/Group <>}\fi
in der Präambel der LaTeX-Quelle verwenden.
is printed when converting *.fig files referencing PNG or TIFF files containing
alpha channels to PDF.To suppress this message, use the -A option.
Use
bmeps -c -Ato configure it as a permanent option.
Alternatively you can create preferences file (Unix/Linux) or registry (Windows) entries manually:
- On Unix/Linux systems edit $HOME/.defaults/all and add a section
[fig2vect] /pdf/suppress-alpha-info=true
- On Windows open the registry key HKCU/Software/DkApp/fig2vect
(create the key if it does not exist) and add an entry
REGEDIT4 [HKEY_CURRENT_USER\Software\DkApp\fig2vect] "/pdf/suppress-alpha-info"="true"
Once I have created a PDF file, how can I optimize it?
- Compression
Get the latest multivalent...jar file from the MultiValent project, avaible on SourceForge at http://sourceforge.net/projects/multivalent.
Additionally you need a Java Run-Time Environment, I suggest to use the one from Sun available at http://java.sun.com.
To compress a PDF file, run:java -Xms64m -Xmx1024m -cp ...path.../Multivalent20060102.jar tool.pdf.Compress -compatible file.pdf
This creates file-o.pdf.
- Fast web view
Use GhostScript (available at http://pages.cs.wisc.edu/~ghost/) to create a fast web view:pdfopt input.pdf output.pdf
TeX driver
What is the purpose of this driver?
This driver supports other drivers which can not handle special text theirselves (i.e. the EPS or PDF driver).
Which configuration entries are needed for the TeX driver?
It depends how you want to handle normal (non-special) text. There are two choices:
- Normal text is handled by the EPS driver and ignored by the TeX driver.
The configuration entries should look like this:
[eps.tex] normal text = handling:none,font:fig,size:fig skip all texts = yes [tex] normal text = handling:none
- Normal text is ignored by the EPS driver and handled by the TeX driver.
The configuration entries should look like this:
[eps.tex] normal text = handling:tex,font:similar,size:fig,mbox skip all texts = yes [tex] normal text = handling:tex,font:similar,size:fig,mbox
How do I create the EPS- and TeX-files?
Run
fig2vect -leps.tex myfile.fig myfile.eps fig2vect -ltex myfile.fig myfile.texIn the LaTeX source include
\begin{figure}
{\centering
\input{myfile.tex}
\caption{My image caption}
\label{fig:my-image-label}
}
\end{figure}
The document LaTeX source imports the figure LaTeX source which in turn
imports the figure EPS file and write the special texts on top of it.
SVG driver
What about the pros and cons of this driver?
When using this driver you can use included images of any type in the
Fig file as the driver does not need to convert included images, it simply
writes a reference. But you must make sure your SVG viewer can render the
included image.
Special comments can be used to insert ECMA-Script code into the SVG output
and to attach event handlers and links to objects.
Using the Adobe SVG viewer you can embed SVG images into other applications
(i.e. Office applications) on Windows systems.
Special text can not be used with this driver.
How do I use SVG images in Office applications on Windows systems?
- Install Adobe SVG viewer.
You can obtain it from http://www.adobe.com/support/downloads/main.html.
- In your application choose to insert an object of type "SVG Document".
- In the context menu change the properties of the object. Change the
value of the "SRC" property to the URL of the SVG file, see the
screenshot below.
- Resize the object if necessary.
Why are some SVG images malformed when using Adobe SVG viewer plugin on Linux systems?
You should try to set the environment variable LC_NUMERIC like this
LC_NUMERIC=C export LC_NUMERICbefore starting the web browser.
The locale definition (LANG environment variable) might indicate the use of "," instead of "." as decimal point in floating point numbers. The SVG file format always uses "." and does not care about your language.
I think the plugin should take care of this and use localization-independent functions to read floating point numbers. Unfortunately version 3.01 doesn't.
How do I configure the SVG level?
Use the
svg version = 1.0configuration option, you can either specify "1.0", "1.1" or "1.2" here.
Standalone SVG image or embedded fragment?
The driver can produce both standalone SVG images and SVG fragments
for embedding in XML documents.
To produce standalone images use
embedded svg fragment = noto produce an embedded fragment switch to "yes". When embedding an SVG fragment in an XML document the surrounding XML document must be prepared to use the XML namespaces "svg" and "xlink".
How can I choose a unit for width and height?
The SVG tag contains width/height information and a viewport
specification. The width and height attributes specify the physical size
of the image, the viewport attribute specifies the logical coordinates
assigned to that area.
The
wh specification = inchesconfiguration setting allows to choose whether to produce with attributes measured in inches, without units ("points") or in px ("pixels").
How do I control object styling?
There are three ways to specify an SVG object's style:
- Multiple simple object property attributes.
Each style property is defined via a separated XML attribute, i.e.:<rect fill="yellow" stroke="black" stroke-width="0.9" .../>
- A single style attribute.
A style attribute is used:<rect style="fill: yellow; stroke: black; stroke-width: 0.9;" .../>
- A class attribute.
The class attribute in an object definition refers to a style in the CSS style section.<style type="text/css"><![CDATA[ .c1 { fill: yellow; stroke: black; stroke-width: 0.9; } ]]></style> <rect class="c1" .../>
If an objects style is defined via style or class attribute, changes made on simple properties have no visible impact.
The multiple property attributes are used by fig2vect automatically if
- it finds instructions to use JavaScript (ECMA-script) files (see below),
- event handlers are attached to objects (see below) or
- the
prepare for modifications = yes
configuration setting is used.
use css = yessetting enables the use of class attributes, "no" uses style attributes instead.
How do I add ECMA-script (JavaScript) code?
To add ECMA-script code into a <script> tag, write it into a file, i.e. "mycode.js". Use either the configuration setting
js library = mycode.jsor add a special comment
## svg: js library = mycode.json the document level.
Document level comments must be inserted between line 8 (transparent color) and 9 (resolution, coord-system), i.e.
#FIG 3.2 Portrait Center Metric A6 100.00 Single -2 1200 2is changed to
#FIG 3.2 Portrait Center Metric A6 100.00 Single -2 ## svg: js library = mycode.js 1200 2When fig2vect writes SVG output, the contents of the file mycode.js is transferred into the <script> section.
How do I attach event handlers and an id to objects?
Comments (and special comments) related to an object must be placed immediately before the line starting the object. Event handlers can be defined in special comments, i.e. by changing
#FIG 3.2 Portrait Center Metric A6 100.00 Single -2 ## svg: js library = mycode.js 1200 2 1 1 0 1 0 7 50 0 -1 0.000 1 0.0000 990 900 450 180 990 900 1440 720to
#FIG 3.2 Portrait Center Metric A6 100.00 Single -2 ## svg: js library = mycode.js 1200 2 ## svg: onmouseover = fill_yellow(evt) ## svg: onmouseout = fill_white(evt) ## svg: id = e1 1 1 0 1 0 7 50 0 -1 0.000 1 0.0000 990 900 450 180 990 900 1440 720This changes
<ellipse transform="translate(49.2 22.1)" rx="27" ry="10.8" fill="none" stroke="#000000" stroke-width="0.9" />to
<ellipse transform="translate(49.2 22.1)" rx="27" ry="10.8" fill="none" stroke="#000000" stroke-width="0.9" id="e1" onmouseover="fill_yellow(evt)" onmouseout="fill_white(evt)" />
How do I attach event handlers to the entire drawing?
Event handlers for the entire drawing can be specified in special comments in the document level, i.e. change
#FIG 3.2 Portrait Center Metric A6 100.00 Single -2 ## svg: js library = mycode.js 1200 2to
#FIG 3.2 Portrait Center Metric A6 100.00 Single -2 ## svg: js library = mycode.js ## svg: onload = handler_onload(evt) 1200 2This changes
<svg width="255px" height="298px" viewBox="0 0 255 298" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >to
<svg width="255px" height="298px" viewBox="0 0 255 298" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onload="handler_onload(evt)" >
How can I improve the quality of text rendering?
Obtain the Ghostscript fonts. Convert them to SVG fonts using the FontForge software (see below). Use the
gs svg-font directory = ...url...configuration setting to tell fig2vect which location to reference in SVG output.
How do I convert the Ghostscript fonts to SVG fonts?
Obtain the Ghostscript fonts and the sources for these fonts.
Unpack both archives into one temporary directory. You should have
35 *.pfb files and 33 *.sfd files there.
Open each of the *.pfb files in FontForge. Save the font using the
same name but suffix ".svg".
Optionally: Open each of the *.sfd files in FontForge. Save the fonts as
*.svg:
NimbusRomanNo9L-Regu.sfd n021003l.svg NimbusRomNo9L-ReguItal.sfd n021023l.svg NimbusRomNo9L-Medi.sfd n021004l.svg NimbusRomNo9L-MediItal.sfd n021024l.svg URWGothicL-Book.sfd a010013l.svg URWGothicL-BookObli.sfd a010033l.svg URWGothicL-Demi.sfd a010015l.svg URWGothicL-DemiObli.sfd a010035l.svg URWBookmanL-Ligh.sfd b018012l.svg URWBookmanL-LighItal.sfd b018032l.svg URWBookmanL-DemiBold.sfd b018015l.svg URWBookmanL-DemiBoldItal.sfd b018035l.svg NimbusMonL-Regu.sfd n022003l.svg NimbusMonL-ReguObli.sfd n022023l.svg NimbusMonL-Bold.sfd n022004l.svg NimbusMonL-BoldObli.sfd n022024l.svg NimbusSansL-Regu.sfd n019003l.svg NimbusSanL-ReguItal.sfd n019023l.svg NimbusSansL-Bold.sfd n019004l.svg NimbusSanL-BoldItal.sfd n019024l.svg NimbusSanL-ReguCond.sfd n019043l.svg NimbusSanL-ReguCondItal.sfd n019063l.svg NimbusSanL-BoldCond.sfd n019044l.svg NimbusSanL-BoldCondItal.sfd n019064l.svg CenturySchL-Roma.sfd c059013l.svg CenturySchL-Ital.sfd c059033l.svg CenturySchL-Bold.sfd c059016l.svg CenturySchL-BoldItal.sfd c059036l.svg URWPalladioL-Roma.sfd p052003l.svg URWPalladioL-Ital.sfd p052023l.svg URWPalladioL-Bold.sfd p052004l.svg URWPalladioL-BoldItal.sfd p052024l.svg s050000l.pfb s050000l.svg URWChanceryL-MediItal.sfd z003034l.svg d050000l.pfb d050000l.svgExperienced users might use scripting.
Place the *.svg files in a separated directory, i.e. /usr/local/share/gs-fonts/svg.
In a separated configuration section use the configuration setting
[svg.gs] gs svg-font directory = file:///usr/local/share/gs-fonts/svgto point to that directory. When preparing SVG files for use on web sites create an additional configuration section, i.e.
[svg.gs-web] gs svg-font directory = http://www.my-org.com/gs-fonts/svgSo you can use the svg.gs configuration as long as you are still editing the Fig files to produce SVG files for local (and offline) viewing. Before uploading the SVG files to the web server produce the final versions using the svg.gs-web configuration.
Note: The Ghostscript fonts are licensed under the terms
of the GNU General Public License.
Please read the file COPYING from the Ghostscript fonts
distribution for details.
If you make GPL-licensed software (i.e. the *.svg font files)
accessable to other users - i.e. by placing them in a shared
directory in a LAN or on a multi-user computer system or
on web/ftp servers - you are responsible
for making all the sources for that software available too.
Access to the sources
should not be more complicated than access to the software.
To fullfill the requirements of the GPL I suggest to place
the archives containing
Ghostscript fonts and the Ghostscript fonts sources used
to build the *.svg font files in the same directories as
the *.svg font files.
UTF-8 support FAQ
What is UTF-8
UNICODE is a character set using 32 bits. Documents using
this character set can use characters/glyphs from different
languages.
UTF-8 is an encoding for UNICODE characters using 1 byte for
the glyphs used most often and up to 6 bytes (48 bits)
for the not-so-popular glyphs.
What problems can occur when using UTF-8 encoding?
The same glyph is encoded differently when using UTF-8 and traditional encodings. An application showing text must know whether or not the text is UTF-8 encoded or not.
What's the problem with Fig files and UTF-8
The Fig file format does not allow to provide information whether
or not UTF-8 is used.
So there are two ways to tell applications processing Fig files which
encoding is used:
- command line options and
- special comments in the Fig files. These comments are processed by programs like fig2vect and ignored by other programs.
On Unix/Linux how will I know whether or not UTF-8 is used?
Check the LANG environment variable. If it ends on ``.UTF-8''
(not case-sensitive) -- like ``de_DE.UTF-8'' your system uses
UTF-8 encoding.
If it does not end on ``.UTF-8'' -- i.e. ``de_DE'' -- your system
does not use UTF-8 encoding.
How does my graphical desktop handle native characters?
Handling of native characters (i.e. german umlauts) depends
on the systems LANG setting.
- If UTF-8 is turned off and you type the german umlaut ä on the keyboard, one byte -- the ANSI code for ä -- is sent from the X11 system to the application.
- If UTF-8 is turned on and you type ä two bytes
-- the UTF-8 encoded ä -- is sent to the application.
An UTF-8 aware application will inspect the two bytes, find the ä and save the ä correctly in output files (using the encoding required by the file format specification). To render texts on screen the ä is sent to X11 UTF-8 encoded.
If the application is not UTF-8 aware it simply stores the two bytes as two characters. In most cases text is shown fine on screen (if X11 is set up to use UTF-8 it will create keyboard events containging UTF-8 encoded data, the routines showing text expect UTF-8 encoded text). When saving data to files, data is stored UTF-8 encoded no matter whether or not the file format specification allows this.
Can I simply change the LANG environment variable for one program?
No! All desktop applications must use the same UTF-8 setting.
You may change LANG from ``de_DE'' to ``en_US'' or from ``de_DE.UTF-8'' to
``en_US.UTF-8'', but not from ``de_DE'' to ``de_DE.UTF-8''.
If you want to change the UTF-8 usage, log in as root (or Administrator),
change the setting globally -- i.e. in /etc/sysconfig/i18n -- and reboot
the system.
If the desktop delivers not-UTF-8 encoded data and an application expects
UTF-8 encoded data (or vice versa) there is a wide variety of results:
unknown keyboard bindings, application crashes...
How do Fig drawing applications handle UTF-8 encoding?
- jFig -- or one of the libraries jFig uses -- seems to handle UTF-8 encoding perfectly (from my point of view). If LANG is set to ``de_DE.UTF-8'' german umlauts are saved to Fig files using 1 byte. This indicates that the texts were recoded internally before saving to file.
- In XFig handling differs depending on where german umlauts are
inserted. When typing text in the drawing area, german umlauts are ignored.
In the "Edit" dialog box german umlauts are converted into two
malformed characters. Text is saved to output files UTF-8 encoded, two
bytes are used for ä.
Note: The statements above are related to XFig 3.2.4 on Fedora Core 5 using ``de_DE.UTF-8''. The behaviour can differ for other XFig versions, other OS and other localization settings.
How does fig2vect handle UTF-8 encoding?
Fig2vect cares about UTF-8 encoded text in non-special text only.
In special text you can use LaTeX code directly to produce the glyphs you need.
Handling UTF-8 encoded strings depends on the driver:
- EPS and PDF: The driver can hande UNICODE characters in the
range 0x00000000...0x000000FF. Texts are recoded from UTF-8 to
ANSI and saved in WinAnsiEncoding in PDF files and in
ISOLatin1Encoding in EPS files.
Characters above 0x000000FF can not be handled. - TeX and MetaPost: The texts are recoded to UNICODE,
the driver uses the dkle_...() functions to find
an appropriate LaTeX encoding.
Note: The encoding tables in dklibs are very incomplete, at this time they contain support for some european languages only.
If you have created a table for codes not yet in the list, please share it and use the bug track/feature request mechanisms on SourceForge.
How are the LaTeX encodings found? How do create my own tables?
The dklibs library set used by fig2vect uses a preference to
find a shared directory (shared between all dklibs-based applications).
This directory is /usr/local/share on Unix/Linux and
c:\programme\krause\share on Windows by default. The
``c:\programme'' part can differ, it depends on your Windows
version and language.
This directory contains a sub-directory ``uc2lat-t'' providing
tables for translation from UNICODE to LaTeX. There is a nested
directory structure containing multiple files. Files are loaded
on demand.
The encoding for UNICODE 0x01234567 is found by searching the
file 01/23/45.dat file for an 0x67 entry.
There are three types of entries in the
file:
- * hex LaTeX
The LaTeX code can be used both in normal and in math mode. - t hex LaTeX
The LaTeX code can be used in normal (non-math) mode only. - m hex LaTeX
The LaTeX code can be used in math mode only.
# Raute
* 0x23 \#
# Asterisk
t 0x2A \textasteriskcentered{}
m 0x2A *
# Smaller-than
t 0x3C \textless{}
m 0x3C <
I use Fig drawings and want to switch to UTF-8 encoding. What do I have to do?
It depends on your drawing application.
- jFig
Just change LANG to ``de_DE.UTF-8'', ``en_US.UTF-8'' or ``whatever.UTF-8'' and reboot.
Modify $sysconfdir/fig2vect/fig2vect.cfg1, in section 1 in the [*] subsection addutf-8 = no
as the default setting for processing your own files.
To process files made by other people provide the-o utf-8=yes
command line option to fig2vect if the files contain UTF-8 encoded texts. - XFig
Change LANG to ``de_DE.UTF-8'', ``en_US.UTF-8'' or ``whatever.UTF-8'' and reboot.
Modify $sysconfdir/fig2vect/fig2vect.cfg1, in section 1 in the [*] subsection addutf-8 = auto
as the default setting (inspect the LANG variable). To process files made by other people or on other computers use the fig2vect command line option-o utf-8=no
or-o utf-8=yes
How do I set a default to enable/disable UTF-8 support in fig2vect?
There are different ways to change the default setting:
- On Linux/Unix systems for all users:
As root, add a section[*/fig2vect] /utf-8 = no
or[fig2vect] /utf-8 = yes
to the $sysconfdir/appdefaults1 file. - On Linux/Unix systems for the current user:
Add a section[fig2vect] /utf-8 = no
or[fig2vect] /utf-8 = yes
to the $HOME/.defaults/all file. - On Windows systems for all users:
In the registry key HKLM\Software\DkApp\fig2vect (create the key if necessary) add a string entry, the name is ``all/all:/utf-8'', the value is either ``yes'' or ``no''. - On windows systems for the current user:
In the registry key HKCU\Software\DkApp\fig2vect add a string entry, the name is ``all:/utf-8'', the value is either ``yes'' or ``no''.
How do I override the default setting on the command line?
Specify the command line options
-o utf-8=yesor
-o utf-8=nowhen running fig2vect.
How can I enable/disable UTF-8 support on a per-file base?
To process Fig files created by another user or on another computer,
open the Fig file in a text editor.
In the document comment section -- between line 8 (transparent color) and
line 9 (resolution and coordinates origin) -- place a special comment
## *: utf-8 = yesto enable UTF-8 support or
## *: utf-8 = noto disable UTF-8 support.
This all sounds complicated. Is there an example?
- Boot you computer or start a desktop session using UTF-8 encoding.
I.e. setLANG="de_DE.UTF-8"
in /etc/sysconfig/i18n and reboot. - Start xfig, create a new file test.fig (in the utf-8-example subdirectory).
- Add a text. If you attempt to type german umlauts, they are ignored.
- Push the Edit button, in the Edit dialog box complete the text
and type the umlauts äöü.
For each of the umlauts you see two glyphs in the dialogbox.
After leaving the dialog box the updated text is shown in the drawing.

Save and close the drawing. - Open the test.fig file in a text editor. Between line 8 (transparent
color) and 9 (resolution, coordinates origin) add a special comment
## *: utf-8 = yes
to indicate that texts in this drawing are UTF-8 encoded.
This allows fig2vect run by other users or on other computers to correctly decode the texts if language settings differ.#FIG 3.2 Landscape Center Inches Letter 100.00 Single -2 ## *: utf-8 = yes 1200 2 2 2 0 1 31 31 51 -1 20 0.000 0 0 -1 0 0 5 1200 1200 3375 1200 3375 1725 1200 1725 1200 1200 4 0 0 50 -1 0 12 0.0000 4 225 1425 1350 1500 Test mit \303\244\303\266\303\274\001
- Now run a conversion, i.e.
fig2vect -lpdf test.fig test.pdf
- The result can be viewed, i.e. in xpdf. The umlauts are shown
correctly.
- If you use jFig instead of XFig, insert
## *: utf-8 = no
because jFig already decoded the UTF-8 encoded data from keyboard and saved the text in traditional encoding.
Developer FAQ
Should I apply changes to the *.c or the *.ctr files?
Apply changes to the *.ctr files only.
The *.c files are generated from the *.ctr files automatically
by running the tracecc preprocessor. See
http://dklibs.sourceforge.net for details, there is a manual tracecc.pdf available.
| 1 | $sysconfdir is the system configuration directory, typically /etc or /usr/local/etc. |

