diff options
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mp-grap.mpiv | 216 | ||||
-rw-r--r-- | metapost/context/base/mp-mlib.mpiv | 54 | ||||
-rw-r--r-- | metapost/context/base/mp-tool.mpiv | 5 | ||||
-rw-r--r-- | metapost/context/fonts/bidi-symbols.mp | 73 | ||||
-rw-r--r-- | metapost/context/fonts/punkfont-bold.mp | 4 | ||||
-rw-r--r-- | metapost/context/fonts/punkfont-boldslanted.mp | 5 | ||||
-rw-r--r-- | metapost/context/fonts/punkfont-characters.mp | 726 | ||||
-rw-r--r-- | metapost/context/fonts/punkfont-definitions.mp | 115 | ||||
-rw-r--r-- | metapost/context/fonts/punkfont-slanted.mp | 4 | ||||
-rw-r--r-- | metapost/context/fonts/punkfont.mp | 2 |
10 files changed, 1164 insertions, 40 deletions
diff --git a/metapost/context/base/mp-grap.mpiv b/metapost/context/base/mp-grap.mpiv index a7115fc7a..64e63b90c 100644 --- a/metapost/context/base/mp-grap.mpiv +++ b/metapost/context/base/mp-grap.mpiv @@ -11,8 +11,6 @@ %C therefore copyrighted by \PRAGMA. See licen-en.pdf for %C details. -% laboff -> mfun_laboff or use plain_label instead - if known context_grap : endinput ; fi ; boolean context_grap ; context_grap := true ; @@ -43,6 +41,7 @@ fi % OUT loc value for labels relative to whole graph % gdata(file,s,text) read coords from file ; evaluate t w/ tokens s[] % auto.<x or y> default x or y tick locations (for interation) +% tick.<bot|top|..>(fmt,u) draw centered tick from given side at u w/ format % itick.<bot|top|..>(fmt,u) draw inward tick from given side at u w/ format % otick.<bot|top|..>(fmt,u) draw outward tick at coord u ; label format fmt % grid.<bot|top|..>(fmt,u) draw grid line at u with given side labeled @@ -135,7 +134,7 @@ enddef ; vardef graph_error(expr x,s) = interim showstopping :=0 ; - show x ; errmessage s; + show x ; errmessage s ; enddef ; %%%%%%%%%%%%%%%%%%%%%%%% Data structures, begingraph %%%%%%%%%%%%%%%%%%%%%%%% @@ -170,8 +169,12 @@ def begingraph(expr w, h) = save graph_last_drawn ; picture graph_last_drawn ; % result of last gdraw or gfill graph_last_drawn = nullpicture ; + save graph_last_path ; + path graph_last_path ; % last gdraw or gfill path in data coordinates. save graph_plot_picture ; picture graph_plot_picture ; % a picture from the `plot' option known when plot allowed + save graph_foreground ; + color graph_foreground ; % drawing color, if set. save graph_label ; picture graph_label[] ; % labels to place around the whole graph when it is done save graph_autogrid_needed ; @@ -356,7 +359,7 @@ vardef graph_set_bounds@#(expr l, h) = graph_clear_bounds@# ; if @#graph_coordinate_type>0 : @#low = if unknown l : - whatever + whatever else : if abs @#graph_coordinate_type=log : graph_mlog fi if string l : scantokens fi l fi ; @@ -366,7 +369,7 @@ vardef graph_set_bounds@#(expr l, h) = if abs @#graph_coordinate_type=log : graph_mlog fi if string h : scantokens fi h fi ; else : - -@#high = if unknown l : + -@#high = if unknown l : whatever else : if abs @#graph_coordinate_type=log : graph_mlog fi if string l : scantokens fi l @@ -500,7 +503,7 @@ enddef ; vardef augment@#(text t) = interim warningcheck := 0 ; if not path begingroup @# endgroup : - Gerr(begingroup @# endgroup, "Cannot augment--not a path") ; + graph_error(begingroup @# endgroup, "Cannot augment--not a path") ; else : def graph_comma= hide(def graph_comma=,enddef) enddef ; if known @# : @# :=@#-- else : @#= fi @@ -517,6 +520,7 @@ enddef ; % Unknown pair components are set to 0 because glabel and gdotlabel understand % unknown coordinates as `0 in absolute units'. vardef graph_unknown_pair_bbox(expr p) = + interim warningcheck:=0 ; if known p : addto graph_current_bb doublepath p ; else : save x,y ; @@ -528,19 +532,24 @@ vardef graph_unknown_pair_bbox(expr p) = graph_current_bb := image(fill llcorner graph_current_bb..urcorner graph_current_bb--cycle) ; enddef ; - % Initiate a gdraw or gfill command. This must be done before scanning the % argument, because that could invoke the `if known graph_plot_picture' test in a following % plot option . def graph_addto = + def graph_errorbar_text = enddef ; + color graph_foreground ; + path graph_last_path ; graph_last_drawn := graph_plot_picture := nullpicture ; addto graph_last_drawn enddef; % Handle the part of a Gdraw command that uses path or data file p. def graph_draw expr p = - if string p : graph_convert_user_path_to_internal graph_readpath(p) - elseif path p or pair p : graph_convert_user_path_to_internal p + if string p : hide(graph_last_path := graph_readpath(p) ;) + graph_convert_user_path_to_internal graph_last_path + elseif path p or pair p : + hide(graph_last_path := p ;) + graph_convert_user_path_to_internal p else : graph_error(p,"gdraw argument should be a data file or a path") origin fi @@ -550,8 +559,10 @@ enddef ; % Handle the part of a Gdraw command that uses path or data file p. def graph_fill expr p = - if string p : graph_convert_user_path_to_internal graph_readpath(p) --cycle - elseif cycle p : graph_convert_user_path_to_internal p + if string p : hide(graph_last_path := graph_readpath(p) --cycle ;) + graph_convert_user_path_to_internal graph_last_path + elseif cycle p : hide(graph_last_path := p ;) + graph_convert_user_path_to_internal p else : graph_error(p,"gfill argument should be a data file or a cyclic path") origin..cycle fi graph_withlist _op_ @@ -564,6 +575,74 @@ def gfill = graph_addto contour graph_fill enddef ; % This is used in graph_draw and graph_fill to allow postprocessing graph_last_drawn def graph_withlist text t_ = t_ ; graph_post_draw; enddef; +def witherrorbars(text t) text options = + hide( + def graph_errorbar_text = t enddef ; + save pic ; picture pic ; pic := image(draw origin _op_ options ;) ; + if color colorpart pic : graph_foreground := colorpart pic ; fi + ) + options +enddef ; + +picture graph_errorbar_picture ; graph_errorbar_picture := image(draw (left--right) scaled .5 ;) ; +%picture graph_xbar_picture ; graph_xbar_picture := image(draw (down--up) scaled .5 ;) ; +%picture graph_ybar_picture ; graph_ybar_picture := image(draw (left--right) scaled .5 ;) ; + +vardef graph_errorbars(text t) = + if known graph_last_path : + save n, p, q ; path p ; pair q ; + save pic ; picture pic[] ; pic0 := nullpicture ; + pic1 := if known graph_xbar_picture : graph_xbar_picture + elseif known graph_errorbar_picture : graph_errorbar_picture rotated 90 + else : nullpicture fi ; + pic2 := if known graph_ybar_picture : graph_ybar_picture + elseif known graph_errorbar_picture : graph_errorbar_picture + else : nullpicture fi ; + if length pic1>0 : + pic1 := pic1 scaled graph_shapesize ; + setbounds pic1 to origin..cycle ; + fi + if length pic2>0 : + pic2 := pic2 scaled graph_shapesize ; + setbounds pic2 to origin..cycle ; + fi + for i=0 upto length graph_last_path : + clearxy ; z = point i of graph_last_path ; + n := 1 ; + for $=t : + if known $ : + q := if path $ : if length $>i : point i of $ else : origin fi + elseif pair $ : $ elseif numeric $ : ($,$) else : origin fi ; + if q<>origin : + p := graph_convert_user_path_to_internal (( + if n=1 : + (-xpart q,0)--(ypart q,0) + else : + (0,-xpart q)--(0,ypart q) + fi ) shifted z) ; + addto pic0 doublepath p ; + if length pic[n]>0 : + if ypart q<>0 : + addto pic0 also pic[n] shifted point 1 of p ; + fi + if xpart q<>0 : + addto pic0 also pic[n] rotated 180 shifted point 0 of p ; + fi + fi + fi + fi + exitif incr n>3 ; + endfor + endfor + if length pic0>0 : + save bg, fg ; color bg, fg ; + bg := if known graph_background : graph_background else : background fi ; + fg := if known graph_foreground : graph_foreground else : black fi ; + addto graph_current_graph also pic0 withpen currentpen scaled 2 _op_ withcolor bg ; + addto graph_current_graph also pic0 withpen currentpen scaled .5 _op_ withcolor fg ; + fi + fi +enddef ; % Set graph_plot_picture so the postprocessing step will plot picture p at each path knot. % Also select nullpen to suppress stroking. @@ -596,6 +675,7 @@ vardef graph_post_draw = if filled graph_last_drawn or not graph_is_null(penpart graph_last_drawn) : addto graph_current_graph also graph_last_drawn ; fi + graph_errorbars(graph_errorbar_text) ; if length graph_plot_picture>0 : for i=0 upto length p if cycle p : -1 fi : addto graph_current_graph also graph_plot_picture shifted point i of p ; @@ -644,7 +724,7 @@ enddef ; % Stash the result drawing command c in the graph_label table using with list w and -% an index based on angle laboff$. +% an index based on angle mfun_laboff$. vardef graph_stash_label(suffix $)(text c) text w = graph_label[1.5+angle mfun_laboff$ /90] = image(c(origin) w) ; enddef ; @@ -679,10 +759,13 @@ def OUT = enddef ; % location text for outside labels % Grid lines and tick marks are transformed versions of the templates below. % In the template paths, (0,0) is on the edge of the frame and inward is to % the right. -path Gtemplate.itick, Gtemplate.otick, Gtemplate.grid ; +path Gtemplate.tick, Gtemplate.itick, Gtemplate.otick, Gtemplate.grid ; +Gtemplate.tick = (-3.5bp,0)--(3.5bp,0) ; Gtemplate.itick = origin--(7bp,0) ; Gtemplate.otick = (-7bp,0)--origin ; -Gtemplate.grid = origin--(1,0) ; +Gtemplate.grid = origin--(1,0) ; + +vardef tick@#(expr f,u) text w = graph_tick_label(@#,@,false,f,u,w) ; enddef; vardef itick@#(expr f,u) text w = graph_tick_label(@#,@,false,f,u,w) ; enddef; @@ -1020,7 +1103,7 @@ vardef format(expr f, x) = textext(strfmt(f, x)) enddef ; % unfilled outline, interior filled with different shades of the background. % This allows overlapping points on a plot to be more distinguishable. -vardef graph_shapesize = .33BodyFontSize enddef ; +vardef graph_shapesize = (.33BodyFontSize) enddef ; path graph_shape[] ; % (internal) symbol path @@ -1101,9 +1184,11 @@ def plotsymbol(expr n, f) text t = save bg, fg ; color bg, fg ; bg := if known graph_background : graph_background else : background fi ; save pic ; picture pic ; pic := image(draw origin _op_ t ;) ; - fg := if color colorpart pic : colorpart pic else : black fi ; + if color colorpart pic : graph_foreground := colorpart pic ; fi + fg := if known graph_foreground : graph_foreground else : black fi ; save p ; path p ; p = graph_shape[n] scaled graph_shapesize ; draw p withcolor bg withpen currentpen scaled 2 ; % halo + currentpen := currentpen scaled .5 ; if cycle p : fill p withcolor if known f : @@ -1120,7 +1205,7 @@ def plotsymbol(expr n, f) text t = bg fi ; fi - draw p withpen currentpen _op_ t ; + draw p _op_ t ; ) else : nullpicture @@ -1193,7 +1278,7 @@ enddef ; def makefunctionpath (expr f, t, n) (text func) = (for x=f step ((t-f)/(abs n)) until t : - if x<>f : .. fi + if x<>f : -- fi (x, func) endfor ) enddef ; @@ -1298,9 +1383,9 @@ numeric fit_chi_squared ; vardef polynomial_fit (suffix p, $) (expr n) (text t) = if not path p : - Gerr(p, "Cannot fit--not a path") ; + graph_error(p, "Cannot fit--not a path") ; elseif length p < n : - Gerr(p, "Cannot fit--not enough points") ; + graph_error(p, "Cannot fit--not enough points") ; else : fit_chi_squared := 0 ; % calculate sums of the data @@ -1314,7 +1399,24 @@ vardef polynomial_fit (suffix p, $) (expr n) (text t) = endfor for i=0 upto length p : clearxy ; z = point i of p ; - w := if length(t) > 0 : t else : 1 fi ; % weight + w := 1 ; % weight + if known t : + if numeric t : + w := 1 if t<>0 : /(abs t) fi ; + elseif pair t : + if t<>origin : + w := 1/(abs t) ; + fi + elseif path t : + if length t>= i: + if point i of t<>origin : + w := 1/(abs point i of t) ; + fi + else : + w := 0 ; + fi ; + fi + fi x1 := w ; for j=0 upto 2n : sumx[j] := sumx[j] + x1 ; @@ -1385,13 +1487,29 @@ vardef exponential_function (suffix $) (expr x) = $1*exp($0*x) enddef ; vardef exponential_fit (suffix p, $) (text t) = save a ; numeric a[] ; - save q ; path q ; % fit to the log of the ordinate + save q ; path q[] ; % fit to the log of the ordinate for i=0 upto length p : - if ypart(point i of p)>0 : - augment.q(xpart(point i of p),ln(ypart(point i of p))) ; + clearxy ; z = point i of p ; + if y>0 : + augment.q0(x,ln(y)) ; + augment.q1( + if known t : + if numeric t : (0,ln(t)) + elseif pair t : (xpart t,ln(ypart t)) + elseif path t : + if length t>=i : + hide(z1 = point i of t;) + (x1,ln(y1)) + else : + origin + fi + fi + else : + (0,1) + fi ) ; fi endfor - linear_fit(q,a,t) ; + linear_fit(q0,a,q1) ; save e ; e := exp(sqrt(fit_chi_squared)) ; fit_chi_squared := e * e ; $0 := a1 ; @@ -1406,13 +1524,29 @@ vardef power_law_function (suffix $) (expr x) = $1*(x**$0) enddef ; vardef power_law_fit (suffix p, $) (text t) = save a ; numeric a[] ; - save q ; path q ; % fit to the logs of the abscissae and ordinates + save q ; path q[] ; % fit to the logs of the abscissae and ordinates for i=0 upto length p : - if (xpart(point i of p)>0) and (ypart(point i of p)>0) : - augment.q(ln(xpart(point i of p)),ln(ypart(point i of p))) ; + clearxy ; z = point i of p ; + if (x>0) and (y>0) : + augment.q0(ln(x),ln(y)) ; + augment.q1( + if known t : + if numeric t : (0,ln(t)) + elseif pair t : (ln(xpart t),ln(ypart t)) + elseif path t : + if length t>=i : + hide(z1 = point i of t) + (ln(x1),ln(y1)) + else : + origin + fi + fi + else : + (0,1) + fi ) ; fi endfor - linear_fit(q,a,t) ; + linear_fit(q0,a,q1) ; save e ; e := exp(sqrt(fit_chi_squared)) ; fit_chi_squared := e * e ; $0 := a1 ; @@ -1440,13 +1574,29 @@ enddef ; vardef gaussian_fit (suffix p, $) (text t) = save a ; numeric a[] ; - save q ; path q ; % fit to the log of the ordinate + save q ; path q[] ; % fit to the log of the ordinate for i=0 upto length p : - if ypart(point i of p)>0 : - augment.q(xpart(point i of p), ln(ypart(point i of p))) ; + clearxy ; z = point i of p ; + if y>0 : + augment.q0(x,ln(y)) ; + augment.q1( + if known t : + if numeric t : (0,ln(t)) + elseif pair t : (xpart t,ln(ypart t)) + elseif path t : + if length t>=i : + hide(z1 = point i of t) + (x1,ln(y1)) + else : + origin + fi + fi + else : + (0,1) + fi ) ; fi endfor - polynomial_fit(q,a,2,if t > 0 : ln(t) else : 0 fi) ; + polynomial_fit(q0,a,2,q1) ; save e ; e := exp(sqrt(fit_chi_squared)) ; fit_chi_squared := e * e ; $1 := sqrt(-lntwo/a2) ; diff --git a/metapost/context/base/mp-mlib.mpiv b/metapost/context/base/mp-mlib.mpiv index 1f1146def..088c856a7 100644 --- a/metapost/context/base/mp-mlib.mpiv +++ b/metapost/context/base/mp-mlib.mpiv @@ -781,7 +781,7 @@ enddef ; % passvariable("boolean",false) ; % passvariable("path",fullcircle scaled 1cm) ; -vardef mfun_p_to_s(expr p,i) = +vardef mfun_point_to_string(expr p,i) = decimal xpart (point i of p) & " " & decimal ypart (point i of p) & " " & decimal xpart (precontrol i of p) & " " & @@ -790,14 +790,54 @@ vardef mfun_p_to_s(expr p,i) = decimal ypart (postcontrol i of p) enddef ; +vardef mfun_transform_to_string(expr t) = + decimal xxpart t & " " & % rx + decimal xypart t & " " & % sx + decimal yxpart t & " " & % sy + decimal yypart t & " " & % ry + decimal xpart t & " " & % tx + decimal ypart t % ty +enddef ; + +vardef mfun_numeric_to_string(expr n) = + decimal n +enddef ; + +vardef mfun_pair_to_string(expr p) = + decimal xpart p & " " & + decimal ypart p +enddef ; + +vardef mfun_rbgcolor_to_string(expr c) = + decimal redpart c & " " & + decimal greenpart c & " " & + decimal bluepart c +enddef ; + +vardef mfun_cmykcolor_to_string(expr c) = + decimal cyanpart c & " " & + decimal magentapart c & " " & + decimal yellowpart c & " " & + decimal blackpart c +enddef ; + +vardef mfun_path_to_string(expr p) = + mfun_point_to_string(value,1) for i=2 upto length(value) : & " " & mfun_point_to_string(value,i) endfor +enddef ; + +vardef mfun_boolean_to_string(expr b) = + if value : "true" else : "false" fi +enddef ; + def passvariable(expr key, value) = special - if numeric value : "1:" & key & "=" & decimal value - elseif pair value : "4:" & key & "=" & ddecimal value - elseif rgbcolor value : "5:" & key & "=" & dddecimal value - elseif cmykcolor value : "6:" & key & "=" & ddddecimal value - elseif boolean value : "3:" & key & "=" & if value : "true" else : "false" fi - elseif path value : "7:" & key & "=" & mfun_p_to_s(value,1) for i=2 upto length(value) : & " " & mfun_p_to_s(value,i) endfor + if numeric value : "1:" & key & "=" & mfun_numeric_to_string(value) + elseif pair value : "4:" & key & "=" & mfun_pair_to_string(value) + elseif rgbcolor value : "5:" & key & "=" & mfun_rgbcolor_to_string(value) + elseif cmykcolor value : "6:" & key & "=" & mfun_cmykcolor_to_string(value) + elseif boolean value : "3:" & key & "=" & mfun_boolean_to_string(value) + elseif path value : "7:" & key & "=" & mfun_path_to_string(value) + elseif transform value : "8:" & key & "=" & mfun_transform_to_string(value) else : "2:" & key & "=" & value fi ; enddef ; diff --git a/metapost/context/base/mp-tool.mpiv b/metapost/context/base/mp-tool.mpiv index 1600edd9a..a39219c67 100644 --- a/metapost/context/base/mp-tool.mpiv +++ b/metapost/context/base/mp-tool.mpiv @@ -77,6 +77,11 @@ def stopplaincompatibility = endgroup ; enddef ; +%D More neutral: + +let triplet = rgbcolor ; +let quadruplet = cmykcolor ; + %D Colors: newinternal nocolormodel ; nocolormodel := 1 ; diff --git a/metapost/context/fonts/bidi-symbols.mp b/metapost/context/fonts/bidi-symbols.mp new file mode 100644 index 000000000..640b2b944 --- /dev/null +++ b/metapost/context/fonts/bidi-symbols.mp @@ -0,0 +1,73 @@ +%D \module +%D [ file=bidi-symbols.mp, +%D version=2013.09.06, +%D title=\CONTEXT\ \METAPOST\ graphics, +%D subtitle=demo font, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +passvariable("fontname","bidi-symbols") ; +passvariable("fontversion","1.007") ; + +numeric font_bidi_dp ; font_bidi_dp := -6 ; +numeric font_bidi_wd ; font_bidi_wd := -12 ; + +% beginfig(1) ; % lre +% charcode := 8234 ; charwd := 0 ; charht := 0 ; chardp := 0 ; +% drawarrow (0,0) -- (0,font_bidi_dp) -- (font_bidi_wd,font_bidi_dp) withcolor red ; +% currentpicture := currentpicture scaled charscale ; +% setbounds currentpicture to boundingbox nullpicture ; +% endfig ; +% +% beginfig(2) ; % rle +% charcode := 8235 ; charwd := 0 ; charht := 0 ; chardp := 0 ; +% drawarrow (0,0) -- (0,font_bidi_dp) -- (-font_bidi_wd,font_bidi_dp) withcolor green ; +% currentpicture := currentpicture scaled charscale ; +% setbounds currentpicture to boundingbox nullpicture ; +% endfig ; +% +% beginfig(3) ; % pdf +% charcode := 8236 ; charwd := 0 ; charht := 0 ; chardp := 0 ; +% draw (0,0) -- (0,font_bidi_dp) -- (-font_bidi_wd/2,font_bidi_dp) -- (font_bidi_wd/2,font_bidi_dp) withcolor blue ; +% currentpicture := currentpicture scaled charscale ; +% setbounds currentpicture to boundingbox nullpicture ; +% endfig ; +% +% beginfig(4) ; % lro +% charcode := 8237 ; charwd := 0 ; charht := 0 ; chardp := 0 ; +% drawarrow reverse ((0,0) -- (0,font_bidi_dp) -- (font_bidi_wd,font_bidi_dp)) withcolor red ; +% currentpicture := currentpicture scaled charscale ; +% setbounds currentpicture to boundingbox nullpicture ; +% endfig ; +% +% beginfig(5) ; % rlo +% charcode := 8238 ; charwd := 0 ; charht := 0 ; chardp := 0 ; +% drawarrow reverse ((0,0) -- (0,font_bidi_dp) -- (-font_bidi_wd,font_bidi_dp)) withcolor green ; +% currentpicture := currentpicture scaled charscale ; +% setbounds currentpicture to boundingbox nullpicture ; +% endfig ; + +beginglyph(8234,0,0,0) ; % lre + drawarrow (0,0) -- (0,font_bidi_dp) -- (font_bidi_wd,font_bidi_dp) withcolor red ; +endglyph ; + +beginglyph(8235,0,0,0) ; % rle + drawarrow (0,0) -- (0,font_bidi_dp) -- (-font_bidi_wd,font_bidi_dp) withcolor green ; +endglyph ; + +beginglyph(8236,0,0,0) ; % pdf + draw (0,0) -- (0,font_bidi_dp) -- (-font_bidi_wd/2,font_bidi_dp) -- (font_bidi_wd/2,font_bidi_dp) withcolor blue ; +endglyph ; + +beginglyph(8237,0,0,0) ; % lro + drawarrow reverse ((0,0) -- (0,font_bidi_dp) -- (font_bidi_wd,font_bidi_dp)) withcolor red ; +endglyph ; + +beginglyph(8238,0,0,0) ; % rlo + drawarrow reverse ((0,0) -- (0,font_bidi_dp) -- (-font_bidi_wd,font_bidi_dp)) withcolor green ; +endglyph ; diff --git a/metapost/context/fonts/punkfont-bold.mp b/metapost/context/fonts/punkfont-bold.mp new file mode 100644 index 000000000..1c62963f9 --- /dev/null +++ b/metapost/context/fonts/punkfont-bold.mp @@ -0,0 +1,4 @@ +boolean bold_punk ; bold_punk := true ; + +input "punkfont-definitions.mp" ; +input "punkfont-characters.mp" ; diff --git a/metapost/context/fonts/punkfont-boldslanted.mp b/metapost/context/fonts/punkfont-boldslanted.mp new file mode 100644 index 000000000..3e5fa1561 --- /dev/null +++ b/metapost/context/fonts/punkfont-boldslanted.mp @@ -0,0 +1,5 @@ +boolean bold_punk ; bold_punk := true ; +boolean slanted_punk ; slanted_punk := true ; + +input "punkfont-definitions.mp" ; +input "punkfont-characters.mp" ; diff --git a/metapost/context/fonts/punkfont-characters.mp b/metapost/context/fonts/punkfont-characters.mp new file mode 100644 index 000000000..da0015b02 --- /dev/null +++ b/metapost/context/fonts/punkfont-characters.mp @@ -0,0 +1,726 @@ +initialize_punk_upper ; + +beginpunkchar("A",13,1,2); +z1=pp(1.5u,0); z2=(.5w,1.1h); z3=pp(w-1.5u,0); +pd z1; pd z3; draw z1--z2--z3; % left and right diagonals +z4=pp .3[z1,z2]; z5=pp .3[z3,z2]; pd z4; pd z5; draw z4--z5; % crossbar +endchar; + +beginpunkchar("B",12,1,1); +z1=pp(2u,0); z2=pp(2u,.6h); z3=pp(2u,h); pd z1; pd z3; draw z1--z3; % stem +z1.5=pp(w-u,.5y2); z2.5=pp(w-u,.5[y2,y3]); draw z2--z2.5--z3; % upper lobe +draw flex(z2,z1.5,z1); % lower lobe +endchar; + +beginpunkchar("C",13,1,2); +z1=pp(w-2u,.8h); z2=pp(.6w,h); z3=pp(u,.5h); z4=(.6w,0); z5=(w-2u,.2h); +pd z1; pd z5; draw z1..z2..z3..z4..z5; % arc +endchar; + +beginpunkchar("D",14,1,2); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(w-u,.6h); +pd z1; pd z2; draw flex(z1,z3,z2); % lobe +draw z1--z2; % stem +endchar; + +beginpunkchar("E",12,.5,1); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(w-2.5u,h); z4=pp(w-2u,0); +pd z3; pd z4; draw z4--z1--z2--z3; % stem and arms +z5=pp(2u,.6h); z6=pp(w-3u,.6h); pd z5; pd z6; draw z5--z6; % crossbar +endchar; + +beginpunkchar("F",12,.5,2); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(w-2u,h); +pd z1; pd z3; draw z1--z2--z3; % stem and arm +z5=pp(2u,.6h); z6=pp(w-3u,.6h); z4=pp .5[z5,z6]-(0,.1h); +pd z5; pd z6; draw flex (z5,z4,z6); % crossbar +endchar; + +beginpunkchar("G",13,.5,.5); +z1=pp(w-2u,.8h); z2=pp(.6w,h); z3=pp(u,.5h); z4=pp(.6w,0); z5=(w-2u,0); +pd z1; draw z1..z2..z3..z4---z5; % arc +z6=pp(.5[u,x5],.4h); pd z6; pd z5; draw z6--(pp(x5,y6))--z5; % spur +endchar; + +beginpunkchar("H",14,1,.5); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(w-2u,0); z4=pp(w-2u,h); +z5=pp(2u,.6h); z6=pp(w-2u,.6h); +pd z1; pd z2; pd z3; pd z4; draw z1--z2; draw flex(z3,z6,z4); % stems +pd z5; draw z5--z6; % crossbar +endchar; + +beginpunkchar("I",5,1,2); +z1=pp(.5w,0); z2=(.5w,1/3h); z3=(.5w,2/3h); z4=(.5w,h); +pd z1; pd z4; draw flex(z1,z2,z3,z4); % stem +endchar; + +beginpunkchar("J",9,1,2); +z1=pp(w-2u,h); z2=pp(w-2u,-.1h); z3=pp(u,0); +pd z1; pd z3; draw z1--z2--z3; % arc +endchar; + +beginpunkchar("K",14,1,2); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(2u,1/3h); z4=pp(w-1.5u,h); +pd z1; pd z2; draw z1--z2; % stem +pd z3; pd z4; draw z3--z4; % upper diagonal +z6=pp(w-u,0); z5=1/3[z3,z4]; +pd z6; draw flex(z5,.8[z1,2/3[z5,z6] ],z6);% lower diagonal +endchar; + +beginpunkchar("L",11,1,2); +z1=pp(2u,h); z2=pp(2u,0); z3=pp(w-1.5u,0); +pd z1; pd z3; draw z1--z2--z3; % stem and arm +endchar; + +beginpunkchar("M",17,.5,2); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(.5w,0); z4=pp(w-2u,h); z5=pp(w-2u,0); +pd z1; pd z5; draw z1--z2--z3--z4--z5; % stems and diagonals +endchar; + +beginpunkchar("N",13,.75,2); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(w-2u,0); z4=pp(w-2u,h); +pd z1; pd z4; draw z1--z2--z3--z4; % stems and diagonals +endchar; + +beginpunkchar("O",12,.5,2); +z1=pp(.5w,h); z2=pp(u,.55h); z3=pp(.5w,0); z4=pp(w-u,.55h); +pd z1; draw z1{left}..z2..z3..z4..z1; % bowl +endchar; + +beginpunkchar("P",13,1,2); +z1=pp(2u,0); z2=pp(2u,1.1h); z3=pp(2u,.5h); z4=pp(w,.6[y3,y2]); +pd z1; pd z3; draw z1--z2--z4--z3; % stem and bowl +endchar; + +beginpunkchar("Q",14,.5,2); +z1=pp(.5w,h); z2=pp(u,.55h); z3=pp(.5w,0); z4=pp(w-u,.55h); +pd z1; draw z1{curl 2}..z2..z3..z4..z1; % bowl +z5=pp(.4w,.2h); z6=pp(w-u,-.1h); z7=pp(.5[x5,x6],-.2h); +pd z5; pd z6; draw z5--z7--z6; % tail +endchar; + +beginpunkchar("R",16,1,2); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(w-u,.6[y2,y4]); z4=pp(2u,.5h); z5=pp(w-1.5u,0); +pd z1; pd z2; pd z5; draw z1--flex(z2,z3,z4)--z5; % stem, bowl, and diagonal +endchar; + +beginpunkchar("S",11,.3,1); +z1=pp(w-2u,.9h); z2=pp(.5w,h); z3=pp(u,.7h); z4=.6[z6,z2]; +z5=pp(w-u,.35h); z6=pp(.5w,u); z7=pp(u,.2h); +pd z1; pd z7; draw z1--z2...z3..z4..z5...z6--z7; % stroke +endchar; + +beginpunkchar("T",13,.75,2); +z1=pp(u,h); z2=pp(w-u,h); z3=pp(.5w,0); +pd z1; pd z2; pd z3; draw z1--z2; % arms +draw .5[z1,z2]--z3; % stem +endchar; + +beginpunkchar("U",13,.3,2); +z1=pp(2u,h); z2=pp(2u,.2h); z3=pp(.5w,0); z4=pp(w-2u,.2h); z5=pp(w-2u,h); +pd z1; pd z5; draw z1---z2...z3{z4-z2}...z4---z5; % stroke +endchar; + +beginpunkchar("V",13,1,2); +z1=pp(1.5u,h); z2=pp(.5w,0); z3=pp(w-1.5u,h); +pd z1; pd z3; draw z1--z2--z3; % diagonals +endchar; + +beginpunkchar("W",18,1,2); +z1=pp(1.5u,h); z2=pp(.5[x1,x3],0); z3=pp(.5w,.8h); z4=pp(.5[x3,x5],0); +z5=pp(w-1.5u,h); +pd z1; pd z5; draw z1--z2--z3--z4--z5; % diagonals +endchar; + +beginpunkchar("X",13,1,1); +z1=pp(1.5u,h); z2=pp(w-1.5u,0); z3=pp(1.5u,0); z4=pp(w-2.5u,h); +pd z1; pd z2; draw z1--z2; % main diagonal +pd z3; pd z4; draw z3--z4; % cross diagonal +endchar; + +beginpunkchar("Y",13,1,2); +z1=pp(1.5u,h); z2=pp(w-1.5u,h); z3=pp(.5w,.5h); z4=pp(.5w,0); +pd z1; pd z2; pd z4; draw z1--z3--z4; % stem and left diagonal +draw z2--z3; % right diagonal +endchar; + +beginpunkchar("Z",11,1,2); +z1=pp(1.5u,h); z2=pp(w-2.5u,h); z3=pp(1.5u,0); z4=pp(w-1.5u,0); +pd z1; pd z4; draw z1--z2--z3--z4; % diagonals +endchar; + +beginpunkchar(198,16,1,2); % \AE +z1=pp(1.5u,0); z2=pp(.6w,h); z3=pp(w-1.5u,h); +pd z1; pd z3; draw z1--z2--z3; % left diagonal and upper arm +z4=pp .3[z1,z2]; z5=pp(.6w,0); z6=pp(w-2u,.3h); +pd z4; pd z6; draw z4--z6; % crossbar +z7=pp(w-u,0); pd z2; pd z7; draw z2--z5--z7; % stem and lower arm +endchar; + +beginpunkchar(338,18,1,2); % \OE +z1=pp(.5w,h); z2=pp(u,.4h); z3=pp(.5w,0); +pd z1; draw z1..z2..{right}z3; % bowl +z4=pp(w-1.5u,h); z5=pp(w-2u,.4h); z6=pp(w-u,0); +pd z4; pd z6; draw z4--z1--z3--z6; % arms and stem +pd z5; draw z5--.4[z3,z1]; % crossbar +endchar; + +beginpunkchar(216,14,1,1); % \O +z1=pp(.5w,h); z2=pp(u,.5h); z3=pp(.5w,0); z4=pp(w-u,.5h); +z5=pp(w-2u,1.1h); z6=pp(2u,-.1h); +pd z1; pd z6; draw z1..z2..z3..z4..z5--z6; % bowl and diagonal +endchar; + +beginpunkchar(915,11,1,2); % $\Gamma$ +z1=pp(2u,0); z2=pp(2u,h); z3=pp(w-1.5u,h); +pd z1; pd z3; draw z1--z2--z3; % stem and arm +endchar; + +beginpunkchar(916,15,1,2); % $\Delta$ +z1=pp(u,0); z2=pp(.5w,h); z3=pp(w-u,0); +pd z1; draw z1--z2..tension 5..z3..tension 5..z1; % triangle +endchar; + +beginpunkchar(920,15,.5,2); % $\Theta$ +z1=pp(.5w,h); z2=pp(u,.6h); z3=pp(.5w,0); z4=pp(w-u,.6h); +pd z1; draw z1..tension.8..z2..z3..z4..tension.8..z1; % bowl +z5=pp(x2+2u,.4h); z6=pp(x4-2u,.4h); pd z5; pd z6; draw z5--z6; % bar +endchar; + +beginpunkchar(923,12,1,2); % $\Lambda$ +z1=pp(u,0); z2=pp(.5w,h); z3=pp(w-u,0); +pd z1; pd z3; draw z1--z2--z3; % diagonals +endchar; + +beginpunkchar(926,12,1,1); % $\Xi$ +z1=pp(u,h); z2=pp(w-u,h); pd z1; pd z2; draw z1--z2; % upper arm +z3=pp(2u,.55h); z4=pp(w-2u,.55h); pd z3; pd z4; draw z3--z4; % bar +z5=pp(u,0); z6=pp(w-u,0); pd z5; pd z6; draw z5--z6; % lower arm +endchar; + +beginpunkchar(928,13,1,.5); % $\Pi$ +z1=pp(1.5u,0); z2=pp(1.5u,h); z3=pp(w-1.5u,h); z4=pp(w-1.5u,0); +pd z1; pd z4; draw z1--z2--z3--z4; % stems and bar +endchar; + +beginpunkchar(931,13,1,1); % $\Sigma$ +z1=pp(w-u,h); z2=pp(u,h); z3=pp(.5w-u,.5h); z4=pp(u,0); z5=pp(w-u,0); +pd z1; pd z5; draw z1--z2{.5[z4,z5]-z2}..z3--z4--z5; % arms and diagonals +endchar; + +beginpunkchar(933,15,1,.5); % $\Upsilon$ +z1=pp(u,.8h); z2=pp(.3w,h); z3=pp(.5w,.5h); z4=pp(.5w,0); +pd z1; pd z4; draw z1..z2..tension2..z3---z4; % left arc and stem +z5=pp(w-u,.8h); z6=pp(.7w,h); +pd z5; draw z5..z6..tension2..{z4-z3}z3; % right arc +endchar; + +beginpunkchar(934,13,1,2); % $\Phi$ +z1=pp(.5w,h); z2=pp(.5w,0); pd z1; pd z2; draw z1--z2; % stem +z3=pp(.5w,2/3h); z4=pp(u,.5h); z5=pp(.5w,1/4h); z6=pp(w-u,.5h); +pd z3; draw z3..z4..z5..z6..z3; % bowl +endchar; + +beginpunkchar(936,14,1,1); % $\Psi$ +z1=pp(.5w,h); z2=pp(.5w,0); pd z1; pd z2; draw z1--z2; % stem +z3=pp(u,.8h); z4=pp(.5w,.2h); z5=pp(w-u,.8h); +pd z3; pd z5; draw z3{.4[z1,z2]-z3}..z4{right}..{z5-.4[z1,z2]}z5; % stroke +endchar; + +beginpunkchar(937,13,1,2); % $\Omega$ +z1=pp(u,0); z2=pp(1/3w,0); z3=pp(u,2/3h); z4=pp(.5w,h); +z5=pp(w-u,2/3h); z6=pp(2/3w,0); z7=pp(w-u,0); +pd z1; pd z7; draw z1--z2{up}..z3..z4..z5..{down}z6--z7; % bowl and arms +endchar; + +beginpunkchar(".",5,1,2); +pd pp(.5w,0); % dot +endchar; + +beginpunkchar(",",5,.5,.5); +z1=pp(.5w,0); z2=pp(w-u,-.1h); z3=pp(.5w,-.3h); +pd z1; pd z3; draw z1--z2--z3; % stroke +endchar; + +beginpunkchar(":",5,1,.5); +pd pp(.5w,0); pd pp(.5w,.4h); % dots +endchar; + +beginpunkchar(";",5,.5,.5); +z1=pp(.5w,0); z2=pp(w-u,-.1h); z3=pp(.5w,-.3h); +pd z1; pd z3; draw z1--z2--z3; % stroke +pd pp(.5w,.4h); % dot +endchar; + +beginpunkchar("!",5,.5,.5); +pd pp(.5w,0); % dot +z1=pp(.5w,1.05h); z2=pp(.5w,.3h); pd z1; pd z2; draw z1--z2; % stem +endchar; + +beginpunkchar(161,5,.5,.5); % spanish inverted ! +pd pp(.5w,.9h); % dot +z1=pp(.5w,-.1h); z2=pp(.5w,.6h); pd z1; pd z2; draw z1--z2; % stem +endchar; + +beginpunkchar("?",9,1,.5); +z1=pp(1.5u,.8h); z2=pp(.5w,h); z3=pp(w-u,.8h); z4=pp(.5w,.3h); +pd z1; pd z4; draw z1..z2..z3..{down}z4; % arc and stem +pd pp(.5w,0); % dot +endchar; + +beginpunkchar(191,9,1,.5); % spanish inverted ? +z1=pp(1.5u,.1h); z2=pp(.5w,-.1h); z3=pp(w-u,.1h); z4=pp(.5w,.6h); +pd z1; pd z4; draw z1..z2..z3..{up}z4; % arc and stem +pd pp(.5w,.9h); % dot +endchar; + +beginpunkchar("&",14,.5,.5); +z1=pp(w-2u,h); z2=pp(u,h); z3=pp(3u,0); z5=pp(w-u,.6h); z6=pp(w-2u,0); +pd z1; pd z5; draw z1--z2--z3--z5; % arms and stem +draw z1--.5[z2,z3]; pd z6; draw z6--.6[z3,z5]; % diagonals +endchar; + +beginpunkchar("$",12,.5,.5); +z1=pp(w-1.5u,.7h); z2=pp(.5w,h); z3=pp(u,.7h); z4=.5[z3,z5]; +z5=pp(w-u,.3h); z6=pp(.5w,0); z7=pp(u,.3h); +pd z1; pd z7; draw z1..z2..z3..z4..z5..z6..z7; % stroke +z8=z2+(0,.1h); pd z8; draw z8--z6; % stem +endchar; + +beginpunkchar("%",18,.5,.5); +z1=pp(3.5u,1.1h); z2=pp(u,.8h); z3=pp(3.5u,.5h); z4=pp(6u,.8h); +z5=pp(w-3.5u,.5h); z6=pp(w-6u,.2h); z7=pp(w-3.5u,-.1h); z8=pp(w-u,.2h); +pd z1; draw z1..z2..z3..z4..z1; % upper bowl +pd z5; draw z5..z6..z7..z8..z5; % lower bowl +z9=pp(w-3u,1.1h); z0=pp(3u,-.1h); pd z0; draw z9--z0; % diagonal +draw z1{z5-z1}..z9; % link +endchar; + +beginpunkchar("@",18,1,.5); +z1=pp(2u,0); z2=pp(1/3w,.7h); z3=pp(w-6u,0); +z4=pp(w,.3h); z5=pp(1/3w,h); z6=pp(u,.5h); z7=.7[z2,z3]; +pd z1; pd z7; draw z1--z2--z3{right}..z4..z5..z6..z7; % diagonals and stroke +endchar; + +beginpunkchar("-",7,.5,.5); +z1=pp(u,.4h); z2=pp(w-u,.5h); pd z1; pd z2; draw z1--z2; % bar +endchar; + +beginpunkchar(8211,9,.5,.5); % -- +z1=pp(0,.5h); z2=pp(w,.4h); pd z1; pd z2; draw z1--z2; % bar +endchar; + +beginpunkchar(8212,18,.5,.5); % --- +z1=pp(0,.5h); z2=pp(w,.4h); pd z1; pd z2; draw z1--z2; % bar +endchar; + +beginpunkchar("+",9,.5,1); +z1=pp(0,.5h); z2=pp(w,.5h); pd z1; pd z2; draw z1--z2; % bar +z3=pp(.5w,.1h); z4=pp(.5w,.9h); pd z3; pd z4; draw z3--z4; % stem +endchar; + +beginpunkchar("*",13,.5,1); +z0=pp(.5w,1.1h); z1=pp(u,.9h); z2=pp(2u,.3h); z3=pp(w-u,.3h); z4=pp(w-u,.9h); +pd z0; draw z0--z2..1/3[.5[z2,z4],z0]..z4--z1--z3--z0; % star +endchar; + +beginpunkchar(39,5,.5,1.5); % ' apostrofe HH/TH (to be checked) +z1=pp(w/2,h); z2=pp(w/2+u,.85h); z3=pp(w/2,2/3h); +pd z1; pd z3; draw z1..z2..z3; % stroke +endchar; + +beginpunkchar(34,9,1,1.5); % " HH/TH (to be checked) +z1=pp(1.5u,h); z2=pp(1.5u,.6h); z3=pp(w-1.5u,h); z4=pp(w-1.5u,.6h); +pd z1; pd z2; pd z3; pd z4; draw z1--z2; draw z3--z4; +endchar; + +beginpunkchar(8216,5,.3,.5); % ` +z1=pp(w-1.5u,h); z2=pp(u,.85h); z3=pp(w-u,2/3h); +pd z1; pd z3; draw z1--z2--z3; % stroke +endchar; + +beginpunkchar(8217,5,.3,.5); % ' +z1=pp(1.5u,h); z2=pp(w-u,.85h); z3=pp(u,2/3h); +pd z1; pd z3; draw z1--z2--z3; % stroke +endchar; + +beginpunkchar(8220,9,.3,.5); % `` quotedblleft +z1=pp(.5w+.5u,h); z2=pp(w-u,.6h); z3=pp(u,.95h); +pd z1; pd z3; draw z1--z2--z3; % stroke +endchar; + +beginpunkchar(8221,9,.3,.5); % '' quotedblright +z1=pp(.5w-.5u,h); z2=pp(u,.6h); z3=pp(w-u,.95h); +pd z1; pd z3; draw z1--z2--z3; % stroke +endchar; + +beginpunkchar("(",7,.5,.5); +z1=pp(w-u,h); z2=pp(u,.5h); z3=pp(w-u,0); +pd z1; pd z3; draw z1..z2..z3; % stroke +endchar; + +beginpunkchar(")",7,.5,.5); +z1=pp(u,h); z2=pp(w-u,.5h); z3=pp(u,0); pd z1; pd z3; draw z1..z2..z3; % stroke +endchar; + +beginpunkchar("[",8,.5,.5); +z1=pp(w-u,h); z2=pp(.5w,h); z3=pp(.5w,0); z4=pp(w-u,0); +pd z1; pd z4; draw z1--z2--z3--z4; % bars and stem +endchar; + +beginpunkchar("]",8,.5,.5); +z1=pp(u,h); z2=pp(.5w,h); z3=pp(.5w,0); z4=pp(u,0); +pd z1; pd z4; draw z1--z2--z3--z4; % bars and stem +endchar; + +beginpunkchar("<",9,.5,.5); +z1=pp(w-u,.9h); z2=pp(u,.5h); z3=pp(w-u,.1h); +pd z1; pd z3; draw z1--z2--z3; % diagonals +endchar; + +beginpunkchar(">",9,.5,.5); +z1=pp(u,.9h); z2=pp(w-u,.5h); z3=pp(u,.1h); +pd z1; pd z3; draw z1--z2--z3; % diagonals +endchar; + +beginpunkchar("{",10,.5,.5); % HH/TH +z1=pp(w-2u,h); z3=pp(2u,.5h); z5=pp(w-2u,0); +z2=pp(w-4u,.6h); z4=(w-4u,.4h); +pd z1; pd z3; pd z5; draw z1{left}..z2--z3 & z3--z4..{right}z5; +endchar; + +beginpunkchar("}",10,.5,.5); % HH/TH +z1=pp(2u,h); z3=pp(w-2u,.5h); z5=pp(2u,0); +z2=pp(4u,.6h); z4=(4u,.4h); +pd z1; pd z3; pd z5; draw z1{right}..z2--z3 & z3--z4..{left}z5; +endchar; + +beginpunkchar("=",9,.5,.5); +z5=pp(u,2/3h); z6=pp(w-u,2/3h); pd z5; pd z6; draw z5--z6; % upper bar +z7=pp(u,1/3h); z8=pp(w-u,1/3h); pd z7; pd z8; draw z7--z8; % lower bar +endchar; + +beginpunkchar("#",15,.5,.5); +z1=pp(.5w,h); z2=pp(3u,0); z3=pp(w-3u,h); z4=pp(.5w,0); +pd z2; pd z3; draw z3--z1--z2; draw z3--z4--z2; % diagonals (linked) +z5=pp(u,2/3h); z6=pp(w-u,2/3h); pd z5; pd z6; draw z5--z6; % upper bar +z7=pp(u,1/3h); z8=pp(w-u,1/3h); pd z7; pd z8; draw z7--z8; % lower bar +endchar; + +beginpunkchar("/",9,1,1); +z1=pp(1.5u,-.05h); z2=pp(w-1.5u,1.05h); pd z1; pd z2; draw z1--z2; % diagonal +endchar; + +beginpunkchar("\",9,1,1); % HH/TH +z1=pp(1.5u,1.05h); z2=pp(w-1.5u,-.05h); pd z1; pd z2; draw z1--z2; % reverse diagonal +endchar; + + +beginpunkchar("0",9,.5,1); +z1=pp(.5w,h); z2=pp(u,.55h); z3=pp(.5w,0); z4=pp(w-u,.55h); +pd z1; draw z1{curl 2}..z2..z3..z4..z1; % bowl +endchar; + +beginpunkchar("1",9,.3,1); +z1=pp(2u,.7h); z2=pp(.6w,h); z3=pp(.6w,0); +pd z1; pd z3; draw z1--z2--z3; % serif and stem +endchar; + +beginpunkchar("2",9,1,1); +z1=pp(2u,.7h); z2=pp(.5w,h); z3=pp(w-u,.6h); z4=pp(u,0); z5=pp(w-2u,0); +pd z1; pd z5; draw z1..z2..z3..z4--z5; % stroke +endchar; + +beginpunkchar("3",9,.5,.5); +z1=pp(2u,.7h); z2=pp(.5w,h); z3=pp(w-u,.5[y2,y4]); +z4=pp(.5w-u,.55h); z5=pp(w-u,.5[y4,y6]); z6=pp(.5w,0); z7=pp(1.5u,.2h); +pd z1; pd z7; draw z1..z2..z3..z4&z4..z5..z6..z7; % arcs +endchar; + +beginpunkchar("4",9,1,1); +z1=pp(w-u,.3h); z2=pp(u,.3h); z3=pp(2/3w,h); z4=pp(2/3w,0); +pd z1; pd z4; draw z1--z2--z3--z4; % stem and diagonals +endchar; + +beginpunkchar("5",9,.5,.5); +z1=pp(w-2u,h); z2=pp(2u,h); z3=pp(u,.7h); z4=pp(w-u,.5[y3,y5]); +z5=pp(.5w,0); z6=pp(u,.2h); +pd z1; pd z6; draw z1--z2--z3..z4..z5..z6; % stroke +endchar; + +beginpunkchar("6",9,1,1); +z1=pp(2/3w,h); z2=pp(u,.3h); z3=pp(.5w,0); z4=pp(w-u,.3h); z5=pp(.6w,.6h); +z6=pp z2; pd z1; pd z6; draw z1..z2..z3..z4..z5--z6; % stroke +endchar; + +beginpunkchar("7",9,.5,1); +z1=pp(2u,h); z2=pp(w-.5u,h); z3=pp(.4w,0); +pd z1; pd z3; draw z1--z2&z2..z3{down}; % stroke +endchar; + +beginpunkchar("8",9,.5,.5); +z1=pp(.5w,h); z2=pp(u,.5[y1,y3]); z3=pp(.5w,.6h); z4=pp(w-u,.5[y3,y5]); +z5=pp(.5w,0); z6=pp(u,.5[y5,y3]); z7=pp(w-u,.5[y1,y3]); +pd z1; draw z1{curl 8}..z2..z3..z4..z5..z6..z3..z7..z1; % stroke +endchar; + +beginpunkchar("9",9,1,1); +z1=pp(1/3w,0); z2=pp(w-u,.7h); z3=pp(.5w,h); z4=pp(u,.7h); z5=pp(.5w,.4h); +pd z1; pd z5; draw z1..z2..z3..z4..z5; % stroke +endchar; + +beginpunkchar(96,9,1,1); % \`{} grave +z1=pp(2.5u,h); z2=pp(.6w,.8h); pd z1; pd z2; draw z1--z2; % diagonal +endchar; + +beginpunkchar(180,9,1,1); % \'{} acute +z1=pp(w-2.5u,h); z2=pp(.4w,.8h); pd z1; pd z2; draw z1--z2; % diagonal +endchar; + +beginpunkchar(710,13,1,1); % \^{} circumflex +z1=pp(2.5u,.8h); z2=pp(.5w,h); z3=(w-2.5u,.8h); +pd z1; pd z3; draw z1--z2--z3; % diagonals +endchar; + +beginpunkchar(711,13,1,1); % \v{} caron +z1=pp(2.5u,.9h); z2=pp(.5w,.7h); z3=pp(w-2.5u,.9h); +pd z1; pd z3; draw z1--z2--z3; % diagonals +endchar; + +beginpunkchar(728,11,1,1); % \u{} breve +z1=pp(2u,h); z2=pp(.5w,.75h); z3=pp(w-2u,h); +pd z1; pd z3; draw flex(z1,z2,z3); % stroke +endchar; + +beginpunkchar(175,12,1,1); % \={} macron +z1=pp(u,.8h); z2=pp(w-u,.8h); pd z1; pd z2; draw z1--z2; % bar +endchar; + +beginpunkchar(729,5,1,1); % \.{} +pd pp(.5w,.9h); % dot +endchar; + +beginpunkchar(168,13,1,1); % \"{} diaeresis +pd pp(1/5w,.9h); pd pp(4/5w,.9h); % dots +endchar; + +beginpunkchar(732,13,1,1); % \~{} tilde +z1=pp(u,.75h); z2=pp(w-u,.9h); pd z1; pd z2; draw z1{up}..{up}z2; % stroke +endchar; + +beginpunkchar(733,13,1,1); % \H{} hungarumlaut +z1=pp(4u,h); z2=pp(2.5u,.7h); z3=pp(w-2u,h); z4=pp(w-3.5u,.7h); +pd z1; pd z3; draw z1--z2--z4--z3; % diagonals (linked) +endchar; + +beginpunkchar(730,13,0,0); % Scandinavian loop, for \AA\ and \aa (ring) +z0=(.5w,.66h); % point $z^2$ of lowercase A +z1=(.5w,.9h); draw z0{z0-(1.5u,0)}..z1..{(w-1.5u,0)-z0}z0; % loop +endchar; + +beginpunkchar(184,13,.5,.5); % Cedilla, for \c c +z1=(.6w,0); z2=pp(.6w,-.1h); z3=pp(2.5u,-.1h); +pd z3; draw z1--z2--z3; % stroke +endchar; + +initialize_punk_lower ; + +beginpunkchar(305,5,1,2); % dotless I +z1=pp(.5w,0); z2=(.5w,1/3h); z3=(.5w,2/3h); z4=(.5w,h); +pd z1; pd z4; draw flex(z1,z2,z3,z4); % stem +endchar; + +beginpunkchar(567,9,1,2); % dotless J +z1=pp(w-2u,h); z2=pp(w-2u,-.1h); z3=pp(u,0); +pd z1; pd z3; draw z1--z2--z3; % arc +endchar; + +beginpunkchar(223,18,.3,1); % German SS +z1=pp(.5w-u,.9h); z2=pp(1/3w,h); z3=pp(u,.7h); z4=.6[z6,z2]; +z5=pp(.5w,.35h); z6=pp(1/3w,u); z7=pp(u,.2h); +pd z1; pd z7; draw z1--z2...z3..z4..z5...z6--z7; % left stroke +for i=1 upto 7: z[i+10]=pp(z[i] shifted (.5w-u,0)); endfor +pd z11; pd z17; draw z11--z12...z13..z14..z15...z16--z17; % right stroke +endchar; + +beginpunkchar("a",13,1,2); +z1=pp(1.5u,0); z2=(.5w,1.1h); z3=pp(w-1.5u,0); +pd z1; pd z3; draw z1--z2--z3; % left and right diagonals +z4=pp .3[z1,z2]; z5=pp .3[z3,z2]; pd z4; pd z5; draw z4--z5; % crossbar +endchar; + +beginpunkchar("b",12,1,1); +z1=pp(2u,0); z2=pp(2u,.6h); z3=pp(2u,h); pd z1; pd z3; draw z1--z3; % stem +z1.5=pp(w-u,.5y2); z2.5=pp(w-u,.5[y2,y3]); draw z2--z2.5--z3; % upper lobe +draw flex(z2,z1.5,z1); % lower lobe +endchar; + +beginpunkchar("c",13,1,2); +z1=pp(w-2u,.8h); z2=pp(.6w,h); z3=pp(u,.5h); z4=(.6w,0); z5=(w-2u,.2h); +pd z1; pd z5; draw z1..z2..z3..z4..z5; % arc +endchar; + +beginpunkchar("d",14,1,2); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(w-u,.6h); +pd z1; pd z2; draw flex(z1,z3,z2); % lobe +draw z1--z2; % stem +endchar; + +beginpunkchar("e",12,.5,1); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(w-2.5u,h); z4=pp(w-2u,0); +pd z3; pd z4; draw z4--z1--z2--z3; % stem and arms +z5=pp(2u,.6h); z6=pp(w-3u,.6h); pd z5; pd z6; draw z5--z6; % crossbar +endchar; + +beginpunkchar("f",12,.5,2); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(w-2u,h); +pd z1; pd z3; draw z1--z2--z3; % stem and arm +z5=pp(2u,.6h); z6=pp(w-3u,.6h); z4=pp .5[z5,z6]-(0,.1h); +pd z5; pd z6; draw flex (z5,z4,z6); % crossbar +endchar; + +beginpunkchar("g",13,.5,.5); +z1=pp(w-2u,.8h); z2=pp(.6w,h); z3=pp(u,.5h); z4=pp(.6w,0); z5=(w-2u,0); +pd z1; draw z1..z2..z3..z4---z5; % arc +z6=pp(.5[u,x5],.4h); pd z6; pd z5; draw z6--(pp(x5,y6))--z5; % spur +endchar; + +beginpunkchar("h",14,1,.5); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(w-2u,0); z4=pp(w-2u,h); +z5=pp(2u,.6h); z6=pp(w-2u,.6h); +pd z1; pd z2; pd z3; pd z4; draw z1--z2; draw flex(z3,z6,z4); % stems +pd z5; draw z5--z6; % crossbar +endchar; + +beginpunkchar("i",5,1,2); +z1=pp(.5w,0); z2=(.5w,1/3h); z3=(.5w,2/3h); z4=(.5w,h); +pd z1; pd z4; draw flex(z1,z2,z3,z4); % stem +endchar; + +beginpunkchar("j",9,1,2); +z1=pp(w-2u,h); z2=pp(w-2u,-.1h); z3=pp(u,0); +pd z1; pd z3; draw z1--z2--z3; % arc +endchar; + +beginpunkchar("k",14,1,2); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(2u,1/3h); z4=pp(w-1.5u,h); +pd z1; pd z2; draw z1--z2; % stem +pd z3; pd z4; draw z3--z4; % upper diagonal +z6=pp(w-u,0); z5=1/3[z3,z4]; +pd z6; draw flex(z5,.8[z1,2/3[z5,z6] ],z6);% lower diagonal +endchar; + +beginpunkchar("l",11,1,2); +z1=pp(2u,h); z2=pp(2u,0); z3=pp(w-1.5u,0); +pd z1; pd z3; draw z1--z2--z3; % stem and arm +endchar; + +beginpunkchar("m",17,.5,2); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(.5w,0); z4=pp(w-2u,h); z5=pp(w-2u,0); +pd z1; pd z5; draw z1--z2--z3--z4--z5; % stems and diagonals +endchar; + +beginpunkchar("n",13,.75,2); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(w-2u,0); z4=pp(w-2u,h); +pd z1; pd z4; draw z1--z2--z3--z4; % stems and diagonals +endchar; + +beginpunkchar("o",12,.5,2); +z1=pp(.5w,h); z2=pp(u,.55h); z3=pp(.5w,0); z4=pp(w-u,.55h); +pd z1; draw z1{left}..z2..z3..z4..z1; % bowl +endchar; + +beginpunkchar("p",13,1,2); +z1=pp(2u,0); z2=pp(2u,1.1h); z3=pp(2u,.5h); z4=pp(w,.6[y3,y2]); +pd z1; pd z3; draw z1--z2--z4--z3; % stem and bowl +endchar; + +beginpunkchar("q",14,.5,2); +z1=pp(.5w,h); z2=pp(u,.55h); z3=pp(.5w,0); z4=pp(w-u,.55h); +pd z1; draw z1{curl 2}..z2..z3..z4..z1; % bowl +z5=pp(.4w,.2h); z6=pp(w-u,-.1h); z7=pp(.5[x5,x6],-.2h); +pd z5; pd z6; draw z5--z7--z6; % tail +endchar; + +beginpunkchar("r",16,1,2); +z1=pp(2u,0); z2=pp(2u,h); z3=pp(w-u,.6[y2,y4]); z4=pp(2u,.5h); z5=pp(w-1.5u,0); +pd z1; pd z2; pd z5; draw z1--flex(z2,z3,z4)--z5; % stem, bowl, and diagonal +endchar; + +beginpunkchar("s",11,.3,1); +z1=pp(w-2u,.9h); z2=pp(.5w,h); z3=pp(u,.7h); z4=.6[z6,z2]; +z5=pp(w-u,.35h); z6=pp(.5w,u); z7=pp(u,.2h); +pd z1; pd z7; draw z1--z2...z3..z4..z5...z6--z7; % stroke +endchar; + +beginpunkchar("t",13,.75,2); +z1=pp(u,h); z2=pp(w-u,h); z3=pp(.5w,0); +pd z1; pd z2; pd z3; draw z1--z2; % arms +draw .5[z1,z2]--z3; % stem +endchar; + +beginpunkchar("u",13,.3,2); +z1=pp(2u,h); z2=pp(2u,.2h); z3=pp(.5w,0); z4=pp(w-2u,.2h); z5=pp(w-2u,h); +pd z1; pd z5; draw z1---z2...z3{z4-z2}...z4---z5; % stroke +endchar; + +beginpunkchar("v",13,1,2); +z1=pp(1.5u,h); z2=pp(.5w,0); z3=pp(w-1.5u,h); +pd z1; pd z3; draw z1--z2--z3; % diagonals +endchar; + +beginpunkchar("w",18,1,2); +z1=pp(1.5u,h); z2=pp(.5[x1,x3],0); z3=pp(.5w,.8h); z4=pp(.5[x3,x5],0); +z5=pp(w-1.5u,h); +pd z1; pd z5; draw z1--z2--z3--z4--z5; % diagonals +endchar; + +beginpunkchar("x",13,1,1); +z1=pp(1.5u,h); z2=pp(w-1.5u,0); z3=pp(1.5u,0); z4=pp(w-2.5u,h); +pd z1; pd z2; draw z1--z2; % main diagonal +pd z3; pd z4; draw z3--z4; % cross diagonal +endchar; + +beginpunkchar("y",13,1,2); +z1=pp(1.5u,h); z2=pp(w-1.5u,h); z3=pp(.5w,.5h); z4=pp(.5w,0); +pd z1; pd z2; pd z4; draw z1--z3--z4; % stem and left diagonal +draw z2--z3; % right diagonal +endchar; + +beginpunkchar("z",11,1,2); +z1=pp(1.5u,h); z2=pp(w-2.5u,h); z3=pp(1.5u,0); z4=pp(w-1.5u,0); +pd z1; pd z4; draw z1--z2--z3--z4; % diagonals +endchar; + +beginpunkchar(230,16,1,2); % \ae +z1=pp(1.5u,0); z2=pp(.6w,h); z3=pp(w-1.5u,h); +pd z1; pd z3; draw z1--z2--z3; % left diagonal and upper arm +z4=pp .3[z1,z2]; z5=pp(.6w,0); z6=pp(w-2u,.3h); +pd z4; pd z6; draw z4--z6; % crossbar +z7=pp(w-u,0); pd z2; pd z7; draw z2--z5--z7; % stem and lower arm +endchar; + +beginpunkchar(339,18,1,2); % \oe +z1=pp(.5w,h); z2=pp(u,.4h); z3=pp(.5w,0); +pd z1; draw z1..z2..{right}z3; % bowl +z4=pp(w-1.5u,h); z5=pp(w-2u,.4h); z6=pp(w-u,0); +pd z4; pd z6; draw z4--z1--z3--z6; % arms and stem +pd z5; draw z5--.4[z3,z1]; % crossbar +endchar; + +beginpunkchar(248,14,1,1); % \o +z1=pp(.5w,h); z2=pp(u,.5h); z3=pp(.5w,0); z4=pp(w-u,.5h); +z5=pp(w-2u,1.1h); z6=pp(2u,-.1h); +pd z1; pd z6; draw z1..z2..z3..z4..z5--z6; % bowl and diagonal +endchar; + +revert_punk_lower; + +beginpunkchar("_",12,.5,.5); % _ +z1=pp(0,-.2h); z2=pp(w,-.2h); pd z1; pd z2; draw z1--z2; % bar +endchar; + +beginpunkchar("^",12,1,.5); % +z1=pp(.5w,h); z2=pp(1.5u,.6h); z3=pp(w-1.5u,.6h); +pd z2; pd z3; draw z2--z1--z3; +endchar; diff --git a/metapost/context/fonts/punkfont-definitions.mp b/metapost/context/fonts/punkfont-definitions.mp new file mode 100644 index 000000000..2901a9d03 --- /dev/null +++ b/metapost/context/fonts/punkfont-definitions.mp @@ -0,0 +1,115 @@ +% Remark: +% +% This file is a merge of the original punk files by Donald Knuth, who +% added this comment: +% +% Font inspired by Gerard and Marjan Unger's lectures, Feb 1985 +% +% The regular punk files are part of TeXLive and in metafont format. All +% errors introduced are ours. We also changed the encoding to unicode. In +% due time we might add a few more more characters. We still need to +% improve some of the metrics which involves a bit of trial and error. The +% font just covers basic latin shapes but in ConTeXt MkIV we add virtual +% composed shapes. There is a module m-punk.tex that implements this. This +% derivate is also used in mk.tex (mk.pdf) which is one of our tests for +% LuaTeX. We published an article on it in the MAPS (NTG magazine). +% +% 2008, Taco Hoekwater & Hans Hagen + +if unknown punk_font_loaded : + + if unknown scale_factor : + scale_factor := 1 ; + fi ; + + boolean punk_font_loaded ; + + punk_font_loaded := true ; + warningcheck := 0 ; + proofing := 0 ; + designsize := 10pt#; + font_identifier := "Punk Nova" ; % dedicated to Don Knuth and Hermann Zapf + + ht# := 7pt# ; % height of characters + u# := 1/4pt# ; % unit width + dev# := .3pt# ; % standard deviation of punk points + + if known bold_punk : + s# := 1.2pt# ; % extra sidebar + px# := 1pt# ; % horizontal thickness of pen + py# := .8pt# ; % vertical thickness of pen + dot# := 1.7pt# ; % diameter of dots + else : + s# := 0 ; % extra sidebar, ok + px# := .6pt# ; % horizontal thickness of pen + py# := .5pt# ; % vertical thickness of pen + dot# := 1.3pt# ; % diameter of dots + fi ; + + pt := .1pt ; + mag := scale_factor * 10 ; + bp_per_pixel := bpppix_ * mag ; + + define_pixels(u,dev) ; + define_blacker_pixels(px,py,dot) ; + define_whole_pixels(s) ; + xoffset := s ; + + pickup pencircle xscaled px yscaled py ; + punk_pen := savepen ; + pickup pencircle scaled dot ; + path dot_pen_path ; + dot_pen_path := tensepath makepath currentpen ; + + defaultcolormodel := 1 ; + + if known slanted_punk : + dot_pen_path := dot_pen_path slanted -0.25 ; + extra_endchar := extra_endchar & "currentpicture := currentpicture slanted 0.25 ;" ; + fi ; + + + def beginpunkchar(expr c,n,h,v) = % code $c$; width is $n$ units + hdev := h * dev ; % modify horizontal amounts of deviation + vdev := v * dev ; % modify vertical amounts of deviation + beginchar(c,n*u#,ht#,0) ; + italcorr 0 ; + % italcorr ht#*slant; + pickup punk_pen + enddef ; + + def ^ = + transformed currenttransform + enddef ; + + def makebox(text rule) = + for y=0, h : % horizontals + rule((-s,y)^,(w-s,y)^) ; + endfor + for x=-s, 0, w-2s, w-s : % verticals + rule((x,0)^,(x,h)^) ; + endfor + enddef ; + + rulepen := pensquare ; + + vardef pp expr z = + z + (hdev * normaldeviate, vdev * normaldeviate) + enddef; + + def pd expr z = % {\bf drawdot} + addto currentpicture contour dot_pen_path shifted z.t_ % withpen penspeck + enddef; + + def initialize_punk_upper = + ht# := 7pt# ; dev# := .3pt# ; + enddef ; + def initialize_punk_lower = + sht# := ht#; sdev := dev; + ht# := .6ht# ; dev := .7dev ; + enddef ; + def revert_punk_lower = + ht# := sht#; dev := sdev; + enddef ; + +fi ; diff --git a/metapost/context/fonts/punkfont-slanted.mp b/metapost/context/fonts/punkfont-slanted.mp new file mode 100644 index 000000000..5c1ff46b2 --- /dev/null +++ b/metapost/context/fonts/punkfont-slanted.mp @@ -0,0 +1,4 @@ +boolean slanted_punk ; slanted_punk := true ; + +input "punkfont-definitions.mp" ; +input "punkfont-characters.mp" ; diff --git a/metapost/context/fonts/punkfont.mp b/metapost/context/fonts/punkfont.mp new file mode 100644 index 000000000..2a03aae81 --- /dev/null +++ b/metapost/context/fonts/punkfont.mp @@ -0,0 +1,2 @@ +input "punkfont-definitions.mp" ; +input "punkfont-characters.mp" ; |