diff options
author | Karl Berry <karl@freefriends.org> | 2006-12-08 23:41:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-12-08 23:41:43 +0000 |
commit | 07f57f0989b2d8ce23bbd08ca8e5d7ed793dcfd8 (patch) | |
tree | 98c6acc01940ef85d7201427e7f6e7787936a689 /Master | |
parent | e2075366cc07edd608fc1018ce240b412e7c834e (diff) |
metapost package textpath 1.5
git-svn-id: svn://tug.org/texlive/trunk@2643 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/metapost/textpath/README | 41 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/textpath/textpath.pdf | bin | 0 -> 235575 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/metapost/textpath/textpath.tex | 456 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/textpath/textpathfigs.mp | 216 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/textpath/textpathfigs.tex | 3 | ||||
-rw-r--r-- | Master/texmf-dist/metapost/textpath/textpath.mp | 370 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/textpath/textpathmp.sty | 14 | ||||
-rw-r--r-- | Master/texmf-dist/tpm/textpath.tpm | 29 | ||||
-rw-r--r-- | Master/texmf/lists/textpath | 11 | ||||
-rw-r--r-- | Master/texmf/tpm/collection-metapost.tpm | 1 |
10 files changed, 1141 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/metapost/textpath/README b/Master/texmf-dist/doc/metapost/textpath/README new file mode 100644 index 00000000000..7f75a43ae3b --- /dev/null +++ b/Master/texmf-dist/doc/metapost/textpath/README @@ -0,0 +1,41 @@ +% This material is subject to the LaTeX Project Public License. See +% http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +% for the details of that license. + +package: textpath v1.5 2006/12/8 +author: Stephan Hennig (stephanhennig@arcor.de) + + +Description +----------- +This MetaPost package provides macros to typeset text along +a free path with the help of LaTeX, thereby preserving kerning +and allowing for 8-bit input (accented characters). + + +Installation +------------ +To install the package put the files into the following +directories in a local textmf tree and update the file +name data base. + +<localtexmftree>/doc/metapost/textpath: + textpath.pdf + textpath.tex + textpathfigs.mp + textpathfigs.tex + +<localtexmftree>/metapost/textpath: + textpath.mp + +<localtexmftree>/tex/latex/textpath: + textpathmp.sty + + +Usage Notes +----------- +See file textpath.pdf. + + +Happy TeXing! +Stephan Hennig diff --git a/Master/texmf-dist/doc/metapost/textpath/textpath.pdf b/Master/texmf-dist/doc/metapost/textpath/textpath.pdf Binary files differnew file mode 100644 index 00000000000..6abe7f6633b --- /dev/null +++ b/Master/texmf-dist/doc/metapost/textpath/textpath.pdf diff --git a/Master/texmf-dist/doc/metapost/textpath/textpath.tex b/Master/texmf-dist/doc/metapost/textpath/textpath.tex new file mode 100644 index 00000000000..4ecbb8a7e66 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/textpath/textpath.tex @@ -0,0 +1,456 @@ +\documentclass{article} +\usepackage{booktabs} +\usepackage{array} +\usepackage{graphicx} +\DeclareGraphicsRule{*}{mps}{*}{} +\usepackage{verbatim} +\newcommand*{\cmd}[1]{\texttt{#1}} +\newcommand*{\pkg}{\cmd{textpath.mp}} +\newcommand{\user}[1]{\emph{#1}} +\newenvironment{listing}{% + \small% + \verbatim% +}{% + \endverbatim% +} +\begin{document} +\title{The \pkg\ package\thanks{This document describes \pkg\ v1.5.}} +\author{Stephan Hennig\thanks{stephanhennig@arcor.de}} +\date{\today} +\maketitle + +\begin{abstract} +The MetaPost package \pkg\ provides macros to set text along a free path. It differs from the \cmd{txp.mp} package in that is uses \LaTeX\ to typeset the text and therefore 8-bit characters, \emph{e.g.}, accented characters, are supported and text is kerned. +\end{abstract} + + + +\section{A first example}\label{sec:firstexample} +The \pkg\ package provides a \cmd{textpath} macro, that takes three arguments: +\begin{enumerate} +\item a text string that is valid \LaTeX\ input, +\item a path the text should follow, and +\item a numeric value that controls justification of the text on the path. +\end{enumerate} +The macro returns a picture that contains the text transformed to the path. A sample call to \cmd{textpath} could be + +\begin{listing} +draw textpath("Greetings from MetaPost!", fullcircle scaled 50bp, 0); +\end{listing} + +The resulting output is shown in figure~\ref{fig:firstexample}. +\begin{figure}[tp] +\begin{minipage}[t]{.45\linewidth} + \centering + \includegraphics{textpathfigs.1} + \caption{Our first application.} + \label{fig:firstexample} +\end{minipage}\hfill +\begin{minipage}[t]{.45\linewidth} + \centering + \includegraphics{textpathfigs.2} + \caption{A refined variant.} + \label{fig:secondexample} +\end{minipage} +\end{figure} + +\user{Interesting, but not what I'd expect.} Well, figure~\ref{fig:firstexample} looks exactly as what we formulated in our MetaPost programme above. The text is drawn along a circle segment that starts at an angle of zero, runs counter clockwise and the text is left aligned on the path. Left aligned in this context means that the text starts at the beginning of the path. + +\user{But the text is inside the circle.} Yes, by default, the text is typeset on the left-hand side of the path if you were virtually walking down the path. There are configuration options to change that behaviour (see section~\ref{sec:textpathRotation}), but those won't help in this situation, since as a result the text would run right-to-left. + +Instead, have a look at the following changes to our code and the resulting figure~\ref{fig:secondexample}: + +\begin{listing} +path p; +p := reverse fullcircle rotated -90 scaled 50bp; +draw textpath("Greetings from MetaPost!", p, 0.5); +\end{listing} + +\user{What a magic path declaration!} The path now starts at an angle of $-90$ degrees and it runs clockwise. Did you notice the last parameter to \cmd{textpath} changed to $0.5$ in the programme? If it were zero, the text would start at the bottom of the circle and run clockwise along the outside of the circle. With the alignment parameter set to $0.5$ the text is centered on the path. That's the reason for rotating the start and end points of the circle to $-90$ degrees. + +By the way, do you notice anything wrong with figure~\ref{fig:secondexample}? We'll come back to that problem at the end of this manual. The next section discusses the parameters of the \cmd{textpath} macro in detail. + +\subsection{Text strings} +\subsubsection{Setting up the \pkg\ package} +Internally, the string you pass to \cmd{textpath} as the first argument is processed by \LaTeX\ by means of the \cmd{latexmp} package. This is hardcoded, currently, but may change in future versions so that you can use conventional \cmd{btex...etex} commands or the \cmd{TEX} macro. + +The \cmd{latexmp} package has to be set up with a proper \LaTeX\ preamble. The easiest way to do so is by providing a preamble file (without \verb+\begin{document}+) and input \cmd{latexmp.mp} using the following lines: + +\begin{listing} +input latexmp +setupLaTeXMP(preamblefile="mypreamble"); +\end{listing} + +The last step in setting up the \pkg\ package is adding the following line to the \LaTeX\ preamble in file \cmd{mypreamble.tex}: + +\begin{listing} +\usepackage{textpathmp} +\end{listing} +Note the trailing ``mp'' in the \LaTeX\ package name! + +\subsubsection{Restrictions on text input and output}\label{sec:restrictions} +Transforming text onto a path, \emph{i.e.}, rotating and shifting the text, should be done character by character, since otherwise there could be characters that move too far away from the path. Unfortunately, MetaPost doesn't provide guaranteed character-wise access to a text picture generated by \LaTeX. Therefore, some provisions have to be taken to enable characer-wise access. Internally, on the \LaTeX\ side the text string passed to \cmd{textpath} is pre-processed by the \cmd{soul} package. + +\paragraph{Invalid input} Therefore, input must not contain any material \cmd{soul} can't handle. If you're encountering errors from the \cmd{soul} package on the console delete the corresponding \cmd{ltx-???.tmp} file in your working directory and try with a simpler text string. Explicitely, the following restrictions apply to input: +\begin{itemize} +\item Vertical material is not valid. +\item Rules are not supported. +\item Font selection commands aren't allowed inside a text string. See section~\ref{sec:textpathFont} for a solution. +\item If you want to add arbitrary horizontal space in the copy, you should do that with \verb+\<{\kernXpt}+, where X is the desired space. +\end{itemize} +In general, try to stick to simple text. + +\paragraph{Valid input} However, input may contain: +\begin{itemize} +\item plain horizontal material, +\item accented characters: These are fine in the input as long as you choose the correct input encoding in the \LaTeX\ preamble and you have a font that provides true accented characters, \emph{e.g.}, a font supporting T1 encoding. +\item mathematical copy: Section~\ref{sec:textpathRaw} explains how to typeset formulae onto a path. +\end{itemize} + +\paragraph{Output} The following restrictions apply to the output of \cmd{textpath} \emph{et al.}: +\begin{itemize} +\item Ligatures are broken in the output. +\end{itemize} + + +\subsection{Paths}\label{sec:paths} +As mentioned before, by default, text is typeset on the left-hand side of a path. That is, the text is rotated to have the natural slope of the path at the desired location. Configuration options to change that behaviour are described in section~\ref{sec:textpathRotation}. + +In case total text width is larger than total path length characters that don't fit on the path are clipped by default (see figure~\ref{fig:textpathClip}). Configuration options to change that behaviour are described in section~\ref{sec:textpathClip}. + +\begin{figure} +\begin{minipage}[t]{.45\linewidth} + \centering + \includegraphics{textpathfigs.4} + \caption{Text on a short horizontal path clipped and unclipped.} + \label{fig:textpathClip} +\end{minipage}\hfill +\begin{minipage}[t]{.45\linewidth} + \centering + \includegraphics{textpathfigs.3} + \caption{Using different fonts in a MetaPost graphic.} + \label{fig:textpathFont} +\end{minipage} +\end{figure} + + +\subsection{Text justification} +Justification of the text on the path can be controlled by the third parameter~\cmd{j}, which is a numeric value. Setting it to zero makes the text left aligned, \emph{i.e.}, text starts right at be beginning of a path. A value of one makes the text right aligned, \emph{i.e.}, text ends at the end point of a path. A value of $0.5$ centers text on a path. + +There is a general rule: the point at fraction \cmd{j} of the total text width is transformed to the point on the path at fraction \cmd{j} of the total path length. Therefore, \cmd{j} should be from the intervall $[0,1]$. + + + +\section{Handling different fonts}\label{sec:textpathFont} +The package provides a variant of the \cmd{textpath} macro called \cmd{textpathFont}, that differs from \cmd{textpath} in only one respect. It takes an additional fourth argument. That argument is a string containing a valid \LaTeX\ font selection command such as \verb+\itshape+. The font selection string has to be given as the first argument. The remaining arguments are the same as for \cmd{textpath} (see figure~\ref{fig:textpathFont}). + +\begin{listing} +p := reverse fullcircle rotated -90; +draw textpathFont("\usefont{T1}{pzc}{m}{n}\huge", "Happy Birthday to", + p scaled 400bp, 0.5) withcolor (1, 0.6, 0.2); +draw textpathFont("\usefont{T1}{bch}{m}{n}\large", "Daisy Duck!", + p scaled 350bp, 0.5) withcolor (0.9, 0.3, 0.1); +\end{listing} + + +Since the \cmd{soul} package can't handle font selection commands in the copy, one were stuck to the font that is setup in the \LaTeX\ preamble for the whole MetaPost document. The \cmd{textpathFont} macro accounts for that by getting the font selection separate from the text and applying it before the \cmd{soul} package comes into play. Unfortunately, switching the font inside text still isn't possible that way. + + + +\section{The raw interface}\label{sec:textpathRaw} +In case you're fine with \cmd{textpath} and \cmd{textpathFont} and you do not intend to typeset mathematical formulae along a path, you may savely skip this section and read on with section~\ref{sec:configuration} where configuration options are described. + +The \pkg\ package provides a third macro \cmd{textpathRaw} to typeset material along a path. This is the so called raw interface. As we've seen in section~\ref{sec:restrictions}, input to \cmd{textpath} and \cmd{textpathFont} is pre-processed by the \cmd{soul} package. In contrast, input to the raw interface isn't pre-processed. Have a look at figure~\ref{fig:rawMetaPost} to see how MetaPost accesses arbitrary chunks of characters at once without pre-processing on the \LaTeX\ side. + +\begin{figure} +\begin{minipage}[t]{.45\linewidth} + \centering + \includegraphics{textpathfigs.11} + \caption{Transforming arbitrary chunks of characters at once using the raw interface.} + \label{fig:rawMetaPost} +\end{minipage}\hfill +\begin{minipage}[t]{.45\linewidth} + \centering + \includegraphics{textpathfigs.12} + \caption{A formula typeset along a path.} + \label{fig:rawFormula} +\end{minipage} +\end{figure} + +\user{Why is the word ``MetaPost'' broken between letters ``P'' and ``o''?} In fact, MetaPost doesn't process \emph{arbitrary} chunks of characters. It rather collects and processes chunks of characters that are typeset without artificial horizontal space between them. That is, text is broken into chunks by MetaPost at inter word space, kerning, \emph{etc.} Clearly, in our example kerning took place between glyphs ``P'' and ``o'' while other glyph pairs weren't kerned. + +Arguments to the \cmd{textpathRaw} macro are the same as to the \cmd{textpath} macro. The differences between \cmd{textpath} and \cmd{textpathRaw} are: +\begin{itemize} +\item Font selection commands are allowed in input to \cmd{textpathRaw}. +\item Rules are supported. +\item Manual horizontal space is allowed in the input. +\item Ligatures are preserved. +\end{itemize} + +As we've seen in figure~\ref{fig:rawMetaPost}, macros \cmd{textpath} and \cmd{textpathFont} are much better suited to typeset plain text along a path than \cmd{textpathRaw}. However, there is one application where \cmd{textpathRaw} performs better than \cmd{textpath}: mathematical formulae. Have a look at figure~\ref{fig:rawFormula}. Have you ever seen stuff like that with any other text processing or graphics application? + +The reason \cmd{textpathRaw} doesn't fail as badly on mathematical input as it does on plain text is that in formulae characters are rarely typeset without extra space between each other. That is, MetaPost quite often breaks formulae into chunks and hence naturally processes them character-wise. The exception to this are operator names such as $\log$, $\sin$, $\arctan$ \emph{etc.\@} and sometimes products of variables. The latter can be avoided by explicitely inserting \verb+\cdot+ between factors. + +\user{What about more complicated formulae with fractions \emph{etc.}?} Have a look at figure~\ref{fig:rawFraction}. Since rules are explicitely supported by \cmd{textpathRaw} fractions are no problem. + +\begin{figure} + \centering + \includegraphics{textpathfigs.13} + \caption{A formula containing fractions.} + \label{fig:rawFraction} +\end{figure} + +\user{Awesome! The rules are curved, too!} Yes, since formulae can look awful otherwise the \pkg\ package puts some efforts into that. Section~\ref{sec:textpathFancyStrokes} describes an option that lets you choose between curved and straight rules. + +\user{Any restrictions?} Well, on concave shapes formulae look even more ugly than plain text. For a technical restriction, formulae shouldn't be of too large height and depth. Section~\ref{sec:textpathCureSqrt} shows a solution to another problem with root operators not discussed so far. + +That's it---almost. The remaining chapter describes global variables to configure the \pkg\ package, \emph{i.e.}, the way macros \cmd{textpath}, \cmd{textpathFont} and \cmd{textpathRaw} work. Quite some interesting effects can be achieved with certain settings. So don't miss the last chapter! + + + +\section{Configuration variables}\label{sec:configuration} +The \pkg\ offers several configuration options through global variables. Some of them have already been mentioned in the other sections. This chapter summarizes all configuration variables. + +\subsection{\cmd{textpathClip}}\label{sec:textpathClip} +As explained in section~\ref{sec:paths} when total text width is larger than path length text that doesn't fit into the path boundaries is clipped. Actually, the location of characters that exeed path boundaries is clipped to the boundaries first. Then variable \cmd{textpathClip} is read and if it is set to zero value those characters are drawn at the boundary, acting as a visual marker that something went wrong, or, if \cmd{textpathClip} is set to one, those characters are omitted (see figure~\ref{fig:textpathClip}). By default, \cmd{textpathClip} is set to one, that is, characters may be clipped. + + +\subsection{\cmd{textpathRepeat}}\label{sec:textpathRepeat} +Variable \cmd{textpathRepeat} determines the number of copys of the text string that should be typeset along a path. Valid are integer values greater or equal to one. By default, \cmd{textpathRepeat} is set to one. + +Note, that the alignment parameter \cmd{j} still works when setting \cmd{textpathRepeat} to arbitrary values. That is, for a value of zero text starts at the beginning of a path and for a value of one text ends at the end of a path. + +\subsection{\cmd{textpathStretch} and \cmd{textpathHSpace}}\label{sec:textpathStretch}\label{sec:textpathHSpace} +When variable \cmd{textpathRepeat} is greater than one (see section~\ref{sec:textpathRepeat}), horizontal spacing between single copies of the text string is determined manually or automatically, depending on variable \cmd{textpathStretch}. If \cmd{textpathStretch} is set to zero value variable \cmd{textpathHSpace} determines the spacing between text string copies. If \cmd{textpathStretch} is set to one, spacing is automatically calculated, which is the default. + +Figure~\ref{fig:textpathHSpace} shows an example of manually spaced text copies. Note, that the space on the left and right of the total text is quite unrelated to \cmd{textpathHSpace} and automatically results from path length, text width, the number of text copies, \cmd{textpathHSpace}, and the justification parameter \cmd{j}. + +\begin{listing} +f := "\usefont{T1}{pzc}{m}{n}\Large"; +p := subpath (5.7,6.3) of fullcircle scaled 1400bp; +draw p withcolor .8white; +textpathRepeat := 3; +textpathStretch := 0; +textpathHSpace := 10pt; +draw textpathFont(f, "Happy Birthday", p, 0.5) withcolor (1, 0.6, 0.2); +\end{listing} + +\begin{figure} + \centering + \includegraphics{textpathfigs.5} + \caption{Repeated text manually spaced and centered.} + \label{fig:textpathHSpace} +\end{figure} + +In contrast, when text copies are automatically spaced, \emph{i.e.}, \cmd{textpathStretch} is set to one, the sum of space before and after all text copies equals the space between text copies. This is quite handy when typesetting text along a cyclic path as in figure~\ref{fig:textpathShift}. + + +\subsection{\cmd{textpathShift}}\label{sec:textpathShift} +Variable \cmd{textpathShift} determines the amount all characters are shifted orthogonally to a path (the base line). Positive values result in characters shifted to the left of a path---looking into the natural direction of a path---, while negative values shift characters to the right of a path. + +In figure~\ref{fig:textpathShift} the thick black border is both, the path our text should follow and the background of the text. Therefore, we need to ``vertically'' center the text on the path. A small negative value of \cmd{textpathShift} serves our purposes well. + +\begin{listing} +% Font Brush Script Italic is available on CTAN. +f := "\usefont{T1}{pbsi}{xl}{n}\fontsize{2.1pt}{2.1pt}\selectfont"; +w := 210bp; +h := .276w; +r := .19h; +p := (-.5w,0)--(-.5w,.5h-r)--quartercircle rotated -90 scaled (2r) + shifted (-.5w,.5h)--(0,.5h); +p := p--reverse p reflectedabout ((0,-1),(0,1)); +p := p--reverse p reflectedabout ((-1,0),(1,0))--cycle; +draw p withpen pensquare scaled 3.5pt; +textpathRepeat := 30; +textpathShift := -.6pt; +draw textpathFont(f, "Fa\ss' Dich kurz!", p, 0.5) withcolor white; +label(textext + ("\usefont{T1}{bfu}{mb}{n}\fontsize{22pt}{22pt}\selectfont Telephonzelle"), + origin);% Bitstream Futura +\end{listing} + +\begin{figure} + \centering + \includegraphics{textpathfigs.10} + \caption{An attempt to resemble the style of classic labels. (Failed badly.)} + \label{fig:textpathShift} +\end{figure} + + +\subsection{\cmd{textpathLetterSpace}}\label{sec:textpathLetterSpace} +If you're typesetting text along a path with a high curvature the text may look squeezed or letter-spaced, depending on path shape, because natural inter letter space refers to unrotated characters and is only proper near the base line of rotated characters. On a convex shape, therefore, text can look letter-spaced where, in fact, it isn't. In contrast, on a concave shape glyphs may touch each other. Comparing figures~\ref{fig:firstexample} and~\ref{fig:secondexample} the latter looks lighter, since inter letter space raises with the distance from the base line. The same effect can be seen in figure~\ref{fig:anchor}, \emph{e.g.}, between characters ``a'' and ``i''. + +The \pkg\ package provides means to manually tweak inter letter space. Before transforming a character onto the path the \pkg\ package inserts an additional amount of horizontal space of width \cmd{textpathLetterSpace} between all characters. This variable is a good friend when shifting or rotating characters. By default, \cmd{textpathLetterSpace} is set to zero, that is, text is typeset at its natural width. + +Variable \cmd{textpathLetterSpace} has only effect when typesetting text through macros \cmd{textpath} and \cmd{textpathFont}. In macro \cmd{textpathRaw} this variable is ignored. + + +\subsection{\cmd{textpathRotation}}\label{sec:textpathRotation} +In section~\ref{sec:paths} it was already mentioned that text turns out on the left-hand side of a path, by default. This is an appropriate setting for cultures where text is read left to right. + +The \pkg\ package, internally, calculates for each character in the text string the position of its anchor point on the path and the slope of the path at that location. The character is then rotated around its anchor point by an angle corresponding to the slope. The anchor point of a character lies at its horizontal center on the base line (see figure~\ref{fig:anchor}). Finally, the anchor point is translated to the required coordinates on the path. As a result, characters appear on the left-hand side of a path. + +\begin{figure} +\begin{minipage}[t]{1\linewidth} + \centering + \includegraphics{textpathfigs.6} + \caption{The anchor point of a character.} + \label{fig:anchor} +\end{minipage} +\end{figure} + +You can manually apply an additional rotation to every character by setting variable \cmd{textpathRotation} to a non-zero value. A value of, \emph{e.g.}, 180 degrees turns each character upside down, so that it turns out on the right-hand side of a path. A value of, \emph{e.g.}, 90 degrees results in characters ``floating'' with the path. By default, \cmd{textpathRotation} is set to zero. + +In figure~\ref{fig:textpathRotation}, note that the heart shape is derived from half circles and the text would have been running on the inside of the path by default, cf. figure~\ref{fig:firstexample}. + +\begin{listing} +string f, t; +path heart; +f := "\usefont{T1}{pzc}{m}{it}\tiny"; +t := "Love"; +heart := halfcircle shifted (-0.5bp,0bp)..{dir-50}(0bp,-1.5bp); +heart := heart--reverse heart reflectedabout ((0,0),(0,1))--cycle; +heart := heart scaled 60bp; +textpathRotation := 90; +textpathLetterSpace := 1pt; +textpathRepeat := 30; +draw textpathFont(f, t, heart, 0) withcolor red+0.1green; +\end{listing} + +\begin{figure} + \centering + \includegraphics{textpathfigs.7} + \caption{Automatically spaced text with an additional rotation of 90 degrees.} + \label{fig:textpathRotation} +\end{figure} + + +\subsection{\cmd{textpathAbsRotation}}\label{sec:textpathAbsRotation} +The interpretation of variable \cmd{textpathRotation} changes when variable \cmd{textpathAbsRotation} is set to a value of one. Then characters are rotated by \cmd{textpathRotation} degrees only, ignoring path slope (see figure~\ref{fig:textpathAbsRotation}). By default, \cmd{textpathAbsRotation} is set to zero. + +\begin{listing} +picture pic; +f := "\usefont{T1}{fwb}{m}{n}\Large";% From the emerald package +t := "Don't panic! Don't panic! Don't panic!"; +p := origin +for i:=1 upto 20: ..(i, sind(i*45)) endfor; +p := p xscaled 20 yscaled 35; +textpathRotation := 0; +textpathAbsRotation := 1; +textpathLetterSpace := 6pt; +pic := textpathFont(f, t, p, 0); +background := black; +bboxmargin := 30bp; +unfill bbox pic; +draw pic withcolor red+green; +\end{listing} + +\begin{figure} + \centering + \makebox[0pt][c]{% + \includegraphics{textpathfigs.8}% + } + \caption{Text without rotation.} + \label{fig:textpathAbsRotation} +\end{figure} + +We could have used \cmd{textpathRepeat} instead of repeating the text manually in the last example as well. But since that required some more letters to type I chose not to do so. In case the path definition inside the for loop---or rather the for loop inside the path definition---in the last listing looks uncommon to you, have a look at chapter~10 of the MetaPost manual, where this usage is explained. + + +\subsection{\cmd{textpathFancyStrokes}}\label{sec:textpathFancyStrokes} +The remaining three variables apply only to macro \cmd{textpathRaw}. In section~\ref{sec:textpathRaw} figure~\ref{fig:rawFraction} showed a formula containing fractions, where the rules were automatically bent to the shape of the path. Variable \cmd{textpathFancyStrokes} determines if rules in the input to \cmd{textpathRaw} should appear curved or straight in the output. A value of zero results in straight rules. If \cmd{textpathFancyStrokes} is set to one, which is the default, the \pkg\ package tries to adjust the shape of rules to that of the path. + +Figures~\ref{fig:textpathFancyStrokesZero} and~\ref{fig:textpathFancyStrokesOne} show a similar formula as in figure~\ref{fig:rawFraction}. Clearly, both, the square root and the fraction look more decent with curved strokes. + +\begin{figure} +\begin{minipage}[t]{.45\linewidth} + \centering + \includegraphics{textpathfigs.14} + \caption{Straight rules in a formula.} + \label{fig:textpathFancyStrokesZero} +\end{minipage}\hfill +\begin{minipage}[t]{.45\linewidth} + \centering + \includegraphics{textpathfigs.15} + \caption{Curved rules in a formula.} + \label{fig:textpathFancyStrokesOne} +\end{minipage} +\end{figure} + + +\subsection{\cmd{textpathStrokePrecision}}\label{sec:textpathStrokePrecision} +When you're typesetting formulae along paths with a high curvature it may be difficult for rules to follow the path. Variable \cmd{textpathStrokePrecision} determines the number of auxillary points that are calculated along a stroke. For higher values of \cmd{textpathStrokePrecision} strokes follow a path more precisely. By default, \cmd{textpathStrokePrecision} is set to a value of ten, which should be enough for most cases. + +This variable applies only if \cmd{textpathFancyStrokes} is set to one. Otherwise, it is ignored. + +\subsection{\cmd{textpathCureSqrt}}\label{sec:textpathCureSqrt} +Did you notice the small gap that is still present in the square root operator in figure~\ref{fig:textpathFancyStrokesOne}? A root sign actually consists of two parts, a leading V part and a trailing horizontal rule spanning the arguments. The V part, in fact, is a single glyph, while the rule is, well, a rule. If typeset horizontally, both parts overlap so that they visually melt into one glyph. + +When typeset onto a path, the V part is rotated according to the slope of the path at its anchor point, which lies at the horizontal center of the glyph. The resulting rotating angle is slightly different from the rotating angle that should be applied to the top right corner of the glyph. Therefore, V and rule part of a square root are missing each other and a gap becomes visible. + +The \pkg\ package tries to fill this gap automatically when variable \cmd{textpathCureSqrt} is set to a value of one, which is the default. In fact, in figure~\ref{fig:textpathFancyStrokesOne} this variable was manually set to zero to provoke the gap. In figure~\ref{fig:textpathCureSqrt} the gap has been filled. Don't expect too fancy results from this option in difficult cases. + +This variable applies only if \cmd{textpathFancyStrokes} is set to one. Otherwise, it is ignored. +Moreover, it only works when \cmd{textpathRepeat} is set to a value of one, \emph{i.e.}, there are no multiple copies of formulae. + +\begin{figure} +\begin{minipage}[t]{.45\linewidth} + \centering + \includegraphics{textpathfigs.16} + \caption{A curved square root without a gap.} + \label{fig:textpathCureSqrt} +\end{minipage}\hfill +\begin{minipage}[t]{.45\linewidth} + \centering + \includegraphics{textpathfigs.9} + \caption{Another logo that didn't fit as an example in the other sections.} + \label{fig:proetcontra} +\end{minipage}\hfill +\end{figure} + +\suppressfloats + +\subsection{Summary} +Table~\ref{tab:configuration} lists all configuration variables, their default values and in what macros they have effect. + +\begin{table} + \centering + \begin{tabular}{>{\ttfamily}l>{\raggedleft}p{3em}ccc} + \normalfont variable name & \makebox[0pt][r]{default value} & \multicolumn{3}{c}{valid in macros}\\ + & & \cmd{textpath} & \cmd{textpathFont} & \cmd{textpathRaw}\\ + \addlinespace\toprule\addlinespace + textpathClip & 1 & $+$ & $+$ & $+$\\ + textpathRepeat & 1 & $+$ & $+$ & $+$\\ + textpathStretch & 1 & $+$ & $+$ & $+$\\ + textpathHSpace & 0pt & $+$ & $+$ & $+$\\ + textpathShift & 0pt & $+$ & $+$ & $+$\\ + textpathLetterSpace & 0pt & $+$ & $+$ & $-$\\ + textpathRotation & 0 & $+$ & $+$ & $+$\\ + textpathAbsRotation & 0 & $+$ & $+$ & $+$\\ + textpathFancyStrokes & 1 & $-$ & $-$ & $+$\\ + textpathStrokePrecision & 10 & $-$ & $-$ & $+$\\ + textpathCureSqrt & 1 & $-$ & $-$ & $+$\\ +% textpathDebug & 0 & $+$ & $+$ & $+$\\ + \end{tabular} + \caption{Summary of configuration variables.} + \label{tab:configuration} +\end{table} + + +\section{Epilogue} +Do you remember when we asked about a problem with figure~\ref{fig:secondexample} in section~\ref{sec:firstexample}? \user{Yes, the first and last characters do not visually line up properly!} Well spotted! Actually, the code is correct. The problem is that ``G'' and ``!'' have quite different glyph shapes. When virtually drawing the bounding boxes of the rotated characters one realizes that the left-most and right-most points of the text on the path do line up. + +\user{Is there a fix?} There's no automatic solution. If the text started, \emph{e.g.}, with letters ``B'', ``E'' or even ``W'' \emph{etc.\@} those characters would visually line up with an exclamation mark. As a work around for letters ``C'', ``G'' \emph{etc.\@} the alignment parameter could be reduced to a value slightly less that 0.5. But honestly, did you really notice the difference? + +\user{Where's the source code of the last examples?} The code of all figures shown in this manual can be found in file \cmd{textpathfigs.mp}, which is part of this package. + +\user{What is the nice calligraphic font you're using throughout this manual?} Since we're dealing with decorative graphics here, \textsc{urw} Zapf Chancery Medium Italic available through the \textsc{psnfss} package is used in many examples. Other decorative fonts with ready-made \LaTeX\ support are Brush Script Italic or the fonts from the \textsc{Emerald} package. Both packages are available on \textsc{ctan}. + +\user{Anything else?} While you're asking, don't try to do too fancy stuff with this package. Text---and mathematical copy---is most legible when typeset horizontally. With increasing curvature of the base line legibility decreases fastly. A decorative, but elegant look can be achieved best by just slightly indicating a curved base line, similar to figure~\ref{fig:textpathFont}. + +\bigskip +\raggedright\itshape +Happy \TeX ing!\par +Stephan Hennig + +\end{document} diff --git a/Master/texmf-dist/doc/metapost/textpath/textpathfigs.mp b/Master/texmf-dist/doc/metapost/textpath/textpathfigs.mp new file mode 100644 index 00000000000..0e09b6c3b23 --- /dev/null +++ b/Master/texmf-dist/doc/metapost/textpath/textpathfigs.mp @@ -0,0 +1,216 @@ +input latexmp +setupLaTeXMP(preamblefile="textpathfigs"); +input textpath + +prologues := 1; + +beginfig(1); + draw textpath("Greetings from MetaPost!", fullcircle scaled 50bp, 0) + withcolor (0.2,0.2,0.6); +endfig; + +beginfig(2); +path p; + p := reverse fullcircle rotated -90 scaled 50bp; + draw textpath("Greetings from MetaPost!", p, 0.5) withcolor (0.2,0.2,0.6); +endfig; + + +beginfig(3); +path p; + p := reverse fullcircle rotated -90; + draw textpathFont("\usefont{T1}{pzc}{m}{n}\huge", "Happy Birthday to", + p scaled 400bp, 0.5) withcolor (1, 0.6, 0.2); + draw textpathFont("\usefont{T1}{bch}{m}{n}\large", "Daisy Duck!", + p scaled 350bp, 0.5) withcolor (0.9, 0.3, 0.1); +endfig; + + +beginfig(4); +path p; + p := (origin--(1bp,0bp)) scaled 75bp; + draw p withcolor .8white; + draw textpath("Greetings from MetaPost!", p, 0.5) withcolor (0.2,0.2,0.6); + p := p shifted (0,-20bp); + draw p withcolor .8white; + textpathClip := 0; + draw textpath("Greetings from MetaPost!", p, 0.5) withcolor (0.2,0.2,0.6); +endfig; + +textpathClip := 1; + + +beginfig(5); +path p; +string f; + f := "\usefont{T1}{pzc}{m}{n}\Large"; + p := subpath (5.7,6.3) of fullcircle scaled 1400bp; + draw p withcolor .8white; + textpathRepeat := 3; + textpathStretch := 0; + textpathHSpace := 10pt; + draw textpathFont(f, "Happy Birthday", p, 0.5) withcolor (1, 0.6, 0.2); +endfig; + +textpathRepeat := 1; +textpathStretch := 1; + + +beginfig(6); +string f; +path p; +picture pic; +numeric lenp, lenpic, tb, k; +color daisy; + daisy := (0.9, 0.3, 0.1); + f := "\usefont{T1}{bch}{m}{n}\fontsize{40pt}{40pt}\selectfont"; + p := subpath (2.7,5.3) of reverse fullcircle rotated -90 scaled 100bp; + draw p withcolor .8white; + textpathAbsRotation := 1; + draw textpathFont(f, "Daisy", p, 0.5) withcolor (white-daisy) + 0.8daisy; + textpathAbsRotation := 0; + draw textpathFont(f, "Daisy", p, 0.5) withcolor daisy; + pic := strToPic(f & "\spaced{Daisy}"); + draw textpathPic(pic, p, 0.5, "debug"); +endfig; + + +beginfig(7); +string f, t; +path heart; + f := "\usefont{T1}{pzc}{m}{it}\tiny"; + t := "Love"; + heart := halfcircle shifted (-0.5bp,0bp)..{dir-50}(0bp,-1.5bp); + heart := heart--reverse heart reflectedabout ((0,0),(0,1))--cycle; + heart := heart scaled 60bp; + textpathRotation := 90; + textpathLetterSpace := 1pt; + textpathRepeat := 30; + draw textpathFont(f, t, heart, 0.5) withcolor red+0.1green; +endfig; + +textpathRepeat := 1; + + +beginfig(8); +path p; +string f, t; +picture pic; + f := "\usefont{T1}{fwb}{m}{n}\Large";% From the emerald package + t := "Don't panic! Don't panic! Don't panic!"; + p := origin + for i:=1 upto 20: ..(i, sind(i*45)) endfor; + p := p xscaled 20 yscaled 35; + textpathRotation := 0; + textpathAbsRotation := 1; + textpathLetterSpace := 6pt; + pic := textpathFont(f, t, p, 0); + background := black; + bboxmargin := 30bp; + unfill bbox pic; + draw pic withcolor red+green; +endfig; + +textpathAbsRotation := 0; +textpathLetterSpace := 0pt; + + +beginfig(9); +string f; +path p; + f := "\usefont{T1}{pzc}{m}{it}\fontsize{56pt}{56pt}\selectfont"; + p := reverse fullcircle rotated 33 scaled 150bp; + textpathLetterSpace := -3pt; + draw textpathFont(f, "Pro \&", p, 1) withcolor (1, 0.6, 0.2); + textpathLetterSpace := 0pt; + f := "\usefont{T1}{pzc}{m}{it}\fontsize{48pt}{48pt}\selectfont"; + p := fullcircle rotated 33 scaled 145bp; + draw textpathFont(f, "Con\<{\kern-2pt}tra", p, 0.0) withcolor (1, 0.6, 0.2); +endfig; + + +beginfig(10); +string f; +path p; +numeric r,h,w; +picture pic; +% Font Brush Script Italic is available on CTAN. + f := "\usefont{T1}{pbsi}{xl}{n}\fontsize{2.1pt}{2.1pt}\selectfont"; + w := 210bp; + h := .276w; + r := .19h; + p := (-.5w,0)--(-.5w,.5h-r)--quartercircle rotated -90 scaled (2r) + shifted (-.5w,.5h)--(0,.5h); + p := p--reverse p reflectedabout ((0,-1),(0,1)); + p := p--reverse p reflectedabout ((-1,0),(1,0))--cycle; + draw p withpen pensquare scaled 3.5pt; + textpathRepeat := 30; + textpathShift := -.6pt; + draw textpathFont(f, "Fa\ss' Dich kurz!", p, 0.5) withcolor white; + label(textext + ("\usefont{T1}{bfu}{mb}{n}\fontsize{22pt}{22pt}\selectfont Telephonzelle"), + origin);% Bitstream Futura +endfig; + +textpathRepeat := 1; +textpathShift := 0pt; + + +beginfig(11); +path p; + p := reverse fullcircle rotated -90 scaled 50bp; + draw p withcolor .8white; + draw textpathRaw("Greetings from MetaPost!", p, 0.5) withcolor (0.2,0.2,0.6); +endfig; + + +beginfig(12); +path p; + p := reverse halfcircle scaled 80bp; + draw p withcolor .8white; + draw textpathRaw("\LARGE$x^2+y^2=r^2$", p, 0.5) withcolor (0.2,0.2,0.6); +endfig; + + +beginfig(13); +path p; + p := reverse halfcircle xscaled 160bp yscaled 80; + draw p withcolor .8white; + textpathShift := 7pt; + draw textpathRaw("\Large$\frac{(x-u)^2}{a^2}+\frac{(y-v)^2}{b^2}=1$", p, 0.5) withcolor (0.2,0.2,0.6); +endfig; + + +beginfig(14); +path p; + p := reverse halfcircle xscaled 160bp yscaled 80; + draw p withcolor .8white; + textpathShift := 9pt; + textpathFancyStrokes := 0; + draw textpathRaw("\Large$y = v+b\sqrt{1-\frac{(x-u)^2}{a^2})}$", p, 0.5) withcolor (0.2,0.2,0.6); +endfig; + + +beginfig(15); +path p; + p := reverse halfcircle xscaled 160bp yscaled 80; + draw p withcolor .8white; + textpathShift := 9pt; + textpathFancyStrokes := 1; + textpathCureSqrt := 0; + draw textpathRaw("\Large$y = v+b\sqrt{1-\frac{(x-u)^2}{a^2})}$", p, 0.5) withcolor (0.2,0.2,0.6); +endfig; + +beginfig(16); +path p; + p := reverse halfcircle xscaled 160bp yscaled 80; + draw p withcolor .8white; + textpathShift := 9pt; + textpathFancyStrokes := 1; + textpathCureSqrt := 1; + draw textpathRaw("\Large$y = v+b\sqrt{1-\frac{(x-u)^2}{a^2})}$", p, 0.5) withcolor (0.2,0.2,0.6); +endfig; + +textpathShift := 0pt; + +end diff --git a/Master/texmf-dist/doc/metapost/textpath/textpathfigs.tex b/Master/texmf-dist/doc/metapost/textpath/textpathfigs.tex new file mode 100644 index 00000000000..054c1cce8ce --- /dev/null +++ b/Master/texmf-dist/doc/metapost/textpath/textpathfigs.tex @@ -0,0 +1,3 @@ +\RequirePackage{fix-cm} +\documentclass{article} +\usepackage{textpathmp} diff --git a/Master/texmf-dist/metapost/textpath/textpath.mp b/Master/texmf-dist/metapost/textpath/textpath.mp new file mode 100644 index 00000000000..03df35cd8f0 --- /dev/null +++ b/Master/texmf-dist/metapost/textpath/textpath.mp @@ -0,0 +1,370 @@ +%%% Global variables. + +%%% Global variable. +%%% Character coordinates that lay outside path boundaries after +%%% transformation are clipped to the boundaries. +%%% Variable textpathClip determines if such characters should be +%%% output at path boundaries, thereby acting as a visual indicator +%%% that something went wrong, or if text outside path boundaries +%%% should be omitted. Variable textpathClip can be either one (omit) +%%% or zero (don't omit). +newinternal textpathClip; +textpathClip := 1; + +%%% Global variable. +%%% Variable textpathLetterSpace determines the amount of space that +%%% is additionally inserted between all characters. This can be +%%% useful, when drawing text along a concacve shape or in general +%%% along paths with a high curvature. Variable textpathLetterSpace +%%% can contain positive or negative values. +newinternal textpathLetterSpace; +textpathLetterSpace := 0bp; + +%%% Global variable. +newinternal textpathRotation; +textpathRotation := 0; + +%%% Global variable. +newinternal textpathAbsRotation; +textpathAbsRotation := 0; + +newinternal textpathRepeat; +textpathRepeat := 1; + +newinternal textpathStretch; +textpathStretch := 1; + +newinternal textpathHSpace; +textpathHSpace := 0; + +newinternal textpathShift; +textpathShift := 0; + +newinternal textpathSoulLetterSpace; +textpathSoulLetterSpace := 10bp; + +newinternal textpathFancyStrokes; +textpathFancyStrokes := 1; + +newinternal textpathStrokePrecision; +textpathStrokePrecision := 10; + +newinternal textpathCureSqrt; +textpathCureSqrt := 1; + +newinternal textpathDebug; +textpathDebug := 0; + +pair textpathHookCoord, textpathHookPoint; +newinternal textpathHookRoot; +textpathHookCoord := origin; +textpathHookPoint := origin; +textpathHookRot := 0; + + + +%%% User Macros. + +%%% User macro. +%%% Set text along a path. +%%% Parameters: +%%% * a text string t that is fed into TeX through latexmp, +%%% * a path p the text should follow. +%%% * a numeric variable j that controls justification: +%%% j=0: text is left aligned on the path, +%%% j=0.5: text is centered on the path, +%%% j=1: text is right aligned on the path, +%%% The general rule is the character at fraction j of the total +%%% text width is transformed to the point at fraction j of the total +%%% path width. j should be from the interval [0, 1]. +%%% Return value: +%%% * a picture variable containing text following a path. +def textpath(expr t, p, j)= + textpathFont("", t, p, j) +enddef; + + +%%% User macro. +%%% Set text in arbitrary font along a path. +%%% Parameters: +%%% * a string f that is a valid LaTeX font selection command, e.g., \itshape, +%%% * a text string t that is fed into TeX through latexmp, +%%% * a path p the text should follow. +%%% * a numeric variable j that controls justification: +%%% j=0: text is left aligned on the path, +%%% j=0.5: text is centered on the path, +%%% j=1: text is right aligned on the path, +%%% The general rule is the character at fraction j of the total +%%% text width is transformed to the point at fraction j of the total +%%% path width. j should be from the interval [0, 1]. +%%% Return value: +%%% * a picture variable containing text following a path. +vardef textpathFont(expr f, t, p, j)= +save pre, post; +string pre, post; + pre := f & "\spaced{"; + post := "}"; + textpathPic(strToPic(pre & t & post), p, j, "") +enddef; + + +%%% User macro. +%%% Set text along a path. +%%% Parameters: +%%% * a text string t that is fed into TeX through latexmp, +%%% * a path p the text should follow. +%%% * a numeric variable j that controls justification: +%%% j=0: text is left aligned on the path, +%%% j=0.5: text is centered on the path, +%%% j=1: text is right aligned on the path, +%%% The general rule is the character at fraction j of the total +%%% text width is transformed to the point at fraction j of the total +%%% path width. j should be from the interval [0, 1]. +%%% Return value: +%%% * a picture variable containing text following a path. +vardef textpathRaw(expr t, p, j)= +save temp, pic, pre, post; +numeric temp; +picture pic; +string pre, post; + pre := "\rule[-30bp]{0pt}{30bp}"; + post := ""; + temp := textpathSoulLetterSpace; + textpathSoulLetterSpace := 0bp; + pic := textpathPicRaw(strToPic(pre & t & post), p, j, ""); + textpathSoulLetterSpace := temp; + pic +enddef; + + + +%%% Internal Macros. + +%%% Internal macro. +%%% Convert a string into a picture using TeX via latexmp package. +%%% Parameters: +%%% * a string. +%%% Return value: +%%% * a picture variable. +vardef strToPic(expr s)= +save loffset, pic; +numeric loffset; +picture pic; + loffset := labeloffset; + labeloffset := 0bp; + pic := thelabel.urt(textext(s), origin); + labeloffset := loffset; + pic +enddef; + + +%%% Internal working macro. +%%% Set text from picture variable along a path with justification j. +%%% Parameters: +%%% * a picture that contains the text that has to be transformed onto a path, +%%% * a path p the text should follow, +%%% * a numeric variable that controls justification, +%%% * a string: "debug" indicates debug mode. +%%% Return value: +%%% * a picture variable containing text following a path. +vardef textpathPic(expr textpic, p, j, debug)= +save tb, db, pic, item, bitem, banker, k, i, lenp, lenpic, bx, cx, ltextpathHSpace; +numeric tb, db, k, i, lenp, lenpic, ltextpathHSpace, bx, cx; +picture pic, item, bitem; +pair banker; + pic := nullpicture; + lenp := arclength(p); + lenpic := 0; + k := 0; + for item within textpic: + if textual item: + bitem := item shifted (-k*textpathSoulLetterSpace, 0bp) shifted (k*textpathLetterSpace, 0bp); + x := xpart lrcorner bitem; + if x > lenpic: + lenpic := x; + fi + k := k + 1; + fi + endfor + if textpathStretch=1: + ltextpathHSpace := lenp/textpathRepeat - lenpic; + else: + ltextpathHSpace := textpathHSpace; + fi + k := 0; + for item within textpic: + if textual item: + bitem := item shifted (-k*textpathSoulLetterSpace, 0bp) shifted (k*textpathLetterSpace, textpathShift); + banker := (xpart center bitem, ypart item); + if textpathStretch=1: + bx := (xpart banker) + j*ltextpathHSpace; + else: + bx := (xpart banker) + j*(lenp - textpathRepeat*lenpic - (textpathRepeat-1)*ltextpathHSpace); + fi + bitem := bitem shifted -banker; + for i:= 1 upto textpathRepeat: + cx := (i-1)*(lenpic + ltextpathHSpace) + bx; + if (textpathClip=0) or ((cx>=0) and (cx<=lenp)): + tb := arctime cx of p; + if textpathAbsRotation=0: + db := textpathRotation + angle direction tb of p; + else: + db := textpathRotation; + fi + if not (debug="debug"): + addto pic also bitem rotated db shifted point tb of p; + else: + addto pic contour fullcircle scaled 2bp shifted point tb of p; + fi + fi + endfor + k := k + 1; + else: + show "Warning! Unsupported picture element found!"; + fi + endfor + pic +enddef; + + + +%%% Internal working macro. +%%% Set text from picture variable along a path with justification j. +%%% Parameters: +%%% * a picture that contains the text that has to be transformed onto a path, +%%% * a path p the text should follow, +%%% * a numeric variable that controls justification, +%%% * a string: "debug" indicates debug mode. +%%% Return value: +%%% * a picture variable containing text following a path. +vardef textpathPicRaw(expr textpic, p, j, debug)= +save tb, db, pic, item, bitem, banker, i, lenp, lenpic, bx, cx, ltextpathHSpace, pp, np, dpp; +numeric tb, db, dpp, i, h, lenp, lenpic, ltextpathHSpace, bx, cx; +picture pic, item, bitem; +pair banker; +path pp, np; + show textpic; + pic := nullpicture; + lenp := arclength(p); + lenpic := xpart (lrcorner textpic - llcorner textpic); + if textpathStretch=1: + ltextpathHSpace := lenp/textpathRepeat - lenpic; + else: + ltextpathHSpace := textpathHSpace; + fi + for item within textpic: + if textual item: +% show "t=" & textpart item & " ASCII=" & decimal ASCII textpart item & " font=" & fontpart item; + bitem := item shifted (0, textpathShift); + banker := (xpart center bitem, 30bp); + if textpathStretch=1: + bx := (xpart banker) + j*ltextpathHSpace; + else: + bx := (xpart banker) + j*(lenp - textpathRepeat*lenpic - (textpathRepeat-1)*ltextpathHSpace); + fi + bitem := bitem shifted -banker; + for i:=1 upto textpathRepeat: + cx := (i-1)*(lenpic + ltextpathHSpace) + bx; + if (textpathClip=0) or ((cx>=0) and (cx<=lenp)): + tb := arctime cx of p; + if textpathAbsRotation=0: + db := textpathRotation + angle direction tb of p; + else: + db := textpathRotation; + fi + addto pic also bitem rotated db shifted point tb of p; + fi + endfor + if ((fontpart item="cmex10") and ((ASCII textpart item>=112) and (ASCII textpart item<=116))) or + ((fontpart item="cmsy5") and (ASCII textpart item=112)) or + ((fontpart item="cmsy6") and (ASCII textpart item=112)) or + ((fontpart item="cmsy7") and (ASCII textpart item=112)) or + ((fontpart item="cmsy8") and (ASCII textpart item=112)) or + ((fontpart item="cmsy9") and (ASCII textpart item=112)) or + ((fontpart item="cmsy10") and (ASCII textpart item=112)) or + ((fontpart item="cmbsy10") and (ASCII textpart item=112)) or + ((fontpart item="fourier-mex") and (ASCII textpart item=114)) or + ((fontpart item="fourier-ms") and (ASCII textpart item=112)) or + ((fontpart item="MnSymbolE5") and (ASCII textpart item=186)) or + ((fontpart item="MnSymbolE5") and (ASCII textpart item=189)) or + ((fontpart item="MnSymbolE10") and (ASCII textpart item=186)): + textpathHookCoord := urcorner item shifted (-xpart center item, -30bp + textpathShift); + textpathHookRot := db; + textpathHookPoint := point tb of p; +% addto pic contour fullcircle scaled 2bp shifted textpathHookCoord rotated db shifted point tb of p withcolor green; + else: + textpathHookCoord := origin; + fi + elseif stroked item: + if textpathFancyStrokes=0: + bitem := item shifted (0, textpathShift); + banker := (xpart center bitem, 30bp); + if textpathStretch=1: + bx := (xpart banker) + j*ltextpathHSpace; + else: + bx := (xpart banker) + j*(lenp - textpathRepeat*lenpic - (textpathRepeat-1)*ltextpathHSpace); + fi + bitem := bitem shifted -banker; + for i:=1 upto textpathRepeat: + cx := (i-1)*(lenpic + ltextpathHSpace) + bx; + if (textpathClip=0) or ((cx>=0) and (cx<=lenp)): + tb := arctime cx of p; + if textpathAbsRotation=0: + db := textpathRotation + angle direction tb of p; + else: + db := textpathRotation; + fi + addto pic also bitem rotated db shifted point tb of p; + fi + endfor + else: + pp := pathpart item; + for i=1 upto textpathRepeat: + if (textpathHookCoord=origin) or (textpathCureSqrt=0): + banker := (0, ypart point 0 of pp - 30bp + textpathShift); + if textpathStretch=1: + bx := (xpart point 0 of pp) + j*ltextpathHSpace; + else: + bx := (xpart point 0 of pp) + j*(lenp - textpathRepeat*lenpic - (textpathRepeat-1)*ltextpathHSpace); + fi + dpp := angle direction 0 of pp; + cx := (i-1)*(lenpic + ltextpathHSpace) + bx; + tb := arctime cx of p; + if textpathAbsRotation=0: + db := textpathRotation + angle direction tb of p; + else: + db := textpathRotation; + fi + np := banker rotated db shifted point tb of p%{dir (dpp+db)} + elseif textpathCureSqrt=1: + np := textpathHookCoord shifted (dir(-90)*xpart point 0 of makepath penpart item); + np := np rotated textpathHookRot shifted textpathHookPoint%{dir textpathHookRot} + fi + for h:=1 upto textpathStrokePrecision: + hide( + banker := (0, ypart point (h/textpathStrokePrecision) of pp - 30bp + textpathShift); + if textpathStretch=1: + bx := (xpart point (h/textpathStrokePrecision) of pp) + j*ltextpathHSpace; + else: + bx := (xpart point (h/textpathStrokePrecision) of pp) + j*(lenp - textpathRepeat*lenpic - (textpathRepeat-1)*ltextpathHSpace); + fi + cx := (i-1)*(lenpic + ltextpathHSpace) + bx; + dpp := angle direction (h/textpathStrokePrecision) of pp; + tb := arctime cx of p; + if textpathAbsRotation=0: + db := textpathRotation + angle direction tb of p; + else: + db := textpathRotation; + fi + ) + ..banker rotated db shifted point tb of p%{dir (dpp+db)} + endfor; + addto pic doublepath np withpen penpart item; + endfor + fi + else: + show "Warning! Unsupported picture element found!"; + fi + endfor + pic +enddef; diff --git a/Master/texmf-dist/tex/latex/textpath/textpathmp.sty b/Master/texmf-dist/tex/latex/textpath/textpathmp.sty new file mode 100644 index 00000000000..1dc4d52008a --- /dev/null +++ b/Master/texmf-dist/tex/latex/textpath/textpathmp.sty @@ -0,0 +1,14 @@ +%%% Support package for the textpath.mp package for MetaPost. +%%% This package provides the \spaced command that is used +%%% by textpath and has to be inserted in your LaTeX preamble. +\RequirePackage{soul} +\newlength{\textpath@inter} +\newlength{\textpath@inner} +\newcommand*{\spaced}[2][]{% + #1% + \setlength{\textpath@inter}{10bp}% + \settowidth{\textpath@inner}{\ }% + \addtolength{\textpath@inner}{\textpath@inter}% + \sodef\textpath@spacedText{}{\textpath@inter}{\textpath@inner}{2\textpath@inner}% + \textpath@spacedText{#2}% +} diff --git a/Master/texmf-dist/tpm/textpath.tpm b/Master/texmf-dist/tpm/textpath.tpm new file mode 100644 index 00000000000..aa137ffb398 --- /dev/null +++ b/Master/texmf-dist/tpm/textpath.tpm @@ -0,0 +1,29 @@ +<!DOCTYPE rdf:RDF SYSTEM "../../support/tpm.dtd"> +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:TPM="http://texlive.dante.de/"> + <rdf:Description about="http://texlive.dante.de/texlive/Package/textpath.zip"> + <TPM:Name>textpath</TPM:Name> + <TPM:Type>Package</TPM:Type> + <TPM:Date>2006/12/07 23:36:00</TPM:Date> + <TPM:Version></TPM:Version> + <TPM:Creator>karl</TPM:Creator> + <TPM:Title>The textpath package.</TPM:Title> + <TPM:Description></TPM:Description> + <TPM:Author></TPM:Author> + <TPM:Size>285519</TPM:Size> + <TPM:Build/> + <TPM:RunFiles size="14786"> +texmf-dist/metapost/textpath/textpath.mp +texmf-dist/tex/latex/textpath/textpathmp.sty +texmf-dist/tpm/textpath.tpm + </TPM:RunFiles> + <TPM:DocFiles size="271817"> +texmf-dist/doc/metapost/textpath/README +texmf-dist/doc/metapost/textpath/textpath.pdf +texmf-dist/doc/metapost/textpath/textpath.tex +texmf-dist/doc/metapost/textpath/textpathfigs.mp +texmf-dist/doc/metapost/textpath/textpathfigs.tex + </TPM:DocFiles> + <TPM:Provides>Package/textpath</TPM:Provides> + </rdf:Description> +</rdf:RDF> + diff --git a/Master/texmf/lists/textpath b/Master/texmf/lists/textpath new file mode 100644 index 00000000000..5c69e866f2d --- /dev/null +++ b/Master/texmf/lists/textpath @@ -0,0 +1,11 @@ +texmf-dist/doc/metapost/textpath/README +texmf-dist/doc/metapost/textpath/textpath.pdf +texmf-dist/doc/metapost/textpath/textpath.tex +texmf-dist/doc/metapost/textpath/textpathfigs.mp +texmf-dist/doc/metapost/textpath/textpathfigs.tex + +texmf-dist/metapost/textpath/textpath.mp +texmf-dist/tex/latex/textpath/textpathmp.sty +texmf-dist/tpm/textpath.tpm + +texmf/lists/textpath diff --git a/Master/texmf/tpm/collection-metapost.tpm b/Master/texmf/tpm/collection-metapost.tpm index 2082575185a..5f463a1bd4a 100644 --- a/Master/texmf/tpm/collection-metapost.tpm +++ b/Master/texmf/tpm/collection-metapost.tpm @@ -33,6 +33,7 @@ <TPM:Package name="roex"/> <TPM:Package name="slideshow"/> <TPM:Package name="splines"/> + <TPM:Package name="textpath"/> <TPM:TLCore name="bin-metapost"/> <TPM:TLCore name="collection-basic"/> </TPM:Requires> |