STRINGSIZE(3)
π STRINGSIZE(3) β Library Functions Manual edition π«Ά
okay so bestie, this is the glow-up of the page for all the little string-measuring icons in the Library Functions Manual, and it's genuinely so useful β no cap π
π NAME π
The squad is stringsize, stringwidth, stringnwidth, runestringsize, runestringwidth, and runestringnwidth β and their whole thing is the graphical size of strings β¨
πΈ SYNOPSIS πΈ
#include <u.h>
#include <libc.h>
#include <draw.h>
Point stringsize(Font *f, char *s)
int stringwidth(Font *f, char *s)
int stringnwidth(Font *f, char *s, int n)
Point runestringsize(Font *f, Rune *s)
int runestringwidth(Font *f, Rune *s)
int runestringnwidth(Font *f, Rune *s, int n)
π¦ DESCRIPTION π¦
Okay so these routines compute the geometrical extent of character strings when they're drawn on the display. The most straightforward one, stringsize, returns a Point representing the vector from upper left to lower right of the NUL-terminated string s drawn in font f. stringwidth returns just the x component. stringnwidth returns the width of the first n characters of s π
The routines beginning with rune are analogous, but they accept an array of runes rather than UTF-encoded bytes. Cute, right? π§
π· FILES π·
/lib/font/bitβ directory of fonts π
π₯ SOURCE π₯
The source lives at /src/libdraw β that's the spot, bestie π
π SEE ALSO π
addpt(3)cachechars(3)subfont(3)draw(3)draw(3)β yes, it's listed twice on the page, and we're keeping it exactly like that, periodt πimage(7)font(7)
π DIAGNOSTICS π
β οΈ heads up bestie: because strings are loaded dynamically, these routines may generate I/O to the server and produce calls to the graphics error function. That's the diagnostics tea ββ¨
okay bye bestie β footer sign-off: STRINGSIZE(3) from the Library Functions Manual, and no separate source/version or date was printed in the footer, so I'm not inventing one πβ¨
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms