File: text.cpp

package info (click to toggle)
vdr-plugin-games 0.6.3-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 472 kB
  • ctags: 448
  • sloc: cpp: 9,884; makefile: 196; sh: 128
file content (45 lines) | stat: -rw-r--r-- 723 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "screen.h"

#include "font.h"
#include "text.h"

namespace Txt {

int
height(void) {
	return (FontHeight);
}

int
width(const char *txt) {
	int w = 0;

	while (txt && *txt) w += width(*txt++);
	return (w);
}

int
width(char c) {
	return ((int)FontData[c-32][0]);
}

int
print(int x, int y, const char *txt, int fg, int bg) {
	unsigned int pxl;

	while (txt && *txt) {
		if ((int)(x+width(*txt)) > Scr::width()) break;
		for (int row=0; row<height(); row++) {
			pxl = FontData[*txt-32][row+1];
			// XXX maybe inrement col befor starting?
			for (int col=width(*txt); col>0; col--) {
				Scr::pixel(x+col, y+row, (pxl&1) ? fg : bg);
				pxl >>= 1; 
			}
		}
		x += width(*txt++);
	}
	return (0);
}

} // namespace