groff 1.23.0 added .MR to its -man macro package. The NEWS file states
that the inclusion of the macro "was prompted by its introduction to
Plan 9 from User Space's troff in August 2020." From d32deab it seems
that the name for Plan 9 from User Space's implementation was suggested
by groff maintainer G. Brandon Robinson.
Not sure if the intention was to make these definitions compatible, but
it would be nice if they were.
Currently, Plan 9 from User Space's .MR expects its second argument to
be parenthesized. groff's .MR does not. This results in extra
parentheses appearing in manual references when viewing Plan 9 from User
Space's manual pages on a system using groff.
70 lines
1.4 KiB
Groff
70 lines
1.4 KiB
Groff
.TH STRINGSIZE 3
|
|
.SH NAME
|
|
stringsize, stringwidth, stringnwidth, runestringsize, runestringwidth, runestringnwidth \- graphical size of strings
|
|
.SH SYNOPSIS
|
|
.nf
|
|
.PP
|
|
.ft L
|
|
#include <u.h>
|
|
#include <libc.h>
|
|
#include <draw.h>
|
|
.ft P
|
|
.ta \w'\fLPoint 'u
|
|
.PP
|
|
.B
|
|
Point stringsize(Font *f, char *s)
|
|
.PP
|
|
.B
|
|
int stringwidth(Font *f, char *s)
|
|
.PP
|
|
.B
|
|
int stringnwidth(Font *f, char *s, int n)
|
|
.PP
|
|
.B
|
|
Point runestringsize(Font *f, Rune *s)
|
|
.PP
|
|
.B
|
|
int runestringwidth(Font *f, Rune *s)
|
|
.PP
|
|
.B
|
|
int runestringnwidth(Font *f, Rune *s, int n)
|
|
.SH DESCRIPTION
|
|
These routines compute the geometrical extent of character strings when drawn on the display. The most straightforward,
|
|
.BR stringsize ,
|
|
returns a
|
|
.B Point
|
|
representing the vector from upper left to lower right of the NUL-terminated string
|
|
.I s
|
|
drawn in font
|
|
.IR f .
|
|
.B Stringwidth
|
|
returns just the
|
|
.I x
|
|
component.
|
|
.B Stringnwidth
|
|
returns the width of the first
|
|
.I n
|
|
characters of
|
|
.IR s .
|
|
.PP
|
|
The routines beginning with
|
|
.B rune
|
|
are analogous, but accept an array of runes rather than
|
|
.SM UTF\c
|
|
-encoded bytes.
|
|
.SH FILES
|
|
.BR /lib/font/bit " directory of fonts
|
|
.SH SOURCE
|
|
.B \*9/src/libdraw
|
|
.SH "SEE ALSO"
|
|
.MR addpt 3 ,
|
|
.MR cachechars 3 ,
|
|
.MR subfont 3 ,
|
|
.MR draw 3 ,
|
|
.MR draw 3 ,
|
|
.MR image 7 ,
|
|
.MR font 7
|
|
.SH DIAGNOSTICS
|
|
Because strings are loaded dynamically, these routines may generate I/O
|
|
to the server and produce calls to the graphics error function.
|