10. Line Width

Given a line of text, calculate the pixel width.

<<funcdefs>>=
int macfont_line_width(macfont_info *fnt,
                       const char *str,
                       int nchars);
<<funcs>>=
int macfont_line_width(macfont_info *fnt,
                       const char *str,
                       int nchars)
{
    int lw;
    int n;

    lw = 0;

    for (n = 0; n < nchars; n++) {
        lw += get_charwidth(fnt, str[n]);
    }

    return lw;
}



prev | home | next