blob: ac57f4a8ab68d79b55215d0ff49865ec5c3826c1 [file] [log] [blame]
rsccfa37a72004-04-10 18:53:55 +00001.TH STRINGSIZE 3
2.SH NAME
3stringsize, stringwidth, stringnwidth, runestringsize, runestringwidth, runestringnwidth \- graphical size of strings
4.SH SYNOPSIS
5.nf
6.PP
7.ft L
8#include <u.h>
9#include <libc.h>
10#include <draw.h>
11.ft P
12.ta \w'\fLPoint 'u
13.PP
14.B
15Point stringsize(Font *f, char *s)
16.PP
17.B
18int stringwidth(Font *f, char *s)
19.PP
20.B
21int stringnwidth(Font *f, char *s, int n)
22.PP
23.B
24Point runestringsize(Font *f, Rune *s)
25.PP
26.B
27int runestringwidth(Font *f, Rune *s)
28.PP
29.B
30int runestringnwidth(Font *f, Rune *s, int n)
31.SH DESCRIPTION
32These routines compute the geometrical extent of character strings when drawn on the display. The most straightforward,
33.BR stringsize ,
34returns a
35.B Point
36representing the vector from upper left to lower right of the NUL-terminated string
37.I s
38drawn in font
39.IR f .
40.B Stringwidth
41returns just the
42.I x
43component.
44.B Stringnwidth
45returns the width of the first
46.I n
47characters of
48.IR s .
49.PP
50The routines beginning with
51.B rune
52are analogous, but accept an array of runes rather than
53.SM UTF\c
54-encoded bytes.
55.SH FILES
56.BR /lib/font/bit " directory of fonts
57.SH SOURCE
rscb5fdffe2004-04-19 19:22:56 +000058.B /usr/local/plan9/src/libdraw
rsccfa37a72004-04-10 18:53:55 +000059.SH "SEE ALSO"
rscbf8a59f2004-04-11 03:42:27 +000060.IR addpt (3),
61.IR cachechars (3),
62.IR subfont (3),
63.IR draw (3),
rsccfa37a72004-04-10 18:53:55 +000064.IR draw (3),
65.IR image (6),
66.IR font (6)
67.SH DIAGNOSTICS
68Because strings are loaded dynamically, these routines may generate I/O
69to the server and produce calls to the graphics error function.