| <head> |
| <title>subfont(3) - Plan 9 from User Space</title> |
| <meta content="text/html; charset=utf-8" http-equiv=Content-Type> |
| </head> |
| <body bgcolor=#ffffff> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=10><td> |
| <tr><td width=20><td> |
| <tr><td width=20><td><b>SUBFONT(3)</b><td align=right><b>SUBFONT(3)</b> |
| <tr><td width=20><td colspan=2> |
| <br> |
| <p><font size=+1><b>NAME </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| allocsubfont, freesubfont, installsubfont, lookupsubfont, uninstallsubfont, |
| subfontname, readsubfont, readsubfonti, writesubfont, stringsubfont, |
| strsubfontwidth, mkfont – subfont manipulation<br> |
| |
| </table> |
| <p><font size=+1><b>SYNOPSIS </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>#include <u.h><br> |
| #include <libc.h><br> |
| #include <draw.h> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Subfont* allocsubfont(char *name, int n, int height, int ascent,<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Fontchar *info, Image *i) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| </table> |
| |
| </table> |
| </font></tt> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| |
| </table> |
| |
| </table> |
| <tt><font size=+1>void freesubfont(Subfont *f) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>void installsubfont(char *name, Subfont *f) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Subfont* lookupsubfont(Subfont *f) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>void uninstallsubfont(Subfont *f) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Subfont* readsubfont(Display *d, char *name, int fd, int dolock) |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Subfont* readsubfonti(Display *d, char *name, int fd, Image *im,<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| int dolock) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| </table> |
| |
| </table> |
| </font></tt> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| |
| </table> |
| |
| </table> |
| <tt><font size=+1>int writesubfont(int fd, Subfont *f) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Point stringsubfont(Image *dst, Point p, Image *src,<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Subfont *f, char *str) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| </table> |
| |
| </table> |
| </font></tt> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| |
| </table> |
| |
| </table> |
| <tt><font size=+1>Point strsubfontwidth(Subfont *f, char *s) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Font* mkfont(Subfont *f, Rune min)<br> |
| </font></tt> |
| </table> |
| <p><font size=+1><b>DESCRIPTION </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Subfonts are the components of fonts that hold the character images. |
| A font comprises an array of subfonts; see <a href="../man3/cachechars.html"><i>cachechars</i>(3)</a>. A new |
| <tt><font size=+1>Subfont</font></tt> is allocated and initialized with <i>allocsubfont</i>. See <a href="../man3/cachechars.html"><i>cachechars</i>(3)</a> |
| for the meaning of <i>n</i>, <i>height</i>, <i>ascent</i>, and <i>info</i>, and the arrangement |
| of characters in image <i>i</i>. The <i>name</i> is |
| used to identify the subfont in the subfont cache; see the descriptions |
| <i>lookupsubfont</i> and <i>installsubfont</i> (<i>q.v.</i>). The appropriate fields |
| of the returned <tt><font size=+1>Subfont</font></tt> structure are set to the passed arguments, |
| and the image is registered as a subfont with the graphics device |
| <a href="../man3/draw.html"><i>draw</i>(3)</a>. <i>Allocsubfont</i> returns 0 on failure. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Freesubfont</i> frees a subfont and all its associated structure including |
| the associated image. Since <i>freesbufont</i> calls <i>free</i> on <tt><font size=+1>f−>info</font></tt>, |
| if <tt><font size=+1>f−>info</font></tt> was not allocated by <a href="../man3/malloc.html"><i>malloc</i>(3)</a> it should be zeroed before |
| calling <i>subffree</i>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| A number of subfonts are kept in external files. The convention |
| for naming subfont files is:<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>/usr/local/plan9/font/</font></tt><i>name</i><tt><font size=+1>/</font></tt><i>class</i><tt><font size=+1>.</font></tt><i>size</i><tt><font size=+1>.</font></tt><i>depth |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </i> |
| |
| </table> |
| where <i>size</i> is approximately the height in pixels of the lower |
| case letters (without ascenders or descenders). If there is only |
| one version of the subfont, the <tt><font size=+1>.</font></tt><i>depth</i> extension is elided. <i>Class</i> |
| describes the range of runes encoded in the subfont: <tt><font size=+1>ascii</font></tt>, <tt><font size=+1>latin1</font></tt>, |
| <tt><font size=+1>greek</font></tt>, etc. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Subfonts are cached within the program, so a subfont shared between |
| fonts will be loaded only once. <i>Installsubfont</i> stores subfont |
| <i>f</i> under the given <i>name</i>, typically the file name from which it |
| was read. <i>Uninstallsubfont</i> removes the subfont from the cache. |
| Finally, <i>lookupsubfont</i> searches for a subfont with the given |
| <i>name</i> in the cache and returns it, or nil if no such subfont exists. |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Subfontname</i> is used to locate subfonts given their names within |
| the fonts. The default version constructs a name given the <i>cfname</i>, |
| its name within the font, <i>fname</i>, the name of the font, and the |
| maximum depth suitable for this subfont. This interface allows |
| a partially specified name within a font to be resolved at |
| run-time to the name of a file holding a suitable subfont. Although |
| it is principally a routine internal to the library, <i>subfontname</i> |
| may be substituted by the application to provide a less file-oriented |
| subfont naming scheme. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The format of a subfont file is described in <a href="../man7/font.html"><i>font</i>(7)</a>. Briefly, |
| it contains a image with all the characters in it, followed by |
| a subfont header, followed by character information. <i>Readsubfont</i> |
| reads a subfont from the file descriptor <i>fd</i>. The <i>name</i> is used |
| to identify the font in the cache. The <i>dolock</i> argument specifies |
| whether |
| the routine should synchronize use of the <i>Display</i> with other processes; |
| for single-threaded applications it may always be zero. <i>Readsubfonti</i> |
| does the same for a subfont whose associated image is already |
| in memory; it is passed as the argument <i>im</i>. In other words, <i>readsubfonti</i> |
| reads only the header and character |
| information from the file descriptor. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Writesubfont</i> writes on <i>fd</i> the part of a subfont file that comes |
| after the image. It should be preceded by a call to <i>writeimage</i> |
| (see <a href="../man3/allocimage.html"><i>allocimage</i>(3)</a>). |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Stringsubfont</i> is analogous to <tt><font size=+1>string</font></tt> (see <a href="../man3/draw.html"><i>draw</i>(3)</a>) for subfonts. |
| Rather than use the underlying font caching primitives, it calls |
| <tt><font size=+1>draw</font></tt> for each character. It is intended for stand-alone environments |
| such as operating system kernels. <i>Strsubfontwidth</i> returns the |
| width of the string <i>s</i> in as it would appear if drawn with |
| <i>stringsubfont</i> in <tt><font size=+1>Subfont f</font></tt>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Mkfont</i> takes as argument a <tt><font size=+1>Subfont</font></tt> <i>s</i> and returns a pointer to |
| a <tt><font size=+1>Font</font></tt> that maps the character images in <i>s</i> into the <tt><font size=+1>Runes</font></tt> <i>min</i> |
| to <i>min</i><tt><font size=+1>+</font></tt><i>s</i><tt><font size=+1>−>n−1</font></tt>.<br> |
| |
| </table> |
| <p><font size=+1><b>FILES </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>/usr/local/plan9/font</font></tt> bitmap font file tree<br> |
| |
| </table> |
| <p><font size=+1><b>SOURCE </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>/usr/local/plan9/src/libdraw<br> |
| </font></tt> |
| </table> |
| <p><font size=+1><b>SEE ALSO </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <a href="../man3/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/allocimage.html"><i>allocimage</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man3/cachechars.html"><i>cachechars</i>(3)</a>, <a href="../man7/image.html"><i>image</i>(7)</a>, |
| <a href="../man7/font.html"><i>font</i>(7)</a><br> |
| |
| </table> |
| <p><font size=+1><b>DIAGNOSTICS </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| All of the functions use the graphics error function (see <a href="../man3/graphics.html"><i>graphics</i>(3)</a>).<br> |
| |
| </table> |
| |
| <td width=20> |
| <tr height=20><td> |
| </table> |
| <!-- TRAILER --> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=15><td width=10><td><td width=10> |
| <tr><td><td> |
| <center> |
| <a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a> |
| </center> |
| </table> |
| <!-- TRAILER --> |
| </body></html> |