[metapost] "3D" Metafont fonts with GNU 3DLDF

Laurence Finston lfinsto1 at gwdg.de
Tue Jan 11 17:44:35 CET 2005


Hello,

Some months ago I wrote about the possibility of using GNU 3DLDF to
generate "3D" Metafont fonts.  I have now produced my first sample,
so anyone who's interested may have a look at it:

http://www.gnu.org/software/3dldf/cdsmpls.html#Globe%20font

The code used to generate it is fairly compact, so I include
it below.  I haven't automated the process of converting the
MP code written by 3DLDF to MF, because I plan to make
it possible for the former to write MF code directly.

Laurence Finston
http://www.gnu.org/software/3dldf/LDF.html

****************************************************************

%%%% Copyright (C) 2003, 2004, 2005 The Free Software Foundation

(GNU General Public License)

%% Globe font.  `beginfig' needs to be changed to `beginchar',
%% and arguments have to be added, e.g., `beginfig(0);' must be changed to
%% `beginchar(0, 10pt#,10pt#,10pt#);'.  `endfig' must also be changed to
%% `endchar'.
%% This code appears at the beginning of the Metafont file:

%% mag := 10;
%% mode=ljfour;
%% mode_setup;

%% displaying:=-1;

circle c[];

division_value := 32;
one_quarter_division_value := 1/4division_value;
three_quarters_division_value := 3/4division_value;

set c0 with_point_count division_value;
scale c0 (8pt, 0, 8pt);
rotate c0 by 90;

point p;
path q[];

q[division_value] += get_point 0 c0;

pen thick_pen;

thick_pen := pencircle scaled (2.5, 2.5, 2.5);

pickup thick_pen;


step_value := 360 / division_value;
j := 1;
for i = 0 step step_value until 360 - step_value:
   rotate c0 (0, step_value);
   if (is_even j):
      draw c0;
   fi;
   for k = 2 step 2 until one_quarter_division_value - 2:
      q[k] += get_point (k) c0;
      q[three_quarters_division_value + k]
         += get_point (three_quarters_division_value + k) c0;
   endfor;
   q[division_value] += get_point 0 c0;
   j += 1;
endfor;

q[division_value] += cycle;
q[division_value] += ..;
draw q[division_value];

for i = 2 step 2 until one_quarter_division_value - 2:
      q[i] += ..;
      q[i] += cycle;
      q[three_quarters_division_value + i] += ..;
      q[three_quarters_division_value + i] += cycle;
      draw q[i];
      draw q[three_quarters_division_value + i];
endfor;

picture p;
p := current_picture;

n := 0;


for i = 0 step 1 until 15:
   if i > 0:
      rotate p by 30;
   fi;
   for j = 0 step 1 until 15:
      if j > 0:
         rotate p (0, 30);
      fi
      beginfig(n);
         output p;
      endfig;
      n += 1;
   endfor;
endfor;
end;





More information about the metapost mailing list