235 lines · 5.0 KB · Text
RawDownload
.TH SUBFONT 2.SH NAMEallocsubfont, freesubfont, installsubfont, lookupsubfont, uninstallsubfont, subfontname, readsubfont, readsubfonti, writesubfont, stringsubfont, strsubfontwidth, mkfont \- subfont manipulation.SH SYNOPSIS.B #include <u.h>.br.B #include <libc.h>.br.B #include <draw.h>.PP.ta \w'\fLSubfont* 'u.BSubfont*	allocsubfont(char *name, int n, int height, int ascent,.br.B	Fontchar *info, Image *i).PP.Bvoid	freesubfont(Subfont *f).PP.Bvoid	installsubfont(char *name, Subfont *f).PP.BSubfont*	lookupsubfont(Subfont *f).PP.Bvoid	uninstallsubfont(Subfont *f).PP.BSubfont*	readsubfont(Display *d, char *name, int fd, int dolock).PP.BSubfont*	readsubfonti(Display *d, char *name, int fd, Image *im,.br.B	  int dolock).PP.Bint	writesubfont(int fd, Subfont *f).PP.BPoint	stringsubfont(Image *dst, Point p, Image *src,.br.B	Subfont *f, char *str).PP.BPoint	strsubfontwidth(Subfont *f, char *s).PP.BFont*	mkfont(Subfont *f, Rune min).SH DESCRIPTIONSubfonts are the components of fonts that hold the character images.A font comprises an array of subfonts; see.IR cachechars (2).A new.B Subfontis allocated and initialized with.IR allocsubfont .See.IR cachechars (2)for the meaning of.IR n ,.IR height ,.IR ascent ,and.IR info ,and the arrangement of characters inimage.IR i .The.I nameis used to identify the subfont in the subfont cache; see the descriptions.I lookupsubfontand.IR installsubfont.RI ( q.v. ).The appropriate fields of the returned.B Subfontstructure are set tothe passed arguments, and the image is registered as a subfontwith the graphics device.IR draw (3)..I Allocsubfontreturns 0 on failure..PP.I Freesubfontfrees a subfont and all its associated structure including theassociated image.Since.I freesbufontcalls.I freeon.BR f->info ,if.B f->infowas not allocated by.IR malloc (2)it should be zeroed before calling.IR subffree ..PPA number of subfonts are kept in external files.The convention for naming subfont files is:.IP.B /lib/font/bit/\fIname\fP/\fIclass\fP.\fIsize\fP.\fIdepth.PD.PPwhere.I sizeis approximately the height in pixels of the lower case letters(without ascenders or descenders).If there is only one version of the subfont, the.BI \&. depthextension is elided..I Classdescribes the range of runes encoded in the subfont:.BR ascii ,.BR latin1 ,.BR greek ,etc..PPSubfonts are cached within the program, so a subfont shared between fonts will be loaded only once..I Installsubfontstores subfont.I funder the given.IR name ,typically the file name from which it was read..I Uninstallsubfontremoves the subfont from the cache.Finally,.I lookupsubfontsearches for  a subfont with the given.I namein the cache and returns it, or nil if no such subfont exists..PP.I Subfontnameis used to locate subfonts given their names within the fonts.The default version constructs a name given the.IR cfname ,its name within the font,.IR fname ,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 resolvedat run-time to the name of a file holding a suitable subfont.Although it is principally a routine internal to the library,.I subfontnamemay be substituted by the application to provide a less file-oriented subfont naming scheme..PPThe format of a subfont file is described in.IR font (6).Briefly, it contains a image with all the characters in it,followed by a subfont header, followed by character information..I Readsubfontreads a subfont from the file descriptor.IR fd .The.I nameis used to identify the font in the cache.The.I dolockargument specifies whether the routine should synchronizeuse of the.I Displaywith other processes; for single-threaded applications it mayalways be zero..I Readsubfontidoes the same for a subfont whose associated image is already in memory; it is passed as theargument.IR im .In other words,.I readsubfontireads only the header and character information from the file descriptor..PP.I Writesubfontwrites on.I fdthe part of a subfont file that comes after the image.  It should be preceded bya call to.IR writeimage(see.IR allocimage (2))..PP.I Stringsubfontis analogous to.B string(see.IR draw (2))for subfonts.  Rather than use the underlying font caching primitives,it calls.B drawfor each character.It is intended for stand-alone environments such as operating system kernels..I Strsubfontwidthreturns the width of the string.I sinas it would appear if drawn with.I stringsubfontin.B Subfont.BR f ..PP.I Mkfonttakes as argument a.B Subfont.I sand returns a pointer to a .B Fontthat maps the character images in.I sinto the.B Runes.I minto.IB min + s ->n-1\f1..SH FILES.TF /lib/font/bit.TP.B /lib/font/bitbitmap font file tree.SH SOURCE.B /sys/src/libdraw.SH SEE ALSO.IR graphics (2),.IR allocimage (2),.IR draw (2),.IR cachechars (2),.IR image (6),.IR font (6).SH DIAGNOSTICSAll of the functions use the graphics error function (see.IR graphics (2)).

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t