shithub: dormer

ref: c40d66e369235ec021af570553b89bd101a42109
dir: /text.c/

View raw version
#include <u.h>
#include <libc.h>
#include <draw.h>
#include "dormer.h"

Text*
mktext(Canvas *c, char *str, char *ft, int x, int y, long fgcol)
{
	Image *fg;
	Image *im;
	c->textv[c->ti].ft = openfont(display, ft);
	c->textv[c->ti].x = x;
	c->textv[c->ti].y = y;
	fg = allocimage(display, Rect(0,0,1,1), CMAP8, 1, fgcol);

	Point size = stringsize(c->textv[c->ti].ft, str);
	c->textv[c->ti].image = allocimage(display, (Rectangle){(Point){0,0},size}, RGBA32, 0, DTransparent);
	im = c->textv[c->ti].image;

	string(im, (Point){0,0}, fg, ZP, c->textv[c->ti].ft, str);
	Text *tx = &c->textv[c->ti++];
	return tx;
}