[metapost] Stroke Font
Laurent Méhats
laurent.mehats at gmail.com
Sat May 16 23:13:52 CEST 2015
Le 16/05/2015 22:25, Troy Henderson a écrit :
> string str,ss[];
> str:="Here is my sentence";
> for i=1 upto length str: ss[i]:=substring(i-1,i) of str;
> p[i]:=ss[i] infont defaultfont; s[i]:=pathpart p[i]; endfor
> draw pathpart glyph ss1 of defaultfont scaled .01;
>
>
> Thank you very much for the advice. I would appreciate any help in doing
> this for the Arev Bold font included in TeXLive.
>
> Troy
Hello,
Here is an attempt that goes the way you describe.
Regards,
Laurent Méhats
--%<-- test.mp
verbatimtex%&latex
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{arev}
\begin{document}
etex;
vardef init (suffix glp_num, pth_num, glp_pth) expr pct=
% pct btex .. etex material
% glp_num number of glyphs within pct
% pth_num[i] number of paths defining the rank i glyph
% (i ranges from 0 to glp_num-1)
% glp_pth[i][j] rank j path of the rank i glyph
% (j ranges from 0 pth_num[i]-1)
string fnt_str, txt_str, sub_str;
numeric txt_wd;
glp_num:=0;
for tkn within pct:
if textual tkn:
fnt_str:=fontpart tkn;
txt_str:=textpart tkn;
txt_wd:=0;
for glp_idx=0 upto (length txt_str-1):
sub_str:=substring (glp_idx, glp_idx+1) of txt_str;
pth_num[glp_num]:=0;
for sub_tkn within glyph ASCII sub_str of fnt_str
scaled (fontsize fnt_str/1000)
xscaled xxpart tkn
yscaled yypart tkn
shifted (txt_wd+xpart tkn, ypart tkn):
glp_pth[glp_num][pth_num[glp_num]]:=pathpart sub_tkn;
pth_num[glp_num]:=pth_num[glp_num]+1;
endfor
glp_num:=glp_num+1;
txt_wd:=txt_wd+
(xxpart tkn)*xpart urcorner (sub_str infont fnt_str);
endfor
fi
endfor
enddef;
picture pct; % btex .. etex material
color fll_clr, % fill color
bkg_clr, % background color
oln_clr; % outlines color
numeric oln_thk; % outlines thickness
pct:=btex{\textbf{The quick brown fox jumps over the lazy dog.}}etex;
fll_clr:=green;
bkg_clr:=white;
oln_clr:=red;
oln_thk:=.5;
beginfig(0)
numeric glp_num, pth_num[];
path glp_pth[][];
init (glp_num, pth_num, glp_pth) pct;
for i=0 upto glp_num-1:
for j=0 upto pth_num[i]-1:
fill glp_pth[i][j] withcolor
if turningnumber glp_pth[i][j]=1: fll_clr else: bkg_clr fi;
draw glp_pth[i][j] withpen pencircle scaled oln_thk withcolor oln_clr;
endfor
endfor
endfig;
end
--%<-- test.mp
--
Laurent Méhats
More information about the metapost
mailing list