Fix typo in the Gentoo initscript.
[fbsplash.git] / misc / fbtruetype / fbtruetype.c
blob5c8199010ed9f148664d88336a05ba005f5901d2
1 /*
2 * fbmngplay - fb console MNG player.
3 * (c) 2001-2002 by Stefan Reinauer, <stepan@suse.de>
4 *
5 * This program is based on mngplay, written and (C) by
6 * Ralph Giles <giles@ashlu.bc.ca>
8 * This program my be redistributed under the terms of the
9 * GNU General Public Licence, version 2, or at your preference,
10 * any later version.
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include <string.h>
16 #include <unistd.h>
17 #include <fcntl.h>
18 #include <getopt.h>
19 #include <sys/mman.h>
20 #include <sys/ioctl.h>
21 #include <linux/fb.h>
22 #include <signal.h>
25 #include "fbtruetype.h"
26 #include "messages.h"
27 #include "console.h"
29 volatile int run = 1;
30 int verbose = 0;
31 int buffered = 0;
32 int waitsignal = 0;
33 int delta = 16;
34 int sconly=0;
36 unsigned int fbbytes, fbx, fby;
37 unsigned int fbypos=100, fbxpos=100;
38 unsigned int fblinelen, alpha=100;
39 unsigned char *framebuffer, *font=DEFAULT_FONTNAME;
40 unsigned int fgcolor=0xff0000;
41 unsigned int fontsize=36;
42 int strict_font=0;
43 int rendertext(char *text, char *fontname, unsigned int size, unsigned int forecol);
45 int main(int argc, char *argv[])
47 int fbdev,c,option_index;
48 unsigned int alpha;
49 struct fb_var_screeninfo var;
50 struct fb_fix_screeninfo fix;
52 /* Check which console we're running on */
53 init_consoles();
55 alpha = 100;
56 while (1) {
57 static struct option long_options[] = {
58 {"help", 0, 0, 'h'},
59 {"verbose", 0, 0, 'v'},
60 {"alpha", 1, 0, 'a'},
61 {"version", 0, 0, 'V'},
62 {"start-console",0,0,'S'},
63 {"size",1,0,'s'},
64 {"console",1,0,'c'},
65 {"font",1,0,'f'},
66 {"textcolor",1,0,'t'},
67 {0, 0, 0, 0}
70 c = getopt_long(argc, argv, "a:x:y:h?vVSc:f:t:s:",
71 long_options, &option_index);
73 if (c == -1)
74 break;
76 switch (c) {
77 case 'a':
78 alpha = atoi(optarg);
79 if (alpha > 100)
80 alpha = 100;
81 break;
82 case 'x':
83 fbxpos = atoi(optarg);
84 break;
85 case 'y':
86 fbypos = atoi(optarg);
87 break;
88 case '?':
89 case 'h':
90 usage(argv[0]);
91 exit(0);
92 case 'v':
93 verbose = 1;
94 break;
95 case 'V':
96 version();
97 exit(0);
98 case 'c':
99 start_console=atoi(optarg)-1;
100 case 'S':
101 sconly=1;
102 break;
103 case 'f':
104 strict_font=1;
105 font=strdup(optarg);
106 break;
107 case 't':
108 fgcolor=strtol(optarg, NULL, 16);
109 break;
110 case 's':
111 fontsize=strtol(optarg, NULL, 10);
112 break;
114 default:
115 break;
118 if (optind >= argc) {
119 printf("No text\n");
120 exit(0);
123 /* Initialize framebuffer */
124 fbdev = open("/dev/fb/0", O_RDWR);
125 if (fbdev < 0) {
126 fbdev = open("/dev/fb0", O_RDWR);
127 if (fbdev < 0) {
128 fprintf(stderr, "error while opening framebuffer.\n");
129 exit(fbdev);
133 ioctl(fbdev, FBIOGET_VSCREENINFO, &var);
134 fbbytes = var.bits_per_pixel>>3;
135 fbx=var.xres;
136 fby=var.yres;
137 ioctl(fbdev, FBIOGET_FSCREENINFO, &fix);
138 fblinelen = fix.line_length;
140 framebuffer = mmap(NULL, fblinelen* fby ,
141 PROT_WRITE | PROT_READ, MAP_SHARED, fbdev, var.yoffset * fblinelen);
143 rendertext (argv[optind], font, fontsize, fgcolor);
144 return 0;