[NTG-pdftex] Colored text, was [ pdftex-Bugs-389 ] Spacing Bug with \pdfliteral direct

Hartmut Henkel hartmut_henkel at gmx.de
Fri Jul 15 21:25:22 CEST 2005


On Fri, 15 Jul 2005 noreply at sarovar.org wrote:

> Comment By: Martin Schröder (oneiros)
> Date: 2005-07-15 15:25
>
> Message:
> Logged In: YES
> user_id=421
>
> This has been fixed in 1.30.0

Thanks a lot, Martin! Let's hope that it's ok. The change also can
affect the PDF file size where lots of \pdfliterals are used for color
change. E. g. if in pdfcolor.tex (used by pdfwebmac.tex) the \pdfliteral
is changed to its direct version, the pdfetex.pdf file made from the
pdfetex.web/.ch sources is smaller by about 8% iirc, while looking
similar.

Also the following font coloring seems to work more efficiently; the
recipe is an update from an E-Mail to texhax at 29 Feb 2004:

Start from cmr10.tfm, put this into some working directory. Then:

$ tftopl cmr10.tfm > cmr10.pl
$ cp cmr10.pl cmrcolor10.vpl

Now in the file cmrcolor10.vpl change

  (FAMILY CMR)
into
  (FAMILY CMRCOLOR)

and just before the 1st line

  (CHARACTER O 0

in cmrcolor10.vpl add a line

(MAPFONT D 0 (FONTNAME cmr10))

so that the cmrcolor10.vpl references cmr10.tfm as real font.

Then do

$ vptovf cmrcolor10.vpl

which creates
  cmrcolor10.tfm
  cmrcolor10.vf

Then do

$vftovp cmrcolor10.vf > cmrcolor10.vpl

which re-creates
   cmrcolor10.vpl

Now you have reached the first goal: A cmrcolor10.vpl file ready for
your tweaking. Then you can add funny pdfTeX specials e. g. by some awk
script:

$ export LANG="C" ; awk -f addspecial.awk cmrcolor10.vpl > temp
$ mv temp cmrcolor10.vpl

where the addspecial.awk looks like:

#begin of addspecial.awk
/SETCHAR/{
  r = 0.6 * rand();
  g = 0.6 * rand();
  b = 0.6 * rand();
  printf("      (SPECIAL pdf:direct: %.3f %.3f %.3f rg)\n", r, g, b);
  print $0;
  printf("      (SPECIAL pdf:direct: 0 0 0 rg)\n");
  next;
}

//{print}
#end of addspecial.awk

Then do a final

$ vptovf cmrcolor10.vpl

This creates the working versions
  cmrcolor10.tfm
  cmrcolor10.vf

Now you can call the colored font by pdftex e. g. from the following
tex file:

\pdfcompresslevel=0
\font\cmrcolor cmrcolor10 at 10pt
\cmrcolor
\input tufte
\bye

BTW, don't try to use \ptexuniformdeviate in the special. It's not
expanded at this late time; else one would get a completely randomly
colored font...

Have fun!

Regards, Hartmut


More information about the ntg-pdftex mailing list