symbolset

From Wiki
Jump to navigation Jump to search

One can create a symbol set with a specific font by using the commands \startsymbolset --- \stopsymbolset. Here is an example which creates the « dangerous bend » used by Donald Kunth with his font manfnt.

Once a symbolset has been declared and set up, one can use the declared symbols (for instance here dbend) with the command \symbol{dbend}, or imbed it in other commands.

In order to find which slot represents a desired glyph, one may look at the afm file and then by trial and error find the correct address… (in our example the file is manfnt.afm). For instance we have found that n:char_7e represents the dangerous bend, while n:char_79 represents a broken arrow.

% First we declare the font where the symbols have to be found
\definefontsynonym[bends][file:manfnt.afm]

% Then we declare a proper set of symbols:
\startsymbolset [Dangerous Bends]
	\definesymbol [dbend]   [\resolvedglyphdirect{bends}{n:char_7e}]
	\definesymbol [lhdbend] [\resolvedglyphdirect{bends}{n:char_7f}]
	\definesymbol[brokenarrow][\resolvedglyphdirect{bends}{n:char_79}]
	\definesymbol[pentastar][\resolvedglyphdirect{bends}{n:char_1e}]
\stopsymbolset

% Here we say which symbolset is to be used:
\setupsymbolset [Dangerous Bends]

% One can use the symbols directly with the command \symbol
% or imbed it in other commands.
\define\dbend{\inmargin{\symbol{dbend}}}
\define\ddbend{\inmargin{\symbol{dbend}\symbol{dbend}}}
\define\dddbend{\inmargin{\symbol{dbend}\symbol{dbend}\symbol{dbend}}}

\starttext
Here we use the symbols directly: \symbol{dbend}\quad \symbol{lhdbend}.
\blank[big]
\symbol{brokenarrow}\quad \symbol{pentastar}.
\blank[big]
\dbend This result is difficult to prove.
\blank[big]
\ddbend This result is more difficult to prove.
\blank[big]
\dddbend This result is even more difficult to prove.
\stoptext