Blob


1 .TH STRINGSIZE 3
2 .SH NAME
3 stringsize, 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
15 Point stringsize(Font *f, char *s)
16 .PP
17 .B
18 int stringwidth(Font *f, char *s)
19 .PP
20 .B
21 int stringnwidth(Font *f, char *s, int n)
22 .PP
23 .B
24 Point runestringsize(Font *f, Rune *s)
25 .PP
26 .B
27 int runestringwidth(Font *f, Rune *s)
28 .PP
29 .B
30 int runestringnwidth(Font *f, Rune *s, int n)
31 .SH DESCRIPTION
32 These routines compute the geometrical extent of character strings when drawn on the display. The most straightforward,
33 .BR stringsize ,
34 returns a
35 .B Point
36 representing the vector from upper left to lower right of the NUL-terminated string
37 .I s
38 drawn in font
39 .IR f .
40 .B Stringwidth
41 returns just the
42 .I x
43 component.
44 .B Stringnwidth
45 returns the width of the first
46 .I n
47 characters of
48 .IR s .
49 .PP
50 The routines beginning with
51 .B rune
52 are 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
58 .B \*9/src/libdraw
59 .SH "SEE ALSO"
60 .MR addpt (3) ,
61 .MR cachechars (3) ,
62 .MR subfont (3) ,
63 .MR draw (3) ,
64 .MR draw (3) ,
65 .MR image (7) ,
66 .MR font (7)
67 .SH DIAGNOSTICS
68 Because strings are loaded dynamically, these routines may generate I/O
69 to the server and produce calls to the graphics error function.