summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mp-core.mp11
-rw-r--r--metapost/context/base/mp-spec.mp153
-rw-r--r--metapost/context/base/mp-text.mp321
-rw-r--r--metapost/context/base/mp-tool.mp22
4 files changed, 335 insertions, 172 deletions
diff --git a/metapost/context/base/mp-core.mp b/metapost/context/base/mp-core.mp
index 51d2d0025..b905d85ce 100644
--- a/metapost/context/base/mp-core.mp
+++ b/metapost/context/base/mp-core.mp
@@ -520,11 +520,12 @@ par_hang_after := ra + estimated_par_lines(py-fy) ;
if (par_hang_indent>0) and (par_hang_after<0) and obey_multi_par_hang :
pair _ul_ ; _ul_ := (xpart ulcorner multipar, ypart snapped_multi_pos(ulxy[fpos]));
pair _pa_ ; _pa_ := _ul_ shifted (0,par_hang_after*par_line_height) ;
- _pa_ := (xpart _pa_,max(ypart _pa_,ypart llcorner multipar)) ;
+% _pa_ := (xpart _pa_,max(ypart _pa_,ypart llcorner multipar)) ;
+ _pa_ := (xpart _pa_,max(ypart _pa_ -TopSkipCorrection,ypart llcorner multipar)) ;
if same_area :
- _pa_ := (xpart _pa_,max(ypart _pa_,ypart llxy[tpos])) ;
+% _pa_ := (xpart _pa_,max(ypart _pa_,ypart llxy[tpos])) ;
+ _pa_ := (xpart _pa_,max(ypart _pa_ -TopSkipCorrection,ypart llxy[tpos])) ;
fi ;
-% vervalt:
if obey_multi_par_more and (round(par_line_height)>0) :
par_hang_after := min(0,round(par_hang_after +
(ypart urxy[fpos]-ypart _pa_)/par_line_height)) ;
@@ -539,7 +540,8 @@ par_hang_after := ra + estimated_par_lines(py-fy) ;
vardef right_top_hang (expr same_area) =
-par_hang_after := ra - estimated_par_lines(py-fy) ;
+% par_hang_after := ra - estimated_par_lines(py-fy) ;
+par_hang_after := ra + estimated_par_lines(py-fy) ;
if (par_hang_indent<0) and (par_hang_after<0) and obey_multi_par_hang :
pair _ur_ ; _ur_ := (xpart urcorner multipar, ypart snapped_multi_pos(urxy[fpos])) ;
@@ -1240,6 +1242,7 @@ vardef PrepareSyncTasks(expr n, collapse, extendtop, prestartnext) =
NOfSyncPaths := NOfSyncPaths + 1 ;
if not ok :
if i>1 :
+% not yet correct when two of teh same follow each other
if sync_t[n][i-1] = sync_t[n][i] :
SyncPaths[NOfSyncPaths] := SyncBox(n, i, SyncLeftOffset, SyncWidth, PaperHeight, -PaperHeight) ;
SyncTasks[NOfSyncPaths] := i ;
diff --git a/metapost/context/base/mp-spec.mp b/metapost/context/base/mp-spec.mp
index b005eb381..ceff7fe90 100644
--- a/metapost/context/base/mp-spec.mp
+++ b/metapost/context/base/mp-spec.mp
@@ -414,34 +414,106 @@ resetspotcolors ; boolean spotcolors ; spotcolors := false ; % true
string spotcolorpattern[] ; % needed for transparancies
+% vardef spotcolor(expr p, s) =
+% if spotcolors :
+% save ok, pc_tag ; boolean ok ; string pc_tag ;
+% pc_tag := "_pct_"&p ;
+% if not unstringed(pc_tag) :
+% _spotcolor_number_ := _spotcolor_number_ + 1 ;
+% setunstringed(pc_tag,_spotcolor_number_) ;
+% fi ;
+% pp := getunstringed(pc_tag) ;
+% if unknown spotcolorhash[pp][s] :
+% ok := false ; % not yet defined
+% elseif spotcolorhash[pp][s] = -1 :
+% ok := false ; % locally defined and undefined
+% else :
+% ok := true ; % globally already defined
+% fi ;
+% if not ok :
+% save ss ; string ss ; ss := p & " " & decimal s ;
+% _spotcolor_counter_ := _spotcolor_counter_ + 1 ;
+% spotcolorpattern[_spotcolor_counter_/1000] := ss ;
+% spotcolorhash[pp][s] := _spotcolor_counter_ ;
+% flush_special(2, 5, decimal _spotcolor_counter_ & " " & ss) ;
+% _local_specials_ := _local_specials_ &
+% "spotcolorhash["&decimal pp&"]["&decimal s&"]:=-1;" ;
+% fi ;
+% (_special_signal_/1000,2/1000,spotcolorhash[pp][s]/1000)
+% else :
+% (1-s,1-s,1-s)
+% fi
+% enddef ;
+
+% vardef spotcolor(expr p, s) =
+% if spotcolors :
+% save ok, pc_tag ; boolean ok ; string pc_tag ;
+% pc_tag := "_pct_"&p ;
+% if not unstringed(pc_tag) :
+% _spotcolor_number_ := _spotcolor_number_ + 1 ;
+% setunstringed(pc_tag,_spotcolor_number_) ;
+% fi ;
+% pp := getunstringed(pc_tag) ;
+% if unknown spotcolorhash[pp][s] :
+% ok := false ; % not yet defined
+% elseif spotcolorhash[pp][s] = -1 :
+% ok := false ; % locally defined and undefined
+% else :
+% ok := true ; % globally already defined
+% fi ;
+% if not ok :
+% save ss ; string ss ; ss := p & " " & decimal s ;
+% _spotcolor_counter_ := _spotcolor_counter_ + 1 ;
+% spotcolorpattern[_spotcolor_counter_/1000] := ss ;
+% spotcolorhash[pp][s] := _spotcolor_counter_ ;
+% flush_special(2, 5, decimal _spotcolor_counter_ & " " & ss) ;
+% _local_specials_ := _local_specials_ &
+% "spotcolorhash["&decimal pp&"]["&decimal s&"]:=-1;" ;
+% fi ;
+% (_special_signal_/1000,2/1000,spotcolorhash[pp][s]/1000)
+% else :
+% (1-s,1-s,1-s)
+% fi
+% enddef ;
+
vardef spotcolor(expr p, s) =
+ multitonecolor(p, 1, "", decimal s)
+enddef ;
+
+vardef multitonecolor(expr n, f, d, p) = % name fractions names factors
if spotcolors :
save ok, pc_tag ; boolean ok ; string pc_tag ;
- pc_tag := "_pct_"&p ;
+ pc_tag := "_pct_" & n ;
if not unstringed(pc_tag) :
_spotcolor_number_ := _spotcolor_number_ + 1 ;
setunstringed(pc_tag,_spotcolor_number_) ;
fi ;
pp := getunstringed(pc_tag) ;
- if unknown spotcolorhash[pp][s] :
+ pc_tag := "_pct_"& decimal f & "_" & if d = "" : n else : d fi & "_" & p ; % check for d empty
+ if not unstringed(pc_tag) :
+ _spotcolor_number_ := _spotcolor_number_ + 1 ;
+ setunstringed(pc_tag,_spotcolor_number_) ;
+ fi ;
+ ps := getunstringed(pc_tag) ;
+ if unknown spotcolorhash[pp][ps] :
ok := false ; % not yet defined
- elseif spotcolorhash[pp][s] = -1 :
+ elseif spotcolorhash[pp][ps] = -1 :
ok := false ; % locally defined and undefined
else :
ok := true ; % globally already defined
fi ;
if not ok :
- save ss ; string ss ; ss := p & " " & decimal s ;
+ save ss ; string ss ; ss := n & " " & decimal f & " " & if d = "" : n else : d fi & " " & p ;
_spotcolor_counter_ := _spotcolor_counter_ + 1 ;
spotcolorpattern[_spotcolor_counter_/1000] := ss ;
- spotcolorhash[pp][s] := _spotcolor_counter_ ;
- flush_special(2, 5, decimal _spotcolor_counter_ & " " & ss) ;
+ spotcolorhash[pp][ps] := _spotcolor_counter_ ;
+ flush_special(2, 7, decimal _spotcolor_counter_ & " " & ss) ;
_local_specials_ := _local_specials_ &
- "spotcolorhash["&decimal pp&"]["&decimal s&"]:=-1;" ;
+ "spotcolorhash["&decimal pp&"]["&decimal ps&"]:=-1;" ;
fi ;
- (_special_signal_/1000,2/1000,spotcolorhash[pp][s]/1000)
+ (_special_signal_/1000,2/1000,spotcolorhash[pp][ps]/1000)
else :
- (1-s,1-s,1-s)
+ .5white
fi
enddef ;
@@ -459,6 +531,63 @@ differencetransparent := 11 ; exclusiontransparent := 12 ;
% fill fullcircle scaled 10cm withcolor transparant(.8,3,color) ;
+% vardef transparent(expr n, t, c) =
+% save s, ss, nn, cc, is_cmyk, is_spot, ok ;
+% string s, ss ; numeric nn ; color cc ; boolean is_cmyk, is_spot, ok ;
+% % transparancy type
+% if string n :
+% if expandafter known scantokens(n&"transparent") :
+% nn := scantokens(n&"transparent") ;
+% else :
+% nn := 0 ;
+% fi
+% else : % nn := min(n,13)
+% nn := if n<13 : n else : nn := 0 fi ;
+% fi ;
+% % we need to expand the color (can be cmyk(..) or predefined)
+% cc := c ; % expand color
+% % check for cmyk special
+% is_cmyk := (redpart cc = _special_signal_/1000)
+% and (greenpart cc = 1/1000) ;
+% is_spot := (redpart cc = _special_signal_/1000)
+% and (greenpart cc = 2/1000) ;
+% % build special string, fetch cmyk components
+% s := decimal nn & " " & decimal t & " " &
+% if is_cmyk : cmykcolorpattern[bluepart cc]
+% elseif is_spot : spotcolorpattern[bluepart cc]
+% else : dddecimal cc fi ;
+% % check if this one is already used
+% ss := "tr_" & s ;
+% % efficiency hack
+% if expandafter unknown scantokens(ss) :
+% ok := false ; % not yet defined
+% elseif scantokens(ss) < 0 :
+% ok := false ; % locally defined and undefined
+% else :
+% ok := true ; % globally already defined
+% fi ;
+% if not ok :
+% if is_spot :
+% flush_special(5, 6, s) ;
+% elseif is_cmyk :
+% flush_special(4, 8, s) ;
+% else :
+% flush_special(3, 7, s) ;
+% fi ;
+% scantokens(ss) := _special_counter_ ;
+% _local_specials_ := _local_specials_ &
+% "scantokens(" & ditto & ss & ditto & ") := -1 ;" ;
+% fi ;
+% % go ahead
+% if is_spot :
+% (_special_signal_/1000,5/1000,scantokens(ss)/1000)
+% elseif is_cmyk :
+% (_special_signal_/1000,4/1000,scantokens(ss)/1000)
+% else :
+% (_special_signal_/1000,3/1000,scantokens(ss)/1000)
+% fi
+% enddef ;
+
vardef transparent(expr n, t, c) =
save s, ss, nn, cc, is_cmyk, is_spot, ok ;
string s, ss ; numeric nn ; color cc ; boolean is_cmyk, is_spot, ok ;
@@ -485,7 +614,9 @@ vardef transparent(expr n, t, c) =
elseif is_spot : spotcolorpattern[bluepart cc]
else : dddecimal cc fi ;
% check if this one is already used
- ss := "tr_" & s ;
+% ss := "tr_" & s ;
+% ss := cleanstring(ss) ;
+ ss := cleanstring("tr_" & s) ;
% efficiency hack
if expandafter unknown scantokens(ss) :
ok := false ; % not yet defined
@@ -496,7 +627,7 @@ vardef transparent(expr n, t, c) =
fi ;
if not ok :
if is_spot :
- flush_special(5, 6, s) ;
+ flush_special(5, 8, s) ;
elseif is_cmyk :
flush_special(4, 8, s) ;
else :
diff --git a/metapost/context/base/mp-text.mp b/metapost/context/base/mp-text.mp
index cb6bb3895..2e061df09 100644
--- a/metapost/context/base/mp-text.mp
+++ b/metapost/context/base/mp-text.mp
@@ -2,165 +2,182 @@
%D [ file=mp-text.mp,
%D version=2000.07.10,
%D title=\CONTEXT\ \METAPOST\ graphics,
-%D subtitle=text support,
+%D subtitle=text support,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
-%C details.
+%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
+%C details.
%D Under construction.
-if unknown context_tool : input mp-tool ; fi ;
-if known context_text : endinput ; fi ;
+if unknown context_tool : input mp-tool ; fi ;
+if known context_text : endinput ; fi ;
-boolean context_text ; context_text := true ;
+boolean context_text ; context_text := true ;
-if unknown noftexpictures :
- numeric noftexpictures ; noftexpictures := 0 ;
-fi ;
+if unknown noftexpictures :
+ numeric noftexpictures ; noftexpictures := 0 ;
+fi ;
-if unknown texpictures[1] :
- picture texpictures[] ;
-fi ;
+if unknown texpictures[1] :
+ picture texpictures[] ;
+fi ;
-numeric textextoffset ; textextoffset := 0 ;
+numeric textextoffset ; textextoffset := 0 ;
-% vardef textext@#(expr txt) =
-% interim labeloffset := textextoffset ;
-% noftexpictures := noftexpictures + 1 ;
-% if string txt :
-% write "% figure " & decimal charcode & " : " &
-% "texpictures[" & decimal noftexpictures & "] := btex " &
-% txt & " etex ;" to jobname & ".mpt" ;
-% if unknown texpictures[noftexpictures] :
-% thelabel@#("unknown",origin)
+% vardef textext@#(expr txt) =
+% interim labeloffset := textextoffset ;
+% noftexpictures := noftexpictures + 1 ;
+% if string txt :
+% write "% figure " & decimal charcode & " : " &
+% "texpictures[" & decimal noftexpictures & "] := btex " &
+% txt & " etex ;" to jobname & ".mpt" ;
+% if unknown texpictures[noftexpictures] :
+% thelabel@#("unknown",origin)
% else :
-% thelabel@#(texpictures[noftexpictures],origin)
-% fi
+% thelabel@#(texpictures[noftexpictures],origin)
+% fi
% else :
-% thelabel@#(txt,origin)
-% fi
-% enddef ;
-
-boolean hobbiestextext ; hobbiestextext := false ;
-
-vardef textext@#(expr txt) =
- interim labeloffset := textextoffset ;
- noftexpictures := noftexpictures + 1 ;
- if string txt :
+% thelabel@#(txt,origin)
+% fi
+% enddef ;
+
+boolean hobbiestextext ; hobbiestextext := false ;
+% string textextstring ; textextstring := "" ;
+
+% def resettextextdirective =
+% textextstring := "" ;
+% enddef ;
+
+% def textextdirective text t =
+% textextstring := textextstring & t ;
+% enddef ;
+
+vardef textext@#(expr txt) =
+ save _s_ ; string _s_ ;
+ interim labeloffset := textextoffset ;
+ noftexpictures := noftexpictures + 1 ;
+ if string txt :
+% if textextstring <> "" :
+% _s_ := "verbatimtex " & textextstring & " etex ;" ;
+% else :
+% _s_ := "" ;
+% fi ;
if hobbiestextext : % the tex.mp method as fallback (see tex.mp)
- write "btex " & txt & " etex" to "mptextmp.mp" ;
+% write _s_ to "mptextmp.mp" ;
+ write _s_ & "btex " & txt & " etex" to "mptextmp.mp" ;
write EOF to "mptextmp.mp" ;
scantokens "input mptextmp"
else :
- write "% figure " & decimal charcode & " : " &
- "texpictures[" & decimal noftexpictures & "] := btex " &
- txt & " etex ;" to jobname & ".mpt" ;
- if unknown texpictures[noftexpictures] :
- thelabel@#("unknown",origin)
+% write "% setup : " & _s_ to jobname & ".mpt" ;
+ write "% figure " & decimal charcode & " : " &
+ "texpictures[" & decimal noftexpictures & "] := btex " &
+ txt & " etex ;" to jobname & ".mpt" ;
+ if unknown texpictures[noftexpictures] :
+ thelabel@#("unknown",origin)
else :
- thelabel@#(texpictures[noftexpictures],origin)
+ thelabel@#(texpictures[noftexpictures],origin)
fi
- fi
+ fi
else :
- thelabel@#(txt,origin)
- fi
-enddef ;
-
-string laboff_ ; laboff_ := "" ;
-string laboff_c ; laboff_c := "" ;
-string laboff_l ; laboff_l := ".lft" ;
-string laboff_r ; laboff_r := ".rt" ;
-string laboff_b ; laboff_b := ".bot" ;
-string laboff_t ; laboff_t := ".top" ;
-string laboff_lt ; laboff_lt := ".ulft" ;
-string laboff_rt ; laboff_rt := ".urt" ;
-string laboff_lb ; laboff_lb := ".llft" ;
-string laboff_rb ; laboff_rb := ".lrt" ;
-string laboff_tl ; laboff_tl := ".ulft" ;
-string laboff_tr ; laboff_tr := ".urt" ;
-string laboff_bl ; laboff_bl := ".llft" ;
-string laboff_br ; laboff_br := ".lrt" ;
-
-vardef textextstr(expr s, a) =
- save ss ; string ss ;
- ss := "laboff_" & a ;
- ss := scantokens ss ;
+ thelabel@#(txt,origin)
+ fi
+enddef ;
+
+string laboff_ ; laboff_ := "" ;
+string laboff_c ; laboff_c := "" ;
+string laboff_l ; laboff_l := ".lft" ;
+string laboff_r ; laboff_r := ".rt" ;
+string laboff_b ; laboff_b := ".bot" ;
+string laboff_t ; laboff_t := ".top" ;
+string laboff_lt ; laboff_lt := ".ulft" ;
+string laboff_rt ; laboff_rt := ".urt" ;
+string laboff_lb ; laboff_lb := ".llft" ;
+string laboff_rb ; laboff_rb := ".lrt" ;
+string laboff_tl ; laboff_tl := ".ulft" ;
+string laboff_tr ; laboff_tr := ".urt" ;
+string laboff_bl ; laboff_bl := ".llft" ;
+string laboff_br ; laboff_br := ".lrt" ;
+
+vardef textextstr(expr s, a) =
+ save ss ; string ss ;
+ ss := "laboff_" & a ;
+ ss := scantokens ss ;
ss := "textext" & ss & "(" & ditto & s & ditto & ")" ;
- scantokens ss
-enddef ;
+ scantokens ss
+enddef ;
-pair laboff.origin ; laboff.origin = (infinity,infinity) ;
-pair laboff.raw ; laboff.raw = (infinity,infinity) ;
+pair laboff.origin ; laboff.origin = (infinity,infinity) ;
+pair laboff.raw ; laboff.raw = (infinity,infinity) ;
-vardef thelabel@#(expr s, z) =
+vardef thelabel@#(expr s, z) =
save p ; picture p ;
p = s if not picture s : infont defaultfont scaled defaultscale fi ;
- if laboff@#<>laboff.origin :
- (p shifted (z + labeloffset*laboff@# - (labxf@#*lrcorner p +
+ if laboff@#<>laboff.origin :
+ (p shifted (z + labeloffset*laboff@# - (labxf@#*lrcorner p +
labyf@#*ulcorner p + (1-labxf@#-labyf@#)*llcorner p)))
else :
(p shifted z)
fi
enddef;
-def build_parshape (expr p, offset_or_path, dx, dy,
+def build_parshape (expr p, offset_or_path, dx, dy,
baselineskip, strutheight, strutdepth, topskip) =
-
- if unknown trace_parshape :
- boolean trace_parshape ; trace_parshape := false ;
+
+ if unknown trace_parshape :
+ boolean trace_parshape ; trace_parshape := false ;
fi ;
begingroup ;
- save q, l, r, line, tt, bb,
- n, hsize, vsize, vvsize, voffset, hoffset, width, indent,
- ll, lll, rr, rrr, cp, cq, t, b ;
+ save q, l, r, line, tt, bb,
+ n, hsize, vsize, vvsize, voffset, hoffset, width, indent,
+ ll, lll, rr, rrr, cp, cq, t, b ;
- path q, l, r, line, tt, bb ;
+ path q, l, r, line, tt, bb ;
numeric n, hsize, vsize, vvsize, voffset, hoffset, width[], indent[] ;
- pair ll, lll, rr, rrr, cp, cq, t, b ;
+ pair ll, lll, rr, rrr, cp, cq, t, b ;
- n := 0 ; cp := center p ;
+ n := 0 ; cp := center p ;
- if path offset_or_path :
- q := offset_or_path ; cq := center q ;
- voffset := dy ;
- hoffset := dx ;
- else :
- q := p ; cq := center q ;
+ if path offset_or_path :
+ q := offset_or_path ; cq := center q ;
+ voffset := dy ;
+ hoffset := dx ;
+ else :
+ q := p ; cq := center q ;
hoffset := offset_or_path + dx ;
- voffset := offset_or_path + dy ;
- fi ;
+ voffset := offset_or_path + dy ;
+ fi ;
- hsize := xpart lrcorner q - xpart llcorner q ;
- vsize := ypart urcorner q - ypart lrcorner q ;
+ hsize := xpart lrcorner q - xpart llcorner q ;
+ vsize := ypart urcorner q - ypart lrcorner q ;
- q := p shifted - cp ;
+ q := p shifted - cp ;
- startsavingdata ;
+ startsavingdata ;
- savedata "\global\parvoffset " & decimal voffset&"bp " ;
- savedata "\global\parhoffset " & decimal hoffset&"bp " ;
- savedata "\global\parwidth " & decimal hsize&"bp " ;
- savedata "\global\parheight " & decimal vsize&"bp " ;
+ savedata "\global\parvoffset " & decimal voffset&"bp " ;
+ savedata "\global\parhoffset " & decimal hoffset&"bp " ;
+ savedata "\global\parwidth " & decimal hsize&"bp " ;
+ savedata "\global\parheight " & decimal vsize&"bp " ;
- if not path offset_or_path :
- q := q xscaled ((hsize-2hoffset)/hsize)
- yscaled ((vsize-2voffset)/vsize) ;
- fi ;
+ if not path offset_or_path :
+ q := q xscaled ((hsize-2hoffset)/hsize)
+ yscaled ((vsize-2voffset)/vsize) ;
+ fi ;
- hsize := xpart lrcorner q - xpart llcorner q ;
- vsize := ypart urcorner q - ypart lrcorner q ;
+ hsize := xpart lrcorner q - xpart llcorner q ;
+ vsize := ypart urcorner q - ypart lrcorner q ;
- t := (ulcorner q -- urcorner q) intersection_point q ;
- b := (llcorner q -- lrcorner q) intersection_point q ;
+ t := (ulcorner q -- urcorner q) intersection_point q ;
+ b := (llcorner q -- lrcorner q) intersection_point q ;
- if xpart directionpoint t of q < 0 :
- q := reverse q ;
+ if xpart directionpoint t of q < 0 :
+ q := reverse q ;
fi ;
l := q cutbefore t ;
@@ -169,82 +186,82 @@ def build_parshape (expr p, offset_or_path, dx, dy,
r := q cutbefore b ;
r := r if xpart point 0 of q > 0 : & q fi cutafter t ;
-% tt := (ulcorner q -- urcorner q) shifted (0,-topskip) ;
-% bb := (llcorner q -- lrcorner q) shifted (0,strutdepth) ;
+% tt := (ulcorner q -- urcorner q) shifted (0,-topskip) ;
+% bb := (llcorner q -- lrcorner q) shifted (0,strutdepth) ;
%
-% l := l cutbefore (l intersection_point tt) ;
-% l := l cutafter (l intersection_point bb) ;
-% r := r cutbefore (r intersection_point bb) ;
-% r := r cutafter (r intersection_point tt) ;
+% l := l cutbefore (l intersection_point tt) ;
+% l := l cutafter (l intersection_point bb) ;
+% r := r cutbefore (r intersection_point bb) ;
+% r := r cutafter (r intersection_point tt) ;
- if trace_parshape :
+ if trace_parshape :
drawarrow p withpen pencircle scaled 2pt withcolor red ;
drawarrow l shifted cp withpen pencircle scaled 1pt withcolor green ;
drawarrow r shifted cp withpen pencircle scaled 1pt withcolor blue ;
- fi ;
+ fi ;
- vardef found_point (expr lin, pat, sig) =
+ vardef found_point (expr lin, pat, sig) =
pair a, b ;
a := pat intersection_point (lin shifted (0,strutheight)) ;
- if intersection_found :
+ if intersection_found :
a := a shifted (0,-strutheight) ;
else :
a := pat intersection_point lin ;
fi ;
b := pat intersection_point (lin shifted (0,-strutdepth)) ;
- if intersection_found :
- if sig :
- if xpart b > xpart a : a := b shifted (0,strutdepth) fi ;
- else :
- if xpart b < xpart a : a := b shifted (0,strutdepth) fi ;
- fi ;
- fi ;
- a
+ if intersection_found :
+ if sig :
+ if xpart b > xpart a : a := b shifted (0,strutdepth) fi ;
+ else :
+ if xpart b < xpart a : a := b shifted (0,strutdepth) fi ;
+ fi ;
+ fi ;
+ a
enddef ;
- if (strutheight+strutdepth<baselineskip) :
- vvsize := vsize ;
- else :
- vvsize := (vsize div baselineskip) * baselineskip ;
- fi ;
+ if (strutheight+strutdepth<baselineskip) :
+ vvsize := vsize ;
+ else :
+ vvsize := (vsize div baselineskip) * baselineskip ;
+ fi ;
- for i=topskip step baselineskip until vvsize :
+ for i=topskip step baselineskip until vvsize :
- line := (ulcorner q -- urcorner q) shifted (0,-i-eps) ;
+ line := (ulcorner q -- urcorner q) shifted (0,-i-eps) ;
ll := found_point(line,l,true ) ;
rr := found_point(line,r,false) ;
- if trace_parshape :
- fill (ll--rr--rr shifted (0,strutheight)--ll
+ if trace_parshape :
+ fill (ll--rr--rr shifted (0,strutheight)--ll
shifted (0,strutheight)--cycle) shifted cp withcolor .5white ;
- fill (ll--rr--rr shifted (0,-strutdepth)--ll
+ fill (ll--rr--rr shifted (0,-strutdepth)--ll
shifted (0,-strutdepth)--cycle) shifted cp withcolor .7white ;
- draw ll shifted cp withpen pencircle scaled 2pt ;
- draw rr shifted cp withpen pencircle scaled 2pt ;
+ draw ll shifted cp withpen pencircle scaled 2pt ;
+ draw rr shifted cp withpen pencircle scaled 2pt ;
draw (ll--rr) shifted cp withpen pencircle scaled .5pt ;
- fi ;
+ fi ;
- n := n + 1 ;
+ n := n + 1 ;
indent[n] := abs(xpart ll - xpart llcorner q) ;
width[n] := abs(xpart rr - xpart ll) ;
- if (i=strutheight) and (width[n]<baselineskip) :
- n := n - 1 ;
- savedata "\global\chardef\parfirst=1 " ;
+ if (i=strutheight) and (width[n]<baselineskip) :
+ n := n - 1 ;
+ savedata "\global\chardef\parfirst=1 " ;
fi ;
- endfor ;
+ endfor ;
- savedata "\global\parlines " & decimal n ;
- savedata "\global\partoks{ " ;
- for i=1 upto n:
- savedata decimal indent[i]&"bp " & decimal width[i]&"bp " ;
- endfor ;
+ savedata "\global\parlines " & decimal n ;
+ savedata "\global\partoks{ " ;
+ for i=1 upto n:
+ savedata decimal indent[i]&"bp " & decimal width[i]&"bp " ;
+ endfor ;
savedata "}" ;
-
- stopsavingdata ;
+
+ stopsavingdata ;
endgroup ;
-enddef ;
+enddef ;
diff --git a/metapost/context/base/mp-tool.mp b/metapost/context/base/mp-tool.mp
index 3064cf239..0db4a3f47 100644
--- a/metapost/context/base/mp-tool.mp
+++ b/metapost/context/base/mp-tool.mp
@@ -1981,12 +1981,20 @@ vardef dodostraightened(expr sign, p) =
fi
enddef ;
+% vardef simplified expr p =
+% dostraightened(+1,p)
+% enddef ;
+
+% vardef unspiked expr p =
+% dostraightened(-1,p)
+% enddef ;
+
vardef simplified expr p =
- dostraightened(+1,p)
+ (reverse dostraightened(+1,dostraightened(+1,reverse p)))
enddef ;
vardef unspiked expr p =
- dostraightened(-1,p)
+ (reverse dostraightened(-1,dostraightened(-1,reverse p)))
enddef ;
% path p ;
@@ -2124,9 +2132,13 @@ enddef ;
string _clean_ascii[] ;
-_clean_ascii[ASCII "-"] := "_" ;
-_clean_ascii[ASCII ":"] := "_" ;
-_clean_ascii[ASCII "."] := "_" ;
+def register_dirty_chars(expr str) =
+ for i = 0 upto length(str)-1 :
+ _clean_ascii[ASCII substring(i,i+1) of str] := "_" ;
+ endfor ;
+enddef ;
+
+register_dirty_chars("+-*/:;.,") ;
vardef cleanstring (expr s) =
save ss ; string ss, si ; ss = "" ;