Tobias Columbus | 16 Oct 23:44 2014

Filling complex paths

Hi all,

I am currently writing a piece of software that should spit out some MetaPost
code. My input are the closed curves of a glyph and I want to produce MetaPost
code that fills them according to Postscript rules. However, as MetaPost cannot
handle non-contiguous closed paths, this task seems difficult at least. 

Note that the glyphs come from non-Postscript fonts, so that the MetaPost
"glyph" primitive does not work for me. I also tried "graphictext" as described
in the Metafun manual but that turned out to be too inaccurate. I traced the
inaccuracy back to "pstoedit", which is called for "graphictext".

My attempt was to fiddle around with specials and
withprescript/withpostscript.  This attempt turned out to be nonsense as
addto always writes "stroke" or "fill" and my specials were ignored. I
could, of course, write the whole glyph with specials, but I would
prefer a cleaner solution.

Has anybody some experience with this kind of problem? How difficult
would it be to add filling of non-contiguous paths to MetaPost?

Thank you in advance,

Vafa Khalighi | 9 Sep 07:09 2014

"Improper transformation argument" Error

I have a metafont source file that has the following code:

  my_T := currenttransform;
  currenttransform := identity slanted my_slant;
  currentpicture := nullpicture;
  picture joined_fit_plus_pic;
  pickup pensquare;
  x1=x2=-2mag;  x3=x4=2mag+kashida_width;
  y1=y4=0;  y2=y3=horiz_width;
 fill (z1--z2--z3--z4--cycle) withweight 1;
  joined_fit_plus_pic := currentpicture;
  currenttransform := my_T;

when I run metafont on this, it runs smoothly without any problems.
but when I use mfplain format of metapost, I get the following error:

>> currenttransform.withweight1
! Improper transformation argument.
<to be read again>
l.61  fill (z1--z2--z3--z4--cycle) withweight 1;


What is wrong? and how do I fix this? If required, I can provide the
full source.
(Continue reading)

Akira Kakuto | 8 Sep 01:32 2014

Processing metafont sources with metapost

s/a final error/final errors/



Vafa Khalighi | 7 Sep 11:20 2014

Processing metafont sources with metapost


I am designing a new font from scratch and I write metafont sources
and then compile them with metapost to generate the svg of each glyph.
To explain my issue, I will use as an example here.

I have a file that contains:

outputtemplate := "%j-%c.svg";
outputformat := "svg";

and I process with mpost&mfplain

As expected for each glyph a svg will be generated; however I get a
warning about bad RGBcolor. Furthermore the glyph will be in gray
color instead black. There is also a grid and some dots, and labels
(numbers) which I do not want. How this can be fixed?

I have attached letter G and the view I got from inkscape.

Toby Thurston | 1 Sep 16:25 2014

Bug with "odd" primitive?

The "odd" primitive appears to return "false" for all negative numbers.  This behaviour is significantly
different from Metafont. 
Can we get it corrected?  Or at least documented?  Thanks Toby

Test program:

    show(odd -3); end

result with Metafont:

    This is METAFONT, Version 2.7182818 (TeX Live 2014) (preloaded base=mf)
    >> true )  
    Transcript written on test.log.

result with Metapost

    This is MetaPost, version 1.902 (TeX Live 2014) (kpathsea version 6.2.0)
    Preloading the plain mem file, version 1.005) ) (./
    >> false )
    Transcript written on test.log.

Thanks T.

France Dacar | 20 Aug 17:15 2014

Troubles rendeting text in PNG output

Hello there.

I am using MetaPost version 1.803 (mpost in MiKTeX 2.9).
I searched the Web, and in particular the MetaPost site, but could not find
the answer to my problem. The following test file


outputformat := "png";
outputtemplate := "%j-%c.%o";

label(btex $(hs,f(s)t)$ etex, (0,0));
label(btex abracadabra etex, (0,-20));


produces the expected result, though it spews out 20 warnings like

     Warning: invalid entry for `pkol0': unknown name `store' ignored

(Continue reading)

Walt Burkhard | 18 Aug 21:04 2014

quick question


Does the current mpost 1.902 from texlive run with "large" integer/double
values?    I am using  something on the order of   97*360  within
the sind and cosd functions.    

If not, what command line option do I need.

Many thanks in advance.

Walt Burkhard
Vadim Radionov | 15 Jul 18:03 2014

dependencies bug

Dear all, 

My colleague found a bug in Metapost 1.803 which I would lile to report.  In the following minimal example, showdependencies shows something inappropriate, which gives "This can't happen (dep)" error later.  But if I move the third s-relation after setting z[4,6,8], everything works fine.


def s(expr A,B,C,D)=
D-C=B-A=((B-D) rotated 90)



z4 = (0,0);
z6 = (1cm,0);
z8 = (0,1cm);

Hartmut Henkel | 14 May 23:29 2014

Experiment: Bézier Arc Length Calculation by Elliptic Integrals


i have done a bit of spare time experimenting with Bézier arc length
calculation, particularly trying out elliptic integrals. You can find a
write-up here:

Regards, Hartmut
Hartmut Henkel | 13 May 23:00 2014

metapost 1.999 Semicolon Weirdness


the following program runs fine with MetaPost Version 1.999:

  path p;
  z1 = (0.000000,0.000000);
z2 = (10.000000,0.000000);
z3 = (10.000000,10.000000);
z4 = (0.000000,0.000000);
p := z1 .. controls z2 and z3 .. z4;
  pickup pencircle scaled 0.050000;  drawdot z1 withcolor red;
  drawdot z2 withcolor red;
  drawdot z3 withcolor red;
  drawdot z4 withcolor red;
  pickup pencircle scaled 0.010000   draw (z1--z2--z3--z4) withcolor red;
  draw p;
  currentpicture := currentpicture scaled 10;

Now i wonder why, since by accident there is no semicolon in line 14
between "pickup pencircle scaled 0.010000" and "draw (z1--z2...".
Shouldn't this give an error?

Regards, Hartmut


Samuel Bronson | 22 Apr 01:38 2014

decimal: The impossible/a segfault happened

Package: texlive-metapost
Version: 2013.20140314-1
Severity: normal

Dear Implementors,

I've discovered a way to get either:
  1. a "! This can't happen (token)." error (MetaPost 1.803 from Debian)
  2. a segfault (MetaPost ~1.999 from SVN r2007)

[Note: I've abused debian-bug.el to include some information on package
version numbers.]

Unfortunately, most of the stuff I tried trimming out of my input makes
both go away; the former disappears if I so much as use "tracingall".

Here's the input file:

Attachment ( text/x-metapost, 2760 bytes

and here's what happens when I run it ...

... under MetaPost 1.803:

% mpost -numbersystem=decimal
This is MetaPost, version 1.803 (kpathsea version 6.1.1)
Preloading the plain base, version 0.99: preliminaries,
 basic constants and mathematical macros,
 macros for converting units,
 macros and tables for various modes of operation,
 macros for drawing and filling,
 macros for proof labels and rules,
 macros for character and font administration,
and a few last-minute items.) (./
Dangerous bend sign
! This can't happen (token).
<for( BAD)> ...el(str(SUFFIX0),z(SUFFIX0)); ENDFOR

l.74 labels(38)
Transcript written on decimal-fail.log.

... under MetaPost 1.999 (under GDB) and poke around a bit:

% gdb --args ../metapost/build/texk/web2c/mpost -numbersystem=decimal
GNU gdb (GDB) 7.6.1 (Debian 7.6.1-1)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from /home/naesten/hacking/texmf/metapost/build/texk/web2c/mpost...done.
(gdb) run
Starting program: /home/naesten/hacking/texmf/dbend/../metapost/build/texk/web2c/mpost
warning: Could not load shared library symbols for
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/i686/cmov/".
This is MetaPost, version 1.999 (TeX Live 2014/dev) (kpathsea version 6.1.1)
Preloading the plain base, version 0.99: preliminaries,
 basic constants and mathematical macros,
 macros for converting units,
 macros and tables for various modes of operation,
 macros for drawing and filling,
 macros for proof labels and rules,
 macros for character and font administration,
and a few last-minute items.) (./
Dangerous bend sign
Program received signal SIGSEGV, Segmentation fault.
__GI___libc_free (mem=0x10000) at malloc.c:2891
2891    malloc.c: No such file or directory.
(gdb) bt
#0  __GI___libc_free (mem=0x10000) at malloc.c:2891
#1  0x080c3eb2 in mp_free_number (mp=0x82c6788, n=0xbfffef5c)
    at ../../../source/texk/web2c/mplibdir/mpmathdecimal.w:618
#2  0x080d395a in mp_gr_choose_scale (mp=mp <at> entry=0x82c6788, p=p <at> entry=0x8e75858)
    at ../../../source/texk/web2c/mplibdir/psout.w:6004
#3  0x080dc819 in mp_gr_ship_out (hh=hh <at> entry=0x8e74a78, qprologues=0, qprocset=qprocset <at> entry=0,
    standalone=standalone <at> entry=0) at ../../../source/texk/web2c/mplibdir/psout.w:6141
#4  0x0809598c in mp_shipout_backend (mp=0x82c6788, voidh=0x8daab00)
    at ../../../source/texk/web2c/mplibdir/mp.w:34121
#5  0x080b4dea in mp_ship_out (h=0x8daab00, mp=0x82c6788)
    at ../../../source/texk/web2c/mplibdir/mp.w:34095
#6  mp_do_ship_out (mp=0x82c6788) at ../../../source/texk/web2c/mplibdir/mp.w:31244
#7  mp_do_statement (mp=mp <at> entry=0x82c6788) at ../../../source/texk/web2c/mplibdir/mp.w:28473
#8  0x080b64c7 in mp_scan_primary (mp=mp <at> entry=0x82c6788)
    at ../../../source/texk/web2c/mplibdir/mp.w:22642
#9  0x080b8d67 in mp_scan_secondary (mp=mp <at> entry=0x82c6788)
    at ../../../source/texk/web2c/mplibdir/mp.w:23444
#10 0x080b8e67 in mp_scan_tertiary (mp=mp <at> entry=0x82c6788)
    at ../../../source/texk/web2c/mplibdir/mp.w:23500
#11 0x080a20df in mp_scan_expression (mp=mp <at> entry=0x82c6788)
    at ../../../source/texk/web2c/mplibdir/mp.w:23544
#12 0x080b31f9 in mp_do_statement (mp=mp <at> entry=0x82c6788)
    at ../../../source/texk/web2c/mplibdir/mp.w:28383
#13 0x080bdcc5 in mp_main_control (mp=<optimized out>)
    at ../../../source/texk/web2c/mplibdir/mp.w:29239
#14 mp_run (mp=mp <at> entry=0x82c6788) at ../../../source/texk/web2c/mplibdir/mp.w:29259
#15 0x0804b401 in main (argc=3, argv=0xbffff9f4)
    at ../../../source/texk/web2c/mplibdir/mpost.w:1385
(gdb) up
#1  0x080c3eb2 in mp_free_number (mp=0x82c6788, n=0xbfffef5c)
    at ../../../source/texk/web2c/mplibdir/mpmathdecimal.w:618
618       free(n->data.num);
(gdb) print *n
$1 = {data = {num = 0x10000, dval = 1.1670980088217614e-312, val = 65536}, type = mp_scaled_type}

So, um, it seems to be trying to use the code in mpmathdecimal.w to free
a plain-old "scaled" number, for some reason ...

After this, I did some more poking around with valgrind vgdb only to
discover that I could have just typed "up" and gotten nearly as much
information, at least if I knew what free_number(ret) meant -- which is
to say, I found out that this mp_free_number() has been passed a pointer
to mp_gr_choose_scale()'s local variable "ret" in frame #2.

-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 3.11-2-686-pae (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages texlive-metapost depends on:
ii  dpkg              1.17.5
ii  tex-common        4.04
ii  texlive-base      2013.20140314-1
ii  texlive-binaries  2013.20130729.30972-2+b2


Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!