lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tex strings output


From: Werner LEMBERG
Subject: Re: tex strings output
Date: Sun, 26 Dec 2004 16:56:10 +0100 (CET)

> I've put the first component of TeX generated text metrics in place
> [...]
>
> as you can see, I used a lispish format for now.  The format is :
>
>   (FONT-NAME MAGNIFICATION TEXT)

After some investigation I found out that you have to do ugly hacks to
convert a Lisp string to a TeX argument.  The main reason is that
after reading an input line the catcodes in TeX are fixed and can't be
changed again.  I had to use an auxiliary file to write the converted
strings, then reading them again -- etex has a new operator to avoid
that but we can't assume that etex is used everywhere...

> If you can define a standard format for TeX input, write macros for
> dimension handling, and provide a TeX output like
>
>   (FONT-NAME MAGNIFICATION TEXT BBOX-LIST)

For the same reasons, it is not possible to repeat the input argument
in the output without using an auxiliary file.  I thus decided to use
the following input format which isn't lispish any more but which
should be easy to generate:

  \input{lilymetrics}

  \documentclass{article}
  \begin{document}

  \lilymetricsfile{lily-output.lpm}
  \lilyglobalscale{1.75729901757299}

  \lilygetmetrics{1}{ecrm10}{1.569055118110236}{%
  \begin{minipage}[b]{240pt}
  Engraved by LilyPond (version 2.5.4)

  \noindent
  This is a test with another paragraph.
  \end{minipage}}
  \lilygetmetrics{2}{ecrm10}{0.569055118110236}{1}
  \lilygetmetrics{3}{ecrm10}{0.569055118110236}{}
  \lilygetmetrics{4}{ecrm10}{0.569055118110236}{foo}
  \end{document}

As can be seen, even paragraphs can be handled.

The output format looks like this:

  (1 . (240 96.10254 5.35951))
  (2 . (4.99878 6.4151 0))
  (3 . (0 0 0))
  (4 . (13.33008 6.8872 0))

Below is `lilymetrics.tex', which works with both TeX and LaTeX.
Please test and comment.


      Werner


======================================================================

%
% lilymetrics.tex
%
\catcode address@hidden

address@hidden
address@hidden
address@hidden
address@hidden

\def\lilyglobalscale#1{%
  address@hidden #1pt
}

\def\lilymetricsfile#1{%
  address@hidden #1\relax
}

\begingroup
  \catcode `P=12
  \catcode `T=12
  \lowercase{%
    \def\x{%
      address@hidden
        ##1\ifnum ##2 > \z@ .##2\fi
      }%
    }%
  }
\expandafter\endgroup\x

address@hidden
  address@hidden
}

\long\def\lilygetmetrics#1#2#3#4{%
  address@hidden address@hidden
  % convert pt to 1000*sp (1000/65536)
  address@hidden address@hidden
  address@hidden = #2 scaled address@hidden
  address@hidden
    address@hidden
    #4%
  }%
  address@hidden@metricsbox}%
  address@hidden@metricsbox}%
  address@hidden@metricsbox}%
  address@hidden
    (#1 . (address@hidden@wd
           address@hidden@ht
           address@hidden@dp))%
  }%
}

\catcode address@hidden

\endinput




reply via email to

[Prev in Thread] Current Thread [Next in Thread]