| 1 |
|
| 2 |
\input minim-doc.sty |
| 3 |
\closeout0 |
| 4 |
|
| 5 |
\newmetapostinstance\hershey |
| 6 |
\runmetapost\hershey{ |
| 7 |
input "hershey"; |
| 8 |
loadHershey timesib; |
| 9 |
} |
| 10 |
|
| 11 |
\def\chapter#1\hfill#2\par{% |
| 12 |
\startelement{Chapter}% |
| 13 |
\outline open {#1}% |
| 14 |
\nextpartag{H}\quitvmode |
| 15 |
\startelement{Span}% |
| 16 |
\red{\runmetapostimage\hershey{ |
| 17 |
baseline origin; |
| 18 |
pickup pencircle scaled .4pt; |
| 19 |
drawHershey timesib ("hershey.mp") withcolor .75red; |
| 20 |
}\setactualtext{hershey.mp}% |
| 21 |
\stopelement{Span}% |
| 22 |
\hfill#2\bigskip\nobreak}} |
| 23 |
|
| 24 |
\def\mailname{hershey} |
| 25 |
\startmetadata |
| 26 |
author {Esger Renkema} |
| 27 |
title {hershey.mp} |
| 28 |
date {2022-08-24} |
| 29 |
version {2022/1.0} |
| 30 |
keywords {MetaPost; Hershey fonts} |
| 31 |
stopmetadata |
| 32 |
|
| 33 |
\maketitle |
| 34 |
|
| 35 |
This package can read the ⟦jhl⟧ format, used for the well known Hershey Fonts. |
| 36 |
Use it like so: |
| 37 |
|
| 38 |
⟦% Where to look for font files (this is also the default) |
| 39 |
hersheyFonts := "/usr/share/hershey-fonts/"; |
| 40 |
% Load the font you want to use |
| 41 |
loadHershey timesib; |
| 42 |
% Draw a character |
| 43 |
beginfig(1) |
| 44 |
drawHershey timesib(7) rotated 180 withcolor .75red; |
| 45 |
endfig; |
| 46 |
% Or typeset a string |
| 47 |
beginfig(2) |
| 48 |
drawHershey timesib("Hello!") withcolor .75red; |
| 49 |
endfig;⟧ |
| 50 |
|
| 51 |
This results in the following pictures: |
| 52 |
|
| 53 |
\bigskip\strut\hfill |
| 54 |
\startelement{Figure} |
| 55 |
\setalttext{An upside-down ampersand.} |
| 56 |
\runmetapostimage \hershey { |
| 57 |
baseline origin; |
| 58 |
drawHershey timesib(7) rotated 180 withcolor .75red;} |
| 59 |
\stopelement{Figure} |
| 60 |
\hfill and\hfill |
| 61 |
\startelement{Figure} |
| 62 |
\setalttext{The text ‘Hello!’.} |
| 63 |
\runmetapostimage \hershey { |
| 64 |
baseline origin; |
| 65 |
drawHershey timesib("Hello!") withcolor .75red;} |
| 66 |
\stopelement{Figure} |
| 67 |
\hfill\strut\bigskip |
| 68 |
|
| 69 |
Typesetting a string will only make sense for the latin fonts, where Hershey’s |
| 70 |
encoding is in ASCII order. For strings, the baseline is adjusted upward by 9~units. |
| 71 |
|
| 72 |
Typical x-height is 14 units (of which 9 are below $y=0$), with an em-space of 21 units. |
| 73 |
|
| 74 |
The paths that make up each character are available to you in the array |
| 75 |
⟦hershey.<fontname>[<charid>][]⟧. You will rarely need this, however, since the trailing tokens to ⟦drawHershey⟧ will be applied to all paths. |
| 76 |
|
| 77 |
Proof sheets of Hershey’s original fonts are included in the following pages. |
| 78 |
|
| 79 |
\licencesection \stopelement{Section} |
| 80 |
|
| 81 |
\font\fiverm {Latin Modern Roman:script=latn;protrusion=default;} at 5pt |
| 82 |
\runmetapost \hershey { |
| 83 |
vardef testfont suffix name = |
| 84 |
save c; c := 1; |
| 85 |
for i = 1 upto 7: draw (45i+22.5,-22.5) -- (45i+22.5,-45*12-22.5); endfor |
| 86 |
for j = 1 upto 11: draw (22.5, -45j-22.5) -- (45*8+22.5, -45j-22.5); endfor |
| 87 |
for i = 1 upto 8: |
| 88 |
for j = 1 upto 12: |
| 89 |
drawHershey.name(c) shifted 45(i,-j); |
| 90 |
draw maketext("{\fiverm "&decimal c&"}") shifted (45(i,-j) + (13,16)); |
| 91 |
c := c + 1; |
| 92 |
endfor |
| 93 |
endfor |
| 94 |
setbounds currentpicture to |
| 95 |
unitsquare xscaled 8 yscaled -12 scaled 45 shifted (22.5, -22.5); |
| 96 |
enddef; } |
| 97 |
|
| 98 |
\def\testfont#1 #2 {\vfil\break |
| 99 |
\chapter{#1}{#2}% |
| 100 |
\startelement{Figure} |
| 101 |
\setalttext{A listing of the ‘#2’ font.} |
| 102 |
\stoptagging |
| 103 |
\runmetapostimage \hershey { testfont #2; } |
| 104 |
\starttagging |
| 105 |
\stopelement{Figure}} |
| 106 |
|
| 107 |
\def\chapter#1#2{% |
| 108 |
\ensurestopelement{Section}% |
| 109 |
\startelement{Chapter}% |
| 110 |
\outline open {#2}% |
| 111 |
\nextpartag{H}\quitvmode |
| 112 |
\vrule depth 20pt height 35pt width 0pt\relax |
| 113 |
\startelement{Span}% |
| 114 |
\red{\runmetapostimage\hershey{ |
| 115 |
loadHershey #2; |
| 116 |
baseline origin; |
| 117 |
pickup pencircle scaled .4pt; |
| 118 |
drawHershey #1 ("#2") withcolor .75red; |
| 119 |
}}\setactualtext{#2}\bigskip |
| 120 |
\stopelement{Span}\nobreak} |
| 121 |
|
| 122 |
\testfont timesr timesr |
| 123 |
\testfont timesi timesi |
| 124 |
\testfont timesrb timesrb |
| 125 |
\testfont timesib timesib |
| 126 |
\testfont timesr timesg |
| 127 |
\testfont timesr cyrillic |
| 128 |
|
| 129 |
\testfont gothiceng gothiceng |
| 130 |
\testfont gothicger gothicger |
| 131 |
\testfont gothicita gothicita |
| 132 |
|
| 133 |
\testfont rowmans rowmans |
| 134 |
\testfont rowmand rowmand |
| 135 |
\testfont rowmant rowmant |
| 136 |
|
| 137 |
\testfont futural futural |
| 138 |
\testfont futuram futuram |
| 139 |
|
| 140 |
\testfont timesr greeks |
| 141 |
\testfont timesr greekc |
| 142 |
|
| 143 |
\testfont scripts scripts |
| 144 |
\testfont scriptc scriptc |
| 145 |
|
| 146 |
\testfont timesr mathlow |
| 147 |
\testfont timesr mathupp |
| 148 |
|
| 149 |
\testfont astrology astrology |
| 150 |
\testfont meteorology meteorology |
| 151 |
\testfont timesr symbolic |
| 152 |
\testfont timesr markers |
| 153 |
\testfont music music |
| 154 |
|
| 155 |
\vfil\break\end |
| 156 |
|