File:  [Plan 9 NeXT] / lucent / sys / src / libgnot / f003243
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 18:01:05 2018 UTC (8 years, 1 month ago) by root
Branches: lucent, MAIN
CVS tags: plan9, HEAD
Plan 9 NeXT

#include <u.h>
#include <libc.h>
#include <libg.h>
#include <gnot.h>

Point
gsubfstrsize(GSubfont *f, char *cs)
{
	int i, l, n;
	Fontchar *info;
	uchar *s;
	Rune c;

	s = (uchar*)cs;
	l = 0;
	n = f->n;
	info = f->info;
	if(s)
		while(c = *s){
			if(c < Runeself)
				s++;
			else{
				i = chartorune(&c, (char*)s);
				if(i == 0){
					s++;
					continue;
				}
				s += i;
			}
			if(c < n)
				l += info[c].width;
		}
	return Pt(l, f->height);
}

long
gsubfstrwidth(GSubfont *f, char *s)
{
	Point p;

	p = gsubfstrsize(f,s);
	return p.x;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.